php-coda / laravel-coda
Coda支付页面集成API
dev-master
2019-09-11 07:00 UTC
Requires
- php: >=5.6.4
This package is auto-updated.
Last update: 2024-09-11 17:36:51 UTC
README
Laravel Coda包
Laravel版本5.x.x
安装
使用composer安装
composer require php-coda/laravel-coda
安装后,在项目的config/app.php文件中,从providers数组中替换以下条目
PhpCoda\LaravelCoda\LaravelCodaServiceProvider::class,
并且
php artisan vendor:publish --provider="PhpCoda\LaravelCoda\LaravelCodaServiceProvider" --force
这是已发布配置文件的内容
return [ 'airtimeURL' => env('airtimeURL'), 'airtimeRestURL' => env('airtimeRestURL'), 'country' => env('country'), 'currency' => env('currency'), 'txnType' => env('txnType'), 'requestType' => env('requestType','json'), ];
将您的应用程序配置添加到.env文件中
airtimeURL=********* airtimeRestURL=******* country=******** currency=******** txnType=********* requestType=********
支付请求[使用支付网关API和SecurePay]
示例构建支付表单
将data-encrypt
字段添加到表单中,以安全地捕获卡信息。
<link rel="stylesheet" href="https://sandbox.codapayments.com/airtime/css/airtime_v1.0.css"> <script type="text/javascript" src="https://sandbox.codapayments.com/airtime/js/airtime_v1.0.js"></script> <script type="text/javascript"> function processPayment (obj) { initTxn (obj, 1); } function initTxn (obj, payType) { $.ajax ( { type: "POST", url: "<your payment request link>", data: $('#itemForm').serialize() + "&type=InitTxn", // console.log(data); success: function (data) { if (payType == 1) { airtime_checkout(data); } else if (payType == 2) { $("#txn_id").val(data); $("#itemForm").attr("action","/php-rest/iframeDesktop.php"); $("#itemForm").submit(); } else if (payType == 3) { $("#txn_id").val(data); $("#itemForm").attr("action","/php-rest/iframeMobile.php"); $("#itemForm").submit(); } }, error: function (jqXHR, textSatus, err) { alert (err); } } ); } </script> <form method="POST" action="#" accept-charset="UTF-8" id="itemForm"> <input type="text" id="Name" placeholder="Enter Name" name="Name" required="required"> <input type="text" id="Item" placeholder="Enter amount" name="Item" required="required"> <input type="text" id="apikey" placeholder="Enter amount" name="apikey" required="required"> <div class="form-actions"> <a href="javascript:processPayment(this);">Payment Now</a> </div> </form>
提交请求,您的后端代码将接收
准备
$payload = \PaymentCoda::CodaRequest($request);
提交支付请求
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。