0

我正在尝试解析 INSendPaymentIntent 的参数,以使金额永远不会小于零。构建失败并在 else 块中显示错误

'/Users/xx/Documents/Appcelerator_Studio_Workspace/SiriTestApp/extensions/SiriTestApp/siritestapp/IntentHandler.swift:123:79: Cannot convert value of type 'NSDecimalNumber' to expected argument type 'INCurrencyAmount'.

它需要一个 INCurrencyAmount 类型的对象。代码有什么问题?

    // Called when you need to resolve the currency amount to be transferred.
    func resolveCurrencyAmount(forSendPayment intent: INSendPaymentIntent, with completion: @escaping (INCurrencyAmountResolutionResult) -> Void) {

    // Resolve the currency amount.
        if let currencyAmount = intent.currencyAmount, let amount = currencyAmount.amount{
            if amount.intValue <= 0 {
                // The amount needs to be a positive value.
                completion(INCurrencyAmountResolutionResult.unsupported())
            }else{
                completion(INCurrencyAmountResolutionResult.success(with: amount ))
            }
        }

}
4

1 回答 1

0

好吧,最后一个 else 块需要作为 INCurrencyAmount 类型传递:

completion(INCurrencyAmountResolutionResult.success(with: currencyAmount ))

谢谢。

于 2017-02-24T10:22:22.670 回答