feexpay / feexpay-php
Php sdk of Feexpay - Online payment solution by credit card and mobile money
Requires
- php: >=7.1
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-26 10:18:55 UTC
README
Feexpay SDK PHP Project - User Guide
This guide explains how to use the Feexpay PHP SDK to easily integrate mobile and card payment methods into your PHP or Laravel application. Follow these steps to get started:
Version 3.0.0 — the SDK uses the Feexpay API v2 (
https://api-v2.feexpay.me). The previous host (https://api.feexpay.me) is no longer available, so older versions of the SDK no longer work: please upgrade.Upgrading from 2.x:
paiementCard()has a new signature,paiementCard(amount, currency, firstName, lastName, email, phoneNumber, city, zip, country), and returnsnullon failure. Update your calls before upgrading.
Requirements
- PHP 7.1 or higher
- The
curlandjsonPHP extensions - Your shop's id and your API key (it starts with
fp_), available in your Feexpay dashboard
Installation
-
Install a local server like Xampp or Wamp etc ...
-
Install Composer if not already done.
-
Check that Composer is installed by running the following command:
composer --version -
Install the Feexpay package in your project:
composer require feexpay/feexpay-phpTo upgrade an existing project:
composer update feexpay/feexpay-php
Usage in a Simple PHP Environment
-
Create your PHP project and install the package with Composer (see above).
You can also download the Git repository instead:
git clone https://github.com/La-Vedette-Media/feexpay-php-sdk.git -
Create a PHP file, for example,
index.php. -
Use the SDK methods in your PHP file:
<?php require 'vendor/autoload.php'; // Without Composer: include 'src/FeexpayClass.php'; $skeleton = new Feexpay\FeexpayPhp\FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)"); // Using the mobile network payment method (MTN, MOOV, MTN CG, ...) // paiementLocal(amount, phoneNumber, network, fullname, email, callback_info, custom_id, otp = "") // phoneNumber: country code + local number, e.g. Benin 229 + 0166000000 => "2290166000000" $reference = $skeleton->paiementLocal(100, "2290166000000", "MTN", "Jon Doe", "jondoe@gmail.com", "order 123", "my-ref-123"); if ($reference === null) { // The API refused the payment: show the real reason $error = $skeleton->getLastError(); echo $error["message"]; // message returned by the API var_dump($error["response"]); // full API response, useful for support } else { $status = $skeleton->getPaiementStatus($reference); var_dump($status); } ?>
-
Check the status of a payment with its reference:
<?php $status = $skeleton->getPaiementStatus($reference); // [ // "amount" => 100, // "clientNum" => "2290166000000", // "status" => "SUCCESSFUL", // or "PENDING", "FAILED" // "reference" => "63ecaff1-7572-413d-93bb-8cba92bb8c2c", // ] ?>
getPaiementStatus()returnsfalsewhen the reference is empty. -
Use the web payment method for the networks that redirect the customer to a payment page:
<?php // requestToPayWeb(amount, phoneNumber, network, fullname, email, callback_info, custom_id, cancel_url, return_url) $response = $skeleton->requestToPayWeb(100, "2250700000000", "network", "Jon Doe", "jondoe@gmail.com", "order 123", "my-ref-124", "https://your-site.com/cancel", "https://your-site.com/return"); if ($response === false || empty($response["payment_url"])) { echo "Payment could not be initialized"; } else { // $response["reference"] and $response["order_id"] identify the payment header("Location: " . $response["payment_url"]); exit(); } ?>
-
Use the card payment method (VISA, MASTERCARD):
<?php // paiementCard(amount, currency, firstName, lastName, email, phoneNumber, city, zip, country) - all arguments are required $responseCard = $skeleton->paiementCard(100, "XOF", "Jon", "Doe", "jondoe@gmail.com", "2290166000000", "Cotonou", "00229", "BJ"); if ($responseCard !== null) { // $responseCard["reference"] identifies the payment header("Location: " . $responseCard["payment_url"]); exit(); } else { // The API refused the payment: show the real reason echo $skeleton->getLastError()["message"]; } ?>
-
You can also integrate a payment button in your PHP page:
<?php require 'vendor/autoload.php'; $price = 50; $id = "shop's id"; $token = "token key API"; $callback_url = 'https://www.google.com'; $mode = 'LIVE'; $feexpayclass = new Feexpay\FeexpayPhp\FeexpayClass($id, $token, $callback_url, $mode); $result = $feexpayclass->init($price, "button_payee"); ?> <div id='button_payee'></div>
Usage with Laravel
-
In a Laravel project, run the following command to install the Feexpay package:
composer require feexpay/feexpay-php -
Create the routes in your
web.phpfile:Route::controller(YourController::class)->group(function () { Route::get('feexpay', 'feexpay')->name('feexpay'); Route::get('feexpay-card', 'feexpayCard')->name('feexpay-card'); });
-
Create a controller, for example,
YourController.php, and use the Feexpay SDK inside this controller to handle payments:<?php namespace App\Http\Controllers; use Feexpay\FeexpayPhp\FeexpayClass; use Illuminate\Http\Request; class YourController extends Controller { // Using the mobile network payment method (MTN, MOOV, MTN CG, ...) public function feexpay() { $skeleton = new FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)"); $reference = $skeleton->paiementLocal(100, "2290166000000", "MTN", "Jon Doe", "jondoe@gmail.com", "order 123", "my-ref-123"); if ($reference === null) { return response($skeleton->getLastError()["message"])->setStatusCode(422); } $status = $skeleton->getPaiementStatus($reference); return response()->json($status); } // Using the card payment method (VISA, MASTERCARD) public function feexpayCard() { $skeleton = new FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)"); $responseCard = $skeleton->paiementCard(100, "XOF", "Jon", "Doe", "jondoe@gmail.com", "2290166000000", "Cotonou", "00229", "BJ"); if ($responseCard !== null) { return redirect()->away($responseCard["payment_url"]); } else { // The API refused the payment: show the real reason return response($skeleton->getLastError()["message"])->setStatusCode(422); } } }
-
Integrate the Feexpay button in a view, for example,
welcome.blade.php:
Create a route:
Route::controller(YourController::class)->group(function () { Route::get('payment', 'payment')->name('payment') ; }) ;
Create a controller by example YourController.php
namespace App\Http\Controllers; use Feexpay\FeexpayPhp\FeexpayClass; use Illuminate\Http\Request; class YourController extends Controller { public function payment() { $data['price'] = $price = 50; $data['id'] = $id= "shop's id"; $data['token'] = $token= "token key API"; $data['callback_url'] = $callback_url= 'https://www.google.com'; $data['mode'] = $mode='LIVE'; $data['feexpayclass'] = $feexpayclass = new FeexpayClass($id, $token, $callback_url, $mode); $data['result'] = $result = $feexpayclass->init($price, "button_payee"); return view('welcome', $data); } }
Make sure you have your views file for our example is welcome.blade.php
<div id='button_payee'></div>
You can now access the URL defined in the route to perform payments using Feexpay.
Security
Never commit your API key to a repository: keep it in an environment variable (for example in your .env file with Laravel) and read it from there.
Documentation
The full API documentation (networks, countries, webhooks) is available at https://docs.feexpay.me.
Make sure to adapt values like "shop's id", "token key API", addresses, amounts, and other details according to your own configuration and needs.