#cho_invoice-attempts
1 messages ยท Page 1 of 1 (latest)
๐ 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/1224751262373773362
๐ 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.
- cho_subscription-schedules-billingcycles, 6 days ago, 10 messages
In a little more detail:
- our product charges subscription and sells an e-commerce good on subscription every month/quarter.
I create a subscription object of my own in database
Sometimes, the customer's payment fails, and so when the invoice clears I need to invoke a function that will make a subscription object in db.
Therefore I need to distinguish which ones are Failed ones retrying and succeeding
Hello! Generally we recommend listening for the invoice.paid webhook event if you want to be notified of invoice payment succeeding. If you want to know if it's been retried, you can check attempt_count on the Invoice
so technically if, I get the invoice.paid, it will have "subscription_create" billing_reason and I can check this "attempt_count" > 1 and it should theoretically be it?
Yup
I guess my ask is do I do attempt_count >1 or >=1 ? As in, if it clears the first time is it 1
I just looked at a different charge event and it says "1" on the attempt_count, but I just wanted to confirm
Actually attempt_count may not be the best one to use since it'll only be increased with automatic payment attempts, not manual ones
GIve me a minute to find a better option
I was going to wonder, because atm our customers Do get comms when it fails and we send them the invoice pdf for them to try
My customers are automatically charged on their card and that is the most standard way for them to pay.
Alternative methods after failure are: manually paying invoice via pdf / retry
In this case, then would this code be sufficient:
case 'subscription_create':
if (invoicePaid.attempt_count > 1 || ``invoicePaid.collection_method === 'send_invoice') {
console.log('attempt count was greater than 1');
}
invoicePaid is the invoice obj
oh, this is js
No, I don't think that'll work - a manual payment attempt after initial failure will have attempt_count=1. If you really want to be sure you'd have to list all the charges associated with the Payment Intent to see how many attempts there were, or you could update the Invoice with metadata after the initial failure and then check to see if that metadata is present on future attempts
hmm, in that case would our original solution work if I disabled sending the customer a pdf copy and asked them to instead, update their default payment method for the subscription and then they did that and the retry succeeded will it have attempt_count = 1
Yes it would still have attempt_count=1
So I don't think my original suggestion of relying on attempt_count will work
It'll be much safer for you to set your own metadata that you're in control of
ouch haha
then could you help me with what webhook to listen to for the failures
I see invoice.finalization_failed is that it?
No, you want invoice.payment_failed
okay fantastic
I will work through with that
the metadata idea was ๐ฅ saves our space complexity
ty ty
๐