Skip to content

Hosted Checkout (UC) ​

The simplest mode: your backend creates a payment, Moko returns a checkout URL, and you redirect the customer.

Flow ​

1. Customer clicks "Pay by card" on your site
2. Your backend → POST /api/v1/payment/orders (HMAC-signed)
3. Moko responds with { data: { links, transaction_uuid, transaction_status, ... } }
4. Your site redirects the customer to data.links
5. Customer enters their card on the Moko page (Cybersource Unified Checkout SDK)
6. 3DS Payer Authentication (frictionless or OTP challenge)
7. Cybersource performs auth + capture
8. Customer redirected to return_url?status=SUCCESS&... (or ?status=FAILED&...)
9. Signed webhook POSTed to callback_url (async, source of truth)

Endpoint ​

POST /api/v1/payment/orders Auth: HMAC (see Authentication)

Request body ​

Based on the PaymentInitiationRequest Pydantic model.

json
{
  "amount": 1.00,
  "currency": "USD",
  "merchant_reference": "INV-042",
  "callback_url": "https://your-shop.com/webhooks/moko",
  "bill_to_forename": "Jean",
  "bill_to_surname": "Kabala",
  "bill_to_email": "client@example.com",
  "bill_to_phone": "+243812345001",
  "bill_to_address_line1": "Av. Kasa-Vubu 42",
  "bill_to_address_city": "Kinshasa",
  "bill_to_address_country": "CD",
  "bill_to_address_state": null,
  "bill_to_address_postal_code": null,
  "return_url": "https://your-shop.com/order/INV-042",
  "redirect_url": null,
  "cancel_url": "https://your-shop.com/order/INV-042/cancelled"
}

Fields ​

FieldTypeRequiredConstraints
amountfloat✅> 0. Min USD 1.00 / CDF 500.00
currencystring✅USD or CDF only
merchant_referencestring✅Min 1 char
callback_urlstring✅Webhook events URL
bill_to_forenamestring✅Min 1 char
bill_to_surnamestring✅Min 1 char
bill_to_emailstring✅Regex ^[^@]+@[^@]+\.[^@]+$, lowercased server-side
bill_to_phonestring✅5-20 chars, regex ^[\d\+][\d\s\-\(\)]+$. Normalized to E.164 server-side.
bill_to_address_line1string✅
bill_to_address_citystring✅
bill_to_address_countrystring✅ISO 3166-1 alpha-2, uppercased server-side
bill_to_address_statestringconditionalRequired for US/CA (2 chars)
bill_to_address_postal_codestringconditionalRequired for US/CA. US format: 12345 or 12345-6789. CA format: A1A1A1.
return_urlstringPost-payment return URL. If omitted, Moko's default page is used.
redirect_urlstringAlias of return_url (accepted for compatibility)
cancel_urlstringReturn URL if the customer cancels

Response body ​

json
{
  "status": "success",
  "data": {
    "amount": "1.00",
    "currency": "USD",
    "transaction_uuid": "FP-20260930-101530-a1b2c3d4-CD",
    "transaction_status": "PENDING",
    "links": "https://uc.card.gofreshpay.com/api/v1/payment/FP-20260930-101530-a1b2c3d4-CD?sig=abc123...",
    "financial_details": {
      "commission_rate": "3.50",
      "commission_amount": "0.04",
      "merchant_amount": "0.96",
      "bank_commission_amount": "0.03",
      "freshpay_commission_amount": "0.01"
    }
  }
}
  • transaction_uuid — format FP-YYYYMMDD-HHMMSS-{8chars}-CD, your unique Moko identifier
  • transaction_status — always PENDING at this stage
  • links — short URL to redirect the customer to (already signed with ?sig=...)
  • financial_details — commission breakdown computed server-side

TTL: the transaction expires after 20 minutes if the customer does not complete checkout (configurable via the CYBERSOURCE_PAYMENT_TTL_MINUTES env variable).

Redirect the customer ​

html
<!-- Backend returns a 303 redirect -->
<a href="{{ data.links }}">Pay USD 1.00</a>

Or in JavaScript:

javascript
window.location.href = resp.data.links;

Return URL ​

The customer is redirected to your return_url with query params.

Success:

?status=SUCCESS&transaction_uuid=FP-...&transaction_id=<cs_id>&amount=1.00&currency=USD&reference=INV-042

Failure:

?status=FAILED&transaction_uuid=FP-...&reason_code=201&message=...

WARNING

The return_url is a client-side redirect — do NOT use it as the source of truth to validate a payment. The customer may close their browser before reaching it. Use the webhook (callback_url) for confirmation.

Webhook ​

See Webhooks for the full schema + signature verification.

PAYMENT payload (excerpt):

json
{
  "status": "SUCCESS",
  "reference": "INV-042",
  "amount": "1.00",
  "currency": "USD",
  "decision": "ACCEPT",
  "message": "Request was processed successfully.",
  "transaction_uuid": "FP-20260930-101530-a1b2c3d4-CD",
  "auth_cavv_result": "3",
  "customer_name": "Jean Kabala",
  "customer_email": "client@example.com",
  "cavv_message": "",
  "card_type": "Visa",
  "card_last4": "3172",
  "card_expiry_date": "12-2028",
  "card_bin_country": "CD",
  "card_issuer": "Equity Bank",
  "card_scheme": "VISA DEBIT"
}

Check the status ​

POST /api/v1/payment/status Auth: HMAC (see Authentication)

Request ​

json
{ "transaction_uuid": "FP-20260930-101530-a1b2c3d4-CD" }

Response ​

json
{
  "status": "success",
  "data": {
    "amount": "1.00",
    "currency": "USD",
    "merchant_reference": "INV-042",
    "message": "Request was processed successfully.",
    "transaction_uuid": "FP-...",
    "transaction_status": "SUCCESS",
    "card_type": "Visa",
    "card_last4": "3172",
    "card_expiry_date": "12-2028",
    "card_bin_country": "CD",
    "card_issuer": "Equity Bank",
    "card_scheme": "VISA DEBIT"
  }
}

Possible transaction_status values: PENDING, SUCCESS, FAILED, CANCELLED, EXPIRED, REFUNDED, PARTIALLY_REFUNDED, VOIDED.

Cross-merchant access is strictly blocked: a merchant can only look up its own transactions (HTTP 404 Transaction not found otherwise).

Common errors ​

HTTPDetailCause
400Currency '{currency}' is not supported. Allowed: CDF, USDCurrency other than USD/CDF
400Minimum amount for USD is 1.00Amount too small
400bill_to_address_state is required for US/CAUS or CA without a state
400Invalid US ZIP code format (expected: 12345 or 12345-6789)Malformed US ZIP
400Invalid Canadian postal code format (expected: A1A1A1)Malformed CA postal code
400Other Pydantic validationMalformed body
401Missing authentication headersAn HMAC header is missing
403Invalid request signatureHMAC does not match
404Merchant not foundmerchant_id derived from X-API-Key not found
500Payment processing errorInternal error

See also ​

  • Authentication — HMAC signature
  • Webhooks — webhook signature verification
  • Refunds — contact henock.barakael@mokoafrika.com (admin API, restricted access)

Moko Afrika · The payment infrastructure of the DRC