shahrooz7216/laravel-multi-payment
Composer 安装命令:
composer require shahrooz7216/laravel-multi-payment
包简介
A driver-based laravel package for online payments via multiple gateways
关键字:
README 文档
README
This is a laravel gateway payment package with multi driver support. Each driver can have multiple configurations.
Supports laravel v7.0+ and requires php v7.4+
Supported Gateways
- Mellat Bank (Behpardakht)
- Saman Bank (Sep)
- Parsian Bank (Top)
- Pasargad Bank (Pep)
- Eghtesad Novin Bank (Pardakht Novin)
- Zarinpal
- IDPay
- Pay.ir
- Zibal
Installation & Configuration
Install using composer
composer require shahrooz7216/laravel-multi-payment
Publish main config file
php artisan vendor:publish --tag=multipayment-config
Publish gateway config file based on tags. like:
- zarinpal-config
- mellat-config
- saman-config
- pasargad-config
- novin-config
For example:
php artisan vendor:publish --tag=zarinpal-config
Also you may have to add Service provider to the providers Array in app.php file in config directory:
'providers' => [
shahrooz7216\MultiPayment\Providers\MultiPaymentServiceProvider::class,
],
And you should add your configuration environment variables to your .env file:
EGHTESAD_NOVIN_TERMINAL_ID="..."
EGHTESAD_NOVIN_MERCHANT_ID="..."
EGHTESAD_NOVIN_MID="..."
EGHTESAD_NOVIN_USER_ID="..."
EGHTESAD_NOVIN_PASSWORD="..."
EGHTESAD_NOVIN_TOKEN=""
EGHTESAD_NOVIN_CALLBACK_URL="https://something.com/novin.php"
EGHTESAD_NOVIN_API_ENDPOINT="https://pna.shaparak.ir"
EGHTESAD_NOVIN_CERT_PATH="..."
EGHTESAD_NOVIN_CERT_USERNAME="..."
EGHTESAD_NOVIN_CERT_PASSWORD="..."
EGHTESAD_NOVIN_MODE="NoSign"
Also you can publish view file for gateway redirection and customize it
php artisan vendor:publish --tag=multipayment-view
In main config file multipayment.php, you can specify default driver. For example, zarinpal.second value states that zarinpal gateway with configuration under second key section on zarinpal config file will be used. There is also an option for auto amount conversion from Iranian Tomans to Iranian Rials currency (IRR) and vice versa.
/** * set default gateway * * valid pattern --> GATEWAY_NAME.GATEWAY_CONFIG_KEY */ 'default_gateway' => env('DEFAULT_PAYMENT_GATEWAY', 'zarinpal.second'), /** * set to false if your in-app currency is IRR */ 'convert_to_rials' => true
In each gateway config file, you can specify multiple credentials, therefore you may have multiple gateways for your app from same provider.
/** * gateway configurations */ 'first' => [ 'merchant_id' => '', 'callback_url' => 'https://yoursite.com/path/to', 'mode' => 'normal', // Supported values: normal, sandbox, zaringate 'description' => 'payment using zarinpal', ], 'second' => [ 'merchant_id' => '', 'callback_url' => 'https://yoursite.com/path/to', 'mode' => 'sandbox', 'description' => 'payment using zarinpal', ]
Usage
Gateway payment has two major phases. first is purchase (start process by calling gateway api for a transaction_id/token) and opening gateway payment web page with received data. second is verification (checking payment was successful).
Purchase
Inovice objects hold payment data. first you create an invoice, set amount and other information, then you pass invoice to PaymentGateway Facade to start payment process. you can use setProvider method on facade to change gateway before payment.
// On top... use shahrooz7216\MultiPayment\Facades\PaymentGateway; //// $invoice = new Invoice(10000); $invoice->setPhoneNumber("989123456789"); return PaymentGateway::purchase($invoice, function (string $transactionId) { // Save transaction_id and do stuff... })->view();
Verification
After payment gateway redirection to your app, you must create an invoice and set it's transaction_id and amount. then use PaymentGateway to verify invoice successful payment.
try { // Get amount & transaction_id from database or gateway request $invoice = new Invoice($amount, $transactionId); $receipt = PaymentGateway::verify($invoice); // Save receipt data and return response // } catch (PaymentAlreadyVerifiedException $exception) { // Optional: Handle repeated verification request } catch (PaymentFailedException $exception) { // Handle exception for failed payments return $exception->getMessage(); }
Other Features
Unverified Payments
There is also a method (supported by zarinpal only for now) to get a list of successful unverified payments. use unverifiedPayments method in PaymentGateway facade for this feature.
Refund
Using refund method, you can refund a successful payment back to customer.
shahrooz7216/laravel-multi-payment 适用场景与选型建议
shahrooz7216/laravel-multi-payment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「payment」 「gateway」 「invoice」 「laravel」 「Bank」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shahrooz7216/laravel-multi-payment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shahrooz7216/laravel-multi-payment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shahrooz7216/laravel-multi-payment 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
Alfabank REST API integration
GovPayNet driver for the Omnipay payment processing library
BlueSnap driver for the Omnipay payment processing library
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-28