hesham.tarek / ibtdi-myfatoorah
此包的最新版本(dev-master)没有提供许可证信息。
ibtdi myfatoorah 集成 API
dev-master
2022-09-19 18:56 UTC
Requires
- php: ^7.4|^8.0
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6.0|^7.0
- illuminate/http: ^6.0|^7.0|^8.0|^9.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-19 23:02:42 UTC
README
laravel myfatoorah 是由 Hisham Tarek 编写的 PHP 包,使用 Laravel 处理 myfatoorah 功能,通过简化其 API 来使其更易于使用。
功能
- 创建发票
- 返回支付
- 检查支付是否成功
- 动态更改令牌
安装指南
在 Laravel 项目中,使用 composer 安装包
composer require hesham.tarek/ibtdi-myfatoorah
此包与 laravel ^6.0|^7.0|^8.0|^9.0 兼容,因此您无需为此包设置提供者或别名
配置
要发布配置,请运行
php artisan vendor:publish --provider="HishamTarek\IbtdiMyFatoorah\IbtdiMyFatoorahServiceProvider"
并修改配置文件,文件位于 /config/ibtdimyfatoorah.php
从 Myfatoorah 获取您的凭证
- 前往 My fatorah
- 您将获得访问令牌
- 前往您的 .env 文件,并粘贴您的凭证,如下所示
IBTDI_MYFATOORAH_MODE=test
IBTDI_MYFATOORAH_TOKEN=token
或者,您可以使用 setAccessToken($token?)->setMode($mode?)
添加它
现在您已准备好使用此包
测试卡片页面
您可以从 DOCS 获取测试卡片
使用示例
创建支付页面
Route::get('payment', [\App\Http\Controllers\MyFatoorahController::class, 'index']);
Route::get('payment/callback', [\App\Http\Controllers\MyFatoorahController::class, 'callback']);
Route::get('payment/error', [\App\Http\Controllers\MyFatoorahController::class, 'error']);
在控制器中,您可以从支付页面获取数据,详情请见 DOCS
use HishamTarek\IbtdiMyFatoorah\Facades\IbtdiMyFatoorah;
public function index() {
$data = [
'CustomerName' => 'New user',
'NotificationOption' => 'all',
'MobileCountryCode' => '+966',
'CustomerMobile' => '0000000000',
'DisplayCurrencyIso' => 'SAR',
'CustomerEmail' => 'test@test.test',
'InvoiceValue' => '100',
'Language' => 'en',
'CallBackUrl' => 'https://yourdomain.test/callback',
'ErrorUrl' => 'https://yourdomain.test/error',
];
// If you want to set the credentials and the mode manually.
// $myfatoorah = IbtdiMyFatoorah::setAccessToken($token)->setMode('test')->createInvoice($data);
// And this one if you need to access token from config
$myfatoorah = IbtdiMyFatoorah::createInvoice($data);
// when you got a response from myFatoorah API, you can redirect the user to the myfatoorah portal
return response()->json($myfatoorah);
}
获取回调以检查支付是否成功
public function callback(Request $request) {
$myfatoorah = IbtdiMyFatoorah::payment($request->paymentId);
// It will check that payment is success or not
// return response()->json($myfatoorah->isSuccess());
// It will return payment response with all data
return response()->json($myfatoorah->get());
}
作者
许可证
本项目采用 MIT 许可证 - 请参阅 LICENSE.md 文件以获取详细信息
注意
- 如果您有任何问题、问题或 PR,请随时联系我。