Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create PaymentMethod with Apple Pay #271

Closed
trex-quo opened this issue May 26, 2021 · 3 comments · Fixed by #295
Closed

Create PaymentMethod with Apple Pay #271

trex-quo opened this issue May 26, 2021 · 3 comments · Fixed by #295
Labels
enhancement New feature or request P2 Address these issues last

Comments

@trex-quo
Copy link

trex-quo commented May 26, 2021

Is your feature request related to a problem? Please describe.
When creating a subscription for a customer with a debit card, it is clear and straightforward that the payment method is stored with the subscription and associated with the customer object. You can either create a PaymentMethod using the card information and associate it with the subscription in that manner, or you can pass in setupFutureUsage: 'OffSession' to confirmPayment() to associate the card information.

When paying with Apple Pay, it is not clear that the Apple Pay payment method is being associated with the subscription. I create a subscription on the server side and pass in payment_behavior: "default_incomplete", and then call confirmApplePayPayment() on the frontend. Do I just trust that the payment method will be associated and charged again when the customer's subscription auto-renews?

Describe the solution you'd like
Allow us to create Apple Pay tokens and create PaymentMethods with them, as noted by Stripe documentation here:
https://support.stripe.com/questions/using-apple-pay-for-recurring-payments

Or add a setupFutureUsage field to the confirmApplePayPayment() so that we can be sure that the customer's payment method is associated with their subscription.

Describe alternatives you've considered
Use confirmApplePayPayment() with a payment_intent secret from the server-side subscription object and hope that the payment associates itself.

Additional context
My main concern here is with changing payment methods on the customer's subscription if the customer has a subscription with no PaymentMethod attached to their customer object. What would happen if we called (server-side)

await stripeClient.subscriptions.update(stripeSubscriptionId, {
  payment_behavior: "default_incomplete",
});

for an Apple Pay payment whose payment_intent never gets confirmed on the frontend? In my mind, if this happened with a debit card payment, at least the associated PaymentMethod attached to the customer object would be a fallback method for payment, but would this wipe the Apple Pay payment method off of the subscription object?

@thorsten-stripe thorsten-stripe added enhancement New feature or request P2 Address these issues last labels May 26, 2021
@thorsten-stripe thorsten-stripe changed the title Create PaymentMethod with Apple Pay or setupFutureUsage with confirmApplePayPayment Create PaymentMethod with Apple Pay May 26, 2021
@thorsten-stripe
Copy link
Contributor

Thanks @trex-quo, we should provide a way to get the payment method from Apple Pay. We'll track this work here.

@trex-quo
Copy link
Author

trex-quo commented May 26, 2021

I think that a workaround for the time being would be to retrieve the PaymentIntent from the subscription immediately after creating it server-side, and then update the PaymentIntent with {setup_future_usage: 'off_session'} before returning the client_secret to the client. Does that sound reasonable?

Edit: I found a solution that works well for the time being (using Apple Pay as a payment method for subscriptions):
Server side

  • For new subscriptions, create a subscription object using {payment_behavior: "default_incomplete"}. Grab the latest_invoice.payment_intent.client_secret off of the subscription and return it to the frontend
  • To update the payment method on an existing subscription, update the subscription object with {payment_behavior: "default_incomplete"}. Grab the pending_setup_intent.client_secret off of the subscription and return it to the frontend

Client side

  • For new subscriptions, call confirmApplePayPayment with the Payment Intent secret to create the subscription and charge the user
  • To update the payment method on an existing subscription, call confirmApplePayPayment with the Setup Intent to update the payment method. Apparently confirmApplePayPayment takes in both Payment Intent secrets as well as Setup Intent secrets.
    • For debit card updates, using confirmPayment is the way to go for initial subscriptions/charges, and confirmSetupIntent is the way to go for updating payment information (with their respective secrets as mentioned in the server side part).

I have verified all of the above with webhooks as well as the Event Logs on the developer dashboard. The Apple Pay payment methods and card payment methods all attach to the user each time I create or update a subscription.

@thorsten-stripe
Copy link
Contributor

Thanks @trex-quo for outlining this workaround! It is a good one for subscriptions 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 Address these issues last
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants