Transferring between accounts

It is possible to transfer funds between merchant accounts using the payouts/transfer action.

Transfers require authentication using a user access token and the following details must be specified:

  • Transfer amount
  • Currency
  • Source account
  • Destination account
  • Reference
  • External reference

Note, you can use the accounts endpoint to get a list of a merchant's available accounts for the source and destination account fields.

The following code snippets demonstrate a basic transfer process. A successful transfer will return http status code 201 and the response body contains a JSON object confirming transfer details.

using System.Net.Http.Json;

//Remember to keep the JWT token safe and secure.
var jwtToken = Environment.GetEnvironmentVariable("NOFRIXION_USER_TOKEN");

string baseUrl = "https://api-sandbox.nofrixion.com/api/v1/payouts/transfer";

var client = new HttpClient();

client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwtToken}");

var data = new Dictionary<string, string>();
data.Add("Amount", "1.00");
data.Add("Currency", "EUR");
data.Add("SourceAccount", "A120P0JR");
data.Add("DestinationAccount", "A120R2Y3");
data.Add("Reference", "My Reference");
data.Add("ExternalReference", "Ext Reference");

HttpContent postData = new FormUrlEncodedContent(data);

try
{
    var response = await client.PostAsync(baseUrl, postData);
    if (response.IsSuccessStatusCode)
    {
        // Status "OK" on success
        Console.WriteLine(response.StatusCode);
        // and JSON object confirming transfer details
        Console.WriteLine(await response.Content.ReadFromJsonAsync<Transfer>());
    }
    else
    {
        // HTTP error codes will return a MoneyMoov API problem object
        Console.WriteLine(await response.Content.ReadFromJsonAsync<ApiProblem>());
    }
}
catch (Exception e)
{
    Console.WriteLine($"Error: {e.Message}");
}

// Type definitions for returned data
record TransferDestination(string type, string id);
record TransferDetails(string sourceAccountId, string destinationId, string destinationType,
            TransferDestination destination, string currency, decimal amount, string reference,
            string externalReference);
record Transfer(bool isEmpty, string approvalStatus, string status, string id,
            string createdDate, string externalReference, TransferDetails details);

record ApiProblem(string type, string title, int status, string detail);
// These modules allow the code to run on Node.js, they aren't required if running in a browser.
const fetch = require('cross-fetch');
const FormData = require('form-data');

// Remember, the JWT access token must be securely store - this example uses an environment variable
const jwtToken = process.env.NOFRIXION_USER_TOKEN;

const url = '<<SANDBOX_URL>>payouts/transfer/';

// Build transferData object.
let transferData = new FormData();
transferData.append('Amount', '1.00');
transferData.append('Currency', 'EUR');
transferData.append('SourceAccount', 'A120P0JR');
transferData.append('DestinationAccount', 'A120R2Y3');
transferData.append('Reference', 'My reference');
transferData.append('ExternalReference', 'Ext reference');

const options = {
    method: 'POST',
    headers: {
        Accept: 'application/json',
        Authorization: 'Bearer ' + jwtToken
    },
    body: transferData
};

fetch(url, options)
    .then(response => response.json())
    // A JSON object containing the details of the transfer is returned.
    .then(responseJson => console.log(responseJson))
    .catch(err => console.error(err));
# The 'requests' library for Python can be used to make calls to the MoneyMoov API in
# popular python frameworks such as Django and Flask.
import requests
import os

# Remember, the JWT access token must be securely stored ('os' module above allows storage in environment variable)
jwtToken = os.environ['NOFRIXION_USER_TOKEN']

baseUrl = "https://api-sandbox.nofrixion.com/api/v1/payouts/transfer"

headers = {
    "Accept": "application/json",
    "Authorization": f"Bearer {jwtToken}"
}

transferData = {
    "Amount": "0.02",
    "Currency": "EUR",
    "SourceAccount": "A120R2Y3",
    "DestinationAccount": "A120P0JR",
    "Reference": "My reference",
    "ExternalReference": "Ext reference"
}

response = requests.request("POST", baseUrl, headers=headers, data=transferData)

if response.ok:
    # Response body confirms transfer details
    print(response.json())
else:
    # If not OK, response contains MoneyMoov problem (https://docs.nofrixion.com/reference/error-messages)
    print(response.json())