Hubtel Repeat Payments API (v1.2)
Hubtel Repeat Payments API (v1.2)
1
API Change Log
Changes between document issues are cumulative. The latest document issue contains all the changes made
in earlier issues.
v1.0 (2019-10-31)
This issue is the first official release
v1.1 (2019-12-12)
This issue contains a cancel invoice API endpoint.
v1.2 (2020-02-12)
This issue includes changes to the callback structure and additional payment channels.
2
Contents
API Change Log ....................................................................................................................................... 2
Contact Us .......................................................................................................................17
3
1.0 Overview
The Hubtel Recurring Payments API allows you to setup and receive recurring payments from
your customers for services provided using mobile money and card options.
With a single integration, you can easily and securely accept recurring mobile money
payments on your application. All you need to do is to simply provide the customer debit
details and Hubtel will handle the scheduling and the various debits.
The following provides an overview of the REST API endpoints for interacting
programmatically with the Hubtel Recurring P API within your application.
2.1 Authentication
You need to authenticate every API request you make to the Recurring Payments API
using Basic Auth. Authenticate by encoding your username and password to Base64 HTTP
Basic Authorization. Use your API ID as your username and API KEY as your password.
A Base64 encoding of your API keys should have your Authorization header appear like this:
Basic a2hlcW2sb3U6bWdhtHd9YW8=.
You will also have to share your public IP address for whitelisting. Only requests from this IP
will be accepted. Send this via email to [email protected].
4
3.0 Understand the Service Flow
The Hubtel Recurring Payments service includes two main API endpoints which are used
together to setup a recurring payment invoice. They are
Create Invoice Endpoint: This allows you to create a recurring payment invoice on a
customer wallet. The invoice will stay in a temporary state until the verification is
done. This step initiates the invoice creation process.
Verify Invoice Endpoint: This allows you to verify the invoice with the customer
involvement through an OTP code. This completes the invoice creation process.
The entire process is asynchronous. The figure below shows the process of creating and
verifying a Recurring Payment Invoice using these two endpoints:
InvoiceCreation Request
1
InvoiceCreation Response
2
VerifyInvoice Response
6
Customer Approval & Initial
Payment Request
7
Customer Approval & Initial
Payment8Response
Final Callback to your App.
9
5
The table below describes the process for creating and verifying a Recurring Payment
Invoice:
Step Description
Hubtel performs authentication on request and sends response to your App with
2
a unique identifier (RecurringInvoiceId)
Hubtel sends verification OTP code to customer number to provide to third party
3
(your app).
Your App sends an Invoice Verification request to Hubtel with the customer OTP
4
code and unique identifier (RecurringInvoiceId)
After first payment is taken, a callback is sent to your App based on the provided
7
URL.
Whenever the invoice is due (scheduled time), a direct debit is made on the
8
customer mobile money wallet and a callback is sent to your App.
6
4.0 API Reference
To initiate a Create Invoice transaction, make an HTTP POST to the below URL with the
required parameters:
Request Parameters:
7
The customer’s mobile money number. This
customerMobileNumber String Mandatory
should be in the international format.
Eg: 233249111411
8
Response Parameters:
Sample Request
POST Endpoint HTTP/1.1
Host: BaseURL
Accept: application/json
Content-Type: application/json
Authorization: Basic endjeOBiZHhza250fT3=
Cache-Control: no-cache
{
"orderDate":"11/05/2019 13:53:00",
"invoiceEndDate":"11/10/2019 13:53:00",
"description":"Extreme Gaming Service",
"startTime":"14:00",
9
"paymentInterval":"DAILY",
"customerMobileNumber":"233246012176",
"paymentOption":"MobileMoney",
"channel":"mtn-gh",
"customerName":"Daniel Barnes",
"recurringAmount":0.10,
"totalAmount":0.10,
"initialAmount":0.10,
"currency":"GHS",
"callbackUrl":"https://webhook.site/b503d1a9-e726-f315254a6ede"
}
Sample Response
{
"responseCode": "0001",
"message": "Your request has been processed successfully.",
"data": {
"recurringInvoiceId": "0f84e20a2839482e807128e8c21d08d6",
"requestId": "a6487bc44eae44849fd80326a0dd802a",
"otpPrefix": "OQDM"
}
}
10
4.2 Verify Invoice API
To send a Verify Invoice request, make an HTTP POST to the below URL with the required
parameters:
Request Parameters:
Response Parameters:
11
Sample Request
POST Endpoint HTTP/1.1
Host: BaseURL
Accept: application/json
Content-Type: application/json
Authorization: Basic endjeOBiZHhza250fT3=
Cache-Control: no-cache
{
"recurringInvoiceId": "0f84e20a2839482e807128e8c21d08d6",
"requestId": "a6487bc44eae44849fd80326a0dd802a",
"otpCode": "OQDM-9514"
}
Sample Response
{
"responseCode": "0001",
"message": "Your request has been processed successfully. You will receive a
callback on the final status shortly.",
"data": {
"recurringInvoiceId": "0f84e20a2839482e807128e8c21d08d6"
}
}
4.3 Callback
When you provide a callback URL in your invoice creation request, you will be sent a
callback on the final state of the invoice as well as the final state of all payments made on
that invoice. This means the callback URL you specify should be implemented to listen for an
HTTP POST payload from Hubtel.
Recurring invoice creation requires a one-time approval from the customer in order for
money to move from the mobile money wallet into your Hubtel Account. As a result, invoice
creation has an asynchronous flow on all networks. This also means that the final status of
12
an invoice cannot be determined immediately after the request. It may take some time
(usually less than 10 minutes). So you're required to implement an HTTP callback on your
server to be able to receive final status of the transaction.
We recommend using service likes RequestBin or Webhook Tester to test your callback.
These services allow you to define temporary dummy endpoints which will show you the
requests and all the data you are receiving from Hubtel.
13
Sample Callback 2 (failed transaction)
{
"ResponseCode":"2001",
"Message": "Failed",
"Data": {
"OrderId": "1d0e06bc689c4de2bb87a54829a89640",
"Description": "My recurring service",
"RecurringInvoiceId": "8ae267e31af748d4934b0420be6f47f0",
"TransactionId": "5814152092296267804084",
"ClientReference": "8ae267e31af748d4934b0420be6f47f0",
"ExternalTransactionId": null,
"OrderDate": "2020-02-10 09:58:00",
"InvoiceEndDate":"2019-10-14 12:00:00",
"CustomerMobileNumber": "233246912184",
"Charges": 0.01,
"AmountAfterCharges": 0.19,
"AmountCharged": 0.20,
"Amount": 0.20,
"InitialAmount": 0.20,
"RecurringAmount": 0.10
}
}
14
4.4 Cancel Invoice API
To send a Cancel Invoice request, make an HTTP POST to the below URL with the required
parameters:
https://rip.hubtel.com/api/proxy/{HubtelAccountNumber}/cancel-
API Endpoint
invoice/{recurringInvoiceId}
Request Parameters:
Response Parameters:
ResponseCode String The unique response code on the status of the request.
Sample Request
DELETE /api/proxy/11920/Cancel-Invoice/0f84e20a2839482e807128e8c21d08d6
HTTP/1.1
Host: rip.hubtel.com
Accept: application/json
Content-Type: application/json
Authorization: Basic endjeOBiZHhza250f3=
Cache-Control: no-cache
15
Sample Response
{
"responseCode": "0000",
"message": "Your request has been processed successfully"
}
Response Codes are included in the JSON response body, which contains information about
the error or status:
The transaction failed. Either because the approval failed with the network
2001
provider or because the initial payment failed.
0005 There was an HTTP failure/exception when reaching the payment partner.
Validation Errors. Something is not quite right with this request. Please check
4000
and try again.
16
Contact Us
Hubtel
63 Hotel Road
Accra - Ghana
General: [email protected]
Sales: [email protected]
Help: [email protected]
www.hubtel.com
17