Hosted checkout

Every request goes to https://api.lemak.cash. About the reference.

Checkout page

GET /c/{token}

The hosted checkout page. The session token in the path is the whole authority, so this route takes no key and the page carries none.

Authentication

None. The checkout session token in the path is the whole authority.

Parameters

NameInTypeDescription
token requiredpathstringThe checkout session token. It is unguessable and short lived.

Responses

200

The page.

text/html

string

Errors

Every error answers with the error object.

StatusWhen
410The session expired. No attempt is created.
Other400 bad parameter, 401 authentication, 402 payment failed, 403 forbidden, 404 not found, 409 conflict, 413 request_too_large (a body over 64 KiB), 422 idempotency key reused, 429 rate limited, 5xx api error.

Example

curl https://api.lemak.cash/c/<token>

Pay checkout session

POST /checkout/sessions/{token}/pay

Start the attempt for the method the payer picked. A session that already holds a pending attempt answers with the credential it already has.

Authentication

None. The checkout session token in the path is the whole authority.

Parameters

NameInTypeDescription
token requiredpathstringThe checkout session token. It is unguessable and short lived.

Request body

application/json

CheckoutPay

FieldTypeDescription
payment_method requiredstring

Responses

200

The payment credential.

application/json

CheckoutState

FieldTypeDescription
status requiredstringOne of created, requires_payment, processing, succeeded, channel_settled, failed, expired, canceled.
next_action optionalNextAction
Fields of next_action
FieldTypeDescription
type requiredstringOne of redirect, qr_code.
url optionalstring (uri)
qr_data optionalstring
redirect_url optionalstring (uri)Where to send the payer once the payment succeeded.

Errors

Every error answers with the error object.

StatusWhen
409live_not_enabled: the session is live and the merchant's review no longer holds live mode open. No attempt is created and no credential is served.
410The session expired. No attempt is created.
Other400 bad parameter, 401 authentication, 402 payment failed, 403 forbidden, 404 not found, 409 conflict, 413 request_too_large (a body over 64 KiB), 422 idempotency key reused, 429 rate limited, 5xx api error.

Example

curl -X POST https://api.lemak.cash/checkout/sessions/<token>/pay \
  -H "Content-Type: application/json" \
  -d '{
  "payment_method": "<payment_method>"
}'

Simulate checkout session

POST /checkout/sessions/{token}/simulate

The test panel of the hosted page. Test mode only: tell the channel behind the pending attempt what to report, as POST /v1/test/payment_intents/{id}/simulate does. A session of a live intent answers 404, as a missing session does.

Authentication

None. The checkout session token in the path is the whole authority.

Parameters

NameInTypeDescription
token requiredpathstringThe checkout session token. It is unguessable and short lived.

Request body

application/json

CheckoutSimulate

FieldTypeDescription
outcome requiredstringOne of succeeded, failed.
failure_code optionalstringThe decline reason a failed outcome reports. It becomes the attempt failure_code. Allowed with outcome failed alone. One of insufficient_funds, payer_cancelled, risk_blocked.

Responses

200

The state of the payment the moment the callback landed.

application/json

CheckoutState

FieldTypeDescription
status requiredstringOne of created, requires_payment, processing, succeeded, channel_settled, failed, expired, canceled.
next_action optionalNextAction
Fields of next_action
FieldTypeDescription
type requiredstringOne of redirect, qr_code.
url optionalstring (uri)
qr_data optionalstring
redirect_url optionalstring (uri)Where to send the payer once the payment succeeded.

Errors

Every error answers with the error object.

StatusWhen
410The session expired.
Other400 bad parameter, 401 authentication, 402 payment failed, 403 forbidden, 404 not found, 409 conflict, 413 request_too_large (a body over 64 KiB), 422 idempotency key reused, 429 rate limited, 5xx api error.

Example

curl -X POST https://api.lemak.cash/checkout/sessions/<token>/simulate \
  -H "Content-Type: application/json" \
  -d '{
  "outcome": "succeeded"
}'

Checkout session status

GET /checkout/sessions/{token}/status

What the page polls. It carries the redirect once the payment succeeds.

Authentication

None. The checkout session token in the path is the whole authority.

Parameters

NameInTypeDescription
token requiredpathstringThe checkout session token. It is unguessable and short lived.

Responses

200

The state of the payment behind this session.

application/json

CheckoutState

FieldTypeDescription
status requiredstringOne of created, requires_payment, processing, succeeded, channel_settled, failed, expired, canceled.
next_action optionalNextAction
Fields of next_action
FieldTypeDescription
type requiredstringOne of redirect, qr_code.
url optionalstring (uri)
qr_data optionalstring
redirect_url optionalstring (uri)Where to send the payer once the payment succeeded.

Errors

Every error answers with the error object.

StatusWhen
410The session expired.
Other400 bad parameter, 401 authentication, 402 payment failed, 403 forbidden, 404 not found, 409 conflict, 413 request_too_large (a body over 64 KiB), 422 idempotency key reused, 429 rate limited, 5xx api error.

Example

curl https://api.lemak.cash/checkout/sessions/<token>/status