#evan_09475
1 messages · Page 1 of 1 (latest)
hello, is there a reason why you don't want to use the Payment Element which also supports Google Pay and Apple Pay?
I already have a custom form for cards, am using the expressElement only to show google pay, apple,pay, and paypal
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?
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:
- Create a customer
- create subscription
ah, you can likely do similarly with the Express Checkout Session then, you can see up till this section for creating the payment token https://stripe.com/docs/elements/express-checkout-element/accept-a-payment#create-pm - then send the token id to your server to process
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
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
you mean this guide? https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements - this guide explains how to use the Payment Element with Subscriptions