Skip to content
Last updated

DimePay Bus Card Top-Up API Documentation

This documentation details the API for topping up student bus cards, including environment endpoints, security, and examples of successful and error payloads.


API Endpoints

EnvironmentBase URLPurpose
Sandboxhttps://sandbox.api.dimepay.appFor development and testing with simulated transactions.
Production Yeshttps://api.dimepay.appFor live transactions with real users and real funds.

Security and Authentication

Authentication requires a Client-Key in the header and a request body that is the HMAC-SHA256 signature of the transaction payload.

1. Client-Key Header

Header NameTypeDescription
Client-KeyStringYour unique identifier for accessing the API.

2. Request Body (data Field)

The entire request body is a JSON object with a single field, data, which is the signature.

Field NameTypeDescription
dataStringThe HMAC-SHA256 signature (hexadecimal string) of the canonical JSON string containing the transaction details.

Signature Calculation

  1. Construct Details Object: Build the JSON object with card_number, amount, currency, and optional billing_details.
  2. Canonicalize: Serialize this object into a JSON string, ensuring alphabetical key order and no whitespace.
  3. Sign: Calculate the HMAC-SHA256 signature of the canonical string using your Secret Key.

Top-Up Endpoint Details

MethodResource PathFull Sandbox URL Example
POST/api/v1/buscards/topuphttps://sandbox.api.dimepay.app/api/v1/buscards/topup

Transaction Details Object (The object you must sign)

Field NameTypeRequiredDescription
card_numberStringYesThe unique identifier for the student bus card.
amountDecimalYesThe top-up amount (e.g., 50.00).
currencyStringYesThe ISO 4217 currency code (e.g., JMD, USD).
billing_detailsObjectNoOptional payment/billing information.

Example Request Body (Final Payload)

This is the body sent to the API, where the data value is the signature.

{
  "data": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2" 
}

Response Payloads

Successful Response (HTTP 200 OK)

A successful transaction returns the final details.

{
  "status": "success",
  "message": "Bus card top-up initiated successfully.",
  "transaction_id": "TXN987654321",
  "card_number": "BC1234567890",
  "amount": 50.00,
  "currency": "JMD"
}

Error Response Example

Errors return a standard JSON object containing a brief status, a specific error code, and a descriptive message.

HTTP StatusError CodeExample Description
401 UnauthorizedINVALID_SIGNATUREThe HMAC-SHA256 signature in the data field failed validation.
{
  "status": "error",
  "code": "INVALID_SIGNATURE",
  "message": "The signature provided in the 'data' field is invalid or could not be verified with the client's secret key."
}
HTTP StatusError CodeExample Description
400 Bad RequestCARD_NUMBER_INVALIDThe bus card number extracted from the payload is malformed.
{
  "status": "error",
  "code": "CARD_NUMBER_INVALID",
  "message": "The card number extracted from the signed payload is in an incorrect format."
}