#yurt_subscription-paused

1 messages Β· Page 1 of 1 (latest)

latent quiverBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

πŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1432812111431471265

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

fringe python
#

This is the code that I am working with to resume the paused subscription:

  if (subscription.status === 'paused') {
    console.log(`Resuming paused subscription.... ${subscription.id}`);
    // Resuming a paused subscription will generate an open invoice.
    await stripe.subscriptions.resume(subscriptionId, {
      proration_behavior: 'none',
    });

    const invoices = await stripe.invoices.list({
      subscription: subscriptionId,
      status: 'open',
      limit: 1,
    });

    // The open invoice must be paid before the subscription is resumed.
    if (invoices.data.length > 0) {
      const result = await stripe.invoices.pay(invoices.data[0].id, {
        payment_method: paymentMethodId,
      });

      console.log(
        'Paying outstanding invoice for paused subscription...',
        result.status
      );
bitter sorrel
#

Hello
sorry for the delay

fringe python
#

hello

bitter sorrel
#

If you unset the default_payment_method from the subscription, does resume work in that case?

fringe python
#

Hmm let me check - how do I unset it?

bitter sorrel
#

I think you can update the subscription and set default_payment_method: ''

latent quiverBOT
fringe python
#

I removed the default payment method on the subscription and replayed the event against my webhook and received the same message

#

The customer does have a default payment method set as well

radiant cradle
#

πŸ‘‹ Taking over, just taking a moment to get caugh up.

fringe python
#

Hi Mossy! Thanks πŸ™‚

radiant cradle
#

Looks like a rough edge with this particular PM.

Seems the solution is to:
1.) Set up the SEPA payment method, but don't make it the customer's default payment method yet
2.) Call the resume endpoint https://docs.stripe.com/api/subscriptions/resume - this will result in the generation of an invoice in an β€œopen” state.
3.) Make the SEPA payment method the customer's default
4.) Call the pay invoice endpoint to pay the open invoice https://docs.stripe.com/api/invoices/pay

fringe python
#

Oh interesting.. If I switch the logic for all payment methods to go in that order, should it work?

radiant cradle
#

I believe so.

#

Which makes sense rather than have two separate flows.

fringe python
#

I am trying to see if this will work as intended

fringe python
#

Sorry it takes a moment to get everything together

#

πŸ™ Yeah that did not seem to work

#

req_jeZQMTP2CgWFDA

#
    await resumePausedSubscription(subscriptionId, paymentMethodId);
    await saveCustomerDefaultPaymentMethod(
      session.customer!.toString(),
      paymentMethodId
    );
    await setSubscriptionPaymentSettings(subscriptionId, paymentMethodId);
    await payOpenInvoice(subscriptionId, paymentMethodId);

This is the order I sent the subscriptionthrough

#

This is the checkout.session.completed event generated: evt_1SNJkaEXjRBPmDmBF6tLHZqC

radiant cradle
#

It looks like the error is saying that the default payment method is sepa, where the work around requires that no default be set until after resume.

#

You might need to check that there is no default set before testing the flow.

fringe python
#

ok, yeah interesting, it seems like somehow the subscription was set to charge the specific method

latent quiverBOT
verbal yew
#

yurt_subscription-paused

fringe python
#

Hi there, I'm still working on seeing what is causing the default payment method to be set

verbal yew
fringe python
#

Oh! Thanks for finding that! I didn't think it was possible for that to happen because I commented it out... maybe it went through anyway. I'm deleting that now and trying again

#

how were you able to find that request?

#

Ohhhhhhh I see what is happening. The request is getting picked up by my staging servers! The IP address of that request finally helped me see what is going on

verbal yew
#

I work at Stripe so I have access to tools internally to pinpoint changes to a given Subscription

#

and glad you could narrow it down quickly from that!

fringe python
#

If I turn off the webhooks for the endpoint, I still should get the webhooks forwarded locally if I'm using the Stripe CLI, right?

verbal yew
#

yes

fringe python
#

ok trying again with it turned off... ha

fringe python
#

OK I think that finally worked!