Checkout
If you need a modern, standard, intuitive checkout for your platform, Fenan offers a hosted checkout solution. The general flow is that the customer will be redirected to the Fenan checkout page, and after the payment is completed, the customer will be redirected back to your platform. You do this by creating a payment intent first, for which you will get a checkout URL for that specific transaction, and you need to redirect the user to that page. After the payment is done, the customer is redirected back, and a webhook is sent to your server.
Authentication
Setting API Key in Headers. Learn more about API Key here.
How to Create Payment Intent
To create a payment intent, all you need to do is send a POST HTTP call to the appropriate endpoint based on your environment. Include the apiKey
in the request headers and provide the required parameters in the body as described in the Parameters section.
https://api.fenanpay.com/api/v1/payment/sandbox/intent
Parameters
The following tables describe the fields required for creating a payment intent.
Payment Intent Request
Field | Type | Description | Required |
---|---|---|---|
amount | number | The total amount for the payment. | true |
items | array of objects | List of items included in the payment. | false |
currency | string | The currency for the payment. | true |
paymentIntentUniqueId | string | Unique identifier for the payment intent. | true |
paymentLinkUniqueId | string | Unique identifier for the payment link. | false |
methods | array of strings | List of payment methods to be accepted. If empty array is passed, all enabled methods will be selected. | true |
splitPayment | array of objects | Details for splitting the payment among multiple beneficiaries. | false |
returnUrl | string | URL to redirect the user after payment completion. | true |
expireIn | integer | Time in minutes before the payment intent expires. | true |
callbackUrl | string | URL to notify the merchant system of the payment status. | false |
commissionPaidByCustomer | boolean | Indicates if the commission is paid by the customer. | true |
customerInfo | object | Information about the customer. | false |
Payment Item
Field | Type | Description | Required |
---|---|---|---|
name | string | Name of the item. | true |
description | string | Description of the item. | false |
image | string | URL of the item’s image. | false |
quantity | integer | Quantity of the item. | true |
type | string | Type of the item (SERVICE, DIGITAL_PRODUCT, PHYSICAL_PRODUCT). | true |
price | number | Price of the item. | true |
Split Payment Details
Field | Type | Description | Required |
---|---|---|---|
amount | number | Amount to be split. | true |
bank | string | Bank for the split payment. | true |
splitType | string | Type of split (PERCENTAGE, NUMBER). | true |
creditAccount | string | Credit account for the split payment. | true |
Customer Info Request
Field | Type | Description | Required |
---|---|---|---|
string | Email of the customer. | false | |
phone | string | Phone number of the customer. | false |
name | string | Name of the customer. | false |
Interface Explanation
The PaymentIntentRequest
interface is used to create a payment intent with Fenan Pay. Below is an explanation of each field:
- amount: The total amount for the payment. This is a required field.
- items: An array of objects representing the items included in the payment. This field is optional and can be null or empty if the amount is set. If both
items
andamount
are specified, the sum ofitems.price
must equal theamount
.- PaymentItem:
- name: The name of the item. (required)
- description: A description of the item. (optional)
- image: URL of the item’s image. (optional)
- quantity: The quantity of the item. Must be an integer with a minimum value of 1. (required)
- type: The type of the item. Can be one of
SERVICE
,DIGITAL_PRODUCT
, orPHYSICAL_PRODUCT
. (required) - price: The price of the item. (required)
- PaymentItem:
- currency: The currency for the payment. Supported values are
ETB
andUSD
. This is a required field. - paymentIntentUniqueId: A unique identifier for the payment intent. This idempotent key is used to identify a unique payment intent shared between Fenan Pay and the merchant system. It must be unique for every payment intent. (required)
- methods: An array of strings representing the payment methods to be accepted. If this field is empty, all enabled payment methods will be selected. Supported values include
TELE_BIRR
,CBE
,ETS_SWITCH
, andM_PESA
. (required). If empty array is passed, all enabled methods will be selected. - splitPayment: An array of objects detailing the split payment among multiple beneficiaries. This field is optional and can be null.
- SplitPaymentDetails:
- amount: The amount to be split. Can be a percentage or a number. (required)
- bank: The bank for the split payment. Ensure the bank supports withdrawal to avoid errors. (required)
- splitType: The type of split. Can be
PERCENTAGE
orNUMBER
. (required) - creditAccount: The credit account for the split payment. (required)
- SplitPaymentDetails:
- returnUrl: The URL to redirect the user after payment completion. This should be a valid URL. (required)
- expireIn: The time in minutes before the payment intent expires. Once expired, the user can no longer make a purchase, and an Expire event will be sent as a webhook. (required)
- callbackUrl: The URL to notify the merchant system of the payment status. If null, it defaults to the webhook settings on the dashboard. This URL will notify the merchant system of events such as failure, timeout/expired, and success. (optional)
- commissionPaidByCustomer: Indicates if the commission is paid by the customer. (required)
- customerInfo: An object containing information about the customer. This field is optional but can be used to take advantage of Fenan Pay’s analytics service.
- CustomerInfoRequestDto:
- email: The email of the customer. (optional)
- phone: The phone number of the customer. (optional)
- name: The name of the customer. (optional)
- CustomerInfoRequestDto:
Example Request
Response of the Request
When you make a request to the Fenan Pay API, you will receive a response indicating the status of your request. Below are examples of both a successful response and an error response.
Successful Response
Successful response will have a status code of 200.
Error Response
Error response will have a status code of 4xx.
Field | Description |
---|---|
status | Status of the response |
message | Message indicating success or error |
content | Checkout URL if the request is successful |
Making payment
After the payment is done, the customer will be redirected back to your platform. You will receive a webhook notification of the payment status. Learn more about webhooks here.