#pcrobinz
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Are you using Stripe Checkout OR are you creating subscriptions by calling the API?
hi, im creating subscription by calling the api
Gotcha. In that case you can either listen for customer.subscription.created webhook event OR call the API to retrieve subscription object.
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 just dont get the process.
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
how can i proceed with that if by creating subscription with trial period wont produce clientsecret
The status should reflect the state subscription is in.
Oh are you trying to collect payment method details at the same time?
ahhh i see. what im doing is collecting payment details first before creating subscription
im following this. "Collect payment details before creating an Intent"4
would the card details be validated by the payment element form?
Yup, the guide has a section for subscriptions too
https://stripe.com/docs/payments/accept-a-payment-deferred?type=subscription
im following that guide, i think i was just confused with that process
correct me if im wrong
so basically, when a subscription is created with trial period. i dont need to confirm the payment right?
i just need to listen to the hook, that when the trial ends, if the payment is successful ill just continue his subscription, and if the payment is not successful, i need to stop his subsciption
So, a subscription with trial would still need an attached payment method that we can charge after the trial ends
with this code.
how can i save the payment details?
So when you have a subscription with trial, there's no associated PaymentIntent but there is a pending_setup_intent property that allows you to capture the PaymentMethod information
So you'd change the confirmPayment function to confirmSetup instead
๐ stepping in
No you pass the pending_setup_intent.client_secret to confirmSetup
Or, if you are rendering Payment Element you pass your elements object
i think i should create setupintent after creating the subscription??
No a Subscription that has a trial automatically creates a SetupIntent and it is returned in the pending_setup_intent property
then how can i use this in confirmsetup? i tried putting that, but it said i need to put clientsecret
Yep so when you create the Sub you want to expand the pending_setup_intent
Are you familiar with expansion?
If not, you should take a quick read through https://stripe.com/docs/expand
Sure
can i also ask some few questions?
Yep
so after 30days, stripe will automatically charge the card right?
then i can listen to webhook if the payment is successful or not, so i can pause or continue the subcsription of an user?
If the Subscription is on a monthly Price then yes
I'd recommend using test clocks (https://stripe.com/docs/billing/testing/test-clocks) to test this stuff out end-to-end
i set the subscription to yearly
Oh well then it will renew yearly
sorry for the confusion, i mean after 30days trial, stripe will automatically charge the card right?
then i can listen to webhook if the payment is successful or not, so i can pause or continue the subcsription of an user?
Oh yes that's correct.
Okay thanks. Also for the test-clocks