DohoneSDK
A NodeJS SDK for easily use Dohone payment API.
Note
This module let you easily integrate Dohone payment API to your application or your web site for every Cameroon mobile payments operators (MTN Mobile Money, Orange Money and Express Union Mobile Money).
Before you start using this package, it's highly recommended to read documents below.
- TUTORIAL D’INSTALLATION DE L’API DE PAIEMENT EN LIGNE POUR APPLICATIONS MOBILES
- TUTORIAL D’INSTALLATION DE L’API DE PAIEMENT EN LIGNE
- TUTORIAL D’INSTALLATION DE L’API DE TRANSFERTS AUTOMATIQUES (PAYOUT)
Table of contents
- 1. Requirements
- 2. Installation
- 3. Payin requests (collect payments)
- 4. Payout requests (refund customer or withdraw money)
1. Requirements
There is no specific requirements for this package.
2. Installation
$ npm install dohone-sdk
3. Payin requests (collect payments)
3.1. Create a DohoneSDK object
You can find DohoneSDK class here.
var dohone = ;// constantsvar merchantKey = '...'; // your dohone merchant key (required)var appName = '...'; // the name by which your application is recognized at Dohonevar hashCode = '...'; // your dohone hash code (only if you handle dohone notifications in your system)var notifyUrl = '...'; // default notification URL for incoming paymentsvar dohoneSdk = dohone;// ...
3.2. Make a « COTATION » command
// .../*** transaction is a JSON object with following properties* - amount: number* - currency: 'XAF', 'EUR' or 'USD'** params is a JSON object with following properties* - mode: 0, 1, 2, 3 or 4 (exact as levelFeeds in Dohone docs)*/var transaction =amount: 1000currency: 'XAF';var params =mode: 0;dohoneSdk;// ...
3.3. Make a « START » command
// .../*** transaction is a JSON object with following properties* - ref: string (unique transaction reference in your system)* - amount: number* - currency: 'XAF', 'EUR' or 'USD'* - operator: 'DOHONE_OM', 'DOHONE_MOMO', 'DOHONE_EU', 'DOHONE_TRANSFER'* - customerPhoneNumber: string* - customerName: string* - customerEmail: string* - reason: string* - notifyUrl: string (notification URL for this transaction)** params is a JSON object with following properties* - OTP: number (payment code in case of Orange Money)*/var transaction =ref: '146eb9e4-fad1-4214-a8ed-9e5316ef2fad'amount: 1000currency: 'XAF'operator: 'DOHONE_OM' // Orange MoneycustomerPhoneNumber: '699999999';var params =OTP: '452132' // provided by user;dohoneSdkstarttransaction params {if err// handle request error hereelse if dohoneResisSuccessif dohoneResneedCFRMSMS// must make a CFRMSMS commandelse if dohoneReshasREF// successful transaction// dohoneRes.REF is transaction referenceelse// unknown response, check dohoneRes.messageelse// Dohone error, check dohoneRes.message};// ...
3.4. Make a « CFRMSMS » command
// .../*** transaction is a JSON object with following properties* - customerPhoneNumber: string** params is a JSON object with following properties* - code: string (Dohone authorization code)*/var transaction =customerPhoneNumber: '699999999';var params =code: 'A123' // provided by user;dohoneSdk;// ...
Bonus tip
We have noticed that the CFRMSMS command often returns an empty answer, it is sometimes necessary to make several attempts before getting a good answer. For this, we have provided a fourth optional parameter to the confirmSMS() method that defines the maximum number of attempts to be made, its default value is 1.
// for example, if you want to allow five attemptsdohoneSdk;
3.5. Make a « VERIFY » command
// .../*** transaction is a JSON object with following properties* - ref: string (unique transaction reference in your system)* - dohoneRef: string (Dohone transaction reference)* - amount: number* - currency: 'XAF', 'EUR' or 'USD'*/var transaction =ref: '146eb9e4-fad1-4214-a8ed-9e5316ef2fad'dohoneRef: '123456789'amount: 1000currency: 'XAF';dohoneSdk;// ...
3.6. Handle Dohone's notifications
// .../*** data must contain request parameters sent by Dohone*/// For example, if you are using Express framework, thenvar data = requestquery;// After that, map data usingdata = dohoneSdk;// Check request integrity using your hashCodeif dohoneSdkdohoneSdk;else// bad signature, you can ignore the request or do something else// ...
4. Payout requests (refund customer or withdraw money)
Need this ? Contact me, I will fill this content for FREE.
4.1. Create a DohonePayoutSDK object
You can find DohonePayoutSDK class here.
// ...
4.2. Make a « COTATION » command
// ...// ...
4.3. Make a transfer
// ...// ...
4.4. Handle Dohone's payout notifications
// ...// ...