Checkout with Stripe Elements
The drop-in’s payment step is useCheckout, useSetupIntent and Stripe’s Payment Element; this page builds the same step by hand so the cart, the card form and the pay button live in your own layout. Schematic stays between your product and Stripe: it prices the cart, saves the card on the company, charges it on finalize and updates entitlements as soon as the subscription changes.
The flow
- Your component writes the cart with
useCheckout().setSelections; every write re-prices on the server, andsnapshot.dueNowis what the finalize will charge. useSetupIntent().create()answers with a setup intent, the Stripe publishable key to load Stripe with, and the client secret the Payment Element mounts on.stripe.confirmSetupsaves the card.usePaymentMethods().setDefaultputs it on file for the company, so the company’s methods on file include it, and the cart names it aspaymentMethodId.finalize()charges the cart. When the result carriesconfirmPaymentIntentClientSecret, the payment needs the customer, as with 3-D Secure, andstripe.confirmCardPaymentcompletes it.
Recipe
Summary renders snapshot.dueNow, snapshot.totalPerBillingPeriod, snapshot.proration and snapshot.discounts, and lists problems beside them; it never totals the cart itself. Derivations has deriveCheckout for the lines and totals the drop-in shows.
A confirmation the customer fails or abandons leaves the checkout completed on the server, so a retry confirms the payment again rather than finalizing again, which the server would refuse. Stripe takes the card off an intent whose authentication failed, which is why the retry names payment_method.
What stays enforced
Downgrade protection, trial rules, bundle compatibility, currency availability, tax collection and the agreement text all apply on the server, so a cart the rules reject answers with problems and a finalize with a blocking one is refused with the fresh list. Show the reasons next to what they concern. What the form collects beside the card, such as an address, email or phone, comes from the catalog’s checkout settings on useCatalog, and the Payment Element’s fields option follows them.
Saved payment methods
usePaymentMethods lists what the company already has on file. For a returning customer, skip the Payment Element and write one of those externalId values as paymentMethodId on the cart before finalize(); snapshot.paymentMethodRequired says whether the cart needs one at all, since a trial that needs no card and a purchase a credit balance covers charge nothing up front.