A client library that talks to the Dapi API.
First add the library module to your project.
go get github.com/dapi-co/dapi-go
- Create a Dapi app and products instances with your App Secret.
package main
import (
"github.com/dapi-co/dapi-go/app"
"github.com/dapi-co/dapi-go/auth"
"github.com/dapi-co/dapi-go/config"
"github.com/dapi-co/dapi-go/data"
"github.com/dapi-co/dapi-go/metadata"
"github.com/dapi-co/dapi-go/payment"
)
func main() {
// create a config object that holds the secret of this app
myAppConfig := &config.Config{
AppSecret: "YOUR_APP_SECRET",
}
// init a DapiApp instance
myApp := &app.DapiApp{
Config: myAppConfig,
}
// init the products you want to use
myAuth := auth.Auth{Config: myAppConfig}
myData := data.Data{Config: myAppConfig}
myPayment := payment.Payment{Config: myAppConfig}
myMetadata := metadata.Metadata{Config: myAppConfig}
// use any of the myApp, myAuth, myData, myPayment, or myMetadata methods..
}
- Now you can use any of the functions of any product (
Data
for example) instance,myData
, to call Dapi with yourappSecret
.
package main
import (
"github.com/dapi-co/dapi-go/app"
"github.com/dapi-co/dapi-go/config"
"github.com/dapi-co/dapi-go/data"
)
func main() {
// create a config object that holds the secret of this app
myAppConfig := &config.Config{
AppSecret: "YOUR_APP_SECRET",
}
// init the product you want to use
myData := data.Data{Config: myAppConfig}
// use any of the `myData` methods..
// provide the operationID and the userInputs only if needed
accountsResp, err := myData.GetAccounts("YOUR_ACCESS_TOKEN", "YOUR_USER_SECRET", nil, "")
if err != nil {
// handle the error..
return
}
if accountsResp.Status != constants.StatusDone {
// handle the unsuccessful response..
return
}
accounts := accountsResp.Accounts
// use the got accounts array..
}
- Or, you can use the
DapiApp
instance to handle requests to a specific endpoint in your server. Our code will basically update the request to add your app'sappSecret
to it, and forward the request to Dapi, then respond back with the got response.
package main
import (
"log"
"net/http"
"github.com/dapi-co/dapi-go/app"
"github.com/dapi-co/dapi-go/config"
)
func main() {
// create a config object that holds the secret of this app
myAppConfig := &config.Config{
AppSecret: "YOUR_APP_SECRET",
}
// init the a DapiApp instance
myApp := &app.DapiApp{
Config: myAppConfig,
}
// start a simple server that listens on the provided endpoint, and handles requests
// through the handler of the DapiApp instance.
err := http.ListenAndServe("YOUR_ADDRESS", http.HandlerFunc(myApp.HandleSDKDapiRequests))
if err != nil {
log.Fatal(err)
}
}
All the responses extend BaseResponse class. Meaning all the responses described below in the document will have following fields besides the ones specific to each response
Parameter | Type | Description |
---|---|---|
OperationID | string |
Unique ID generated to identify a specific operation. |
Success | bool |
Returns true if request is successful and false otherwise." |
Status | ApiStatus (Enum) |
The status of the job. done - Operation Completed. failed - Operation Failed. user_input_required - Pending User Input. initialized - Operation In Progress. For further explanation see Operation Statuses. |
UserInputs | []UserInput |
Specifies the type of further information required from the user before the job can be completed. Note: It's only returned if operation status is user_input_required |
Type | string |
Type of error encountered. Note: It's only returned if operation status is failed |
Msg | string |
Detailed description of the error. Note: It's only returned if operation status is failed |
Parameter | Type | Description |
---|---|---|
Id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
Query | string |
Textual description of what is required from the user side. |
Index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
Answer | string |
User input that must be submitted. In the response it will always be empty. |
Method is used to obtain user's permanent access token by exchanging it with access code received during the user authentication (user login).
You can read more about how to obtain a permanent token on Obtain an Access Token.
func (*Auth) ExchangeToken(accessCode string, connectionID string) (*response.ExchangeTokenResponse, error)
Parameter | Type | Description |
---|---|---|
accessCode REQUIRED |
string |
Unique code for a user’s successful login to Connect. Returned in the response of UserLogin. |
connectionID REQUIRED |
string |
The connectionID from a user’s successful log in to Connect. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
AccessToken | string |
A unique permanent token linked to the user. |
Method is used to retrieve personal details about the user.
func (*Data) GetIdentity(accessToken string, userSecret string, userInputs []response.UserInput, operationID string) (*response.IdentityResponse, error)
Parameter | Type | Description |
---|---|---|
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
Id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
Index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
Answer | string |
User input that must be submitted. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
Identity | Identity |
An object containing the identity data of the user. |
Method is used to retrieve list of all the bank accounts registered on the user. The list will contain all types of bank accounts.
func (*Data) GetAccounts(accessToken string, userSecret string, userInputs []response.UserInput, operationID string) (*response.AccountsResponse, error)
Parameter | Type | Description |
---|---|---|
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
Accounts | []Account |
An array containing the accounts data of the user. |
Method is used to retrieve balance on specific bank account of the user.
func (*Data) GetBalance(accessToken string, userSecret string, accountID string, userInputs []response.UserInput, operationID string) (*response.BalanceResponse, error)
Parameter | Type | Description |
---|---|---|
accountID REQUIRED |
string |
The bank account ID which its balance is requested. Retrieved from one of the accounts returned from the GetAccounts method. |
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be valid if the status is done
:
Parameter | Type | Description |
---|---|---|
Balance | Balance |
An object containing the account's balance information. |
Method is used to retrieve transactions that user has performed over a specific period of time from their bank account. The transaction list is unfiltered, meaning the response will contain all the transactions performed by the user (not just the transactions performed using your app).
Date range of the transactions that can be retrieved varies for each bank. The range supported by the users bank is shown in the response parameter transactionRange
of Get Accounts Metadata endpoint.
func (*Data) GetTransactions(accessToken string, userSecret string, accountID string, fromDate time.Time, toDate time.Time, userInputs []response.UserInput, operationID string) (*response.TransactionsResponse, error)
Parameter | Type | Description |
---|---|---|
accountID REQUIRED |
string |
The bank account ID which its transactions are requested. Retrieved from one of the accounts returned from the getAccounts method. |
fromDate REQUIRED |
time.Time |
The start date of the transactions wanted. |
toDate REQUIRED |
time.Time |
The end date of the transactions wanted. |
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be valid if the status is done
:
Parameter | Type | Description |
---|---|---|
Transactions | []Transaction |
Array containing the transactional data for the specified account within the specified period. |
Method is used to retrieve list of all the beneficiaries already added for a user within a financial institution.
func (*Payment) GetBeneficiaries(accessToken string, userSecret string, userInputs []response.UserInput, operationID string) (*response.BeneficiariesResponse, error)
Parameter | Type | Description |
---|---|---|
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
Beneficiaries | []Beneficiary |
An array containing the beneficiary information. |
Method is used to retrieve list of all the beneficiaries already added for a user within a financial institution.
func (*Payment) CreateBeneficiary(accessToken string, userSecret string, beneficiary request.CreateBeneficiaryInfo, userInputs []response.UserInput, operationID string) (*response.BaseResponse, error)
Parameter | Type | Description |
---|---|---|
beneficiary REQUIRED |
request.CreateBeneficiaryInfo |
An object that contains info about the beneficiary that should be added. |
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
Parameter | Type | Description |
---|---|---|
Name REQUIRED |
string |
Name of the beneficiary. |
AccountNumber REQUIRED |
string |
Account number of the beneficiary. |
Iban REQUIRED |
string |
Beneficiary's IBAN number. |
SwiftCode REQUIRED |
string |
Beneficiary's financial institution's SWIFT code. |
Type REQUIRED |
response.BeneficiaryType (Enum) |
Type of beneficiary. For further explanation see Beneficiary Types. |
Address REQUIRED |
response.BeneficiaryAddress |
An object containing the address information of the beneficiary. |
Country REQUIRED |
string |
Name of the country in all uppercase letters. |
BranchAddress REQUIRED |
string |
Address of the financial institution’s specific branch. |
BranchName REQUIRED |
string |
Name of the financial institution’s specific branch. |
PhoneNumber OPTIONAL |
string |
Beneficiary's phone number. |
RoutingNumber OPTIONAL |
string |
Beneficiary's Routing number, needed only for US banks accounts. |
Parameter | Type | Description |
---|---|---|
Line1 REQUIRED |
string |
Street name and number. Note: value should not contain any commas or special characters. |
Line2 REQUIRED |
string |
City name. Note: value should not contain any commas or special characters. |
Line3 REQUIRED |
string |
Country name. Note: value should not contain any commas or special characters. |
Method returns only the fields defined in the BaseResponse.
Method is used to initiate a new payment from one account to another account.
We suggest you use TransferAutoflow
method instead to initiate a payment. TransferAutoFlow
abstracts all the validations and processing logic, required to initiate a transaction using CreateTransfer
method.
You can read about TransferAutoFlow
further in the document.
func (*Payment) CreateTransfer(accessToken string, userSecret string, transfer CreateTransfer, userInputs []response.UserInput, operationID string) (*response.TransferResponse, error)
Parameter | Type | Description |
---|---|---|
transfer REQUIRED |
CreateTransfer |
An object that contains info about the transfer that should be initiated. |
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
Parameter | Type | Description |
---|---|---|
SenderID REQUIRED |
string |
The id of the account which the money should be sent from. Retrieved from one of the accounts array returned from the getAccounts method. |
Amount REQUIRED |
float64 |
The amount of money which should be sent. |
ReceiverID OPTIONAL |
string |
The id of the beneficiary which the money should be sent to. Retrieved from one of the beneficiaries array returned from the getBeneficiaries method. Needed only when creating a transfer from a bank that requires the receiver to be already registered as a beneficiary to perform a transaction. |
Name OPTIONAL |
string |
The name of receiver. Needed only when creating a transfer from a bank that handles the creation of beneficiaries on its own, internally, and doesn't require the receiver to be already registered as a beneficiary to perform a transaction. |
AccountNumber OPTIONAL |
string |
The Account Number of the receiver's account. Needed only when creating a transfer from a bank that handles the creation of beneficiaries on its own, internally, and doesn't require the receiver to be already registered as a beneficiary to perform a transaction. |
Iban OPTIONAL |
string |
The IBAN of the receiver's account. Needed only when creating a transfer from a bank that handles the creation of beneficiaries on its own, internally, and doesn't require the receiver to be already registered as a beneficiary to perform a transaction. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
reference | String |
Transaction reference string returned by the bank. |
Method is used to initiate a new payment from one account to another account, without having to care nor handle any special cases or scenarios.
func (*Payment) TransferAutoflow(accessToken string, userSecret string, transfer TransferAutoflow, userInputs []response.UserInput, operationID string) (*response.TransferResponse, error)
Parameter | Type | Description |
---|---|---|
transfer REQUIRED |
TransferAutoflow |
An object that contains info about the transfer that should be initiated, and any other details that's used to automate the operation. |
accessToken REQUIRED |
string |
Access Token obtained using the ExchangeToken method. |
userSecret REQUIRED |
string |
The userSecret from a user’s successful log in to Connect. |
operationID OPTIONAL |
string |
The OperationID from a previous call's response. Required only when resuming a previous call that responded with user_input_required status, to provided user inputs. |
userInputs OPTIONAL |
[]UserInput |
Array of UserInput object, that are needed to complete this operation. Required only if a previous call responded with user_input_required status. You can read more about user inputs specification on Specify User Input |
Parameter | Type | Description |
---|---|---|
id | UserInputID (Enum) |
Type of input required. You can read more about user input types on User Input Types. |
index | int |
Is used in case more than one user input is requested. Will always be 0 If only one input is requested. |
answer | string |
User input that must be submitted. |
Parameter | Type | Description |
---|---|---|
SenderID REQUIRED |
string |
The id of the account which the money should be sent from. Retrieved from one of the accounts array returned from the getAccounts method. |
Amount REQUIRED |
float64 |
The amount of money which should be sent. |
Beneficiary REQUIRED |
request.BeneficiaryInfo |
An object that holds the info about the beneficiary which the money should be sent to. |
BankID REQUIRED |
string |
The bankID of the user which is initiating this transfer. |
Parameter | Type | Description |
---|---|---|
Name REQUIRED |
string |
Name of the beneficiary. |
AccountNumber REQUIRED |
string |
Account number of the beneficiary. |
Iban REQUIRED |
string |
Beneficiary's IBAN number. |
SwiftCode REQUIRED |
string |
Beneficiary's financial institution's SWIFT code. |
Address REQUIRED |
response.BeneficiaryAddress |
An object containing the address information of the beneficiary. |
Country REQUIRED |
string |
Name of the country in all uppercase letters. |
BranchAddress REQUIRED |
string |
Address of the financial institution’s specific branch. |
BranchName REQUIRED |
string |
Name of the financial institution’s specific branch. |
PhoneNumber OPTIONAL |
string |
Beneficiary's phone number. |
RoutingNumber OPTIONAL |
string |
Beneficiary's Routing number, needed only for US banks accounts. |
In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is done
:
Parameter | Type | Description |
---|---|---|
reference | String |
Transaction reference string returned by the bank. |