#WhySoAsync-subscription-status

1 messages · Page 1 of 1 (latest)

safe cradle
#

Hello 👋
If I understand it correctly, you have a subscription and you want to update it so that you can make next invoice payable which should fail since you updated the card with the one that has insufficient balance?

glacial hare
#

yes, because i want to add a button with retry so user can manually retry after he changed card to a card with enough balance

#

i mean this is how it should work right? the flow

#

You still here?

safe cradle
#

Yup sorry juggling between a few threads at the moment

fading laurel
#

Hello! Taking over and catching up...

glacial hare
#

Hello

fading laurel
#

I'm not sure I understand exactly what you're trying to do and what's blocking you. Can you provide more specific details?

glacial hare
#

Yes

#

So i pay the subscription, status active all good.

I've created a functionality for changing the card and updating the default_payment_method of the subscription with the new card, that will be invoiced once per month.

But my concern is now the case where the invoice fails because user doens't have funds or the card is declined.

I need to catch that case so i can create a retry button when status is not_paid.

So the user can change his payment method to a card that has money or can't be decliend, and press the retry button to pay the invoice that failed, and activate the subscription and the functionalities of my app again.

#

My issue is to make the subscriptio not_paid somehow

#

so i can work on that functionality

#

I can't wait one month for that :))

#

So i need to trigger the next invoice now, so it will fail because the stripe test card that attaches but fails is added which is this one: 4000000000000341

fading laurel
#

What you're describing isn't really possible. Specifically this part:

So the user can change his payment method to a card that has money or can't be decliend

Any card can be declined for any reason at any time. If it's not time for the next Subscription payment you'll need to wait until it is to charge them, unless you want to charge them some kind of additional fee (but that still won't mean the upcoming Subscription payment will work later).

glacial hare
#

Yea, but if the invoice happened today for example. And my card doens't have funds, the subscription will be not_paid

#

And if i need to add another card that has money

#

i update default_payment_method of subscription with the new card that has money

#

and retry the payment so i can activate the subscription

fading laurel
#

You can do that by confirming the Payment Intent belonging to the outstanding Invoice.

#

But that's not what you described above, unless I'm misunderstanding.

glacial hare
#

Yea i'm updating the default_payment_method and changing card already.

Now i have attached a card that will fail on next invoice

#

But the next invoice is in April, and i cannot wait one month to see the status of the subscription not_paid

#

And i need to trigger the invoice of the subscription now, so it will fail, i will have the status not paid, and i can make the retry button, change to a card with funds, use that retry button to pay with that new card i added and activate the subscription again

fading laurel
#

To clarify, you update the default_payment_method, then you charge the card immediately?

glacial hare
#

I'm using the PaymentElement from @stripe/react-stripe-js to collect card details.

Then i use

const paymentData = await stripe.confirmSetup({ elements, redirect: 'if_required' });

#

i get payment method and update the default_payment_method on subscription

#

await stripe.subscriptions.update( subscriptionId, { default_payment_method: payment_method, payment_settings: { payment_method_types: ['card'], }, }, );

#

So now it will invoice from the new card, and the card i added is the one from stripe test

#

But the next invoice will happen next month. I want to trigger it somehow so it will fail, i will have the status: not_paid and create the button of retry

#

retry with the same card after i add money to the card, or retry after i change to a new card that has money

fading laurel
#

Okay, so at this point there should be an outstanding Invoice that hasn't been paid yet, correct?

glacial hare
#

yes

#

now it's active and the next invoice is in April

#

and the card attached will fail on next invoice

fading laurel
#

Hang on.

#

The outstanding Invoice, are you triggering payment on that or no?

glacial hare
#

I don't know how to trigger payment to invoice

#

Now it's triggering invoice automatically each month

#

from the card that will be declined for insufficient funds

fading laurel
glacial hare
#

yea, but i don't know how to get that id

#

of the next invoice

fading laurel
#

It's not the next Invoice.

#

It's the current Invoice.

#

You can get it from the Subscription's latest_invoice property.

glacial hare
#

Invoice is already paid

#

const activeSubscriptions = await stripe.subscriptions.list({ customer: customerDetails.data[0].id, expand: ['data.latest_invoice.payment_intent.payment_method', 'data.default_payment_method'] });

#

i'm using expand to get the latest_invoice

#

the latest_invoice doens't contain the last invoice that was paid this month?

fading laurel
#

I think there's been some kind of miscommunication. I thought the scenario was that a Subscription is created, the first payment works fine, then later on one of the recurring payments fails, so the customer provides new payment details. When they provide the new payment details you want to immediately pay the outstanding Invoice with those details to make sure that payment succeeds. What part do I have wrong there?

glacial hare
#
  1. The first payment works fine.
  2. Then i change the default_payment_method to the card that will fail on next invoice, the one i send image uptop.
  3. I can't wait one month for the recurring invoice, and i want to trigger the next invoice right now, so i can get status not_paid, so i can create the retry button and after the client adds 20$ to his account, he can press retry button and activate the subscription again.

It's for developing only, because i don't have anyother way to trigger a not_paid case so i can create the functionality

fading laurel
#

Wait, so this is all about testing the flow in test mode only, not an actual production flow?

glacial hare
#

Yes, because i've never seen the status: not_paid.

I need status: not_paid, so i can create the retry functionality

#

I think this is what i need !! Advance instantly one month so the reccuring payment triggers with the card that will fail, so i can see different subscription statuses.

#

Thank you !