#soumya

1 messages · Page 1 of 1 (latest)

crisp saddleBOT
upbeat flax
#

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

#

You can expand that and there'll be a client_secret to use

vague drum
#

But will the added payment method will be attached to the further invoice for renewals for the subscription?

upbeat flax
#

Yep!

vague drum
#

so we dont have to pass any params to setup intent specifically right?

upbeat flax
#

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

vague drum
#

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?

upbeat flax
#

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

vague drum
#

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

upbeat flax
#

What's the sub_xxx ID?

vague drum
#

sub_1NdAKbSCfQjwTWJ0YnGh4UVi

upbeat flax
#

Well that's because the cus_OCvVl2tkZW8b5J has a default PM saved so we'll automatically use that for subscription payments

vague drum
#

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?

upbeat flax
upbeat flax
vague drum
#

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?

upbeat flax
#

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

vague drum
#

how can we unset this filed can u share the relevant doc?

#

by passing null?

upbeat flax
#

Pass an empty string

vague drum
#

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

upbeat flax
#

It'd be set as the default on the subscription not the customer

vague drum
#

so the same will be used for renewal right?

upbeat flax
#

Yes, default_payment_method will be set and that takes precedence for recurring payments

vague drum
# upbeat flax Pass an empty string

"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

upbeat flax
#

invoice_settings is a hash. You need:

invoice_settings: {
  default_payment_method: ""
}
vague drum
#

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

upbeat flax
#

Checking to see why there is no intent

vague drum
#

pending_setup_intent this is client secret key right?

upbeat flax
#

Bear with me please

crisp saddleBOT
upbeat flax
#

cus_O9SYxuk4MwNYvs has a default_source

#

You need to unset that, otherwise we'll use that (and we won't generated a Setup Intent)

vague drum
#

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'

upbeat flax
#

Ok, great!

vague drum
#

but with this how will we create payment sheet?

#

we need client secret for frontend right

upbeat flax
#

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

vague drum
#

expand: ['latest_invoice.pending_setup_intent'],
?

upbeat flax
#

No: expand: ['pending_setup_intent']

vague drum
#

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?

upbeat flax
#

It's the default_source field that needs unsetting

vague drum
#

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?

grizzled sun
#

Hey! Taking over for my colleague. Let me catch up.

#

What is the issue you are facing actually after setting the invoice_settings.default_payment_method of the customer

vague drum
#

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?

grizzled sun
#

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 ?

vague drum
#

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
#

Hi I'm monitoring your thread

#

please be mindfull

vague drum
#

Okay

#

their was no response hence

grizzled sun
vague drum
#

yes

#

evt_1NdBOtSCfQjwTWJ0HG7g7WKH

#

this is generated when invoice was paid for trail period

grizzled sun
#

Yes and what is the issue ?

#

this is an invoice.paid event

vague drum
grizzled sun
#

Could you share the failure request Id ?

vague drum
#

req_sSnTiZU0kBSNfs

grizzled sun
#

that customer cus_OCvVl2tkZW8b5J don't have a default payment method in their invoice settings invoice_settings.default_payment_method

upbeat flax
#

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

vague drum
#

manually how?

#

how will we get the payment menthod id added because the webhook doesnot send that

upbeat flax
#

Make an API call to update the Customer object and set invoice_settings.default_payment_method

upbeat flax
vague drum
upbeat flax
#

Yes, there will be a customer.subscription.created event

vague drum
#

what is the difference between invoice.paid and customer.subscription.created? both are same

upbeat flax
#

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)

vague drum
#

Okay so we can use customer.subscription.created this to update customers defualt paymenthod method is what ur suggesting?

upbeat flax
#

Well the default_payment_method probably won't be set at the point of creation

vague drum
#

Then how do we manually setup customerd defualt payment method ?

upbeat flax
#

There will likely be a setup_intent.succeeded event. Use that