Choose a language javascript

Creating a payment link

In order to create a payment link for your customer, there are a couple of steps you will need to undertake. This guide assumes that you have a booking for your customer, however you can create a payment link without one. The steps are as follows.

1. Authenticate - Authenticate your user and get a bearer token to be able to undertake actions against the API

2. Create a booking - Create a booking for your customer

3. Create a payment link - Create a payment link for your customer

1. Authenticating

Authenticating against the API

import axios from 'axios';
const getToken = async () => {
const response = await axios({
method: 'post',
url: 'https://api.felloh.com/token',
headers: {
'Content-Type': 'application/json'
},
data: JSON.stringify({
"public_key": process.env.PUBLIC_KEY,
"private_key": process.env.PRIVATE_KEY,
},
),
});
return response.data.data;
};
const { token } = await getToken();

The following code will authenticate you against the api and get the bearer token, you can then use this for all future calls against the API.

You will need to get your public and private keys from the dashboard and them set these either in the environment or via another method.

More information on authentication can be found here.

2. Creating a booking

Creating a booking

const response = await axios(
{
method: 'put',
url: `https://api.felloh.com/agent/bookings`,
data : JSON.stringify({
organisation: 'X9876',
customer_name: 'James Dean',
email: 'james@felloh.org',
booking_reference: 'XXX123789',
departure_date: '2022-07-18',
return_date: '2022-07-25',
gross_amount: 1000000,
}),
headers: {
'Content-Type': 'application/json',
Authorization: token
},
},
);
const bookingID = response.data.data.id;

As mentioned, this step can be skipped if you do not currently have a booking and would just like to create a payment link, however you will need to use the assign endpoint at a later stage to get payouts on the booking.

More information on creating a booking can be found here.

Creating a payment link

const response = await axios(
{
method: 'put',
url: `https://api.felloh.com/agent/payment-links`,
data : JSON.stringify({
customer_name: 'James Dean',
email: 'james@felloh.org',
booking_id: bookingID,
amount: 20000,
organisation: 'X9876',
open_banking_enabled: true,
card_enabled: true,
description: 'Final payment for cruise holiday'
}),
headers: {
'Content-Type': 'application/json',
Authorization: token
},
},
);
const paymentLinkID = response.data.data.id;
const paymentURL = `https://pay.felloh.com/${paymentLinkID}`

You can now create the payment link, with this ID you can then send this link to the customer or alternatively display in your system.

More information on creating a payment link can be found here.