Search by

feexpay / feexpay-php

feexpay

Php sdk of Feexpay - Online payment solution by credit card and mobile money

Package info

github.com/La-Vedette-Media/feexpay-php-sdk

pkg:composer/feexpay/feexpay-php

Statistics

Installs: 8 244

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v3.0.0 2026-10-06 19:07 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 returns null on failure. Update your calls before upgrading.

Requirements

  • PHP 7.1 or higher
  • The curl and json PHP extensions
  • Your shop's id and your API key (it starts with fp_), available in your Feexpay dashboard

Installation

  1. Install a local server like Xampp or Wamp etc ...

  2. Install Composer if not already done.

  3. Check that Composer is installed by running the following command:

    composer --version
    
  4. Install the Feexpay package in your project:

    composer require feexpay/feexpay-php
    

    To upgrade an existing project:

    composer update feexpay/feexpay-php
    

Usage in a Simple PHP Environment

  1. 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
    
  2. Create a PHP file, for example, index.php.

  3. 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);
    }
    ?>
  4. 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() returns false when the reference is empty.

  5. 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();
    }
    ?>
  6. 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"];
    }
    ?>
  7. 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

  1. In a Laravel project, run the following command to install the Feexpay package:

    composer require feexpay/feexpay-php
    
  2. Create the routes in your web.php file:

    Route::controller(YourController::class)->group(function () {
        Route::get('feexpay', 'feexpay')->name('feexpay');
        Route::get('feexpay-card', 'feexpayCard')->name('feexpay-card');
    });
  3. 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);
             }
        }
    }
  4. 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.