#yaziit-default

1 messages · Page 1 of 1 (latest)

tame jewel
#

@twin tiger can you describe in more detail overall what you're doing?

wraith island
#

const sub: Stripe.SubscriptionCreateParams = {
customer,
default_payment_method,
items: [{ price }],
default_tax_rates: [tax_rates.eu_vat_greece],
trial_end: nthOfNextMonth(2),
off_session: true,
payment_behavior: 'allow_incomplete'
}

await Promise.all([
stripe.subscriptions.create(sub),
stripe.customers.update(customer, { invoice_settings: { default_payment_method }})
])

tame jewel
#

@wraith island thanks but do you mind if I help out here instead?

twin tiger
#

hi

tame jewel
#

hello there

#

so what exactly are you trying to do? You mentioned "source" but Source/Card objects are deprecated so you generally would not be using those

#

we also don't have a concept of a "default" payment method for customers in general(only for recurring payments), so it really depends overall what you're trying to do here and what you have already built.

twin tiger
#

i want to create a route for updating user cards

Im using this in front

const result = await stripe.createSource(await elements?.getElement(CardElement), {
type: 'card',
currency: 'eur',
owner: {
name: cbName,
},
})

#

then i do this in back

await this.stripe.customers.update(
customerId,
{source}
);

#

the new card is added, but the old card is still there as default payment

tame jewel
#

well that is a legacy way of using the API and you shouldn't do that at all

#

but if you're doing it that way, you need to update default_source instead, that remoes the old one and adds the new one while also making it the default.

                customerId,
                {default_source: "src_xxx"}
            );
twin tiger
#

ohh ok, thanks and whats the good way to make this ?

tame jewel
#

I assume you have a legacy codebase you're working on, since none of our guides have described using your approach for a few years now

twin tiger
#

thanks so much ❤️

#

i will update all my code i think ><

#

thanks dude i appreciate