I am creating a subscription from a Stripe checkout session. After a customer goes through the checkout session, an invoice is then created and triggers invoice.created. On this event, I have a webhook that is attempting to update the invoice, however, by the time it gets here, the invoice is already set to finalized and I cannot update it.
How do I get around this?
I contacted Stripe support and their recommendation (for our situation) is to give the subscription a trial period and then set the trial end to a few minutes from that point in time so that the invoice can go through each event properly.
Related
My use-case is that whenever I have a trial subscription, once the trial ends and the user has no payment method on stripe, I simply want to cancel the subscription instead of generating an invoice. Is there a way to configure this on Stripe or would it need an external task to run each day and do this for me?
A new invoice will always be generated when a payment is due, and Stripe will try to charge the customer for it. If you want to avoid it, you will need to check if the customer has a PaymentMethod on the last day of the trial, and update the Subscription to set the cancel_at_period_end property to true.
Alternatively, you can listen to customer.subscription.updated webhook event - when the status changes from trialing to active and the customer does not have a PaymentMethod, you can cancel the Subscription manually. In this case, however, a draft Invoice will still be created, but automatic collection will be stopped - the invoice will stay as a draft and will never be finalized.
I'm new to stripe webhooks. My application runs with user subsctipns. I got the user successfully use strie to activate their subscription plan monthly. now all i want is when ever stripe chargers the user with a monthly subscription, I want to update my database with the next payment date.
Ex: If user was charged on 27th July and the next payment date would be 27th Aug, I want to update my database with the customer's next payment date and send the user the notification regarding the same, as. you have been charged by your monthly subscription o plan(on 27th July) and your next payment date would next month(27 Aug).
I have an idea of how can i send user notifications but the problem I'm facing is the stripe is not updated by the database. I have used webhooks to get the notifications and update method but am unable to do so.
If anyone could guide me with this,
Thanks
To be notified when customers pay an invoice, you can listen to the webhook event invoice.payment_succeeded. In the payload you will get an invoice object, which has a subscription property.
If you retrieve that subscription, then you can find the current_period_end property to know when the next invoice will be created.
According to stripe's dashboard (test mode), customer's next subscription invoice should have been created on April 28th at 5AM but it's April 29th today and the invoice has not been created yet and when I am trying to update the customer's subscription with stripe api for node js, I get the following error :
StripeInvalidRequestError: The subscription is currently invoicing and thus cannot be updated.
Then I tried to force to create an invoice but got the following error :
StripeInvalidRequestError: Nothing to invoice for customer
I have not Idea why stripe doesn't want to create this invoice and I don't know how I can force it to be created.
Any idea ?
When an invoice is created, Stripe will send an invoice.created event and wait for a successful webhook response to finalize and attempt to pay the invoice.
If the Stripe doesn't receive a successful webhook response, it will wait for 72 hours before finalizing the invoice. This is a long delay that you want to avoid.
You might want to check if your webhook endpoint and see if it's responding to invoice.created events quickly.
So, I noticed the following behavior. When I create a checkout session with at least on recurring item (subscription), an invoice is automatically created. When the customer opens their Customer Portal, he will see the previous invoices for all subscriptions.
But, when I create a checkout session with no recurring items (one-time payment), invoice is not automatically created. Because of that, when customer opens Customer Portal, he will not see invoices for these orders.
I would like to show all customer invoices in the Customer Portal, both for recurring and one-time payments. So, is there a way generate an invoice for one-time payment and link it to the checkout session?
I contacted Stripe Support for this:
With regards to the invoices for one time charge, the checkout session
for one-time payment doesn't generate an invoice. I understand that it
is helpful for your business to create invoices for a one time charge
on the checkout session. While there’s currently no way to do that,
the workaround we can provide for your customer to see their invoices
on the customer portal, is for you to create the invoice for one time
charge rather than using the Stripe Checkout.
This is now available, but it's a little hidden in the Stripe documentation at the moment, and it's been renamed since the beta checkout invoice feature, which doesn't make it that easy to find. You just need to pass the following for non-reoccurring products...
invoice_creation => true
...when creating your Checkout Session.
Official Stripe documentation here.
I am using stripe for a subscription based project and recently found out that you can subscribe without the user requiring payment information with a trial period.
How does stripe handle the user once the trial period ends but didn't any payment information?
When I look at customers it says that there isn't any default source.
At the end of the trial period, the Subscription would renew its billing cycle. This would make the Subscription move to status: "active" and send customer.subscription.updated. A new Invoice would also be created. This would send the invoice.created event.
An hour or two later, the Invoice would be automatically finalized and Stripe would attempt to pay it. The payment would fail since the Customer has no payment method attached. This would send an invoice.payment_failed event. The Invoice would be retried multiple times as documented here. Stripe can even send emails to your Customer asking them to add/update their card.
If all payment retries fail, the Subscription would then be canceled automatically.