#soumya
1 messages · Page 1 of 1 (latest)
If you're using trials, then there will be no initial payment due. So instead of there being a Payment Intent, we generate a Setup Intent
It's on the Subscription creation response, pending_setup_intent: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You can expand that and there'll be a client_secret to use
But will the added payment method will be attached to the further invoice for renewals for the subscription?
Yep!
so we dont have to pass any params to setup intent specifically right?
No, the flow is largely the same as with a Payment Intent
You're just using a different field: pending_setup_intent.client_secret instead of latest_invoice.payment_intent.client_secret
but even if we call setup intent to generate client secret key we need to call subcription api with trail period data as well right?
how is this both connected?
You don't create the Setup Intent, it's generated by your Subscription creation call if you set a trial
Try it out, there'll be a pending_setup_intent in the response
it is null
for me
await stripe.subscriptions.create({
customer: "CUS",
items: [
{ price: "price" }
],
trial_period_days: 5,
payment_settings: {
save_default_payment_method: 'on_subscription',
},
trial_settings: {
end_behavior: {
missing_payment_method: "create_invoice",
},
},
expand: ['latest_invoice.payment_intent'],
}) this is the payload
What's the sub_xxx ID?
sub_1NdAKbSCfQjwTWJ0YnGh4UVi
Well that's because the cus_OCvVl2tkZW8b5J has a default PM saved so we'll automatically use that for subscription payments
in this case how do we proceed ?
because we need client secret key for UI to show the payment sheet
payment_settings: {
save_default_payment_method: 'on_subscription', this settiing means make the newly added card as defualt one for subscription right?
You'd use a different Customer object, or unset the invoice_settings[default_payment_method] field
Yes, but it's redundant as the Customer has a default PM set already
so before we call subscription api we can unset the invoice settings and the newly added card will made as default is that what it means?
If you unset that field, and make the same API request we will generate a pending_setup_intent you can use with the Payment Sheet yes
Pass an empty string
Also one more query if we are passing this payment_settings: {
save_default_payment_method: 'on_subscription', this means the added card from payment sheet shd be the defualt one right? but in dashboard it doesnot reflect
It'd be set as the default on the subscription not the customer
so the same will be used for renewal right?
Yes, default_payment_method will be set and that takes precedence for recurring payments
"An invalid request occurred: "You passed an empty string for 'invoice_settings'. We assume empty values are an attempt to unset a parameter; however 'invoice_settings' cannot be unset. You should remove 'invoice_settings' from your request or supply a non-empty value
this error i got
invoice_settings is a hash. You need:
invoice_settings: {
default_payment_method: ""
}
i tired with this approach but still client secret is null
sub_1NdAhNSCfQjwTWJ0L1UMo50e
and also withoun sending client secret key i can see the trail plan is active for the customer
with only backend api call the traill plan is active
That's expected for a Subscription with a trial
Checking to see why there is no intent
pending_setup_intent this is client secret key right?
Bear with me please
cus_O9SYxuk4MwNYvs has a default_source
You need to unset that, otherwise we'll use that (and we won't generated a Setup Intent)
i hv unset from code
and is this correct?pending_setup_intent this is client secret key right?
i hv got this
pending_setup_intent:
'seti_1NdAl8SCfQjwTWJ02B6DCNtD'
Ok, great!
but with this how will we create payment sheet?
we need client secret for frontend right
So you need to expand that field in your create call instead of latest_invoice
Then it'll return the full Setup Intent object, including client_secret
expand: ['latest_invoice.pending_setup_intent'],
?
No: expand: ['pending_setup_intent']
Okay but am trying this const customer = await stripe.customers.update(
customerId,
{ invoice_settings: {default_payment_method:""} }
); to unset the payment methods which didnot work
then i manualyy deleted all cards of customer
how do we make sure this unset is done from dashboard?
Okay let me try this
How can we make sure that the newly added card is made as defualt payment menthod because in dashbaord apart from making card as defualt their is no differentiator to make sure it si working
i checked everywhere in invoice or in subscription customer it never says this is the so and so defualt method which will be used
hello?
Hey! Taking over for my colleague. Let me catch up.
For payment method priority I invite you to check this guide:
https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority
What is the issue you are facing actually after setting the invoice_settings.default_payment_method of the customer
after unsetiing this is their a way we make sure it is actually unset on dashbaord
is this mean making card defualt for a customer or this is different?
yes I think so, I don't know what is the logic used behind the "default" of the dashboard but if you unset all default payment methods, customer's default source and set only invoice_settings then you should see that payment method in the dashboard
are you observing something different in your case ?
It is very confusing
Also we are unsetting defualt payment method before calling subscription api and then passing this params const subscribe = await stripe.subscriptions.create({
customer: customerId,
items: [
{ price: priceId }
],
payment_settings: {
save_default_payment_method: "on_subscription"
},
expand: ['latest_invoice.payment_intent'],
}); even after this the paymenthod added with payment sheet is not attached to the customer
When we again call subcribe api we get this error - 'This customer has no attached payment source or default payment method. Please consider adding a default payment method
How is ths works?
we are unsetting priorly and mentioning that newly added card to be the defualt payment method but it doeanot work
Hello?
Is this chat on?
HELLO
hELLO
ANYONE IN THIS CHAT?
@grizzled sun ?
Do you have a new requestId after setting a default payment methods
yes
evt_1NdBOtSCfQjwTWJ0HG7g7WKH
this is generated when invoice was paid for trail period
i hv set this in subcription but still it says defulat payment method not set
Could you share the failure request Id ?
req_sSnTiZU0kBSNfs
that customer cus_OCvVl2tkZW8b5J don't have a default payment method in their invoice settings invoice_settings.default_payment_method
save_default_payment_method: "on_subscription" saves the PM to the Subscription (default_payment_method), it does not set it as default on the Customer
If you want to do that, you need to update the Customer manually
manually how?
how will we get the payment menthod id added because the webhook doesnot send that
Make an API call to update the Customer object and set invoice_settings.default_payment_method
Which event? It should be in customer.subscription.* events
will this be generated when we are subscribing with trail periods?
Yes, there will be a customer.subscription.created event
what is the difference between invoice.paid and customer.subscription.created? both are same
Not the same at all. One is a Invoice object, the other a Subscription object
invoice.paid will theoretically fire every billing cycle, customer.subscription.created only fires on creation (once)
Okay so we can use customer.subscription.created this to update customers defualt paymenthod method is what ur suggesting?
Well the default_payment_method probably won't be set at the point of creation
Then how do we manually setup customerd defualt payment method ?
There will likely be a setup_intent.succeeded event. Use that