API reference
Retrieve a payment intent
const url = 'https://pay.fanak.ly/api/v1/payment-intents/4d893346-bd5e-482f-8347-3f509a877f1a';const options = { method: 'GET', headers: {'X-API-Key': '<X-API-Key>', Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://pay.fanak.ly/api/v1/payment-intents/4d893346-bd5e-482f-8347-3f509a877f1a \ --header 'Authorization: Bearer <token>' \ --header 'X-API-Key: <X-API-Key>'Returns the intent’s current state. This is the source of truth for whether an order was paid: call it
when a webhook arrives or the customer comes back from the checkout, and fulfil the order only when
status is succeeded.
An intent created by another application returns 403.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The intent’s uuid.
Example
4d893346-bd5e-482f-8347-3f509a877f1aResponses
Section titled “Responses”The payment intent.
object
object
The intent’s ID. Store it with your order: you need it to retrieve the intent.
A short Fanak reference, shown to the customer on the checkout receipt (in capitals).
The merchant_reference you created the intent with.
The amount in the currency’s minor unit (5000 = 5.000 LYD).
ISO 4217 currency code
The intent’s state.
requires_payment_method: waiting for the customer to pay (or to try again after a failed attempt).
processing: a payment attempt is under way. succeeded: paid; final. canceled: expired unpaid;
a verified late payment can still move it to succeeded. Fulfil the order on succeeded only.
What the customer is paying for.
object
Your identifier for the customer, if you sent one.
Where the hosted checkout sends the customer back, if you set one.
The key-value pairs you sent, returned as-is.
When the checkout stops taking payments (ISO 8601).
The hosted checkout page. Redirect the customer here to pay; append ?lang=en for English
(Arabic is the default).
Example
{ "data": { "reference": "c5pk2mfgmv167awg", "currency": "LYD", "status": "requires_payment_method" }}Missing or invalid credentials. A missing or invalid access token returns message; a missing or unknown API key returns error.
An error
object
Error overview.
Example
{ "message": "Unauthorized access to payment intent."}No intent with this uuid. The body is {"message": "Not found."}.
object
Example generated
{ "message": "example"}