#evan_09475

1 messages · Page 1 of 1 (latest)

restive irisBOT
urban pulsar
#

hello, is there a reason why you don't want to use the Payment Element which also supports Google Pay and Apple Pay?

sturdy axle
#

I already have a custom form for cards, am using the expressElement only to show google pay, apple,pay, and paypal

urban pulsar
#

ah, so we don't have a Stripe repo explaining how to use it with Subscriptions explicitly, but i can give you a high level overview. Give me a few minutes to type it out

#

i assume you're collecting the payment method first then creating a subscription using that payment method?

sturdy axle
#

When I used to work with cards before,
My react app used to create a payment token via stripe.createToken then I would send the payment token along with the payer name and email to my server.
Then my server does the following:

  1. Create a customer
  2. create subscription
urban pulsar
sturdy axle
#

In the doc sent above, I can see create CreatePaymentMethod

#

This should have the token I assume ?

#

because stripe.createToken can not be called on an expressElement

urban pulsar
#

yep, CreatePaymentMethod will create a PaymentMethod object instead. You would pass that PaymentMethod into the default_payment_method of the Subscription [0] or by settng it on invoice_settings.default_payment_method [0].
Otherwise, you can also set payment_settings.save_default_payment_method =on_subscription [2] so that it's automatically done for you

[0] https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method
[1] https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
[2] https://stripe.com/docs/api/subscriptions/object#subscription_object-payment_settings-save_default_payment_method

#

i'd recommend moving away from using Tokens at this point. It's a legacy object / API and we've since moved on to PaymentMethods now

#

you can use stripe.createPaymentMethod with your card element instead

sturdy axle
#

If I change to paymentElement, is there a way to intergate with subscriptions.

I can see in the doc that the sample is simple, not explainging the intergration of payment element with subscription

urban pulsar