Skip to content
FanakDocs
WebsiteDashboard

Start here

Quickstart

Take one order from creation to payment.

Put your dashboard credentials in your server’s environment:

Terminal window
FANAK_API_KEY=pk_your_api_key
FANAK_ACCESS_TOKEN=your_access_token
FANAK_WEBHOOK_SECRET=whsec_your_webhook_secret
  1. Amounts are in minor units: 5000 is 5.000 LYD.

    Terminal window
    curl https://pay.fanak.ly/api/v1/payment-intents \
    -H "X-API-Key: $FANAK_API_KEY" \
    -H "Authorization: Bearer $FANAK_ACCESS_TOKEN" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{
    "merchant_reference": "order-1042",
    "amount": 5000,
    "currency": "LYD",
    "description": "Order #1042",
    "return_url": "https://shop.example.com/orders/1042/return"
    }'

    Response, 201 Created:

    {
    "data": {
    "uuid": "4d893346-bd5e-482f-8347-3f509a877f1a",
    "reference": "c5pk2mfgmv167awg",
    "merchant_reference": "order-1042",
    "amount": 5000,
    "currency": "LYD",
    "status": "requires_payment_method",
    "description": "Order #1042",
    "customer": { "external_id": null },
    "return_url": "https://shop.example.com/orders/1042/return",
    "metadata": null,
    "expires_at": "2026-10-10T16:19:07+00:00",
    "checkout_url": "https://pay.fanak.ly/payment-intents/4d893346-bd5e-482f-8347-3f509a877f1a/checkout",
    "created_at": "2026-10-09T16:19:07+00:00",
    "updated_at": "2026-10-09T16:19:07+00:00"
    }
    }

    Save data.uuid. On a timeout, resend with the same merchant_reference (Idempotency).

  2. Redirect to data.checkout_url as is. Add ?lang=en for English.

    return redirect()->away($intent['checkout_url']);
  3. Check the result when the customer returns

    Section titled “Check the result when the customer returns”

    Nothing is added to return_url, so put your order ID in it. Re-fetch the intent there.

    Terminal window
    curl https://pay.fanak.ly/api/v1/payment-intents/4d893346-bd5e-482f-8347-3f509a877f1a \
    -H "X-API-Key: $FANAK_API_KEY" \
    -H "Authorization: Bearer $FANAK_ACCESS_TOKEN" \
    -H "Accept: application/json"

    processing is not a failure: say the payment is being confirmed.

  4. The customer may never return; the webhook still arrives. Set it up in Webhooks.