#Robert de Nuiro-subscriptions

1 messages ยท Page 1 of 1 (latest)

bleak yew
#

๐Ÿ‘‹ happy to help

heady pawn
#

Thank you for taking my problem into consideration

bleak yew
#

are you using checkout?

heady pawn
#

I am using the payment element from stripe

#

I use react for the front

#

I don't use the checkout page hosted by stripe

bleak yew
#

ok

heady pawn
bleak yew
#

there's a new parameter

#

it would do that without having to rely on webhooks

heady pawn
#

Ok nice, so I have to set the var default_payment_method while creating the subscription ?

bleak yew
#

no you don't, it will do it for you once the first invoice is paid

#

by setting this param when creating the subscription

heady pawn
#

ok so I don't have to change anything in my code ?

#

The problem is that I create the subscription before the customer has finished paying

bleak yew
#

you do have to do two small things, 1- remove the webhook code for that event, 2- set the save_default_payment_method to true when creating the subscription

#

all the rest of the flow would still be the same

heady pawn
#
const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{
        price: priceId,
      }],
      default_payment_method: "",
      payment_behavior: 'default_incomplete',
      expand: ['latest_invoice.payment_intent'],
    });`
#

"payment_settings.save_default_payment_method optional enum
Either off, or on_subscription. With on_subscription Stripe updates subscription.default_payment_method when a subscription payment succeeds."

#

Ok so I'll put payment_settings: {save_default_payment_method:"on_subscription"}

#
const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{
        price: priceId,
      }],
      default_payment_method: "",
      payment_behavior: 'default_incomplete',
      expand: ['latest_invoice.payment_intent'],
      payment_settings: {
        save_default_payment_method: "on_subscription"
      }
    });
#

Sorry for the inconvenience, your api is really great

bleak yew
#

perfect

#

sorry, it's a new feature we just added last week, I'm still not on top of it a 100%

#

I thought it was a boolean ๐Ÿ™ˆ

heady pawn
#

Haha no problem, I find it already incredible the help you bring on discord and the speed at which you answer

bleak yew
#

let me know if you need any more help

heady pawn
#

I'm sorry to bother you again but I feel like it doesn't set the default payment method when I added save_default_ payment_method: "on_subscription"

I did remove the webhook, here is my code :

const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{
        price: priceId,
      }],
      payment_behavior: 'default_incomplete',
      expand: ['latest_invoice.payment_intent'],
      payment_settings: {
        save_default_payment_method: "on_subscription"
      }
    });
#

customer id : cus_Lk2FdMg3qQFQF6
payment id : pm_1L2YCEHe8JvDQ9Zm4HDC01ZN
subscription id : sub_1L2YBFHe8JvDQ9ZmyYL5qO3i

rigid cypress
#

seems like it worked to me

#

why do you think it didn't?

heady pawn
#

Oh ok thank you

#

I don't see the payment method in the customers tab

#

And when I want to change the billing period (monthly to annual) I get a 400 with this error message: "This customer has no attached payment source or default payment method. Please consider adding a default payment method."

rigid cypress
rigid cypress
heady pawn
#

Oh yes, I see, it seems clear now ๐Ÿ’€

#

I feel so dumb ;_;

rigid cypress
#

not at all! it's complicated