#Eranga-webhook

1 messages ยท Page 1 of 1 (latest)

potent ginkgo
sleek tendon
#

@potent ginkgo Sorry, it seems to be working.

potent ginkgo
#

Glad to hear!

sleek tendon
#

Anyway I have another question

#

Now I see that an invoice is scheduled to be charged in one hour

#

I mean finalized in one hour

#

Can I finalize it now manually using the CLI? So that I can test this quickly without waiting an hour?

potent ginkgo
#

Yeah you have the Finalize API to finalize it immediately

#

hmm using CLI

#

let me see

#

I think this is the syntax

stripe invoices finalize_invoice <in_xxx>
sleek tendon
#

Thank you @potent ginkgo for your time ๐ŸŽ‰

#

I finalized the invoice

#

And the customer has no payment method

#

Ideally, I would expect the payment failure webhook to be triggered

#

Instead, I am seeing this in Stripe invoice

#

Could you be able to explain to me if I miss something in the process?

potent ginkgo
#

Yes, so the Invoice was meant to finalized and collect payment in 1 hour later, however if you call the Finalize API, it will finalize immediately, but not trying to collect. You would need to call Pay API to collect payment separatedly

#

Or it will still wait until that 1 hour mark

#
stripe invoices pay in_xxx
sleek tendon
#

Ah haaa... So finalizing means that it is uneditable. Not that it will try to attempt the payment

potent ginkgo
#

yeah that's separated steps

sleek tendon
#

Cool, so if I use stripe invoices pay in_xxx it will charge immediately

#

?

potent ginkgo
#

yes

#

it will try to charge

sleek tendon
#

Thank you ๐Ÿป

sleek tendon
#

I tried this and it works perfectly.
However, in the dashboard, I see the following details for the invoice under subscription

#

However, I can see that it is in past_due

#

I'm guessing the reason is that the subscription has two invoices. It looks like the when the subscription starts, there is an invoice for the trial period which is 0$. Could you explain what am I doing wrong here?

potent ginkgo
#

Hi, yes it normally has an $0 invoice for trial period

#

It looks like the "real" Invoice is still waiting for payment

#

Did you call Pay API on the correct Invoice Id?

sleek tendon
#

Yeah, I used the Stripe-CLI

#

But I got an error

#

Let me show you

#

Payment attempt failed

#

I have a webhook to listen to payment failure as well. So I received the failure event with attempt_count = 1

potent ginkgo
#

Ah yeah so it's expected, isn't it? Because the customer doesn't have a Payment Method

sleek tendon
#

Yes, correct.

#

But according to the subscription lifecycle, I was hoping the subscription would have transitioned to incomplete

potent ginkgo
#

I think it's still attemping due to a setting in Dashboard

#

let me find it

sleek tendon
#

Cool, thank you ๐Ÿ™

potent ginkgo
#

How does this section looks like in your Dashboard?

sleek tendon
#

I changed this to use custom schedule

potent ginkgo
#

Yes so it will wait for 7 days to retry. How about removing those 2 rules? I think the Subscription will become incomplete as you want

sleek tendon
#

If I remove that rule, it means I will be going for smart retries, right?

potent ginkgo
#

You can just leave the check box as the second options, but click on the x button

sleek tendon
#

Ah haaa... Okay, let me try

#

After saving this, I would have to redo the things again like creating the subscription, finalize the invoice, and then pay?

#

Or will it be updated to the existing one?

potent ginkgo
#

I think you will need to redo ๐Ÿค”

#

let's try and see how it goes with existing one

sleek tendon
#

Okay, no problem. Yeah, I will redo if it doesn't work

#

Then the subscription got canceled after the failed payment

#

As you can see, since there is no valid payment source, and there is no retry scheduled, ideally the subscription should be canceled, right?

#

I'm wondering whether I misunderstood the subscription lifecycle document ๐Ÿ™„

#

I think the subscription should be on past_due based on this diagram

#

Since the first invoice was for the trial, from the second invoice onwards, the subscription should be on past_due if the latest invoice payment is failed

#

So my thought earlier is wrong

"the subscription should go to incomplete status after the payment failure after the trial"

potent ginkgo
#

Let's clarify a few thing

#

What's the Subscription status for now? and what is the Invoice status for now?

#

Can you give me the Subscription Id?

sleek tendon
#

Subscription status: canceled, Invoice status: failed
Subcription Id: sub_1JmssXC8JGuaUdU6bEDxUbZr

#

Do you want my account ID?

potent ginkgo
#

No, just Sub Id is okay

#

So the Subscription was active, then we changed the retry rules, then call Finalize and Pay API again, and now it transited from active to cancel

sleek tendon
#

Actually, I created the subscription from the scratch

#

After I changed the retry rules

#

Subscription was on trialing -> active -> canceled

potent ginkgo
#

ah

#

But you expect it to be either incomplete or past_due, correct?

sleek tendon
#

Earlier I thought it should be on incomplete but now when I read again, I think it should be past_due

#

But I understand why it got canceled. It is because there is no retries for the failed payment, right?

#

And I have setup the subscriptions to be canceled if all the retries are failed

potent ginkgo
#

yes (where is that setup the subscription to be canceled if all the retried are failed , out of curiousity?)

sleek tendon
#

Subscription settings

potent ginkgo
#

ahh

sleek tendon
potent ginkgo
#

yeah so it's expected to transited to canceled

sleek tendon
#

So to summarize, if I start a subscription with a trial, if the first payment after the trial fails, it will be on past_due (assuming we have more than one retries enabled)

#

If the subscription does not have a trial, then it should be on incomplete if the first payment fails

#

Do you think this is correct? ๐Ÿ‘ผ

potent ginkgo
#

"Yes" for the first sentence. "It depends" for the second sentence due to this

#

by default, you create a Subscription with payment_behavior = default_incomplete

sleek tendon
#

Got it. I didn't change the default, so in that scenario, it will be incomplete and the customer have about a day to enter the proper card information

potent ginkgo
#

yeah

#

More in here

#

Use allow_incomplete to create subscriptions with status=incomplete if the first invoice cannot be paid. Creating subscriptions with this status allows you to manage scenarios where additional user actions are needed to pay a subscriptionโ€™s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior.

sleek tendon
#

Great ๐ŸŽ‰. I think I solved all my questions. Thank you for all your help @potent ginkgo.

potent ginkgo
#

you are welcome! I will run for today. If there is anything else feel free to open a new thread!

#

other of us can help