Wire API (US only)
Wire API provides all the functionality required to manage beneficiaries and initiate payments on your user's behalf.
The Payment APIs are:
- CreateWireTransfer - The easiest and most efficient way to facilitate payments.
- [Not required when using CreateWireTransfer] Get Wire beneficiaries - Retrieve beneficiaries from the bank account.
- [Not required when using CreateWireTransfer] Create Wire Beneficiary - Create a beneficiary into the bank account.
- [Not required when using CreateWireTransfer] CreateWireTransferToExistingBeneficiary - Initiate a transfer to an existing wire beneficiary only.
createWireTransfer [Recommended]
createWireTransfer
automatically takes care of all requirements for adding a beneficiary as well as initiating a transfer. We recommend using createWireTransfer
to initiate a payment.
you can send money from
an account to
an account with a specific amount
.All 3 variables are optional.
Parameters
Note
Behavior of the SDK depends on the parameters that will be set.
Parameter | Description |
---|---|
toBeneficiary | If you are accepting a transfer into your own company's account, you don't need to set the parameter. You can simply add one in your dashboard under your app. The toBeneficiary will automatically be set to that account. |
fromAccount | Account from where the amount must be transferred. If you don't set a from account, SDK will simply display a popup screen for your user to pick the account from our UI. If you do provide a from object, this screen won't be displayed. |
amount | Amount to be transferred. If you don't set an amount SDK will display a screen with a numpad screen for your user to enter the amount in. |
remark | A message associated with the transfer. |
Example - When fromAccount
Is Not Specified
let address = new DapiLineAddress(
'Line1',
'Line2',
'Line3'
);
let wireBeneficiary = new DapiWireBeneficiary(
address,
"TestAccount",
"John",
"Doe",
"JohnDoe",
"Conway",
"Arkansas",
"US",
"72303",
"retail",
"checking",
"953344235",
"1234567654321",
);
await connection.createWireTransfer(wireBeneficiary, null, 100, 'remark')
.then(response => {
console.log(`Transfer success ${response}`);
})
.catch(error => {
console.log(`Transfer failed with error ${error}`);
});
The SDK shows UI for the user to select an account to send money from
Example - When amount
Is Not Specified
let address = new DapiLineAddress(
'Line1',
'Line2',
'Line3'
);
let wireBeneficiary = new DapiWireBeneficiary(
address,
"TestAccount",
"John",
"Doe",
"JohnDoe",
"Conway",
"Arkansas",
"US",
"72303",
"retail",
"checking",
"953344235",
"1234567654321",
);
let accountsResponse = await connection?.getAccounts();
await connection.createWireTransfer(wireBeneficiary, accountsResponse!.accounts[0], 0, 'remark')
.then(response => {
console.log(`Transfer success ${response}`);
})
.catch(error => {
console.log(`Transfer failed with error ${error}`);
});
The SDK shows UI for the user to enter the amount to send
Example - When amount
and fromAccount
Are Not Specified
let address = new DapiLineAddress(
'Line1',
'Line2',
'Line3'
);
let wireBeneficiary = new DapiWireBeneficiary(
address,
"TestAccount",
"John",
"Doe",
"JohnDoe",
"Conway",
"Arkansas",
"US",
"72303",
"retail",
"checking",
"953344235",
"1234567654321",
);
await connection.createWireTransfer(wireBeneficiary, null, 0, 'remark')
.then(response => {
console.log(`Transfer success ${response}`);
})
.catch(error => {
console.log(`Transfer failed with error ${error}`);
});
}
The SDK shows UI for the user to select an account to send money from then navigate to the amount screen to enter the amount to send
createWireTransferToExistingBeneficiary
Note
If you use
createWireTransferToExistingBeneficiary
you have to implement bank processing logic and validations on your end. You will require the use of the following APIs to process a transaction:
- Get Account
- Create Wire Beneficiary
- Get Wire Beneficiaries
createWireTransfer
abstracts all these requirements. There is no need to implement bank processing logic or validations. Dapi recommends usingcreateWireTransfer
to initiate a payment.
A method for sending money to an existing wire beneficiary.
Parameters
Parameter | Description |
---|---|
fromAccount | Account from where the amount must be transferred. |
toBeneficiaryID | The id of the beneficiary to which the money must be transferred. Obtain by connection.getBeneficiaries() |
amount | Amount to be transferred |
remark | A message associated with the transfer. |
Example
let accountsResponse = await connection?.getAccounts();
await connection.createWireTransferToExistingBeneficiary(
accountsResponse!.accounts[0],
beneficiaryID, //get from connection.getWireBeneficiaries() call
100,
'remark',
)
.then(transferResponse => {
console.log(`Transfer success ${transferResponse}`);
})
.catch(error => {
console.log(`Transfer failed with error ${error}`);
});
Beneficiary Not Activated error on Sandbox
This error occurs If you make a transfer on Sandbox to wrong or random beneficiary details, instead you should make the beneficiary details to be of another sandbox user.
To get the beneficiary details of a sandbox user you can do the following:
1- Open your app on the dashboard and navigate to the Sandbox tab. You'll see the Sandbox Users table.
2- Click an Account from the Accounts column.
3- A dialog shows up containing beneficiary details.
createWireBeneficiary
A method for adding a new wire beneficiary
Parameters
Parameter | Description |
---|---|
beneficiary | Information of the wire beneficiary to add. |
Example
let address = new DapiLineAddress(
'Line1',
'Line2',
'Line3'
);
let wireBeneficiary = new DapiWireBeneficiary(
address,
"TestAccount",
"John",
"Doe",
"JohnDoe",
"Conway",
"Arkansas",
"US",
"72303",
"retail",
"checking",
"953344235",
"1234567654321",
);
await connection.createWireBeneficiary(wireBeneficiary)
getWireBeneficiaries
A method for obtaining registered wire beneficiaries
Parameters
Method does not receive any parameter.
Example
await connection?.getWireBeneficiaries()
.then(response => {
console.log('Beneficiaries: ', response);
})
.catch(error => {
console.log('Dapi#getWireBeneficiaries() failed with error: ', error);
});
Updated 12 months ago