GladysDevelopers

Quickstart

Take your first test payment, end to end.

This walks through a complete TEST payment: create an app, get a token, create a payment, approve it as the payer, and confirm it went through. Everything here uses play money.

You need a Gladys merchant account with a business. A TEST app can be created before your business is verified.

Create a TEST app

In the Gladys dashboard, open Developer and choose New application:

  • Application type: Server-to-server. Payments are made by your server, as your app, with no user signed in.
  • Environment: Test (sandbox).
  • Business: the business that receives the money.
  • Scopes: payments:create, payments:read, payments:capture and payments:refund.

Copy the client ID (client_test_…) and client secret (secret_test_…). The secret is shown once; if you lose it, regenerate it from the app's page.

To send payers back to your site after they pay, add the page they should land on under Redirect URIs on the app's page, for example https://shop.example/payment-complete.

Get an access token

Exchange your app's keys for an access token, from your server:

curl https://api.joingladys.com/api/v1/oauth/token \
  -d grant_type=client_credentials \
  -d client_id=client_test_… \
  -d client_secret=secret_test_…
{
  "access_token": "access_…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "payments:create payments:read payments:capture payments:refund"
}

The token lasts an hour. Ask for a new one the same way when it expires. See Authentication.

Create a payment

Amounts are major-unit decimal strings: "1500.00" is KES 1,500.00. Requests also accept plain JSON numbers, rounded half-up to currency precision; responses always use fixed-precision strings. See Amounts and currencies for the full contract.

curl https://api.joingladys.com/api/v1/payments \
  -H "Authorization: Bearer access_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042" \
  -d '{
    "amount": "1500.00",
    "description": "Order #1042",
    "merchant_reference": "order_1042",
    "return_url": "https://shop.example/payment-complete"
  }'
{
  "success": true,
  "message": "Payment created",
  "data": {
    "reference": "pay_yM5jfhPZAGaJPTSMrSVpklbh",
    "status": "CREATED",
    "checkout_url": "https://api.joingladys.com/pay/pay_yM5jfhPZAGaJPTSMrSVpklbh",
    "amount": "1500.00",
    "currency": "KES",
    "capture_method": "AUTOMATIC",
    "environment": "TEST",
    "expires_at": "2026-10-05T12:15:00Z",
    …
  }
}

The Idempotency-Key makes the request safe to retry: sending it again returns the same payment instead of creating a second one. See Idempotency.

Approve it as the payer

Open the checkout_url in a browser. Because this is a TEST payment, the page offers Approve as test payer: choose it. No Gladys account or PIN is needed; you pay from your own play-money test wallet.

The page shows Paid, and Back to your business links to your return_url, with the payment's reference and status added.

Confirm the payment

Never trust the return link alone: anyone can type a URL. Ask the API:

curl https://api.joingladys.com/api/v1/payments/pay_yM5jfhPZAGaJPTSMrSVpklbh \
  -H "Authorization: Bearer access_…"

"status": "CAPTURED" means the money has moved to your business. Ship the order.

Next

On this page