How can I send invoices to customers with subscriptions taking auto charges? - stripe-payments

I would like to see how I can send subscription invoices with auto charge.
From the Invoice API, billing can be either set to charge automatically or send to customers for manual payment.
But I want to charge my customers automatically and send them the invoices. It seems that it's a common option in Saas monthly subscription. Not sure how I can achieve it.
I've finished creating a subscription for a customer. But the record and invoice are only on the Stripe dashboard.
One way I thought of is to get the invoice pdf file from API and send them on my own. I am using Python / Django now.
Can someone help me out?

There are 2 ways to go about it:
1) Send the invoice with the send_invoice (see the Python example). It will know that the payment was already settled for that invoice based on the invoice ID.
2) Add a webhook endpoint to your Django app and subscribe to the webhook events invoice.created, invoice.finalized, invoice.sent, invoice.payment_succeeded. This way though you need to create your own template (email or PDF up to you)

Related

How do you generate a stripe invoice after a successfull checkout session

Quite suprisingly, it is not possible to automatically generate an invoice after as successfull checkout session with Stripe.
An invoice must always come before a payment in the stripe system.
I am left with having to recreate the invoice through a bunch of API calls fetching the PaymentIntent or the CheckoutSession that was just performed to recompute the data for the invoice and mark it as paid (not even sure I can retrieve everything I need)
This seems quite hacky... Is this the right way to do it or shall I just handle invoicing outside of stripe (quite annoying too) ?
just want clarify if you need Invoice or Receipt, because they are two different things
Invoice is something you send to customer to ask for payment (before payment)
Receipt is a proof of succeeded payment (after payment)
My understanding is that the payment is already collected upon a succeeded checkout session, so you probably want to send receipts to customers. To enable email receipts, you can go to Settings -> Emails and tick the Email customers about Successful payment box. Please note that emails won't be sent in test mode.
Let me explain a solution that you can use to generate invoices after payment in stripe. This solution is based on Zapier connectors.
There are three systems that we should connect.
Stripe
Zapier
Plumsail Documents
First, you have to set up a Stripe connection to Zapier. Go to Zapier, create a Zap, find the Stripe connection, and select "New Payment" as the trigger event. Then, connect your Stripe account with Zapier and make a test in Zap. If everything ok, go to the second step.
Second. After you have done the Zap connection for Stripe, go to Plumsail Documents, create the process, and make a template for your invoice.
Third. Set up a Plumsail Documents connection to Zapier. Go to your Zap (where you have made the connection to Stripe before), find the Plumsail Documents action, and set the Start Process as Action Event. Next, you have to select your process and match output data from Stripe payment with your invoice template in Plumsail Documents.
It seems a bit complicated, so you can read the article with a more detailed description of this solution. Also, there are screenshots for all processes.
As a result, you will get a fully automated custom invoice generation whenever you will get a payment in Stripe.
Max, product manager at Plumsail.

How to create an invoice for one-time payments in Stripe checkout

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.

Stripe subscription links that end after a number of payments

I am using the Stripe dashboard to create a subscription product link. This will be a simple web link - I am not using a server or the Stripe API. I want the subscription to be monthly, but end automatically after 6 months and stop charging the customer.
I see in the Stripe API documentation this can be accomplished with Phases and Iterations and setting end_behavior=cancel. But I don't see how to do this with Payment Links - there is only the option to add name/value metadata fields for the payment link.
Is it possible to have a Stripe Subscription link that ends after a number of iterations without having to use the server API or webhooks (just using the dashboard)?

Docusign and Stripe integration - Payments are created without a customer

I'm trying to integrate the Docusign eSignature API with Stripe.
I've created a Quickstart application and have successfully run through the process, signing the contract and making a test payment.
However, I noticed that the payment in Stripe does not have a customer object attached to it:
I'd like to know if it's possible to specify a customerId, or create one as part of the process. I did notice that the PaymentDetails constructor accepts a customerId parameter, but I could not see any relevant documentation for this, and specifying it in my request didn't seem to make any difference.
Any advice appreciated.
Thanks
Dan,
For regular payments that are one time and right away - DocuSign will not create a customer record. This is "by design" and is meant to support quick payments without any customer record.
You can set recurring/future payments and then you'll get customer records when you set the gateway. If you want, your recurring payment or future payment can be just one time in the near future and then you can achieve what you want and get a customer record.

How to create invoices using Stripe Connect Express, on Stripe Subscriptions invoices are automatically created, but not on Stripe Connect payments

I charge Customers using this guide https://stripe.com/docs/connect/destination-charges adding amount, application fee and Service provider accound_id, after that I listen for "charge.succeeded" event with webhooks. If the payment was successful I generate invoice using this this guide - https://stripe.com/docs/billing/invoices/connect, but I get this error
"Nothing to invoice for customer"
Is it possible Stripe automatically to create Invoice for me?
Do I have to manually create this invoice and then make it paid.
Should I generate the Invoice before Payment or after Payment?
When you process a payment, Stripe will send your customers a receipt automatically per your email settings [1]. In some respects, this receipt serves as an invoice of services rendered, and might be sufficient for your needs. You can see an example of what a receipt will look like for a given payment by looking at a given payment in the dashboard (under the 'Receipt history' heading).
Now, if the receipt automatically generated by Stripe doesn't meet your needs (e.g., you want to be able to list more customer info on there), then you'll want to use the Invoices API [2] instead of the Payment Intents API to process the payment. Using the Invoices API also allows you send the invoice to the customer so they can initiate payment on their own [3].
So, with that out of the way, if you intend to create Invoices for your customers you need to first create Invoice Items on the Customer and then create an invoice off that Customer. Once you finalize the Invoice, Stripe will either process a payment automatically under the hood, or send the Invoice to your Customers via email so they can initiate the payment (through a Stripe hosted page). At that point you can send your customers a copy of the Invoice PDF. With this integration there is no need to process the payment on your own or deal with any other APIs. The Invoices API takes care of everything for you. These steps are documented in detail here:
https://stripe.com/docs/billing/invoices/create
To answer your questions more directly:
No. Stripe will only automatically create invoices when you make subscriptions. But, Stripe does automatically create receipts as described above.
Yes, you manually would need to add Invoice Items to the Customer, then create an Invoice off that Customer. Note that this step will also charge the customer, so you don't need to do that separately.
Invoices process the payment under the hood once they are finalized.
[1] https://stripe.com/docs/receipts
[2] https://stripe.com/docs/billing/invoices/create
[3] https://stripe.com/docs/api/invoices/create#create_invoice-collection_method

Resources