Third-party payment processing
When you use Stripe Billing with third-party payment processors, Stripe consolidates all of your key billing data, such as subscriptions, invoices, payment amounts, and payment frequencies.
Want to learn about improvements to our integration?
Thank you! We'll be in touch soon.
Mark as paid out-of-band integration
In this type of integration, your system submits payments based on Stripe Invoices to the third-party processor. When the payment completes on the other processor, your system records the Stripe invoice as paid out-of-band. The rest of Billing’s subscription cycle continues normally. You’ll customize two key Stripe Billing workflows:
- Collecting customers’ payment method details
- Paying invoices
The following diagrams illustrate the high-level request flows of a multiprocessor integration.
Collecting and storing customers’ payment method details
Paying invoices
Configure Stripe
To set up a multiprocessor integration, you have to make some configuration changes to Stripe.
Disable invoice emails
To prevent customers from paying directly on Stripe, disable automatic emails for any customer who processes payments on a third party provider. Here’s how you can do that:
- Disable Send finalized invoices and credit notes to customers in Stripe’s automatic billing settings. After you change this setting, changes to any subscription with collection_method set to
send_invoice
won’t trigger customer emails. Only use this if all of your emailed subscription invoices are paid with a third-party payment provider.
Configure customer portal
If you use the customer portal, disable Allow customers to view and update payment methods in Stripe’s customer portal settings. (You also need to disable Customers can switch plans.) You’ll need to build custom flows for allowing users to self-serve updates to their payment method on a third-party processor.
Sign up new customers
Create a Stripe customer
First create a blank Customer record on Stripe.
Create a subscription
Next, create a Subscription and set the collection_method
to send_invoice
. This setting doesn’t require a Stripe payment method and generates Invoices which must be paid directly instead. Set the days_until_due
parameter to the number of days an unpaid invoice remains open before your configured failed payment logic activates. You’re responsible for retrying failed payments on the third-party provider, and you need to set this long enough so that any recovery workflows you implement have time to complete.
Present the amount to the user for payment
Third-party payments don’t work with Stripe Checkout or Elements. You have to build a checkout flow that uses the third-party to create a valid payment method but with Stripe as the source of truth for billable amounts. To determine the amount to charge in the checkout flow, retrieve the initial invoice generated by the subscription.
Collect payment method details Third party
Follow the instructions from the third-party payment provider to collect payment method details from customers. Make sure to set up payment methods for use in future or off-session transactions.
The output of this step varies by processor. Some third-party processors provide a payment method token that you use to generate payments on that processor.
Update the Customer object
Update the Customer record created in the first step of the subscription creation flow. For convenience, store non-sensitive third-party tokens as metadata on the Customer record.
Remember to turn off the Send finalized invoices and credit notes to customers option before setting the email
property on the Customer.
Collect payment
Listen for invoice.created
webhook events
All invoices (including the first invoice created from a subscription) start in a draft state and trigger invoice.created webhooks. Invoices created by a subscription are automatically finalized after 1 hour to give time for integrations to modify the draft invoice. Finalize the invoice manually to skip this delay.
Invoice finalization triggers an invoice.finalized event. Listen to this event to trigger payments on the third-party processor.
Process payments Third party
Follow the instructions from the third-party payment provider to collect payments for the amounts represented on each invoice using the tokens stored on the associated Customer record. This might include listening to webhooks from the third party for notifications of successful payments.
Mark the Stripe Invoice as paid out-of-band
When payment on the third party is successful, mark the corresponding invoice as paid_out_of_band
.
Mark the invoice as paid before the subscription’s payment due date to keep the subscription operating normally. The Subscription object’s days_until_due attribute defines the payment due date.
Handle state changes
Stripe Subscription cancellation
To cancel Subscriptions, remove third-party payment method details from Stripe’s Customer records and your database. Listen for the customer.subscription.deleted event and delete any tokens related to the cancelled subscription.
Third-party payment cancellation Third party
Some third-party payment processors allow end customers to cancel billing agreements directly. If the processor allows this, listen for any associated events and then cancel the subscription on Stripe.
Refunds and disputes Third party
You’re responsible for processing refunds and disputes originating from the third-party processor. To maintain accurate accounting data, use Credit Notes to adjust the amounts on issued invoices to log refunds. Create a Credit Note, and set the out_of_band_amount to the refunded amount.
Other considerations
Switching between third-party payments and Stripe
To switch a customer from a third-party processor to Stripe:
- Collect a new payment method for the customer by setting up future payments or using the Customer Portal.
- Update the subscription collection_method from
send_invoice
tocharge_automatically
and set the new payment method as thedefault_payment_method
. - Delete any existing third-party payment method tokens.
Retries
You must handle any recovery of failed third-party payments yourself. Stripe doesn’t have any visibility into third-party payment state until you mark an invoice as paid.
Taxes
Stripe Tax automatically adds the correct tax amounts to invoices as long as you set a billing postal code or IP address when updating the Customer record after checkout.
Partial Payments
Partial Payments on out_of_band
invoices are not directly supported today. In the event of a partial payment, use a Credit Note to adjust the original invoice then manually generate a new invoice for any remaining balance.