INSendPaymentIntent的解析参数失败

时间:2017-02-23 12:59:37

标签: ios swift sirikit

我正在尝试解析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 ))
            }
        }

}

1 个答案:

答案 0 :(得分:0)

需要作为一种INCurrencyAmount传递的最后一个else块:

completion(INCurrencyAmountResolutionResult.success(with: currencyAmount ))

感谢。