hawkiq/laravel-zaincash 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hawkiq/laravel-zaincash

Composer 安装命令:

composer require hawkiq/laravel-zaincash

包简介

Laravel package to use in Laravel helps you to make dealing with Zain Cash API easier

README 文档

README

Total Downloads Latest Stable Version License

About hawkiq laravel zaincash

ZainCash offers a simple robust payment gateway to transfer money instantly from anywhere to everywhere inside Iraq, and this package for Laravel developers since there are no official package to use in Laravel so I've decided to create one.

Requiremnt

Version PHP Laravel
1.x 7.1 <= PHP 5.8 <= Laravel

Installation

composer require hawkiq/laravel-zaincash

Publish config file

php artisan vendor:publish --tag="zaincash"

setup redirect route in web.php to handle payment result and put route name in zaincash.php config file

Route::get('/redirect', [App\Http\Controllers\HomeController::class, 'redirect'])->name('redirect');

all config variables are well described

config Description Type Default
msisdn The mobile phone number for your wallet, example format: 9647835077893. given by Zain Cash String 9647835077893
secret This is used to decode and encode JWT during requests. also must be requested from ZainCash String secret found in config
merchantid You can request a Merchant ID from ZainCash's support String 5ffacf6612b5777c6d44266f
live Test enviroment or Live server (true=live , false=test) Bool false
lang setting langauge for zain cashe payment page String en
order_id you can use it to help you in tagging transactions with your website IDs String Str::slug(env('APP_NAME')) . '_hawkiq_'
redirection_url to handle payment after successfull First you need to Specify name for redirect route in web.php String redirect

or you can set those parameters inside .env file

ZCASH_MSISDN=
ZCASH_MERCHANTID=
ZCASH_SECRET=
ZCASH_LANG=en
ZCASH_LIVE=false
ZCASH_CALLBACK_ROUTE="redirect"

inside your controller

Now you can use zain cash as API or web just pass the isWeb variable value as boolean or use asApi method

//Your Controller 
use Hawkiq\LaravelZaincash\Services\ZainCash;

public function send()
{
    // Now you can use zain cash as API or web just pass the isWeb variable value as boolean or use asApi method
    $zaincash = new ZainCash(); // for normal Web version
    // OR
    $zaincash = (new ZainCash())->asApi(); // for API version
    // OR
    $zaincash = (new ZainCash())->asWeb(false); // for API version

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

if you used web version it will redirect you to payment page otherwise it will show a response with information about your payload you can use payment_url to redirect user inside app.

this will redirect us to Zain Cash page to enter user credentials ( MSISDN and Pin)

you can use this test user

MSISDN PIN OTP
9647802999569 1234 1111

We check for status in our callback method in controller

//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..
        }

result will be in JSON format like this

{
   "status":"success",
   "orderid":"laravel_hawkiq_20222009",
   "id":"632eb6cb8726f6b4b8ea2fc3",
   "operationid":"1006596",
   "msisdn":"9647802999569"
}

Security Vulnerabilities

If you discover a security vulnerability within hawkiq Laravel Zaincash, please send an e-mail to OsaMa via info@osama.app. All security vulnerabilities will be promptly addressed.

Preview

this class used in following sites

feel free to contact me if you want to add your site.

Todo

  • Add custom redirect route.
  • Api version.
  • Add additional views for easy integration into blade.

License

Laravel Zaincash is open-sourced software licensed under the MIT license.

hawkiq/laravel-zaincash 适用场景与选型建议

hawkiq/laravel-zaincash 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 453 次下载、GitHub Stars 达 9, 最近一次更新时间为 2022 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hawkiq/laravel-zaincash 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hawkiq/laravel-zaincash 我们能提供哪些服务?
定制开发 / 二次开发

基于 hawkiq/laravel-zaincash 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 453
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-21