stripe icon indicating copy to clipboard operation
stripe copied to clipboard

Feature Request: Split Methods for Apple/Google Pay to Separate Payment Method Retrieval from Confirmation

Open maylorsan opened this issue 1 year ago • 1 comments

Description

I am currently using the capacitor-community/stripe plugin in my project and need to implement Apple/Google Pay with a specific flow. My requirement is to first retrieve the payment method and then confirm the payment separately using the Stripe JS library method confirmCardPayment. However, the plugin seems to lack the necessary tools for this distinct two-step process.

Current Behavior

The plugin offers a single method to handle Apple Pay, which combines both the retrieval of the payment method and its confirmation in one step. The current implementation is as follows:

await Stripe.createApplePay({
  paymentIntentClientSecret,
  paymentSummaryItems,
  countryCode,
  currency,
  merchantIdentifier,
});

const { paymentResult } = await Stripe.presentApplePay();

return paymentResult;

Requested Feature

I propose the introduction of split methods for Apple/Google Pay within the plugin. Specifically, the first method should only retrieve the payment method without confirming it. The second method should be responsible for confirming the payment using the retrieved payment method. This separation is crucial for the specific payment flow required in my project.

Use Case

This feature is particularly useful in scenarios where additional processing or validation is needed between retrieving the payment method and confirming the payment. It provides greater flexibility and control over the payment process.

Suggested Implementation

Ideally, the implementation could involve separating the existing combined method into two distinct methods:

  • Method to Retrieve Payment Method: This method should handle the initial part of the Apple/Google Pay process, stopping short of confirming the payment.
  • Method to Confirm Payment: This method should accept the retrieved payment method as an input and handle the confirmation of the payment.

This approach would align with the standard Stripe JS library's confirmCardPayment method, offering more versatility in handling different payment flows.


Using Function:

  • [ ] Payment Sheet / Payment Flow
  • [x] Apple Pay
  • [x] Google Pay
  • [ ] Identity Verification Sheet

maylorsan avatar Jan 06 '24 10:01 maylorsan

Thanks for issue.

Example Apple Pay, As the applePayContext is automatically called, it seems difficult to separate this. Can you provide a hint, URL or sample code where this implementation is possible?

https://docs.stripe.com/apple-pay?platform=ios&locale=ja-JP#%E3%82%AF%E3%83%A9%E3%82%A4%E3%82%A2%E3%83%B3%E3%83%88%E5%81%B4

rdlabo avatar Mar 08 '24 15:03 rdlabo