feexpayme/feexpay-sdk-php

Feexpay PHP SDK - 通过信用卡和移动支付在线支付解决方案

dev-foxinnovs-patch-1 2023-08-09 00:00 UTC

This package is not auto-updated.

Last update: 2024-09-19 20:40:19 UTC


README

注意:FeexpayLOUGBEGNONhttps://feexpay.mecontact@feexpay.meFeexpayFeexpayPhpPhp sdk of Feexpay - Online payment solution by credit card and mobile money 替换为 README.mdCHANGELOG.mdCONTRIBUTING.mdLICENSE.mdcomposer.json 文件中的正确值,然后删除此行。您可以在命令行中运行 $ php prefill.php 来一次性完成所有替换。同时删除 prefill.php 文件。

这里应该是您的描述。尽量限制在一到两段话,并提及您支持的 PSRs 以避免用户和贡献者产生混淆。

Feexpay SDK PHP 项目 - 用户指南

本指南解释了如何使用 Feexpay PHP SDK 将移动和卡支付方式轻松集成到您的 PHP 或 Laravel 应用程序中。按照以下步骤开始使用

安装

  1. 安装本地服务器,如 Xampp 或 Wamp 等 ...

  2. 如果尚未安装,请安装 Composer。

  3. 通过运行以下命令检查 Composer 是否已安装

    composer --version
    

在简单 PHP 环境中的使用

  1. 创建您的 PHP 项目。

  2. 通过打开终端并运行以下命令下载 Git 仓库

    git clone https://github.com/foxinnovs/feexpay-sdk-php.git
    
  3. 创建一个 PHP 文件,例如 index.php

  4. 在您的 PHP 文件中使用 SDK 方法

    <?php
    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)
    $response = $skeleton->paiementLocal("amount", "phone_number", "network (MTN, MOOV)", "Jon Doe", "jondoe@gmail.com");
    $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", "jondoe@gmail.com", "country(Benin)", "address(Cotonou)", "district(Littoral)", "currency(XOF, USD, EUR)");
    $redirectUrl = $responseCard["url"];
    header("Location: $redirectUrl");
    exit();
    ?>
  5. 您还可以在 PHP 页面中集成支付按钮

    <?php
    include 'src/FeexpayClass.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>

与 Laravel 一起使用

  1. 在 Laravel 项目中,运行以下命令安装 Feexpay 包

    composer require feexpayme/feexpay-sdk-php
    
  2. 在您的 web.php 文件中创建一个路由

    Route::controller(YourController::class)->group(function () {
        Route::get('feexpay', 'feexpay')->name('feexpay');
    });
  3. 创建一个控制器,例如 YourController.php,并在该控制器中使用 Feexpay SDK 处理支付

    <?php
    
    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", "jondoe@gmail.com", "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","jondoe@gmail.com");
             $status = $skeleton->getPaiementStatus($response);
             var_dump($status);
        }
    }

<?php

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", "jondoe@gmail.com", "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);
         }
    }
}
  1. 在视图中集成 Feexpay 按钮,例如 welcome.blade.php

创建一个路由

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

创建一个控制器,例如 YourController.php

以下是代码

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

 

}

确保您有视图文件,例如我们的示例是 welcome.blade.php

以下是代码

<div id='button_payee'></div>
  1. 现在您可以通过访问路由中定义的 URL 使用 Feexpay 进行支付。

注意:FeexpayLOUGBEGNONhttps://feexpay.mecontact@feexpay.meFeexpayFeexpayPhpPhp sdk of Feexpay - Online payment solution by credit card and mobile money 替换为 README.mdCHANGELOG.mdCONTRIBUTING.mdLICENSE.mdcomposer.json 文件中的正确值,然后删除此行。您可以在命令行中运行 $ php prefill.php 来一次性完成所有替换。同时删除 prefill.php 文件。

这里应该是您的描述。尽量限制在一到两段话,并提及您支持的 PSRs 以避免用户和贡献者产生混淆。

请确保根据您的配置和需求调整“商店 ID”、“API 令牌密钥”、“地址”、“金额”和其他详细信息。