Payment notifications

Payment Notification

POST /subscribe

Request header

The request sent to the callback URL will have the following headers

key: irembopay-signature

value: t=<timestamp>, s=<signature>

Request payload

The payload section represents the request's payload that is sent to the callback URL

Signature

<signature> = HMAC_SHA256(<Secret_Key>, <Payload_To_Hash>)

where:

  • HMAC_SHA256 is a function to Compute an HMAC with the SHA256 hash function.

  • <Secret_Key> is the merchant secret key configured in the portal.

  • <Payload_To_Hash> is the concatenation of the timestamp, the character “#” and the request body.

Example

irembopay-signature: t=1653405045000,s=bfecb20753326e5e8602f4a6e727bcd22b7cb1d00797fe5bd65db8cfaf2f4903        

Verifying the signature

Merchants can follow the steps below to verify a signature:

Step 1: Extract the timestamp and signatures from the header irembopay-signature. Split the header using the , character as the separator, to get a list of elements. Then split each element, using the = character as the separator, to get a prefix and value pair. The value for the prefix t corresponds to the timestamp, and s corresponds to the signature

Step 2: Prepare the signed_payload string. The signed_payload string is created by concatenating: The timestamp (as a string), the character # and the actual JSON payload (the request body).

Step 3: Determine the expected signature. Compute an HMAC with the SHA256 hash function. Use the merchant’s secret key as the key and use the signed_payload string as the message.

Step 4: Compare the signatures. Compare the signature in the header to the expected signature. Optionally, you can also check if the timestamp is not too far from the current time to prevent replay attacks.

Request samples

POST: /subscribe

{
  "success": true,
  "data": {
    "amount": 100,
    "invoiceNumber": "880519183280",
    "transactionId": "B221024053141FNNX",
    "createdAt": "2023-04-19T11:58:02.895+02",
    "updatedAt": "2023-04-19T11:58:02.895+02",
    "paidAt": "2023-04-20T11:58:02.895+02",
    "expiryAt": "2023-04-21T11:58:02.895+02",
    "paymentMethod": "MOMO_PUSH",
    "paymentReference": "0fMRp7R5KotFDrg4VAO6spSao5CMfj",
    "customer": {
      "email": "example@gmail.com",
      "phoneNumber": "0780000001",
      "name": "Jixle Manzi"
    },
    "paymentItems": [
      {
        "unitAmount": 2000,
        "quantity": 1,
        "code": "PI-3e5fe23f2d"
      }
    ],
    "paymentAccountIdentifier": "TST-RWF",
    "paymentStatus": "PAID",
    "currency": "RWF"
  }
}

Last updated