Dinar Dragon

Dinar Dragon API Documentation



How to make a payout to a bank account with code:

To make a payout to a bank account with Dinar Dragon, there are two steps to complete. STEP 1 is to initialize your payout. In return, you will get an authentication code. STEP 2 is to use the authentication code to finalize the payment. Once you have done this, the funds will land in the specified bank account(s) within 15 minutes and the payout will be complete. Here is a detailed explanation of exactly what to do:

-------------------------------------------------------------------------------------------------------------------------------------------------



API URL for Step 1 HTTP Method

https://dinardragon.com/get-authcode

POST



STEP 1: Create a data object containing information about the payment you want to make. Then pass this data object as the body in your request to the /get-authcode POST endpoint. Your data object should contain the following fields:


EXPECTED FIELDS TO GET AUTHENTICATION CODE:

amount (float) accounts (array of objects)

The total amount in USD to pay out for the entire payment. So e.g. if you were making 5 payouts of $10 each, you would enter $50 for the amount parameter.

An array of objects to describe all the payments you want to make to different bank accounts. Each object in the array represents one payment directly to a bank account.


Each payment object in the accounts array should contain the following fields -


EXPECTED FIELDS FOR EACH PAYMENT OBJECT IN ACCOUNTS (ARRAY OF OBJECTS):

acc (integer) amount (float) bank (string) country (string) recipient (string)
The account number to make the payment to The amount in USD to pay to that one bank account The name of the bank to make the payment to for that one payment The country of the bank account you want to pay The name of the person who is being paid


-------------------------------------------------------------------------------------------------------------------------------------------------


Here is an example of how to structure your HTTP body for this request:


Example - JSON Request Body For /get-authcode endpoint

                
                    {
                        "amount": 195, //amounts in "accounts" array must add up to the amount you pass here
                        "accounts": [
                          {
                            "acc": 123456789,
                            "amount": 50,
                            "bank": "somebank",
                            "country": "US",
                            "recipientname": "somename"
                          },
                          {
                            "acc": 987654321,
                            "amount": 70,
                            "bank": "someotherbank",
                            "country": "SA",
                            "recipientname": "someothername"
                          },
                          {
                            "acc": 111111111,
                            "amount": 75,
                            "bank": "yetanotherbank",
                            "country": "US",
                            "recipientname": "yetanothername"
                          }

                          //......and so on
                        ]
                      }
                
              

You will also need to provide an Authorization value in the header of your HTTP request. You provide your private key here.


Once you pass all the expected data to the /get-authcode POST endpoint, you will get back an authentication code to use to finalize the payment for good in Step 2. The finalization in Step 2 is irreversible. Here is the JSON response to expect from the /get-authcode POST endpoint:


SUCCESS:

code (integer) charge_in_usd (float) authcode (string)
HTTP Response Code, e.g. 200, 201 Amount Dinar Dragon will charge your dashboard balance to make this payout Authentication Code

FAIL:

code (integer) error (string)
HTTP Response Code, e.g. 403, 400 Error message that tells you why the request failed

Here are some examples of the format of the HTTP responses to expect:

JSON Response - Success

                
                    {
                        "code": 200, //OK
                        "charge_in_usd": 4.875, //amount in USD Dinar Dragon will charge your dashboard balance to make this payout
                        "authcode": "6afc61f8c5e7738819b7021dc0664cab", //unique authentication code
                    }
                
            

If your HTTP request fails, you will get a response in this format:

JSON Response - Fail

                
                    {
                        "code": 403, //Fail
                        "error": "Your request failed because your Dinar Dragon dashboard balance is insufficient to complete this payout.",
                    }
                
            

Here are some code examples you can copy and paste to get an authentication code:

Step 1 - Pass Payment Data To Get Unique Authentication Code


            // Example JavaScript to call /get-authcode API endpoint
            async function getAuthCode() {
                const data = {
                    amount: 100,
                    accounts: [
                       {acc: 123456789, amount: 50, bank: 'somebank', country: 'US'}, 
                       {acc: 987654321, amount: 70, bank: 'someotherbank', country: 'SA'}, 
                       {acc: 111111111, amount: 75, bank: 'yetanotherbank', country: 'US'}
                    ],
                };

                try {
                    const response = await fetch('https://dinardragon.com/get-authcode', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                            'Authorization': 'Bearer ${yourPrivateKey}'
                        },
                        body: JSON.stringify(data)
                    });
                    
                    const result = await response.json();

                    if (result.code === 200) {
                        return result.authcode;  // Return the authcode
                    } else {
                        console.error('Error:', result.error);
                    }
                } catch (error) {
                    console.error('Error:', error);
                }
            }

                const authcode = await getAuthCode(); //access the authcode in a variable

                console.log('Auth code received:', authcode);  // Display the authcode
    
            


Step 2 -- Execute Payout
Step 3 -- Check Payment Status
General Functionality Expected Input Response
/get-authcode - POST endpoint to retrieve an authentication code for making a payout request. You will pass payment data to obtain this code and if the payout you're trying to make is permitted, you will receive an authentication code. This initiates your payout. You will then use this authentication code to either execute the initiated payout in Step 2, or cancel it by not executing within 15 minutes. Once the payout is executed, it cannot be reversed. The code lasts for upto 15 minutes before expiring. - **accounts**: (array of objects). Lists accounts to be paid and details.

- **amount**: Total amount to be paid out (number in USD)

- **privatekey**: Your private key in 'Authorization' field of headers (string)
- **code**: HTTP response code (number)

- **authcode**: The unique authentication code (string)

- **charge_in_usd**: Charge for this payout (float)

- **error**: If there's an issue, an error message (string)


Step 2 -- Execute Payout
Step 3 -- Check Payment Status

©2024 dinardragon.com. All rights reserved.