Changelog

Payment API

Payment API provides all the functionality required to manage beneficiaries and initiate payments on your user's behalf.

The Payment APIs are:

  • Dapi AutoFlow - The easiest and most efficient way to facilitate payments.
  • [Not required when using Autoflow] Get beneficiaries - Retrieve beneficiaries from the bank account.
  • [Not required when using Autoflow] Create Beneficiary - Create a beneficiary into the bank account.
  • [Not required when using Autoflow] Create Transfer - Initiate a transfer to an existing beneficiary only.

Transfer Autoflow [Recommended]

Transfer Autoflow

Transfer Auto Flow automatically takes care of all requirements for adding a beneficiary as well as initiating a transfer. We recommend using Transfer Auto Flow to initiate a payment.

Using Dapi AutoFlow you can easily create a transfer and listen to the success or failure results.

Parameter

Type

Description

transfer

Object

Transfer Object (see details below)

clientHeaders

Object
Optional

More details

clientBody

Object
Optional

More details

Transfer Object Schema

Parameter

Type

Description

senderID

String

This is the id of a particular sub account. You can get this from calling getAccounts function.

beneficiary

Object

Its params can be found
here

amount

Number

This is the amount you want to send.

remarks

String

Unique ID generated by your application. Can be used to track the transfer during settlement.

NB! No special characters allowed

Example

var transfer = {
    senderID: "XXXAAABBBCCC",
    amount: 0,
    remarks: "",
    beneficiary: {
      name: "Mohammad Omar Amr",
      nickname: "Mohammad Omar LIV",
      iban: "DAPIBANKAELIV1619116273261987517393",
      accountNumber: "1619116273261987517393",
      swiftCode: "EBILAEAD",
      address: {
          line1: "Maryam Street",
          line2: "Abu Dhabi",
          line3: "United Arab Emirates"
      },
      country: "AE",
      branchAddress: "Dubai Mall",
      branchName: "Main Branch"  
    }
  }
  ba.payment.transferAutoflow(transfer)
    .then(transferResponse => {
          if(transferResponse.status === "done") {
            console.dir(transferResponse)
          } else {
            console.error("API Responded with an error")
            console.dir(transferResponse)
          }
        })
        .catch(error => {
            console.dir(error)
        })

❗️

How to set beneficiary details?

There are multiple ways to communicate the beneficiary details to Dapi. Please follow the best approach based on your exact use case and security requirements


  • Option 1: Set the beneficiary on the Dapi Dashboard.
    • ⚠️ Works only for static beneficiaries. (All of the transfers will be sent to beneficiaries that you know ahead of time.)
    • No configuration required on the SDK nor on the SDK Backend Server side.

  • Option 2: Set the beneficiary as the DAPIBeneficiary object in the SDK function call
    • Works for both dynamic and static beneficiaries.
    • ⚠️ You should be double-checking the beneficiary details integrity in the SDK Backend Server that you set up. This is to ensure no tampering with the data on the front-end layer.

  • Option 3: Set the beneficiary details only in the SDK Backend Server (in principle the same as Option 2)
    • Works for both dynamic and static beneficiaries.
    • You never have to expose the beneficiary details to the front-end layer.
    • You want your backend to be in full control of the beneficiary details.
    • ⚠️ Don't recommend for static beneficiary use cases, since it would be unnecessary additional development work on the Backend Server Side.


No Autoflow Approach

❗️

If you do not use AutoFlow you will be responsible for:

  • ⚠️ Handling beneficiary addition based on each bank's requirements
  • ⚠️ Handling beneficiary existence checks
  • ⚠️ Setting up a way to call the Accounts API to obtain the sender account information

Get Beneficiaries

Access the bank account's beneficiaries array.

Parameter

Type

Description

clientHeaders

Object
Optional

More details

clientBody

Object
Optional

More details

Example

ba.payment.getBeneficiaries()
    .then(benefResponse => {
          if(benefResponse.status === "done") {
            console.dir(benefResponse)
          } else {
            console.error("API Responded with an error")
            console.dir(benefResponse)
          }
        })
        .catch(error => {
            console.dir(error)
        })

Get Beneficiaries Response

Create Beneficiary

Create a beneficiary into the bank account with this endpoint.

Parameter

Type

Description

beneficiary

Object

Its params can be found here

clientHeaders

Object
Optional

More details

clientBody

Object
Optional

More details

Example

var beneficiary = {
      name: "Mohammad Omar Amr",
  		nickname: "Mohammad Omar Liv",
      iban: "DAPIBANKAELIV1619116273261987517393",
      accountNumber: "1619116273261987517393",
      type: "local",
      swiftCode: "EBILAEAD",
      address: {
          line1: "Maryam Street",
          line2: "Abu Dhabi",
          line3: "United Arab Emirates"
      },
      country: "United Arab Emirates",
      branchAddress: "Dubai Mall",
      branchName: "Main Branch"  
  }
  ba.payment.createBeneficiary(beneficiary)
    .then(benefResponse => {
          if(benefResponse.status === "done") {
            console.dir(benefResponse)
          } else {
            console.error("API Responded with an error")
            console.dir(benefResponse)
          }
        })
        .catch(error => {
            console.dir(error)
        })

Create Transfer

Send money to a particular existing beneficiary.

Parameter

Type

Description

Transfer

Object

See details below

clientHeaders

Object
Optional

More details

clientBody

Object
Optional

More details

Transfer Object Schema

Parameter

Type

Description

senderID

String

This is the id of a particular sub account. You can get this by calling the getAccounts function.

receiverID

String

This is the id of a particular beneficiary. You can get this by calling the getBeneficiaries function

accountNumber

String
Optional

This is the accountNumber of a new beneficiary you want to send money to. Some banks require it

iban

String
Optional

This is the iban of a new beneficiary you want to send money to. Some banks require it

amount

Number

This is the amount you want to send

remarks

String
Optional

This is the id you can use to track the transaction.

Example

var transfer = {
    senderID: "ntV7rbYoexYaGDRfLCAo8vw1xXgu2VaXXtqvNoMU0sfy6aNErfUEGMD+P6lAlkzu/GKxPeoef7d7eNoxlHKyRw==",
    receiverID: "kSSWuq7RXww1VZpvF05KBfeiQxr8nb/uHQ35ZqSmhnp2gVoqZ7+DCnI/zRLzcg32myS/e8BLPhMJaT7mJ3z9Uw==",
    accountNumber: "1619116273261987517393",
    name: "Mohammad Omar Amr",
    iban: "DAPIBANKAELIV1619116273261987517393",
    amount: 10,
    remarks: "",
  }
  
  ba.payment.createTransfer(transfer)
    .then(transferResponse => {
          if(transferResponse.status === "done") {
            console.dir(transferResponse)
          } else {
            console.error("API Responded with an error")
            console.dir(transferResponse)
          }
        })
        .catch(error => {
            console.dir(error)
        })