#dominikganic_best-practices

1 messages ยท Page 1 of 1 (latest)

uncut wharfBOT
#

๐Ÿ‘‹ 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/1333376956280082432

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

timber wigeon
#

hi there!

#

you would update the payment method of the customer/subscription to one that would fail the payment.

#

or a simpler option is to create a subscription with a short free trial (a dew seconds), and without a payment method. as soon as the trial ends, the subscription becomes upaid

flint vortex
#

Ah alright. I will try that fast, will come asap back in a second

#

In my SubscriptionOptions I can set "trial_period_days" but how do I set this to seconds as it requires days and minimum 1? (Backend Subscription Creation API)

flint vortex
#

I've set this to "now"

The subscription has been created with status "incomplete" as the payment intent hasn't been paid yet

#

But it's still not "unpaid" - Do I have to perform a failed payment?

uncut wharfBOT
timber wigeon
#

I've set this to "now"
no, you need to set it to a few seconds in the future

patent torrent
flint vortex
#

I don't understand Test Clocks to be honest, I don't know what to do there haha

#

Okay, I'll try setting it a few secs ahead, even though the docs mention "now" is a possible value

#

This is btw. the created sub yet: sub_1QlpGjLZihhBkt1cTXpHu0fa

patent torrent
flint vortex
#

Okay now I've created a new subscription with trial_end from now + 10 seconds (time() + 10)

The subscription was in state "trialing"

After the 10 seconds, it became now "active" even though no payment has been done and an invalid payment method was added (Testcard with failing)

Now I see in the stripe dashboard the notice that the invoice will be created and charged in one hour?

#

sub_1QlpLoLZihhBkt1cOPQgtCmG

patent torrent
flint vortex
#

Yes I've tried manually paying it with the invalid payment method and now I'm in mode "past_due" which is also great for me for implenenting an alert "Please pay your invoices" ๐Ÿ™‚

Now I will try re-paying it a few times until it triggers to set the state to "unpaid"

flint vortex
#

I've re-tried now the payment 4 times.
But when I call my API to get the information for the "past_due" status, I receive this:

attempt_count: 1
max_retry_attempts: 3

I wonder why I still receive the attempt_count is 1?

This is how I fetch the attempt_count in my backend through the API:

            $AmountDue = $LatestInvoice->amount_due / 100;
            $NextAttempt = $LatestInvoice->next_payment_attempt ? $LatestInvoice->next_payment_attempt : null;
            $MaxRetryAttempts = $Subscription->automatic_tax->enabled ? 3 : 3;```
#

I feel like $MaxRetryAttempts is wrong.

#

But why is attempt_count 1, even though I've retried the payment already 4 times as you can see on the picture? ๐Ÿ™‚

patent torrent
#

I think it counts only automatic retries, not manual retries.

flint vortex
#

Ah okay, that makes sense

#

Can I create a clock now to this subscription and this customer to retry that?

#

Okay nevermind I will just await this invoice, I'm not in a hurry actually.

#

But, where can I setup retry attempts counts?

I'd like to set it to 2 retries within 1 day

#

So I don't have to wait now for 8 retries in 14 days ๐Ÿ™‚ I remember there are some settings in the dashboard anywhere.

patent torrent
flint vortex
#

I will for sure give this a hit when I have some free time ๐Ÿ™‚