laravelified-zarinpal / zarinpal
zarinpal的交易请求系统(适用于Laravel 5.2)
v2.0.4
2016-07-31 16:21 UTC
Requires
- guzzlehttp/guzzle: ^5.3
Requires (Dev)
- phpunit/phpunit: 5.3.*
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2024-09-14 19:36:46 UTC
README
zarinpal的交易请求库
##Laravel兼容 此包将适用于各种项目,但为了Laravel,我添加了提供者使其尽可能简单。只需将这些声明行添加到config/app.php中:
'providers' => [ ... Zarinpal\Laravel\ZarinpalServiceProvider::class ... ]; 'aliases' => [ ... 'Zarinpal' => Zarinpal\Laravel\Facade\Zarinpal::class, ];
将提供者列表添加到"config/app.php"。然后运行'php artisan vendor:publish --provider="Zarinpal\Laravel\ZarinpalServiceProvider"
'以将配置文件添加到Laravel的配置目录,配置它,现在你可以像这样访问zarinpal库:
use Zarinpal; Zarinpal::request("example.com/testVerify.php",1000,'testing'); Zarinpal::verify('OK',1000,$answer['Authority']);
##用法 ###安装 composer require laravelified-zarinpal/zarinpal
或
"require": { ... "laravelified-zarinpal//zarinpal" : "^2", ... },
###请求
use Zarinpal; $test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'); echo json_encode($answer = $test->request("example.com/testVerify.php",1000,'testing')); if(isset($answer['Authority'])) { file_put_contents('Authority',$answer['Authority']); $test->redirect(); } //it will redirect to zarinpal to do the transaction or fail and just echo the errors. //$answer['Authority'] must save somewhere to do the verification
###验证
use Zarinpal; $test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'); $answer['Authority'] = file_get_contents('Authority'); echo json_encode($test->verify('OK',1000,$answer['Authority'])); //'Status'(index) going to be 'success', 'error' or 'canceled'
##更改驱动程序 驱动程序可以使用restAPI、soap和NuSoap进行更改,使用:
restAPI(推荐)
$test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
或 soap
use Zarinpal\Drivers\SoapDriver; $test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',new soapDriver());
或 nuSoap
use Zarinpal\Drivers\NuSoapDriver; $test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',new NuSoapDriver());