Checkout Redirect

The Checkout API enables you to securely accept payments from your customers. By calling the Create Payment API on your server, you generate a unique checkout link. Users are then directed to this link to make their payment. Once the payment is completed, users are redirected back to your website.

Get Started

1. Collect Payment Details

To initiate the transaction, you’ll need to provide essential details including the customer’s email, first name, last name, transaction amount, reference, and any other pertinent information required for processing.

Request parameters for the payment endpoint.

FieldData typeRequiredDescription
amountintegerRequiredThe amount to charge the customer.
currencystringRequiredThe currency in which the customer should be charged. Options supported currently is only [UGX]
namestringRequiredThe name of the customer
emailstringRequiredThe email of the customer
phonestringRequiredThe mobile number of the customer
metastringRequiredJSON object containing any information you’d want to send to FanitePay in this object.
redirectUrlstringOptionalThe URL to redirect your customer when the transaction is complete.

2. Initiate Payment

Once you’ve gathered all the required payment information, you’ll need to send a POST request to our create checkout endpoint. This request will include the details you’ve collected, allowing us to initiate the checkout process.

Endpoint:

POST
{host}/checkout/init

Sample checkout Init:

Node.js
var axios = require("axios").default;
var options = {
method: 'POST',
url: '{host}/checkout/init',
headers: {
Accept: '*/*',
Authorization: 'Bearer FNTPPUBK_LIVE-***************',
'Content-Type': 'application/json'
},
data: {
amount: 5000,
currency: 'UGX',
name: 'Customer Name',
email: 'customer@email.com',
phone: '+2567xxxxxxxx',
address: 'N/A',
description: 'checkout test',
logo: 'https://images.pexels.com/photos/7960508/pexels-photo-7960508.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
meta: {item: 'item name', quantity: '5'},
redirectUrl: 'https://yoursite.com/myredirect',
items: '{"items":[{"id":"1703005868775","name":"Minute maid","slug":"Minute maid","unit":"500 ml","image_original":"https://sefbuy.com/wp-content/uploads/2022/05/1-814.jpg","stock":"10","price":5000,"quantity":1,"itemTotal":5000}],"isEmpty":false,"totalItems":1,"totalUniqueItems":1,"total":5000,"meta":null}'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});

PHP cURL Sample Code:

PHP cURL
curl -X POST \
'{host}/checkout/init' \
--header 'Accept: */*' \
--header 'Authorization: Bearer FNTPPUBK_LIVE-***************' \
--header 'Content-Type: application/json' \
--data-raw '{
"amount": 5000,
"currency": "UGX",
"name": "Customer Name",
"email": "customer@email.com",
"phone": "+2567xxxxxxxx",
"address": "N/A",
"description": "checkout test",
"logo": "https://images.pexels.com/photos/7960508/pexels-photo-7960508.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1",
"meta": {
"item": "item name",
"quantity": "5"
},
"redirectUrl": "https://yoursite.com/myredirect",
"items": "{\"items\":[{\"id\":\"1703005868775\",\"name\":\"Minute maid\",\"slug\":\"Minute maid\",\"unit\":\"500 ml\",\"image_original\":\"https://sefbuy.com/wp-content/uploads/2022/05/1-814.jpg\",\"stock\":\"10\",\"price\":5000,\"quantity\":1,\"itemTotal\":5000}],\"isEmpty\":false,\"totalItems\":1,\"totalUniqueItems\":1,\"total\":5000,\"meta\":null}"
}
'

Response on successful post request:

Response
{
"status": true,
"message": "Hosted link generated",
"data": {
"link": "https://checkout.fanitepay.com/?payref=fnt-p-**************",
"payRef": "fnt-p-**************"
}
}

Following receipt of the response mentioned, the next step is to redirect your customer to the checkout URL provided in the response. This allows them to proceed with completing their payment. After the payment process is finalized or in the case of any failure, FanitePay will then redirect your customer to the redirectUrl specified by you.

Additionally, the transaction reference will be included as a query parameter in the redirectUrl for further processing.

Example: https://my-redirectUrl/?reference=YOUR_REFERENCE

If no redirectUrl is provided, the customer will receive visual confirmation indicating the successful completion of the payment. They will remain on the current webpage and won’t be redirected elsewhere. This ensures a seamless user experience without any forced redirection after payment confirmation.

3.Verify payment

Endpoint:

GET
{host}/verify/payments/?payref={reference}

Response:

POST
{
"status": "Success",
"amount": "5000",
"currency": "UGX"
}