Skip to content

Quick Start

Before you begin

You need an ElasticPay account and sandbox API keys. Find them in Settings > API Keys in the dashboard. Keys come in two types: secret (sk_sandbox_...) for server-side use and publishable (pk_sandbox_...) for client-side use.

Create a payment intent

A payment intent represents a single payment attempt. Create one server-side with an amount (in cents) and currency.

Terminal window
curl -X POST https://api.elasticpay.co/api/v1/payment_intents \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"amount": 2000, "currency": "AUD"}'

Response:

{
"id": "pi_0abc123def456ghi789jkl012mn",
"amount": 2000,
"currency": "AUD",
"status": "requires_payment_method",
"client_secret": "pi_0abc123def456ghi789jkl012mn_secret_xyz987",
"livemode": false,
"created_at": "2025-01-15T10:00:00Z"
}

The client_secret is passed to the widget to collect card details. Keep the payment intent id on your server.

Confirm the payment

After the widget tokenises the card and returns a pm_xxx, confirm the payment:

Terminal window
curl -X POST https://api.elasticpay.co/api/v1/payment_intents/pi_0abc123def456/confirm \
-H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"payment_method": "pm_0xyz789abc123def456ghi012jkl"}'

A status of succeeded means the payment is complete. For async processing you may see processing — listen for the payment_intent.succeeded webhook as the authoritative signal.

Next steps