#dan-subscription-trial-wallets
1 messages · Page 1 of 1 (latest)
dan-subscription-trial-wallets
Do you have an example transaction where I can have a look at it?
What info do you need? This is something we only discovered when testing in prod
Some request id req_123 where the payment happen or something similar? I'm still barely understanding what you describe and how you use our API.
Like if you do Subscriptions and a trial period, there's no PaymentIntent upfront
I think the PaymentIntent comes into play with the Wallet Elements
But it shouldn't. If you have a PaymentIntent and confirm it, this really takes a payment upfront
Okay; gimme just a second (a few convos going on) and I can walk through the process I've setup
Okay:
- When our custom wallet element first loads, we send the price of the subscription along w/ any extra data to a new backend call we created to create a PaymentIntent and get back a client_secret. Additionally we check if we have/can create a PaymentRequest; we pass that PaymentRequest to the
PaymentRequestButtonElement - Now that we have a PaymentRequest, a client_secret, and a visible wallet button, we start listening for changes on the PaymentRequest, specifically
paymentmethod. When that event fires, we callstripe.confirmCardPaymentwith the paymentMethodId passed in from the event and our client_secret. Assuming that works, it returns a PaymentIntent. - We send that paymentMethodId to our backend which completes the process (I can get the details for how we handle this; I can't describe it off the top of my head and this explaination was getting a little long 🙂 )
Generally the process outlined here https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=react
Not to my knowledge
Gotcha, so there's no Subscription, no Invoice, no trial period at all right? What you do is you have your own logic to charge a payment each month or something and you handle the trial period yourself?
We create the subscription with Stripe.subscriptions.create
items: [{plan: plan.gatewayPlanId}],
trial_from_plan: true,```
Not seeing reqIds, but this is a payment ID from a test payment yesterday pm_1M9GvUKDJMRN1di2upI22Z4m
(real payment, used while testing)
👍
So to clarify are you creating a separate PaymentIntent or grabbing the client secret from the Subscription's latest_invoice on Subscription creation?
These would all be for new subscriptions, so we're creating the PaymentIntent. We haven't really worked with PaymentIntents before, so the creation and usage of their client_secret are the only places we use them
Okay but you shouldn't be creating a PaymentIntent at all
These Subscriptions involve a trial, correct?
yes. It's my understanding we need to get a client_secret from the PaymentIntent as outlined here https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html&html-or-react=react#html-js-create-payment
and use that client_secret in this step https://stripe.com/docs/stripe-js/elements/payment-request-button?client=html&html-or-react=react#html-js-complete-payment
So yeah that guide is only for one-off payments
Since you are using Subscriptions, the PaymentIntent (or SetupIntent in the case of a trial) is generated for you
So when you create the Subscription, you want to retrieve the latest_invoice.payment_intent.client_secret
And pass that to your frontend
Then use that with confirmPayment
Or, if there is a trial, there is a pending_setup_intent property on the Subscription: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Which you grab the client secret from that to use on the frontend to set up a PaymentMethod for future use with the Sub
I don't think we create the subscription until all the payment processing stuff is done
(we could re-configure, just calling it out)
What "payment processing stuff" specifically?
If you do want to collect the PaymentMethod ahead of creating the Subsription then you should just be creating a SetupIntent instead of a PaymentIntent to collect the PaymetnMethod from the Payment Request Button
Yes, I believe this is what we want to do, "PaymetnMethod from the Payment Request Button"
Yep okay then create a SetupIntent, not PaymentIntent, and pass the SetupIntent's client secret to the frontend
Okay. I need to grab lunch and read through those docs. If I have questions later, can I ping you here?
(and thanks)
Yep we'll be here! I'll likely archive this thread but you can ping again in the main channel
Perfect. Thanks so much!