Managing payouts

After creating a payout, you have the option to update, delete, or submit the payout. This section offers examples for:

  1. Retrieving a single payout by ID.
  2. Retrieving all payouts awaiting authorisation.
  3. Modifying a payout that is pending authorisation.
  4. Deleting a payout that is pending authorisation.

For guidance on submitting a payout for payment, refer to the examples in authorising a payout.

Retrieve a single payout by ID

A payout can be selected for authorisation through the payouts/{id} GET endpoint, as demonstrated below. It's important to note that the response data contains a URL for authorising the payout, identified by the property named "ApprovePayoutUrl":

using System.Net.Http.Json;

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

var jwtToken = "<ACCESS_TOKEN>";

// specify id of payout to return
string payoutID = "<PAYOUT_ID_TO_GET>";

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

try
{
    var response = await client.GetAsync($"{baseUrl}/{payoutID}");
    if (response.IsSuccessStatusCode)
    {
        // returns requested payout
        var payout = await response.Content.ReadFromJsonAsync<Payout>();
        if (payout != null)
        {
            // displays payout data
            Console.WriteLine(payout);
        }
    }
    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 AccountIdentifier(string type, string currency, string iban, string bic, string sortCode, string accountNumber, string bitcoinAddress);

record Counterparty(string name, AccountIdentifier Identifier);
record Payout(string id, string accountID, string merchantID, string currentUserID, string currentUserRole, 
    string approvePayoutUrl, string userID, string type, string description, string currency,
    decimal amount, string yourReference, Counterparty destination, string theirReference);

record ApiProblem(string type, string title, int status, string detail);
const axios = require('axios');

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

// Access token
const jwtToken = "<ACCESS_TOKEN>";

// Specify id of payout to return
const payoutID = "<PAYOUT_ID_TO_GET>";

// Set up headers for the HTTP request
const headers = {
    "Accept": "application/json",
    "Authorization": `Bearer ${jwtToken}`
};

// Function to perform the GET request
async function getPayout() {
    try {
        const response = await axios.get(`${baseUrl}/${payoutID}`, { headers });

        if (response.status === 200) {
            // Returns requested payout
            const payout = response.data;
            // Displays payout data
            console.log(payout);
        } else {
            // HTTP error codes will return a MoneyMoov API problem object
            console.error('Error:', response.status, response.data);
        }
    } catch (error) {
        console.error('Error:', error.response ? error.response.data : error.message);
    }
}

// Call the function to perform the GET request
getPayout();

// Type definitions for returned data (used for reference, not needed in actual Node.js code)
// AccountIdentifier: { type, currency, iban, bic, sortCode, accountNumber, bitcoinAddress }
// Counterparty: { name, Identifier }
// Payout: { id, accountID, merchantID, currentUserID, currentUserRole, approvePayoutUrl, userID, type, description, currency, amount, yourReference, destination, theirReference }
// ApiProblem: { type, title, status, detail }

import requests

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

# Access token
jwt_token = "<ACCESS_TOKEN>"

# Specify id of payout to return
payout_id = "<PAYOUT_ID_TO_GET>"

# Set up headers for the HTTP request
headers = {
    "Accept": "application/json",
    "Authorization": f"Bearer {jwt_token}"
}

# Function to perform the GET request
def get_payout():
    try:
        response = requests.get(f"{base_url}/{payout_id}", headers=headers)

        if response.status_code == 200:
            # Returns requested payout
            payout = response.json()
            # Displays payout data
            print(payout)
        else:
            # HTTP error codes will return a MoneyMoov API problem object
            print("Error:", response.status_code)
            print(response.json())
    except Exception as e:
        print(f"Error: {str(e)}")

# Call the function to perform the GET request
get_payout()

# Type definitions for returned data (used for reference, not needed in actual Python code)
# AccountIdentifier: {type, currency, iban, bic, sortCode, accountNumber, bitcoinAddress}
# Counterparty: {name, Identifier}
# Payout: {id, accountID, merchantID, currentUserID, currentUserRole, approvePayoutUrl, userID, type, description, currency, amount, yourReference, destination, theirReference}
# ApiProblem: {type, title, status, detail}

Updating a payout

If a payout needs to be updated prior to submission, this can be done by calling the "PUT" method against the /payouts/{id} endpoint as shown below:

using System.Net.Http.Json; // Make sure this namespace is included

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

var jwtToken = "<ACCESS_TOKEN>";

// specify id of payout to update
string payoutIDToUpdate = "<PAYOUT_ID_TO_UPDATE>";

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

// The data now should be an object that matches the JSON structure expected by the API
var data = new
{
    AccountID = "<YOUR_SOURCE_ACCOUNT_ID>",
    // Account identifier type. Can be IBAN for EUR, SCAN for GBP and BTC for Bitcoin
    Type = "IBAN", 
    // Currency can be EUR, GBP or BTC
    Currency = "EUR",
    Amount = "20.00",
    YourReference = "My updated Ref",
    Destination = new
    {
        Name = "Updated Dest Name",
        Identifier = new
        {
            // For EUR payment you can use IBAN
            IBAN = "GB94BARC10201530093459",
            //BIC = "BARCGB22",
            
            // For GBP payment you can use SortCode and AccountNumber
            // SortCode = "102015",
            // AccountNumber = "30093459",
            
            // For Bitcoin payment you can use BitcoinAddress
            // BitcoinAddress = "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2"
        }
    },
    TheirReference = "Their updated Ref",
    // Parameters to schedule this payout to process on a later date
    // Scheduled = true,
    // ScheduleDate = DateTimeOffset.Now + TimeSpan.FromHours(1)
};

try
{
    // Using the PostAsJsonAsync extension method to send JSON data
    var response = await client.PutAsJsonAsync($"{baseUrl}/{payoutIDToUpdate}", data);
    if (response.IsSuccessStatusCode)
    {
        // "OK" on success
        Console.WriteLine(response.StatusCode);

        // The newly created payout object will be returned in the response body
        Console.WriteLine(await response.Content.ReadFromJsonAsync<Payout>());
    }
    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 AccountIdentifier(string type, string currency, string iban, string bic, string sortCode, string accountNumber, string bitcoinAddress);

record Counterparty(string name, AccountIdentifier Identifier);
record Payout(string id, string accountID, string merchantID, string currentUserID, string currentUserRole, 
    string approvePayoutUrl, string userID, string type, string description, string currency,
    decimal amount, string yourReference, Counterparty destination, string theirReference);

record ApiProblem(string type, string title, int status, string detail);
const axios = require('axios');

// Base URL for the API
const baseUrl = "https://api-sandbox.nofrixion.com/api/v1/payouts";

// Your access token
const jwtToken = "<ACCESS_TOKEN>";

// Specify the ID of the payout to update
const payoutIDToUpdate = "<PAYOUT_ID_TO_UPDATE>";

// Setting up the axios client with default headers
const client = axios.create({
    headers: {
        'Accept': 'application/json',
        'Authorization': `Bearer ${jwtToken}`
    }
});

// The data should be an object that matches the JSON structure expected by the API
const data = {
    AccountID: "<YOUR_SOURCE_ACCOUNT_ID>",
    Type: "IBAN", // Account identifier type. Can be IBAN for EUR, SCAN for GBP and BTC for Bitcoin
    Currency: "EUR", // Currency can be EUR, GBP or BTC
    Amount: "20.00",
    YourReference: "My updated Ref",
    Destination: {
        Name: "Updated Dest Name",
        Identifier: {
            // For EUR payment you can use IBAN
            IBAN: "GB94BARC10201530093459",
            // For GBP payment you can use SortCode and AccountNumber
            // SortCode: "102015",
            // AccountNumber: "30093459",
            // For Bitcoin payment you can use BitcoinAddress
            // BitcoinAddress: "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2"
        }
    },
    TheirReference: "Their updated Ref",
    // Parameters to schedule this payout to process on a later date
    // Scheduled: true,
    // ScheduleDate: new Date(Date.now() + 3600000) // 1 hour from now
};

// Making the PUT request using axios
async function updatePayout() {
    try {
        const response = await client.put(`${baseUrl}/${payoutIDToUpdate}`, data);
        if (response.status === 200) {
            // "OK" on success
            console.log("Status:", response.status);

            // The newly created payout object will be returned in the response body
            console.log("Payout Data:", response.data);
        } else {
            // HTTP error codes will return a MoneyMoov API problem object
            console.log("Error Status:", response.status);
            console.log("Error Data:", response.data);
        }
    } catch (error) {
        console.error(`Error: ${error.message}`);
    }
}

updatePayout();

import requests
import json
from datetime import datetime, timedelta

# Base URL for the API
base_url = "https://api-sandbox.nofrixion.com/api/v1/payouts"

# Your access token
jwt_token = "<ACCESS_TOKEN>"

# Specify the ID of the payout to update
payout_id_to_update = "<PAYOUT_ID_TO_UPDATE>"

# Setting up the headers for the request
headers = {
    'Accept': 'application/json',
    'Authorization': f'Bearer {jwt_token}'
}

# The data should be a dictionary that matches the JSON structure expected by the API
data = {
    'AccountID': "<YOUR_SOURCE_ACCOUNT_ID>",
    'Type': "IBAN", # Account identifier type. Can be IBAN for EUR, SCAN for GBP, and BTC for Bitcoin
    'Currency': "EUR", # Currency can be EUR, GBP, or BTC
    'Amount': "20.00",
    'YourReference': "My updated Ref",
    'Destination': {
        'Name': "Updated Dest Name",
        'Identifier': {
            # For EUR payment, you can use IBAN
            'IBAN': "GB94BARC10201530093459",
            # For GBP payment, you can use SortCode and AccountNumber
            # 'SortCode': "102015",
            # 'AccountNumber': "30093459",
            # For Bitcoin payment, you can use BitcoinAddress
            # 'BitcoinAddress': "1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2"
        }
    },
    'TheirReference': "Their updated Ref",
    # Parameters to schedule this payout to process on a later date
    # 'Scheduled': True,
    # 'ScheduleDate': (datetime.now() + timedelta(hours=1)).isoformat()
}

# Making the PUT request using requests
def update_payout():
    try:
        response = requests.put(f'{base_url}/{payout_id_to_update}', headers=headers, json=data)
        if response.status_code == 200:
            # "OK" on success
            print("Status:", response.status_code)

            # The newly created payout object will be returned in the response body
            print("Payout Data:", response.json())
        else:
            # HTTP error codes will return a MoneyMoov API problem object
            print("Error Status:", response.status_code)
            print("Error Data:", response.json())
    except Exception as e:
        print(f"Error: {e}")

update_payout()

Deleting a payout

Payouts can be deleted using the "DELETE" method against the "/payouts/{id}" endpoint and specifying the relevant payout id. For example:

using System.Net.Http.Json;

var jwtToken = "<ACCESS_TOKEN>";

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

var client = new HttpClient();

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


// Specify ID of the payout you want to delete
string payoutID = "<PAYOUT_ID_TO_DELETE>";

HttpResponseMessage response = await client.DeleteAsync($"{baseUrl}/{payoutID}");
if (response.IsSuccessStatusCode)
{
    // HTTP status code OK on success
    Console.WriteLine(response.StatusCode);
}
else
{
    // HTTP error codes will return a MoneyMoov API problem object
    Console.WriteLine(await response.Content.ReadFromJsonAsync<ApiProblem>());
}

record ApiProblem(string type, string title, int status, string detail);
const axios = require('axios');

// Your access token
const jwtToken = "<ACCESS_TOKEN>";

// Base URL for the API
const baseUrl = "https://api-sandbox.nofrixion.com/api/v1/payouts";

// Setting up the axios client with default headers
const client = axios.create({
    headers: {
        'Accept': 'application/json',
        'Authorization': `Bearer ${jwtToken}`
    }
});

// Specify the ID of the payout you want to delete
const payoutID = "<PAYOUT_ID_TO_DELETE>";

// Making the DELETE request using axios
async function deletePayout() {
    try {
        const response = await client.delete(`${baseUrl}/${payoutID}`);
        if (response.status === 200) {
            // HTTP status code OK on success
            console.log("Status:", response.status);
        } else {
            // HTTP error codes will return a MoneyMoov API problem object
            console.log("Error Status:", response.status);
            console.log("Error Data:", response.data);
        }
    } catch (error) {
        console.error(`Error: ${error.message}`);
    }
}

deletePayout();

import requests

# Your access token
jwt_token = "<ACCESS_TOKEN>"

# Base URL for the API
base_url = "https://api-sandbox.nofrixion.com/api/v1/payouts"

# Headers with Accept and Authorization
headers = {
    'Accept': 'application/json',
    'Authorization': f'Bearer {jwt_token}'
}

# Specify the ID of the payout you want to delete
payout_id = "<PAYOUT_ID_TO_DELETE>"

# Making the DELETE request
response = requests.delete(f"{base_url}/{payout_id}", headers=headers)

if response.status_code == 200:
    # HTTP status code OK on success
    print(f"Status: {response.status_code}")
else:
    # HTTP error codes will return a MoneyMoov API problem object
    print(f"Error Status: {response.status_code}")
    print("Error Data:", response.json())

# Note: Python doesn't have a direct equivalent of C#'s record type for ApiProblem.
# The response.json() will provide the error details in a dictionary format.