#lesc-subscription-paymentintent

1 messages ยท Page 1 of 1 (latest)

brittle wolfBOT
merry river
azure tartan
#

Well I tried to create the subscription like that:

subscription = await stripe.subscriptions.create({
  customer: customerId,
  items: [{
    price: priceId,
  }],
  payment_behavior: 'default_incomplete',
  metadata: metadata,
  default_payment_method: paymentMethodId,
  off_session: true,
  expand:['latest_invoice.payment_intent'],
});

But it leaves the subscription on incomplete even though the payment method was set. Can I just confirm the payment intent on the backend which I received from the subscription creation?

merry river
#

Do you have the API request ID for this subscription creation?

azure tartan
#

Let me check

#

Idk if that's the request ID: req_b1hd76MrQjFOJS

merry river
#

Wait...this is the first invoice, correct?

azure tartan
#

Yes

brittle wolfBOT
merry river
#

In that case it will remain in draft state for 1 hour so you can apply any changes you might need.

azure tartan
#

And after that 1 hour? Will the payment intent be confirmed? If so can I do that manually after the subscription creation?

merry river
azure tartan
#

Yea but if I take the payment intent id and call stripe.paymentIntents.confirm() it should be confirmed right?

topaz topaz
#

@azure tartan What are you really trying to do here? What's your overall integration flow?

#

lesc-subscription-paymentintent

#

Like your code is explicitly passing payment_behavior: 'default_incomplete'. This is literally here to say "please do not attempt to do anything, I'll get the customer to pay client-side" which doesn't seem like what you want at all right?

azure tartan
#

In the docs it says the following:

Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment

To me that just sounds like if that's the right value if the invoice requires payment in general which is obviously the case

topaz topaz
#

It isn't no, this is solely for integrations that will then collect paymeht method details client-side later

#

In your flow, it doesn't make sense I'd say to use this

azure tartan
#

Hmm ok, didn't know that sorry. I figured it out now. Thanks for your support!

topaz topaz
#

sorry wrong button

#

Okay so if you remove that parameter, it should in theory attempt to charge the customer's default payment method. Or set the right one on Subscription creation in default_payment_method

#

and then it should do the right thing for you. Can you try @azure tartan and let me know?

azure tartan
#

It worked yes. Thank you

topaz topaz
#

@azure tartan awesome! so make sure to handle declines too since that synchronous payment could fail

#

and then you need to decide what behaviour you want: do you want the Subscription to fail creation, or do you want it to go to incomplete

azure tartan
#

I think failing creation would be better.
Also I have one additional question. In my subscription system customers can subscribe to the same plan again if they have a canceled plan that is still running out. In this case can I just pass billing_cycle_anchor with the canceled sub's end date and proration_behavior: 'none' for the subscription to start at a later date?

topaz topaz
#

I don't understand what that sentence could mean

azure tartan
#

Sorry ๐Ÿ˜…
I'll try again: Let's say a customer starts a monthly subscription plan. Then they cancel the subscription after 2 weeks. This means the subscription is canceled and the current cycle ends in 2 weeks. Now the customer starts a new subscription plan of the same product/price. If the customer tries to do that, I fetch the old, canceled subscription. Now how do I make it so billing of the new subscription starts at the end of the canceled subscription's cycle (and from there every 4 weeks)? By setting billing_cycle_anchor and proration_behavior: 'none'?

#

...without using subscription schedules

topaz topaz
#

All you want to do is "stop the cancellation" right? Like they changed their mind and are basically re-activating their subscription, no?

azure tartan
#

Basically yes. But I want to create a new subscription that starts when the canceled subscription ends (like when the last cycle ends)

#

Figured it out. That's all I needed. Thanks again for your support guys

topaz topaz
#

@azure tartan why aren't you keeping the current Subscription?

#

it's better than a new Subscription

azure tartan
#

In my case it's more convenient and gives customers a better overview

#

Will take a look at that though

topaz topaz
#

sounds good, just wanted to make sure you were aware of this possibility

azure tartan
#

Yea I am aware of that

topaz topaz
#

awesome!

azure tartan
#

You can close this thread. Thanks for helping out :)