# Direct Receive Money (/docs/api-documentation/payment-apis/direct-receive-money)



##### Overview [#overview]

The **Hubtel Sales API** allows you to sell goods and services online, instore and on mobile. With a single integration, you can:

1. Accept mobile money payments on your application, sell services in-store, online and on mobile as well as process all your sales on your Hubtel account.
2. Send money to your customers.

This API can be used to provide a range of services including processing e-commerce payments, mobile banking, bulk payments and more. You can also accept payments for goods and services into your account.

The following provides an overview of the **Receive Money API** endpoints for interacting programmatically within your application.

> **Note**
> Businesses are required to implement a security feature for this API in order to prevent individuals from receiving unsolicited prompts.
>
> This security feature may be:
>
> 1. Only registered users can make payments and before payment initiation, they
>    cannot edit their numbers.<br />
>    **OR**
> 2. Send OTP to unregistered users to confirm the numbers before proceeding to
>    initiate payment.
<br />

###### Available Channels [#available-channels]

The following are the available channels through which a merchant can **receive mobile money** into a Hubtel Merchant Account.

| Mobile Money Provider | Channel Name    |
| --------------------- | --------------- |
| MTN Ghana             | **mtn-gh**      |
| Telecel Ghana         | **vodafone-gh** |
| AirtelTigo Ghana      | **tigo-gh**     |

<br />

##### Getting Started [#getting-started]

<br />

###### Business IP Whitelisting [#business-ip-whitelisting]

You must share your public IP address with your Retail System Engineer for whitelisting.

> **Note**
> All API Endpoints are live and only requests from whitelisted IP(s) can reach these endpoints shared in this reference.
>
> Requests from IP addresses that have not been whitelisted will return a **403 Forbidden** error response or a **timeout**.
>
> We permit a maximum of 4 IP addresses per service.
<br />

###### Understanding the Service Flow [#understanding-the-service-flow]

The **Hubtel Sales API** allows you to integrate multiple functionalities into your applications.
This document focuses on:

* <strong>Direct Receive Money API</strong>: REST API to receive money directly into your Hubtel Merchant Account from a Mobile Money Wallet for all available networks.
* <strong>Transaction Status Check API</strong>: REST API to check for the status of any debit transaction initiated <strong>after five (5) or more</strong> minutes of the debit transaction’s completion. It is <strong>mandatory</strong> to implement the Transaction Status Check API <strong>only</strong> for transactions that you do not receive a callback from Hubtel.

The entire process is asynchronous. The figure below demonstrates the service flow using these two endpoints:

<img alt="Service Flow" src="__img0" />

The table below describes the steps involved in Receiving Money using the API:

| Step | Description                                                                                                                                                                                                                                                                                                                                              |
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1    | Client App makes a Receive Money request to Hubtel.                                                                                                                                                                                                                                                                                                      |
| 2    | Hubtel performs authentication on the request and sends a response to Client App accordingly.                                                                                                                                                                                                                                                            |
| 3    | A final callback is sent to Client App via the PrimaryCallbackURL provided in the request. (See sample callback [here](/docs/api-documentation/payment-apis/direct-receive-money#receive-money-callback))                                                                                                                                                |
| 4    | In instances where a merchant does not receive the final status of the transaction **after five (5) minutes** from Hubtel, it is **mandatory** to perform a status check using the Status Check API to determine the final status of the transaction. (Refer [here](/docs/api-documentation/payment-apis/direct-receive-money#transaction-status-check)) |

<br />

##### API Reference [#api-reference]

Direct Receive Money allows you to accept direct mobile money payments into your Hubtel Merchant Account. Note that the flow for charging mobile subscribers differs across the various Telco networks.

To initiate a Receive Money transaction, send an HTTP **POST** request to the below URL with the required parameters. It is also **mandatory** to pass your **Collection Account Number** for Receive Money requests in the endpoint. Find your **Collection Account Number** [here](/docs/get-started/programmable-api-keys?curr_idx=3).

<br />

|              |                                                                                                                                                                                                                  |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| API Endpoint | [https://rmp.hubtel.com/merchantaccount/merchants/\{'\{Collection_Account_Number}'}/receive/mobilemoney](https://rmp.hubtel.com/merchantaccount/merchants/\{'\{Collection_Account_Number}'}/receive/mobilemoney) |
| Request Type | **POST**                                                                                                                                                                                                         |
| Content Type | **JSON**                                                                                                                                                                                                         |

<br />

###### REQUEST PARAMETERS [#request-parameters]

| Parameter          | Type   | Requirement | Description                                                                                                                                                             |
| ------------------ | ------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CustomerName       | String | Optional    | The name on the customer’s mobile money wallet.                                                                                                                         |
| CustomerMsisdn     | String | Mandatory   | The customer’s mobile money number. This should be in the international format. **E.g.: "233249111411"**                                                                |
| CustomerEmail      | String | Optional    | Email of customer.                                                                                                                                                      |
| Channel            | String | Mandatory   | The mobile money channel provider. Available channels are: **mtn-gh**, **vodafone-gh**, **tigo-gh**.                                                                    |
| Amount             | Float  | Mandatory   | Amount of money to be debited during this transaction. **NB**: Only 2 decimal places is allowed **E.g.: 0.50**.                                                         |
| PrimaryCallbackURL | String | Mandatory   | URL used to receive callback payload of Receive Money transactions from Hubtel.                                                                                         |
| Description        | String | Mandatory   | A brief description of the transaction.                                                                                                                                 |
| ClientReference    | String | Mandatory   | The reference provided by the API user and must be **unique for every transaction** and preferably be **alphanumeric** characters. Maximum length is **36 characters**. |

> **Note**
> Kindly note that a **clientReference** must never be duplicated for any transaction.
<br />

###### SAMPLE REQUEST [#sample-request]

**HTTP**

  ```http
  POST /merchantaccount/merchants/11684/receive/mobilemoney HTTP/1.1
  Host: rmp.hubtel.com
  Accept: application/json
  Content-Type: application/json
  Authorization: Basic endjeOBiZHhza250fT3==
  Cache-Control: no-cache

  {
      "CustomerName": "Joe Doe",
      "CustomerMsisdn": "233200000000",
      "CustomerEmail": "username@example.com",
      "Channel": "vodafone-gh",
      "Amount": 0.8,
      "PrimaryCallbackUrl": "https://webhook.site/b503d1a9-e726-f315254a6ede",
      "Description": "Union Dues",
      "ClientReference": "3jL2KlUy3vt21"
  }
  ```

**cURL**

  ```bash
  curl --location 'https://rmp.hubtel.com/merchantaccount/merchants/11684/receive/mobilemoney' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic endjeOBiZHhza250fT3==' \
  --data '{
      "CustomerName": "Joe Doe",
      "CustomerMsisdn": "233200000000",
      "CustomerEmail": "username@example.com",
      "Channel": "vodafone-gh",
      "Amount": 0.8,
      "PrimaryCallbackUrl": "https://webhook.site/b503d1a9-e726-f315254a6ede",
      "Description": "Union Dues",
      "ClientReference": "3jL2KlUy3vt21"
  }'
  ```

**PHP**

  ```php
  <?php

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://rmp.hubtel.com/merchantaccount/merchants/11684/receive/mobilemoney',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "CustomerName": "Joe Doe",
      "CustomerMsisdn": "233200000000",
      "CustomerEmail": "username@example.com",
      "Channel": "vodafone-gh",
      "Amount": 0.8,
      "PrimaryCallbackUrl": "https://webhook.site/b503d1a9-e726-f315254a6ede",
      "Description": "Union Dues",
      "ClientReference": "3jL2KlUy3vt21"
  }',
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/json',
      'Authorization: Basic endjeOBiZHhza250fT3=='
    ),
  ));

  $response = curl_exec($curl);

  curl_close($curl);
  echo $response;
  ```

**Python**

  ```bash
  import requests
  import json

  url = "https://rmp.hubtel.com/merchantaccount/merchants/11684/receive/mobilemoney"

  payload = json.dumps({
    "CustomerName": "Joe Doe",
    "CustomerMsisdn": "233200000000",
    "CustomerEmail": "username@example.com",
    "Channel": "vodafone-gh",
    "Amount": 0.8,
    "PrimaryCallbackUrl": "https://webhook.site/b503d1a9-e726-f315254a6ede",
    "Description": "Union Dues",
    "ClientReference": "3jL2KlUy3vt21"
  })
  headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Basic endjeOBiZHhza250fT3=='
  }

  response = requests.request("POST", url, headers=headers, data=payload)

  print(response.text)
  ```

**JS**

  ```javascript
  const myHeaders = new Headers();
  myHeaders.append("Content-Type", "application/json");
  myHeaders.append("Authorization", "Basic endjeOBiZHhza250fT3==");

  const raw = JSON.stringify({
    "CustomerName": "Joe Doe",
    "CustomerMsisdn": "233200000000",
    "CustomerEmail": "username@example.com",
    "Channel": "vodafone-gh",
    "Amount": 0.8,
    "PrimaryCallbackUrl": "https://webhook.site/b503d1a9-e726-f315254a6ede",
    "Description": "Union Dues",
    "ClientReference": "3jL2KlUy3vt21"
  });

  const requestOptions = {
    method: "POST",
    headers: myHeaders,
    body: raw,
    redirect: "follow"
  };

  fetch("https://rmp.hubtel.com/merchantaccount/merchants/11684/receive/mobilemoney", requestOptions)
    .then((response) => response.text())
    .then((result) => console.log(result))
    .catch((error) => console.error(error));
  ```

<br />

###### RESPONSE PARAMETERS [#response-parameters]

| Parameter             | Type   | Description                                                                                                    |
| --------------------- | ------ | -------------------------------------------------------------------------------------------------------------- |
| Message               | String | The description of response received from the Receive Money API that is related to the ResponseCode.           |
| ResponseCode          | String | The unique response code on the status of the transaction.                                                     |
| Data                  | Object | An object containing the required data response from the API.                                                  |
| Amount                | Float  | The transaction amount.                                                                                        |
| Charges               | Float  | The charge/fee for the transaction.                                                                            |
| AmountAfterCharges    | Float  | The transaction amount after charges/fees deduction.                                                           |
| AmountCharged         | Float  | The actual amount that is charged from the customer’s mobile money wallet.                                     |
| Description           | String | The description initially provided by API user in the request payload.                                         |
| ClientReference       | String | The reference ID that is initially provided by the client/API user in the request payload (**from merchant**). |
| TransactionId         | String | The unique ID used to identify a Hubtel transaction (**from Hubtel**).                                         |
| ExternalTransactionId | String | The transaction reference from the mobile money provider (**from Telco**).                                     |
| OrderID               | String | The unique ID used to identify a transaction order.                                                            |
| DeliveryFee           | Float  | The delivery fee of the transaction is normally zero (0.0).                                                    |

<br />

###### SAMPLE RESPONSE [#sample-response]

```js
{
  "Message": "Transaction pending. Expect callback request for final state",
  "ResponseCode": "0001",
  "Data": {
      "TransactionId": "09f84e20a283942e807128e8c21d08d6",
      "Description": "Union Dues",
      "ClientReference": "3jL2KlUy3vt21",
      "Amount": 0.8,
      "Charges": 0.05,
      "AmountAfterCharges": 0.8,
      "AmountCharged": 0.85,
      "DeliveryFee": 0.0
  }
}
```

<br />

<br />

##### Receive Money Callback [#receive-money-callback]

The **Hubtel Receive Money API** mandatorily sends a payload to the callbackURL provided in each request. The callback payload determines **final status** of a pending transaction response i.e.; transaction with **0001** ResponseCode. The callback URL you specified in the Receive Money request should be implemented to listen for an HTTP **POST** payload from Hubtel.

To process a **Receive Money** request, customer **approval** is required to transfer money from their mobile money account to your Hubtel Merchant Account. Consequently, the transaction flow is **asynchronous**. This means the **final status** of a transaction is not immediately available and may take up to 30 seconds to be confirmed. Therefore, it is **crucial** to implement an HTTP callback on your server to receive the **final transaction status**.

<br />

> **Note**
> Businesses that want to add an extra layer of security to ensure callbacks reach their endpoint securely can whitelist Hubtel’s callback IP address: **18.202.122.131**
<br />

###### SAMPLE CALLBACK (Successful) [#sample-callback-successful]

```js
{
  "ResponseCode": "0000",
  "Message": "success",
  "Data": {
      "Amount": 0.8,
      "Charges": 0.05,
      "AmountAfterCharges": 0.8,
      "Description": " The Vodafone Cash payment has been approved and processed successfully",
      "ClientReference": "3jL2KlUy3vt21",
      "TransactionId": "09f84e20a283942e807128e8c21d08d6",
      "ExternalTransactionId": "2116938399",
      "AmountCharged": 0.85,
      "OrderId": "09f84e20a283942e807128e8c21d08d6",
      "PaymentDate": "2024-05-14T00:44:57.5142719Z"
  }
}
```

<br />

###### SAMPLE CALLBACK (Failed) [#sample-callback-failed]

```js
{
  "ResponseCode": "2001",
  "Message": "failed",
  "Data": {
      "Amount": 0.8,
      "Charges": 0.05,
      "AmountAfterCharges": 0.8,
      "Description": "FAILED",
      "ClientReference": "3jL2KlUy3vt21",
      "TransactionId": "09f84e20a283942e807128e8c21d08d6",
      "ExternalTransactionId": "2116938399",
      "AmountCharged": 0.85,
      "OrderId": "09f84e20a283942e807128e8c21d08d6",
      "PaymentDate": "2024-05-14T00:44:57.5142719Z"
  }
}
```

<br />

<br />

##### Transaction Status Check [#transaction-status-check]

It is **mandatory** to implement the **Transaction Status Check API** as it allows merchants to check for the status of a transaction in rare instances where a merchant does not receive the final status of the transaction from Hubtel **after five (5) minutes**.

To check the status of a transaction, send an HTTP **GET** request to the below URL, with either one or more unique transaction identifiers as parameters.

It is also **mandatory** to parse your **Collection Account Number** for Status Check requests in the endpoint.
Find your **Collection Account Number** [here](/docs/get-started/programmable-api-keys?curr_idx=3).

> **Note**
> Only requests from whitelisted IP(s) can reach the endpoint. Requests from IP addresses that have not been whitelisted will return a **403 Forbidden** error response or a **timeout**. Submit your public IP(s) to your Retail Systems Engineer to be whitelisted.
<br />

|              |                                                                                                                                                                                  |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| API Endpoint | [https://api-txnstatus.hubtel.com/transactions/\{'\{Collection_Account_Number}'}/status](https://api-txnstatus.hubtel.com/transactions/\{'\{Collection_Account_Number}'}/status) |
| Request Type | **GET**                                                                                                                                                                          |
| Content Type | **JSON**                                                                                                                                                                         |

<br />

###### REQUEST PARAMETERS [#request-parameters-1]

| Parameter            | Type   | Requirement           | Description                                                               |
| -------------------- | ------ | --------------------- | ------------------------------------------------------------------------- |
| clientReference      | String | Mandatory (preferred) | The client reference of the transaction specified in the request payload. |
| hubtelTransactionId  | String | Optional              | Transaction ID from Hubtel after successful payment.                      |
| networkTransactionId | String | Optional              | The transaction reference from the mobile money provider.                 |

> **Note**
> Although either one of the unique transaction identifiers above could be passed as parameters,
> **clientReference** is recommended to be used often.
<br />

###### SAMPLE REQUEST [#sample-request-1]

**HTTP**

  ```http
  GET /transactions/11684/status?clientReference=3jL2KlUy3vt21 HTTP/1.1
  Host: api-txnstatus.hubtel.com
  Authorization: Basic QmdfaWghe22NU6bXVhaHdpYW8pfQ==
  ```

**cURL**

  ```bash
  curl --location 'https://api-txnstatus.hubtel.com/transactions/11684/status?clientReference=3jL2KlUy3vt21' \
  --header 'Authorization: Basic QmdfaWghe22NU6bXVhaHdpYW8pfQ=='
  ```

**PHP**

  ```php
  <?php

  $curl = curl_init();

  curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api-txnstatus.hubtel.com/transactions/11684/status?clientReference=3jL2KlUy3vt21',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
      'Authorization: Basic QmdfaWghe22NU6bXVhaHdpYW8pfQ=='
  ),
  ));

  $response = curl_exec($curl);

  curl_close($curl);
  echo $response;
  ```

**Python**

  ```bash
  import requests

  url = "https://api-txnstatus.hubtel.com/transactions/11684/status?clientReference=3jL2KlUy3vt21"

  payload = {}
  headers = {
      'Authorization': 'Basic QmdfaWghe22NU6bXVhaHdpYW8pfQ=='
  }

  response = requests.request("GET", url, headers=headers, data=payload)

  print(response.text)
  ```

**JS**

  ```javascript
  const myHeaders = new Headers();
  myHeaders.append("Authorization", "Basic QmdfaWghe22NU6bXVhaHdpYW8pfQ==");

  const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
  };

  fetch("https://api-txnstatus.hubtel.com/transactions/11684/status?clientReference=3jL2KlUy3vt21", requestOptions)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.error(error));
  ```

<br />

###### RESPONSE PARAMETERS [#response-parameters-1]

| Parameter             | Type    | Description                                                                                                    |
| --------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| message               | String  | The description of response received from the API that is related to the ResponseCode.                         |
| responseCode          | String  | The response code of the API after the request.                                                                |
| data                  | Object  | An object containing the required data response from the API.                                                  |
| date                  | String  | Date of the transaction                                                                                        |
| status                | String  | Status of the transaction i.e.: **Paid**, **Unpaid** or **Refunded**.                                          |
| transactionId         | String  | The unique ID used to identify a Hubtel transaction (**from Hubtel**).                                         |
| externalTransactionId | String  | The transaction reference from the mobile money provider (**from Telco**).                                     |
| paymentMethod         | String  | The mode of payment.                                                                                           |
| clientReference       | String  | The reference ID that is initially provided by the client/API user in the request payload (**from merchant**). |
| currencycode          | String  | Currency of the transaction; could be **null**.                                                                |
| amount                | Float   | The transaction amount.                                                                                        |
| charges               | Float   | The charge/fee for the transaction.                                                                            |
| amountAfterCharges    | Float   | The transaction amount after charges/fees deduction.                                                           |
| isFulfilled           | Boolean | Whether service was fulfilled; could be **null**.                                                              |

<br />

###### SAMPLE RESPONSE (Paid) [#sample-response-paid]

```js
{
  "message": "Successful",
  "responseCode": "0000",
  "data": {
      "date": "2024-04-25T21:45:48.4740964Z",
      "status": "Paid",
      "transactionId": "7fd01221faeb41469daec7b3561bddc5",
      "externalTransactionId": "0000006824852622",
      "paymentMethod": "mobilemoney",
      "clientReference": "3jL2KlUy3vt21",
      "currencyCode": null,
      "amount": 0.1,
      "charges": 0.02,
      "amountAfterCharges": 0.08,
      "isFulfilled": null
  }
}
```

###### SAMPLE RESPONSE (Unpaid) [#sample-response-unpaid]

```js
{
  "message": "Successful",
  "responseCode": "0000",
  "data": {
      "date": "2024-04-25T21:45:48.4740964Z",
      "status": "Unpaid",
      "transactionId": "7fd01221faeb41469daec7b3561bddc5",
      "externalTransactionId": "0000006824852622",
      "paymentMethod": "mobilemoney",
      "clientReference": "3jL2KlUy3vt21",
      "currencyCode": null,
      "amount": 0.1,
      "charges": 0.02,
      "amountAfterCharges": 0.08,
      "isFulfilled": null
  }
}
```

<br />

<br />

##### Response Codes [#response-codes]

The Hubtel Sales API uses standard HTTP error reporting. Successful requests return HTTP status codes in the 2xx. Failed requests return status codes in 4xx and 5xx. Response codes are included in the JSON response body, which contain information about the response.

| Response Code | Description                                                                                                                                                                                                                                                                                                                                                                                                                               | Required Action                                                                                                                                                                                                                                       |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0000          | The transaction has been processed successfully.                                                                                                                                                                                                                                                                                                                                                                                          | None                                                                                                                                                                                                                                                  |
| 0001          | Request has been accepted. A callback will be sent on final state                                                                                                                                                                                                                                                                                                                                                                         | None                                                                                                                                                                                                                                                  |
| 2001          | • The MTN Mobile Money user has reached counter or balance limits, has insufficient funds or is missing permissions.<br />• The Vodafone Cash failed<br />• You entered the wrong PIN. Please try again<br />• Dear Customer, you have insufficient funds. Avail. Balance:#### 5 successive invalid transfers will lock your account. Thank you.<br />• MTN Exception: Account Holder with FRI Not Found<br />• Transaction id is invalid | • Customer either entered no or invalid PIN<br />• Mobile network not able to parse your request<br />• USSD session timeout<br />• Having strange characters (&\*!%@) in your description<br />• Ensure that the number provided matches the channel |
| 4000          | Validation errors                                                                                                                                                                                                                                                                                                                                                                                                                         | Validation errors. Something is not quite right with this request. Please check again.                                                                                                                                                                |
| 4070          | We're unable to complete this payment at the moment. Please try again later. Fees not set for given conditions.                                                                                                                                                                                                                                                                                                                           | Ensure you are passing the required minimum amount or contact your Hubtel relationship manager to setup fees for your account if error persists.                                                                                                      |
| 4101          | • The business you're trying to pay isn't fully set up to receive payments at the moment. Please try again later<br />• Supplied API keys does not have "mobilemoney-receive-direct" in scopes.<br />• Client request keys do not match API keys on business                                                                                                                                                                              | • Contact your Retail Systems Engineer to enable Receive Money Scopes<br />• Ensure that you're providing the correct Basic Auth key for the Authorization header and ensure you’re passing your Collection Account Number in the endpoint.           |
| 4103          | • Permission denied.<br />• Sorry, your account is not allowed to transact on this channel                                                                                                                                                                                                                                                                                                                                                | Contact your Retail Systems Engineer                                                                                                                                                                                                                  |

<br />
