kpashokhi / savano
Savano 支付网关 For Laravel
1.0
2018-02-13 11:47 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-29 05:08:13 UTC
README
Savano 支付网关 For Laravel
安装
安装此扩展的首选方式是通过 composer。
运行
php composer.phar require kpasokhi/savano
或者添加
"kpasokhi/savano": "1.*"
到您的 composer.json 文件的 require 部分。
如何使用此扩展
例如,假设您有一个名为 PaymentController 的控制器,最初您需要两个操作,一个是请求支付,另一个是验证支付。
您需要一个存储来保存您的支付和支付状态。
PaymentController.php
.....
<?php
public function actionRequest()
{
/* Your Data */
$pin = 'Your Pin';
$callback = 'Your Callback Url';
/* Save Price, OrderId and Authority In Your Storage */
$price = 1000;
$orderId = 1;
$savano = new Savano;
$savano->pin = $pin;
if($request = $savano->request($price, $orderId, $callback)->getResult() === 1)
{
// $authority = $savano->getAuthority();
// You can save your payment request data to the database in here before redirect user to bank
return $this->redirect($savano->getRedirectUrl());
}
else
{
// Show Error.
echo $savano->getErrorMessage();
}
}
public function actionVerify()
{
$pin = 'Your Pin';
/* Fetch Price, OrderId and Authority From Your Storage */
$authority = 'xxxxxxxxxxxxxxx';
$price = 1000;
$orderId = 1;
$savano = new Savano;
$savano->pin = $pin;
if($verify = $savano->verify($authority, $price, $orderId)->getResult() === 1)
{
// Payment Successfully
}
else
{
// Show Error
echo $savano->getErrorMessage();
}
}
.....