Skip to content

Search documentation

Find a page of the Sovgate documentation and jump straight to it.

Add Checkout to your site

Open a checkout session from your server, send your customer to pay, and fulfil the order when Sovgate tells you it's paid.

The Dashboard has the same steps, with your progress on each, in Checkout, Integration guide. Do them in test mode first.

Get your API keys

Your server opens sessions with a secret key, or with a restricted key that has Checkout sessions on Write. Keep it on your server, in its environment: it never goes to a browser. See Manage your API keys.

Create a session from your server

When your customer clicks to pay, your server reads the cart from your own records, never prices sent by the browser, and opens a session with what it sells: each line's name, description, image, amount and quantity. Nothing is added to your product catalog. Name your order in client_reference_id to find it again.

Send your customer to pay

Answer your customer's browser with a redirect to the session's url, Sovgate's hosted page. Once they've paid, the page sends them to your success_url.

Fulfil orders on checkout.session.completed

Sovgate sends checkout.session.completed to your webhook endpoint once a customer has paid. Check its Sovgate-Signature, read the session back, check that payment_status is paid, then fulfil the order you find by client_reference_id, once: the same event can arrive more than once. See Receive events with webhooks.

Test with test cards

In test mode, pay on the page with a test card that succeeds and watch the session complete, then with one that's declined and see it stay open for the next try. See Test your setup.

Go live

Put your live keys in your server's environment in place of the test ones, add a live webhook endpoint for checkout.session.completed, and open your first live session. Live and test mode keep their own keys, endpoints and sessions.

Create a session

Create a session
bash
curl https://api.sovgate.com/v1/checkout/sessions \  -H "Authorization: Bearer $SOVGATE_SECRET_KEY" \  -H "Idempotency-Key: $(uuidgen)" \  -H "Content-Type: application/json" \  -d '{    "mode": "payment",    "line_items": [{      "quantity": 2,      "price_data": {        "currency": "usd",        "unit_amount": 2000,        "product_data": {          "name": "T-shirt",          "description": "Comfortable cotton t-shirt"        }      }    }],    "client_reference_id": "order_8812",    "customer_email": "jenny@example.com",    "success_url": "https://shop.example.com/thanks?session_id={CHECKOUT_SESSION_ID}"  }'

Every request that creates something carries an Idempotency-Key, so a retry never makes a second session.

Read a session back

Read a session
bash
curl https://api.sovgate.com/v1/checkout/sessions/$SESSION_ID \  -H "Authorization: Bearer $SOVGATE_SECRET_KEY"
Allow your return addresses

In live mode, Checkout sends customers only to the domains on your list. Add yours in Settings, Checkout and Payment Links under Allowed return addresses. See Customize your checkout.