Sites WayDevelopers

Quickstart

Take your first test payment with the hosted payment page.

You need a test API key (merchant portal → Developers → API keys) and your website's address registered there for the return after payment.

1. Create a payment (your server)

curl -X POST https://api.sw-staging.dev/v1/payments \
  -H "Authorization: Bearer sw_test_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 10050, "currency": "SAR", "description": "Order #1042" }'

amount is in the minor unit: 10050 is 100.50 SAR. The answer is the payment, with its id (pay_…). Unless you set expires_in_seconds, it can be paid for 1 day.

2. Ask for the hosted payment page (your server)

curl -X POST https://api.sw-staging.dev/v1/payments/pay_…/checkout-link \
  -H "Authorization: Bearer sw_test_…" \
  -H "Content-Type: application/json" \
  -d '{ "return_url": "https://shop.example.com/orders/1042" }'

The answer carries a url. The origin of return_url must be one of the addresses you registered.

3. Redirect the customer to url

Send it exactly as it is: the part after # is the customer's access to this payment. Do not log it.

4. Pay with a test card

On the page, pay with 4242 4242 4242 4242, any future expiry date and any CVC. Other test cards decline, ask for 3-D Secure, and so on.

5. The customer comes back — confirm from your server

After paying, the customer returns to your return_url with payment_id added. The return is not proof of payment. Ship the order when your server knows the payment SUCCEEDED: from the payment.succeeded webhook, or by reading the payment (GET /v1/payments/{id}).

On this page