stripe icon indicating copy to clipboard operation
stripe copied to clipboard

Terminal package missing 'confirmPaymentIntent' method to process payment

Open yllaw opened this issue 11 months ago • 1 comments

Platform

  • [ ] Web
  • [X] iOS
  • [X] Android

Describe the bug

After collecting the payment intent via StripeTerminal, the next step is to confirmPaymentIntent.

Without this step the Stripe paymentIntent state cannot be changed to succeeded or requires_capture

This method is missing from the plugin

Expected behavior A simple example could look like this in swift:

// StripeTerminal.swift

    public func confirmPaymentIntent(_ paymentIntent: PaymentIntent, call: CAPPluginCall) {
        Terminal.shared.confirmPaymentIntent(paymentIntent) { confirmResult, confirmError in
               if let error = confirmError {
                   print("confirmPaymentIntent failed: \(error)")
                   self.plugin?.notifyListeners(TerminalEvents.Failed.rawValue, data: [:])
                   call.reject(error.localizedDescription)
               } else if let confirmedIntent = confirmResult {
                   print("PaymentIntent confirmed: \(confirmedIntent)")
                   self.plugin?.notifyListeners(TerminalEvents.Completed.rawValue, data: [:])
                   call.resolve()
               }
           }
    }

And perhaps in the capacitor app the code to collect and process payment looks like this:

// Collect payment intent
await StripeTerminal.collect({ paymentIntent: "**************" });

// Process payment intent 
await StripeTerminel.confirmPaymentIntent();

More info on processing the payment intent can be found here

yllaw avatar Mar 13 '24 20:03 yllaw

I have added a PR #342 for this

yllaw avatar Mar 13 '24 22:03 yllaw

merged, and released @capacitor-community/[email protected]

rdlabo avatar Mar 19 '24 10:03 rdlabo