WaafipaydocsWaafiPay

Hosted Payment Page

WaafiPay provides a Hosted Payment Page (HPP) for handling purchases, refunds, and transaction inquiries through a secure, web-based interface. Use the serviceName parameter to specify the action for each transaction.

1. Initiate Purchase

  • serviceName: HPP_PURCHASE
  • Purpose: Redirects customers to a secure HPP to complete their transaction.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_PURCHASE",
    "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "storeId": {{STORE_ID}},
    "hppKey": "{{HPP_KEY}}",
    "paymentMethod": "MWALLET_ACCOUNT",
    "hppSuccessCallbackUrl": "{{redirect_callback_URL}}/hpp/success",
    "hppFailureCallbackUrl": "{{redirect_callback_URL}}/hpp/failure",
    "hppRespDataFormat": 1,
     "payerInfo": {
        "subscriptionId": "252611111111"
    },
    "transactionInfo": {
      "referenceId": "422334",
      "amount": 10,
      "currency": "USD",
      "description": "Payment for order #422334"
    }
  }
}

Request Parameters

ParameterData TypeLengthPresenceDescription
schemaVersionString5ConstantAPI schema version (e.g. "1.0")
requestIdString36 (UUID)RequiredUnique request identifier (e.g. UUID)
timestampString20RequiredDate and time of the request
channelNameString3-10ConstantThe channel through which the request was made (e.g. WEB )
serviceNameString15-25ConstantThe name of the service being called (e.g. HPP_PURCHASE)
merchantUidString7-15RequiredUnique identifier provided by WaafiPay upon merchant account setup
storeIdNumber10-50RequiredUnique identifier provided by WaafiPay store account setup
hppKeyString20-40RequiredUnique alphanumeric string assigned by WaafiPay upon merchant account activation
paymentMethodString5-20RequiredPayment method being used (e.g. MWALLET_ACCOUNT from Waafi/EVCPlus, Zaad and Sahal)
subscriptionIdString1-50RequiredCustomer mobile number in full international format, starting with the country code (e.g., 252611111111). Do not include + or leading zeros. This will pre-fill the HPP with the customer's phone number and will not be editable by the customer. Required for MWALLET_ACCOUNT payment method.
hppSuccessCallbackUrlString0-255RequiredURL we'll call after a successful payment. Must be reachable via HTTPS and return HTTP 200.
hppFailureCallbackUrlString0-255RequiredURL we'll call if the payment fails or is aborted. Must also be HTTPS.
hppRespDataFormatNumber1-3RequiredFormat of the data we include in our callback: 1= POST, 2= GET, 4= Result Token.
transactionInfo.referenceIdString1-50RequiredYour unique internal transaction or order reference (e.g. order number, invoice ID, or bill number). Used for querying and reconciliation. Only letters, numbers, dashes, underscores, and dots are allowed.
transactionInfo.amountNumberN/ARequiredAmount to be charged for the customer (numeric) in two decimal places
transactionInfo.currencyString3RequiredISO 4217 currency code for the transaction (e.g. USD, SLSH, DJF)
transactionInfo.descriptionString0-255OptionalA short description of the order or item being purchased by the customer, e.g. "Payment for order #422334" or "Subscription to premium plan".

Response Structure

{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 09:19:10.131",
  "responseId": "12314",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "hppUrl": "https://sandbox.waafipay.net/hpp/token/4542676573566A5261366B6A485049715056534A45773D3D",
    "directPaymentLink": "https://sandbox.waafipay.net/hpp/token/4542676573566A5261366B6A485049715056534A45773D3D?r=10629",
    "orderId": "1185941",
    "referenceId": "OrderId_422334"
  }
}

Response Parameters

ParameterData TypeLengthDescription
schemaVersionString5API schema version (e.g., "1.0")
timestampString20Date and time of the response
responseIdString1-50Unique response identifier
responseCodeString1-10Response code indicating the result of the request
errorCodeString1-5Error code (e.g., "0" for success)
responseMsgString0-255Human-readable message for the response
params.hppUrlString0-255URL for the HPP page (to process the payment)
params.orderIdString1-50WaafiPay Order ID reference for the transaction
params.referenceIdString1-50Merchant Reference for the transaction

Summary:

  • Request Key Parameters: Includes details for initiating an HPP purchase, such as paymentMethod, hppSuccessCallbackUrl, transactionInfo.referenceId, and transactionInfo.amount.
  • Response Key Parameters: Contains the result of the purchase request, including the URLs for the HPP page hppUrl, the order details (orderId, hppRequestId), and the referenceId of the transaction.

2. Refund Purchase

  • serviceName: HPP_REFUNDPURCHASE
  • Purpose: Processes a refund for a previously completed transaction by either using the transactionId or referenceId from the original purchase.

We allow partial refunds, meaning you can refund less than the original transaction amount.

Request Structure

POST /asm
{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_REFUNDPURCHASE",
  "serviceParams": {
    "merchantUid": "{{MERCHANT_UID}}",
    "storeId": {{STORE_ID}},
    "hppKey": "{{HPP_KEY}}",
    "amount": "10",
    "referenceId": "OrderId_422334",
    "description": "Order refund"
  }
}

Refund Request Parameters

ParameterData TypeLengthPresenceDescription
schemaVersionString5ConstantAPI schema version (e.g., "1.0")
requestIdString36 (UUID)RequiredUnique request identifier (e.g., UUID)
timestampString20RequiredDate and time of the request
channelNameString3-10ConstantThe channel through which the request was made
serviceNameString15-25ConstantThe name of the service being called (e.g., HPP_REFUNDPURCHASE)
merchantUidString7-15RequiredUnique identifier provided by WaafiPay upon merchant account setup
storeIdString7-15RequiredUnique identifier provided by WaafiPay upon merchant account setup
hppKeyString20-40RequiredUnique alphanumeric string assigned by WaafiPay upon merchant account activation
amountNumberN/ARequiredRefund amount (numeric)
transactionIdNumberN/ARequiredTransaction ID being refunded
referenceIdString1-50OptionalMerchant Reference ID from the original transaction (e.g., "OrderId_422334")
descriptionString0-255OptionalDescription of the refund request (e.g., "Hpp refund")

Refund Response Structure

{
    "schemaVersion": "1.0",
    "timestamp": "2025-05-05 01:54:47.571",
    "responseId": "e69b9629-4aa3-46e1-b7ce-97e7ebc7a099",
    "responseCode": "2001",
    "errorCode": "0",
    "responseMsg": "RCS_SUCCESS",
    "params": {
        "description": "success",
        "state": "approved",
        "transactionId": "XXX",
        "referenceId": "OrderId_422334"
    }
}

state parameter should be checked to ensure the refund was successful. If state is "approved", the refund was successful; if it is "declined" or "failed", the refund failed.

Example Error Response

  {
    "schemaVersion": "1.0",
    "timestamp": "2024-11-05 09:24:48.347",
    "responseId": "12314",
    "responseCode": "5202",
    "errorCode": "E10207",
    "responseMsg": "RCS_TRAN_ALREADY_CANCELLED",
  }

Refund Response Parameters

ParameterData TypeLengthDescription
schemaVersionString5API schema version (e.g., "1.0")
timestampString20Date and time of the response
responseIdString1-50Unique response identifier
responseCodeString1-10Response code indicating the result of the request
errorCodeString1-5Error code (e.g., "E10207" for an error)
responseMsgString0-255Human-readable message for the response
paramsObjectN/AEmpty object, as there is no further data in this response

Summary:

  • Request Key Parameters: Includes details for initiating an HPP refund, such as amount, transactionId, and a description (e.g., "Hpp refund").
  • Response Key Parameters: Contains the result of the refund request, including an error code (E10207), message (RCS_TRAN_ALREADY_CANCELLED), and an empty params object indicating no additional data.

3. Retrieve Transaction Information

  • serviceName: HPP_GETTRANINFO
  • Purpose: Fetches transaction details for a specific transaction with either transactionId or referenceId.

Request Structure

{
  "schemaVersion": "1.0",
  "requestId": "{{$randomUUID}}",
  "timestamp": "{{$timestamp}}",
  "channelName": "WEB",
  "serviceName": "HPP_GETTRANINFO",
  "serviceParams": {
      "merchantUid": "{{MERCHANT_UID}}",
      "storeId": {{STORE_ID}},
      "hppKey": "{{HPP_KEY}}",
      "referenceId": "OrderId_422334"
  }
}

Request Parameters

ParameterData TypeLengthPresenceDescription
schemaVersionString5ConstantAPI schema version (e.g., "1.0")
requestIdString36 (UUID)RequiredUnique request identifier (e.g., UUID)
timestampString20RequiredDate and time of the request
channelNameString3-10ConstantThe channel through which the request was made
serviceNameString15-25ConstantThe name of the service being called (e.g., HPP_GETTRANINFO)
merchantUidString7-15RequiredUnique identifier provided by WaafiPay upon merchant account setup
storeIdString7-15RequiredStore ID associated with the transaction
hppKeyString20-40RequiredHPP key for secure transaction information fetch
referenceIdString1-50RequiredWaafiPay Reference ID for the transaction

Response Structure

POST /asm
{
  "schemaVersion": "1.0",
  "timestamp": "2024-11-05 12:19:05.05",
  "responseId": "123114",
  "responseCode": "2001",
  "errorCode": "0",
  "responseMsg": "RCS_SUCCESS",
  "params": {
    "tranStatusDesc": "Approved",
    "amount": "2.0",
    "payerId": "252700000000",
    "paymentMethod": "mwallet_account",
    "description": "payment",
    "tranDate": "2024-11-05 10:58:50.0",
    "currency": "USD",
    "invoiceId": "16F7F28E21EC",
    "referenceId": "16F7F28E21EC",
    "tranAmount": "2.0",
    "transactionId": "126895",
    "tranStatusId": "3",
    "status": "Approved"
  }
}

Response Parameters

ParameterData TypeLengthDescription
schemaVersionString5API schema version (e.g., "1.0")
timestampString20Date and time of the response
responseIdString1-50Unique response identifier
responseCodeString1-10Response code indicating the result of the request
errorCodeString1-5Error code (e.g., "0" for no error)
responseMsgString0-255Human-readable message for the response
params.tranStatusDescString0-255Description of the transaction status (e.g., "Approved")
params.amountNumberN/AAmount of the transaction
params.payerIdString1-50Payer's unique identifier
params.paymentMethodString1-50Payment method used (e.g., "mwallet_account")
params.descriptionString0-255Description of the transaction (e.g., "payment")
params.tranDateString20Date and time of the transaction
params.currencyString3Currency code (e.g., "USD")
params.invoiceIdString1-50Invoice ID for the transaction
params.tranAmountNumberN/AAmount of the transaction
params.transactionIdString1-50Transaction ID
params.tranStatusIdString1-10Status ID of the transaction
params.statusString0-255Status of the transaction (e.g., "Approved")

Summary:

  • Request Key Parameters: Includes details for fetching transaction information, such as referenceId, merchantUid, and hppKey.
  • Response Key Parameters: Contains detailed transaction information, including tranStatusDesc (e.g., "Approved"), payerId, amount, transactionId, and other transaction-specific details such as currency, status, and invoiceId.