hawkiq / laravel-zaincash
Laravel 包,用于在 Laravel 中使用,使处理 Zain Cash API 更加简单
v1.0.5
2024-01-04 21:15 UTC
Requires
- firebase/php-jwt: ^6.3
README
关于 hawkiq laravel zaincash
ZainCash 提供了一个简单且强大的支付网关,可以在伊拉克的任何地方即时转账,因为这个包是为 Laravel 开发者准备的,因为没有官方的 Laravel 包可以使用,所以我决定创建一个。
要求
安装
composer require hawkiq/laravel-zaincash
发布配置文件
php artisan vendor:publish --tag="zaincash"
在 web.php 中设置重定向路由以处理支付结果,并在 zaincash.php 配置文件中放置路由名称
Route::get('/redirect', [App\Http\Controllers\HomeController::class, 'redirect'])->name('redirect');
所有配置变量都有详细说明
在你的控制器中
//Your Controller use Hawkiq\LaravelZaincash\Services\ZainCash; public function send() { $zaincash = new ZainCash(); //The total price of your order in Iraqi Dinar only like 1000 (if in dollar, multiply it by dollar-dinar exchange rate, like 1*1500=1500) //Please note that it MUST BE MORE THAN 1000 IQD $amount = 1000; //Type of service you provide, like 'Books', 'ecommerce cart', 'Hosting services', ... $service_type="Shirt"; //Order id, you can use it to help you in tagging transactions with your website IDs, if you have no order numbers in your website, leave it 1 $order_id="20222009"; $payload = $zaincash->request($amount, $service_type, $order_id); return $payload; }
这将带我们到 Zain Cash 页面以输入用户凭据(MSISDN 和 Pin)
你可以使用这个测试用户
我们在控制器中的重定向方法中检查状态
//get token from request Url $token = \Request::input('token'); if (isset($token)) { $zaincash = new ZainCash(); $result = $zaincash->parse($token); if ($result->status == 'success'){ // success || failed || pending return 'Thanks for Buying'; // We can do what ever you like , insert transaction into database, send email etc.. }
结果将以如下 JSON 格式呈现
{ "status":"success", "orderid":"laravel_hawkiq_20222009", "id":"632eb6cb8726f6b4b8ea2fc3", "operationid":"1006596", "msisdn":"9647802999569" }
安全漏洞
如果你在 hawkiq Laravel Zaincash 中发现安全漏洞,请通过 info@osama.app 发送电子邮件给 OsaMa。所有安全漏洞都将得到及时解决。
预览
此类在以下网站中使用
如果你想要添加你的网站,请随时联系我。
待办事项
- 添加额外的视图,以便更容易集成到 blade 中。
许可证
Laravel Zaincash 是开源软件,根据 MIT 许可证 授权。