PHP code example of feexpay / feexpay-php

1. Go to this page and download the library: Download feexpay/feexpay-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

feexpay / feexpay-php example snippets


   
   on = new Feexpay\FeexpayPhp\FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)");

   // Using the mobile network payment method (MTN, MOOV)
   $response = $skeleton->paiementLocal("amount", "phone_number", "network (MTN, MOOV)", "Jon Doe", "[email protected]");
   $status = $skeleton->getPaiementStatus($response);
   var_dump($status);

   // Using the card payment method (VISA, MASTERCARD)
   $responseCard = $skeleton->paiementCard("amount", "phoneNumber(66000000)", "typeCard (VISA, MASTERCARD)", "Jon", "Doe", "[email protected]", "country(Benin)", "address(Cotonou)", "district(Littoral)", "currency(XOF, USD, EUR)");
   $redirectUrl = $responseCard["url"];
   header("Location: $redirectUrl");
   exit();
   

   
    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");
   

   Route::controller(YourController::class)->group(function () {
       Route::get('feexpay', 'feexpay')->name('feexpay');
   });
   

   

   namespace App\Http\Controllers;
   use Feexpay\FeexpayPhp\FeexpayClass;
   use Illuminate\Http\Request;

   class YourController extends Controller
   {
       public function feexpay()
       {

            // Using the card payment method (VISA, MASTERCARD)

           $skeleton = new FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)");
           $responseCard = $skeleton->paiementCard("amount", "phoneNumber(66000000)", "typeCard (VISA, MASTERCARD)", "Jon", "Doe", "[email protected]", "country(Benin)", "address(Cotonou)", "district(Littoral)", "currency(XOF, USD, EUR)");
           $redirectUrl = $responseCard["url"];
           return redirect()->away($redirectUrl);


           // Using the mobile network payment method (MTN, MOOV)


            $skeleton = new FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)");
            $response = $skeleton->paiementCard("amount", "phone_number", "network (MTN, MOOV)", "Jon Doe","[email protected]");
            $status = $skeleton->getPaiementStatus($response);
            var_dump($status);
       }
   }
   

Route::controller(YourController::class)->group(function () {
    Route::get('payment', 'payment')->name('payment') ;
}) ;
   


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);
    }
}
   

   git clone https://github.com/La-Vedette-Media/feexpay-php-sdk.git
   

   composer 

   

   namespace App\Http\Controllers;
   use Feexpay\FeexpayPhp\FeexpayClass;
   use Illuminate\Http\Request;

   class YourController extends Controller
   {
       public function feexpay()

       {

        // Using the card payment method (VISA, MASTERCARD)


           $skeleton = new FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)");
            $responseCard = $skeleton->paiementCard("amount", "phoneNumber(66000000)", "typeCard (VISA, MASTERCARD)", "Jon", "Doe", "[email protected]", "country(Benin)", "address(Cotonou)", "district(Littoral)", "currency(XOF, USD, EUR)");

            // Display response structure for debugging purposes
            var_dump($responseCard);

            // Check for the presence of the "url" key
            if (isset($responseCard["url"])) {
                $redirectUrl = $responseCard["url"];
                return redirect()->away($redirectUrl);
            } else {
                // Handle the case where "url" is not present in the response
                return response("Erreur de réponse de paiement")->setStatusCode(500);
            }
       }
   }