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