#yaziit-default
1 messages · Page 1 of 1 (latest)
as the other person said, you can set you need to pass either https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method or set https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
, to make something the default for recurring payments(not sure of your overall goal/use case).
@twin tiger can you describe in more detail overall what you're doing?
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 }})
])
@wraith island thanks but do you mind if I help out here instead?
hi
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.
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
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"}
);
ohh ok, thanks and whats the good way to make this ?