Skip to main content
This guide gets one hosted checkout payment moving end to end. It uses inline line items so you can integrate first and add catalog objects later.

Prerequisites

  • A test-mode secret key (sk_v1_test_...), created in the Dashboard.
  • A backend route that can call Ionic without exposing the secret key to the browser.
  • A success URL and cancel URL in your application.
Never create checkout sessions directly from browser code with a secret key. Your frontend should call your server, and your server should call Ionic.
If your backend runs Node, install the server SDK. It carries typed request and response shapes for every endpoint, generates an idempotency key for each mutating call, and retries transient failures with backoff. Every step below also shows the raw HTTP call for other stacks.

1. Create a session

Create the session from your server.
amount is in cents: 15000 is $150.00. Repeating the request with the same Idempotency-Key and body returns the original session instead of creating a duplicate; the SDK generates a key per call when you omit the field. The response includes a session id, status fields, line item totals, and a hosted checkout url when the session can be opened by the buyer.

2. Redirect the buyer

On your frontend, redirect to the returned url.

3. Verify the result

After the buyer returns to your success page, use the session_id from the URL to look up the session from your server.
Treat the redirect as a user experience step, not confirmation of payment. Fulfill from a verified checkout.session.completed webhook only when the session is both complete and paid. The webhook quickstart sets one up in about five minutes.

What to build next

  • Fulfill orders from the checkout.session.completed webhook; the Hosted Checkout guide shows the handler.
  • Keep buyers on your own domain with embedded checkout, or compare all three surfaces in Ways to accept payments.
  • Add products and prices when inline amounts become hard to manage.
  • Add optional items for add-ons and upgrades at checkout.
  • Add payment links when the same payment surface should be reused or shared.