Stripe subscription links that end after a number of payments - stripe-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)?

Related

Is there a way to avoid creating "status: incomplete" subscriptions during Stripe Checkout?

Background:
When creating subscriptions through the Stripe API, you can use payment_behavior: error_if_incomplete when you want Stripe to return an HTTP 402 status code in case a subscription’s first invoice cannot be paid. In this case Stripe does not create a subscription at all if the payment fails.
Question:
Is there a way to achieve the same behavior when using Stripe Checkout?
My experience is that even if the payment fails, Stripe creates a subscription with status: incomplete which is then expired if no successful payment is made within 23 hours. I've checked the parameters for creating Checkout Sessions but found no option to set payment_behavior there.
Sources:
https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
https://stripe.com/docs/api/checkout/sessions/create
Bad News
Unfortunately this is not something that can be configured presently. When Checkout creates a subscription, all the parameters not provided directly are set to the Subscription default. The default payment_behavior for a Subscription is default_incomplete.
Good News
You can achieve this behavior using Webhooks. You would listen for the invoice.payment_failed event, check the billing_reason property of the invoice is subscription_create (identifies the first invoice of a new subscription), and then cancel the related subscription.
If you are using Subscriptions and Invoices, it is recommended you use webhooks anyway to keep track of changes in status.

Stripe SEPA payment method

I am trying to implement stripe subscriptions in php. I create my subscriptions on the checkout session which payment method is Card and everything works fine. However, I want to check if going one step further is possible. I want to keep the first payment method as Card upon creating the subscription but I want all the succeeding payments to have SEPA payment method. Is that possible? And if yes could you please give me general steps for the overall process?
Just start your subscription with the initial card payment.
Separately, you should follow Steps 1-4 of the guide for setting up Sepa Debit subscriptions.
Then, at Step 5, you can either set the Customer invoice_settings.default_payment_method (API ref) or you can set the default_payment_method (API ref) on the Subscription, depending on how you choose to set things up. This will replace the payment method to be used for future renewal payments on the Subscription.

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

Migrating stripe subscription to be SCA compliant

I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.
From what I understand the subscription API is not SCA compliant. Instead
An off_session payment Intent must first be setup when collecting card details.
At the end of each month a scheduler must be triggered to attempt to charge the registered card.
Is this the case? Am I now responsible for scheduling payments?
Update
For those who want some starter code, I created a working playground here with subscriptions, frontend (react) and backend (express) on glitch.
It's not true that Stripe's Subscription API is not SCA-ready, it is, and you don't have to set up your own scheduling like that. The docs you linked to are generally aimed at processing one-off payments(like saving a customer's details and then allowing them to use them again when they re-visit your site to purchase something new, for example) as opposed to recurring ones.
https://stripe.com/docs/billing/subscriptions/payment describes how to set up a subscription in a way that is SCA-ready. While the customer is on-session on your payment page, you collect card details and create a subscription for the customer, which will generally attempt a payment for the first billing period. You then check the status of the subscription after it's created, and handle the outcomes:
the subscription is active and the payment was successful, so you can proceed with provisioning your service to the customer.
the subscription is incomplete — for SCA purposes, let's say this is because 3D Secure authentication was required for that first payment. In this case, the latest_invoice of the subscription exposes a PaymentIntent property, and you use that PaymentIntent in conjunction with your frontend code using stripe.js to walk the customer through authenticating the payment, and that activates the subscription.
the subscription is trialing — if the subscription doesn't involve an initial payment, like when using a trial period for example, you can also check if the subscription has a pending_setup_intent. You can use this on your frontend to have the customer complete a 3D Secure authentication, so that future payments(like the first one after the trial) are more likely to successfully claim an exemption and not require having the user authenticate at that point.
You can also instead use Stripe Checkout to easily collect payment details and set up a customer and subscription for you, while also handling any initial authentication that's needed : https://stripe.com/docs/payments/checkout/server#create-subscriptions
As for the recurring payments, Billing can handle that for you. You can configure you settings to automatically email the customer to complete 3D Secure if it's encountered on a recurring payment. So you can absolutely build an SCA-ready solution with the subscriptions API on Stripe.

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

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)

Resources