Create 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. Authenticating
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.
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();
More information on authentication can be found here.
2. Creating a Booking
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.
const token = 'YOUR TOKEN HERE (FROM STEP 1)'; 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: `Bearer ${token}`, }, }, ); const bookingID = response.data.data.id;
More information on creating a booking can be found here.
3. Creating a Payment Link
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.
const token = 'YOUR TOKEN HERE (FROM STEP 1)' const bookingID = 'FELLOH BOOKING ID HERE (FROM STEP 2)'; const response = await axios( { method: 'put', url: `https://api.felloh.com/agent/payment-links`, data : JSON.stringify({ organisation: 'X9876', customer_name: 'James Dean', email: 'james@felloh.org', booking_id: bookingID, amount: 20000, open_banking_enabled: true, card_enabled: true, description: 'Final payment for cruise holiday' }), headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, }, }, ); const paymentLinkID = response.data.data.id; const paymentURL = `https://pay.felloh.com/${paymentLinkID}
More information on creating a payment link can be found here.