dena-a / iran-payment
一个用于处理伊朗银行系统互联网支付网关的 Laravel 扩展包
v2.2.1
2024-08-13 09:35 UTC
Requires
- php: ^7.4|^8.0
- ext-curl: *
- ext-json: *
- ext-soap: *
- illuminate/database: ^5.7|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/http: ^5.7|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^5.7|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- nesbot/carbon: *
Requires (Dev)
- doctrine/dbal: ^3.0
- fakerphp/faker: ^1.4
- laravel/pint: ^1.17
- orchestra/testbench: ^6.0
- phpstan/phpstan: ^0.12.0@dev
- phpunit/phpunit: ^9.5
README
Laravel 的 IranPayment
一个用于处理伊朗银行系统互联网支付网关 (IPG) 的 Laravel 扩展包
支持 Sadad (Melli)、Saman (Sep)、Zarinpal 以及更多伊朗支付网关。只需使用 IranPayment 就可以在您的网站上直接接收付款。
网关
网关
要求
安装
-
通过
composer require
命令将包添加到您的 composer 文件中$ composer require dena-a/iran-payment:^2.0
或者手动将其添加到
composer.json
"require": { "dena-a/iran-payment": "^2.0" }
-
IranPayment 的服务提供者将自动使用 Laravel 的自动发现功能进行注册。
注意:对于 Lumen,您需要手动将 IranPayment 服务提供者添加到
bootstrap/app.php
$app->register( Dena\IranPayment\IranPaymentServiceProvider::class);
-
使用以下命令发布配置文件和迁移
php artisan vendor:publish --provider="Dena\IranPayment\IranPaymentServiceProvider"
-
迁移发布后,您可以通过运行迁移来创建事务表
php artisan migrate
用法
创建新付款
use Dena\IranPayment\IranPayment; // Default gateway $payment = IranPayment::create(); // Select one of available gateways $payment = IranPayment::create('sadad'); // Test gateway (Would not work on production environment) $payment = IranPayment::create('test'); // Or use your own gateway $payment = IranPayment::create(NewGateway::class); $payment->setUserId($user->id) ->setAmount($data['amount']) ->setCallbackUrl(route('bank.callback')) ->ready(); return $payment->redirect();
验证付款
use Dena\IranPayment\IranPayment; use Dena\IranPayment\Exceptions\IranPaymentException; try { $payment = IranPayment::detect()->confirm(); $trackingCode = $payment->getTrackingCode(); $statusText = $payment->getTransactionStatusText(); } catch (Dena\IranPayment\Exceptions\IranPaymentException $ex) { throw $ex; }
创建您自己的支付网关类
use Dena\IranPayment\Gateways\AbstractGateway; use Dena\IranPayment\Gateways\GatewayInterface; class NewGateway extends AbstractGateway implements GatewayInterface { public function getName(): string { return 'new-gateway'; } public function initialize(array $parameters = []): self { parent::initialize($parameters); return $this; } public function purchase(): void { // Send Purchase Request $reference_number = 'xxxx'; $this->transactionUpdate([ 'reference_number' => $reference_number, ]); } public function purchaseUri(): string { return 'http://new-gateway.com/token/xxxx'; } public function verify(): void { $this->transactionVerifyPending(); // Send Payment Verify Request $tracking_code = 'yyyy'; $this->transactionSucceed([ 'tracking_code' => $tracking_code ]); } }
贡献
欢迎贡献!
支持
如果您认为您找到了一个错误,请使用 GitHub 问题跟踪器 报告它,或者最好是分支库并提交一个 pull request。
许可协议
MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件。