feexpay/feexpay-php
Composer 安装命令:
composer require feexpay/feexpay-php
包简介
Php sdk of Feexpay - Online payment solution by credit card and mobile money"
README 文档
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:
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
Usage in a Simple PHP Environment
-
Create your PHP project.
-
Download the Git repository by opening your terminal and running the following command:
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 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(); ?>
-
You can also integrate a payment button in your PHP page:
<?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>
Usage with Laravel
-
In a Laravel project, run the following command to install the Feexpay package:
composer require feexpay/feexpay-php -
Create a route in your
web.phpfile:Route::controller(YourController::class)->group(function () { Route::get('feexpay', 'feexpay')->name('feexpay'); });
-
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 { 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); } }
or
<?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);
}
}
}
- 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.
Make sure to adapt values like "shop's id", "token key API", addresses, amounts, and other details according to your own configuration and needs.
feexpay/feexpay-php 适用场景与选型建议
feexpay/feexpay-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.65k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 feexpay/feexpay-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 feexpay/feexpay-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-22