Payments may be received via payment initiation services (PISP) without using the payframe. For a payer to complete a payment via PISP:
- A PISP provider must be selected.
- A payment initiation request must be submitted to the chosen PISP payment provider.
- The payment provider will return a URL to redirect the payer to their nominated financial institution to complete payment.
Remember, when working with payment requests use a MERCHANT access token.
Payment Initiation Service Payment
Open Recipe
Getting a list of PISP providers
The paymentrequests/{id}/pisp/providers GET action can be used to retrieve a list of PISP payment providers as shown below:
using System.Net.Http.Json;
const string baseUrl = "<<SANDBOX_URL>>paymentrequests";
// Payment requests use MERCHANT tokens (remember to keep these safe and secure).
var jwtToken = Environment.GetEnvironmentVariable("NOFRIXION_MERCHANT_TOKEN");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwtToken}");
string paymentRequestID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
try
{
HttpResponseMessage response = await client.GetAsync($"{baseUrl}/{paymentRequestID}/pisp/providers");
if (response.IsSuccessStatusCode)
{
// returns a list of PISP providers
var providers = await response.Content.ReadFromJsonAsync<List<PispProvider>>();
if (providers != null)
{
// Response is an array JSON objects containing PISP provider details
foreach (PispProvider provider in providers)
{
Console.WriteLine(provider);
}
}
else
{
Console.WriteLine("No providers returned.");
}
}
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 definition for response data
record PispProvider(string id, string name, string imageUrl, bool singleImmediateEnabled, bool standingOrderEnabled);
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');
// Remember, the JWT access token must be securely store - this example uses an environment variable
const jwtToken = process.env.NOFRIXION_MERCHANT_TOKEN;
const baseUrl = '<<SANDBOX_URL>>paymentrequests';
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer ' + jwtToken
}
};
var paymentRequestID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
fetch(`${baseUrl}/${paymentRequestID}/pisp/providers`, options)
.then(response => response.json())
// the response body is an array of JSON objects representing PISP providers.
.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)
# ... and when dealing with payment requests, use a MERCHANT token!
jwtToken = os.environ['NOFRIXION_MERCHANT_TOKEN']
baseUrl = "<<SANDBOX_URL>>paymentrequests"
paymentRequestID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {jwtToken}"
}
try:
response = requests.request("GET", f"{baseUrl}/{paymentRequestID}/pisp/providers", headers=headers)
if response.ok:
# If successful, the API returns the list of pisp payment providers
print(response.json())
else:
# If not OK, response contains MoneyMoov problem (https://docs.nofrixion.com/reference/error-messages)
print(response.json())
except Exception as ex:
print(ex)
Initiating payment
The following examples show how to submit a payment request to a PISP provider for fulfilment. If payment initiation is successful the response will contain a redirection URL that can be used to redirect the payer to their financial institution where they can complete the PISP payment.
using System.Net.Http.Json;
using System.Text;
const string baseUrl = "<<SANDBOX_URL>>paymentrequests";
// Payment requests use MERCHANT tokens (remember to keep these safe and secure).
var jwtToken = Environment.GetEnvironmentVariable("NOFRIXION_MERCHANT_TOKEN");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwtToken}");
// Specify the payment request ID and PISP provider
string paymentRequestID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
string providerID = "XXXXXXXXXXX";
var postData = new StringContent($"providerID={providerID}", Encoding.UTF8, "application/x-www-form-urlencoded");
try
{
HttpResponseMessage response = await client.PostAsync($"{baseUrl}/{paymentRequestID}/pisp", postData);
if (response.IsSuccessStatusCode)
{
Console.WriteLine(await response.Content.ReadFromJsonAsync<PispResponse>());
}
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 definition for response data
record PispResponse(string paymentInitiationId, string redirectUrl, string plaidLinkToken);
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_MERCHANT_TOKEN;
const baseUrl = '<<SANDBOX_URL>>paymentrequests';
var paymentRequestID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
// Example form data
var form = new FormData();
form.append('providerID', 'XXXXXXXXXXX');
var options = {
method: 'POST',
headers: {
Accept: 'application/json',
Authorization: 'Bearer ' + jwtToken
},
body: form
};
fetch(`${baseUrl}/${paymentRequestID}/pisp`, options)
.then(response => response.json())
// Payment initiation ID and redirect URL will be returned in JSON response object.
.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)
# ... and when dealing with payment requests, use a MERCHANT token!
jwtToken = os.environ['NOFRIXION_MERCHANT_TOKEN']
baseUrl = "<<SANDBOX_URL>>paymentrequests"
paymentRequestID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# PISP provider id, use the paymentrequests/{id}/pisp/providers GET action to see a list
providerID = "XXXXXXXXXXX"
headers = {
"Accept": "application/json",
"Authorization": f"Bearer {jwtToken}"
}
paymentData = {
"providerID": providerID
}
try:
response = requests.request("POST", f"{baseUrl}/{paymentRequestID}/pisp", headers=headers, data=paymentData)
if response.ok:
# On successful update, the API returns the payment initiation response containing
# payment initiation ID and the URL to redirect the payer to their financial institution.
print(response.json())
else:
# If not OK, response contains MoneyMoov problem (https://docs.nofrixion.com/reference/error-messages)
print(response.json())
except Exception as ex:
print(ex)