0

I am trying to resolve the parameter for the INSendPaymentIntent such that the amount should never be less than zero. The build fails with an error in the else block saying

'/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'.

It expects an INCurrencyAmount type object. What is the wrong in the code?

    // 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 ))
            }
        }

}
Adnan Hussein
  • 261
  • 1
  • 4
  • 14

1 Answers1

0

Aright the last else block needed to be passed as a type of INCurrencyAmount:

completion(INCurrencyAmountResolutionResult.success(with: currencyAmount ))

Thanks.

Adnan Hussein
  • 261
  • 1
  • 4
  • 14