Quickstart
Accept your first payment in three steps.
1. Get your API keys
Open the Developer section of your dashboard to find your keys:
- Publishable key —
sp_client_…, used in the browser. - Secret key —
sp_secret_…, used only on your server.
Read API keys before you start.
2. Create a payment on your server
Create a payment with your secret key. Only amount and currency are required — the amount is in the smallest currency unit (cents), so 2000 means $20.00. The other fields are optional but useful: reference and metadata stay on the intent for you to read back, and externalid (keep it to 128 characters — a longer one makes the payment fail when the customer pays) travels with the payment into webhooks and the transaction record. There is no idempotency key: every call creates a new intent.
curl https://checkout.securepayapi.com/api/v1/payment-intents \
-H "Authorization: Bearer sp_secret_…" \
-H "Content-Type: application/json" \
-d '{
"amount": 2000,
"currency": "USD",
"reference": "order_123",
"externalid": "shop-order-123",
"metadata": { "plan": "pro", "seats": "5" },
"theme": "light"
}'See the API reference for every field, its limits and which are required. You'll get back a client_secret — this is what the browser uses to complete the payment:
{
"id": "k3m9q2x7v1b8n4c6d0f5g7h2",
"client_secret": "pi_k3m9q2x7v1b8n4c6d0f5g7h2_secret_…",
"amount": 2000,
"currency": "USD",
"status": "requires_payment",
"mode": "live"
}Keep the id with your order — you will read it back in step 4.
3. Collect the card in the browser
Drop in the JavaScript SDK and mount the checkout with your client_secret:
<script src="https://checkout.securepayapi.com/sdk/v1/securepay.js"></script>
<div id="pay"></div>
<script>
SecurePay('sp_client_…').mount('#pay', {
clientSecret: 'pi_…_secret_…',
onSuccess: function (r) { /* r.intentId — tell your server the customer is done */ },
onError: function (e) { /* show e.message */ }
});
</script>The widget handles card entry and 3-D Secure authentication, and tells you when the payment succeeds. r.status is "succeeded", or "pending" when the charge was accepted but its outcome is not settled yet — show "being confirmed" and never ask for the money again; your server settles it in step 4. Want to wire the iframe yourself? See Embedded checkout.
4. Confirm on your server
The browser's success is not proof — anyone can send your page a message. Before you fulfil, read the intent back with your secret key and check it:
curl https://checkout.securepayapi.com/api/v1/payment-intents/k3m9q2x7v1b8n4c6d0f5g7h2 \
-H "Authorization: Bearer sp_secret_…"Mark the order paid only when status is succeeded, amount and currency match your order and mode is live. A processing intent means the charge was sent and is not final yet — wait and read again, never charge a second time. If the customer approved a Google Pay payment and the intent still reads requires_payment, look the payment up in the dashboard or with the transactions API (transaction_reference) before asking for another one — a bank redirect during Google Pay can leave the intent behind. Details in Payment Intents.
To be told even when the customer never returns to your page, pass a notify_url when you create the intent — see Payment notification.
Prefer no front-end work? Use a hosted checkout page instead — a shareable URL that collects the payment for you.
Next steps
- Test your integration before going live.
- Learn about Payment Intents and their statuses.
- Set up recurring payments with the same widget.
- Build a product catalog with prices and coupons.