Stripe
Online payments in a store and an app: choosing the flow, webhooks, idempotency and subscriptions.
IntegrationsUsing since 2022 · Featured project: CAS Marketplace (in the Code & Pepper team)
- Category
- Integrations
- Using since
- 2022
- Featured project
- CAS Marketplacein the Code & Pepper team
In practice
I pick Stripe for online payments when a store or an app takes one-off payments or subscriptions and should not build that from scratch. In the Code & Pepper team I worked with it on Gaia Lens, for subscriptions, and on CAS Marketplace, for marketplace payments.
What is Stripe?
Stripe is an online payments service with a public API, plugged into a store or an app. One-off payments and subscriptions run through a payment page, a form embedded in your app or a custom layout built from Elements components, and on the server you create a payment session or a PaymentIntent object.
The app learns the outcome of a payment from webhooks: Stripe sends events to your HTTPS address, for example when a bank confirms a payment or a customer disputes a charge, or a recurring payment succeeds. Retried requests are protected with an idempotency key, so an operation is not carried out twice.
How I work with Stripe
I start from what happens when a payment fails, not from the "Pay" button. Stripe handles the payment, but the order, the invoice and access to the product live in your app and have to agree with the state in Stripe.
The payment flow
I choose between a Stripe payment page, an embedded form and a custom layout with Elements, and I ask who will maintain it after launch. The full payment page needs the least upkeep and Elements the most.
Webhooks and retries
I change an order's state from webhooks, not from the customer merely returning to the site, and I protect requests with an idempotency key. Otherwise a customer pays and the order stays unpaid, or the other way round. A repeated event must not close an order twice.
A payment that fails
I check what the customer sees and what happens to the order when a bank declines a card or asks for extra authentication. The compensating steps for a failed payment are in the entry on Medusa.js.
When it fits, and when it doesn't
Stripe fits where a payment should be a ready-made process, not a project of its own that you have to write and maintain.
A good fit when
- Your own store or a marketplace that takes online payments from customers by several payment methods.
- An app with subscriptions where recurring payments should lead to invoices and statuses.
- A team that prefers a ready payment flow to its own card form.
- A project where orders move on events instead of on redirects.
Not a fit when
- Sales where customers pay only by a traditional bank transfer or on delivery.
- A company that has to use a payment provider imposed by its bank or a partner, and cannot change that.
- A project with nobody to handle refunds and disputes on the business side.
When a Polish provider matters, for example Przelewy24, I look at it next to Stripe and compare the two on the payment methods your customers want.
Frequently asked questions
Planning a store or an app with online payments?
Tell me what you sell, how customers should pay and where orders land today. I will say whether a Stripe payment page is enough or you need your own order and subscription logic.