ExpressPay: Direct Payment Processing
ExpressPay offers a streamlined approach to payment processing. This integration method is designed for scenarios where:- You have already implemented a checkout process in your application.
- A specific payment method has been pre-selected or is preferred.
- You aim to minimize the number of steps in the payment flow.
Authentication
Setting API Key in Headers. Learn more about API Key here.How to Create Express payment
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 theapiKey in the request headers and provide the required parameters in the body as described in the Parameters section.
- Test
- Prod
https://api.fenanpay.com/api/v1/payment/express/sandbox/payParameters
The following tables describe the fields required for creating an express payment.Express Payment Request
* returnUrl is required for all payment methods except M-PESA
* testMode is only required in sandbox environment * Either amount or items must be provided
Payment Item
Split Payment Details
Customer Info Request
Test Mode (Sandbox Only)
Interface Explanation
TheExpressPaymentRequestDto interface is used to create an express payment with Fenan Pay. Below is an explanation of each field:
- amount: The total amount for the payment. This is a required field with a positive number and up to two decimal places.
- items: An array of objects representing the items included in the payment. This field is optional, but either
itemsoramountmust be provided.- 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
ETBandUSD. 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)
- paymentLinkUniqueId: A unique identifier for the payment link. (optional)
- phoneNumber: Phone number for the payment. Required for M-PESA payments if not provided in customerInfo. (optional)
- debitAccount: Debit account for the payment. (optional)
- description: Description of the payment. (optional)
- method: A string representing the payment method code. Supported values include
TELE_BIRR_USSD,CBE,ETS_SWITCH, andM_PESA. (required) - splitPayment: An array of objects detailing the split payment among multiple beneficiaries. This field is optional.
- 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
PERCENTAGEorNUMBER. (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 for all payment methods except M-PESA.
- expireIn: The time in seconds before the payment intent expires. Must be at least 5 seconds. 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. Required for M-PESA if not provided in the phoneNumber field. (optional)
- name: The name of the customer. (optional)
- CustomerInfoRequestDto:
- testMode: An object containing test mode configuration. Required only in sandbox environment.
- TestModeDto:
- testModeType: The type of test mode. Can be
ACTUAL_TESTorSIMULATED_TEST. (required) - simulationStatus: The simulation status. Required when testModeType is
SIMULATED_TEST. (conditional)
- testModeType: The type of test mode. Can be
- TestModeDto:
Example Request
M-PESA Payment Example
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.Payment Response
ThePayment Response object contains the details of the response from the payment service provider. Below is a table describing the fields in the PspPaymentResponseDto object.
PaymentStatus is an enumeration that represents the possible statuses of a payment. The possible values are:
SUCCESSFAILURE
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.Important Validation Rules
- Amount or Items Required: You must provide either an amount or a non-empty list of items.
- Return URL Requirement: A valid returnUrl is required for all payment methods except M_PESA, TELE_BIRR_USSD, E_BIRR and CBE.
-
On M_PESA, TELE_BIRR_USSD, E_BIRR and CBE Phone Number Requirement: For phone number must be provided either in the
phoneNumberfield or in thecustomerInfo.phonefield.