#lil-nasty_best-practices
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/1268319492035973193
đ 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.
- lil-nasty_best-practices, 5 days ago, 47 messages
Note that this is in a subscriptions context where the invoice is generated automatically by stripe based on a price's recurring interval
I assume invoice.created would prob be the field, but not sure if that's accurate, especially for payment methods that take time to process (like a bank account)
You'd want to look at invoice.paid in this case
Unless you specifically want the date that the invoice was created instead
invoice.paid the webhook event, which is an Event object that contains an Invoice object
So would I simply take the date we received the paid event?
Exactly
For card payments this is a simple answer because they happen almost immediately, but I want to ensure the payment date we display to the user is consistent with their bank statement if they used a bank account and it paid more than a day later
From what I understand bank account payments can take more than 1 day, but I believe in many cases that the bank displays the payment date as the day the payment processing was initiated
Which delayed payment method are you using? ACH? SEPA?
We offer many
One sec, I'll find the list
We offer
We offer many
I realized we can't rely on created date either bc if a payment fails and the user updates their payment method 2 days later and then pays the date would be wrong
There's also the potential scenario where the webhook event fails and is retried a day later
You would still get only get an invoice.paid event on the successful attempt, so that's not really a problem. As for the payment date, as far as I know, Invoices won't send an invoice.paid event until the funds reconcile
The date on the Event won't change though
Correct
Is there anyway to differentiate if an invoice is for one of the reasons below?
- Reg subscription payment
- Subscription created
- Subscription trial ended
- Subscription upgrade proration
I need to know which scenario caused the invoice out of those 4
I see billing_reason on the invoice object, but idk that it would be sufficient to differentiate all of those
You can look at the line_items for prorations: https://docs.stripe.com/api/invoices/object#invoice_object-lines-data-proration
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
For the rest you would need to inspect the Subscription that's attached to the Invoice: https://docs.stripe.com/api/invoices/object#invoice_object-subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So proration items would determine it's scenario 4
On the subscription object I would need to check the trial_end and things like that or is there a simpler way to determine the other 3?
I think if it's the initial payment that would be simple because the invoice has billing reason subscription_create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But for trial end I suppose I'd have to compare trial end date and the invoice creation date?
Actually I think the following would prob work
- Reg payment
billing_reason === subscription_cycle - Subscription creation payment
billing_reason === subscription_create - Subscription trial ended payment
billing_reason === subscription_update && subscription.trial_end === TODAY - Upgrade proration payment
billing_reason === subscription_update && LINE_ITEMS_CONTAIN_PRORATION
That sounds like the right path
Sure thing! Best of luck!