Skip to main content

Rechage Transaction

Authentication

Basic Authentication

  • Username: Client Id
  • Password: Secret Key

Example Authorization Header:

Authorization: Basic eGV0dGxlXzgzMjg2NjU5YmRmNzBkZWEzMDUwMzcwNzE1MTYwMzA0MDo3YzE1ZDQyYTZhYjEyOTYzYWI4NzJhMzFkOTk4MDk1ZDMwNTAzNzA3MTUxNjMyMDg5

Request Body

{
"phone": "1234567890",
"amount": "299",
"operatorId": "6",
"clientRefId": "363636342454"
}

Parameters

ParameterTypeRequiredDescription
phoneStringYesCustomer's phone number that will be recharged
amountStringYesRecharge amount
operatorIdStringYesID of the mobile operator
clientRefIdStringYesUnique reference ID generated by client for transaction tracking

Request Examples

Request Examples

curl --location 'https://xyz.com/v1/service/recharge/initiate' --header 'Content-Type: application/json' --header 'Authorization: Basic eGV0dGxlXzgzMjg2NjU5YmRmNzBkZWEzMDUwMzcwNzE1MTYwMzA0MDo3YzE1ZDQyYTZhYjEyOTYzYWI4NzJhMzFkOTk4MDk1ZDMwNTAzNzA3MTUxNjMyMDg5' --data '{
"phone" :"1234567890",
"amount" :"299",
"operatorId" :"6",
"clientRefId" :"363636342454"
}'

Response Examples

{
"code": "0x0200",
"message": "status fetch successfully",
"status": "SUCCESS",
"data": {
"clientRefId": "363636342469",
"stan_no": "BR000C3NF5GA",
"status": "processed"
}
}

Response Codes

The API uses the following response codes to indicate the status of requests:

CodeDescriptionMeaning
0x0200SUCCESSThe request was processed successfully.
0x0201UNAUTHORIZEDAuthentication failed or insufficient permissions.
0x0202FAILEDThe request processing failed for a reason other than those specifically identified.
0x0203MISSING_PARAMETERThe request is missing one or more required parameters.
0x0206PENDINGThe request has been received and is being processed, but processing has not yet completed.
0x0205SOMETHING_WENT_WRONGA server error occurred during processing of the request.

Response Format

All API responses follow a standard JSON format:

{
"code": "STATUS_CODE",
"message": "Human-readable message",
"status": "STATUS_TEXT",
"data": {
// Optional response data
}
}

Response Scenarios

Successful Transaction

When a transaction has been processed successfully, the API returns:

{
"code": "0x0200",
"message": "status fetch successfully",
"status": "SUCCESS",
"data": {
"clientRefId": "363636342469",
"stan_no": "BR000C3NF5GA",
"status": "processed"
}
}

Key indicators of success:

  • code is 0x0200 (SUCCESS_CODE)
  • status is "SUCCESS"
  • data.status is "processed"
  • stan_no contains a valid transaction reference number

Failed Transaction

When a transaction has failed but the status check was successful:

{
"code": "0x0200",
"message": "status fetch successfully",
"status": "SUCCESS",
"data": {
"clientRefId": "363636342468",
"stan_no": " ",
"status": "failed"
}
}

Key indicators of transaction failure:

  • code is still 0x0200 because the status check itself succeeded
  • status is "SUCCESS" (referring to the status check, not the transaction)
  • data.status is "failed"
  • stan_no is empty or blank

Invalid Request

When the request itself is invalid (e.g., incorrect reference ID):

{
"code": "0x0202",
"status": "FAILURE",
"message": "Invalid clientRefId."
}

Key indicators of invalid request:

  • code is 0x0202 (FAILED_CODE)
  • status is "FAILURE"
  • No data object is returned
  • message describes the specific error

Processing Transaction

When a transaction is still being processed:

{
"code": "0x0200",
"message": "status fetch successfully",
"status": "SUCCESS",
"data": {
"clientRefId": "363636342467",
"stan_no": null,
"status": "processing"
}
}

Key indicators of processing:

  • code is 0x0200 because the status check succeeded
  • status is "SUCCESS" (referring to the status check)
  • data.status is "processing"
  • stan_no is typically null

Integrating with Frontend

function checkTransactionStatus(clientRefId) {
// Make API call to check status

// Handle response based on code and status
if (response.code === "0x0200") {
if (response.data.status === "processed") {
showSuccess("Transaction completed successfully!");
logTransaction(response.data.stan_no);
} else if (response.data.status === "processing") {
showPending("Transaction is processing...");
// Poll again after 5 seconds
setTimeout(() => checkTransactionStatus(clientRefId), 5000);
} else if (response.data.status === "failed") {
showError("Transaction failed. Please try again.");
}
} else {
// Handle other error codes
showError(`Error: ${response.message}`);
}
}