stripe
stripe copied to clipboard
Terminal package missing 'confirmPaymentIntent' method to process payment
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
I have added a PR #342 for this
merged, and released @capacitor-community/[email protected]