Logo Blue Finalse
Console 
  Français   English


Javascript


  • GETTING STARTED
  • Authentication
  • Hello World
  • Pricing
  • Rate Limit
  • USE CASES
  • FPay UI Integration
  • Custom UI Integration
  • Interoperability  New
  • Payment links and QRCodes
  • Third Parties Money  New
  • Audit & Dashboard  New
  • REFERENCES
  • Attempt
  • AuthAccess
  • Deposit
  • FundRequest
  • QuasiTransfer
  • Transaction
  • Transfer
  • Wallet
Logo Blue FinalseLogo Blue Finalse
Javascript
Console 
  Français   English
  • GETTING STARTED
  • Authentication
  • Hello World
  • Pricing
  • Rate Limit
  • USE CASES
  • FPay UI Integration
  • Custom UI Integration
  • Interoperability  New
  • Payment links and QRCodes
  • Third Parties Money  New
  • Audit & Dashboard  New
  • REFERENCES
  • Attempt
  • AuthAccess
  • Deposit
  • FundRequest
  • QuasiTransfer
  • Transaction
  • Transfer
  • Wallet

Hello World

Goal  

First thing First
The purpose of this first application will be to retrieve programmatically money from an MtnMoney account and make a deposit to your FPay's main wallet.
Of course, we support all 3 telcos and MTN has just been selected for illustrative purposes in this example.

Environment Set Up  


Javascript

Pre Requisites  

Javascript
This SDK requires
Node >=9.5

Authentication
We assume that you have of course opened your FPay account and that you are in possession of your  token and your secretKey  obtained during the creation of the AuthAccess object as explained  on the Authentication page.

Initialization  

  • NPM
  • Yarn
npm install @finalse/sdk-node
yarn add @finalse/sdk-node

The Code  

const sdk = require('@finalse/sdk-node');
// or alternatively 
// import * as sdk from '@finalse/sdk-node';

const fPay = sdk.FPayClient(sdk.Auth({token: '<token>', secretKey: '<secretKey>' }));
const depositPromise = 
    fPay.deposit.initiate({
        amount: "10_000 XOF",
        source: "CI MtnMoney +2250500000000",
        h1: "First Deposit via API"
    });
depositPromise.then(deposit => {
    console.log(deposit.toString());
});

Remarks  

  • First, Note that the value of field h1  is the title, the justification, the label of this operation. For our operations, we'll need to choose a clear descriptive value to find our way around and better organize ourselves later.
  • We then notice that, when we specify the amount "10_000 XOF", we can add the facultative character  "_"  to perform a visual separation.
  • We also notice that if we want to get money from an  Orange Money account in Côte d'Ivoire , we'll simply have to change the value of the field source  with the following value  "CI OrangeMoney +22507xxxxxxxx".   Because  CI is the Côte d'Ivoire's ISO 3166 Alpha 2 code, there's no need to explain what would have happened if we had set the value  "CI MoovMoney +22501xxxxxxxx" or the value  "BF OrangeMoney +22678xxxxxxxx" . Simple, logical, isn't it ?

That's It   

Congratulations, you can run the previous code and you have just completed your first integration with our API. The Deposit object just created is available on your console . On the phone, you will receive a message inviting you to validate the transaction. Please dial *133# then 1 then your Momo secret code to validate the transaction.
Please confirm your MTN Money operation

What's happened ?   

In the background, here's an overview of what happened with just the above code :

  • Authenticated servers using digital signatures based on public key cryptography
  • Established a secure connection with encryption suites ensuring perfect forward secrecy
  • Signed the request with an algorithm based on the SHA-512 cryptographic hash function
  • Added mechanism to prevent replay attacks
  • Added mechanism to prevent timming attacks

Bonus  

We offer you the long version of the previous code, which does exactly  the same thing as the code above, just to show you a glimpse of FPay's possibilities.

const sdk = require('@finalse/sdk-node');
// or alternatively 
// import * as sdk from '@finalse/sdk-node';

const fPay = sdk.FPayClient(sdk.Auth({token: '<token>', secretKey: '<secretKey>' }));
const depositPromise = 
    fPay.deposit.initiate({
        amount: {
            currency: "XOF",
            value: "10_000"
        },
        source: {
            _type: "Single",
            account: {
                country: "CI",
                identifier: "+2250500000000",
                providerKey: "MtnMoney"
            }
        },
        h1: "First Deposit via API"
    });
depositPromise.then(deposit => {
    console.log(deposit.toString());
});

Simplicity is a great virtue but it requires hard work to achieve it,
and education to appreciate it

Edsger W. Dijkstra

Welcome to Great Usability
Welcome to Simplicity
Welcome to Finalse

HELLO WORLD
  • Goal
  • Environment Set Up
  • Pre Requisites
  • Initialization
  • The Code
  • Remarks
  • That's It
  • What's happened ?
  • Bonus