stephenjude / laravel-payment-gateways
一个简单的Laravel API实现,适用于所有支付服务提供商,如Paystack、Flutterwave、Paypal等。
3.0.5
2024-07-08 10:02 UTC
Requires
- php: ^8.1|^8.2|8.3
- archtechx/enums: *
- illuminate/contracts: ^9.0|^10.0|^11.0
- illuminate/http: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- spatie/laravel-data: ^1.4|^2.0|^3.12
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^5.0|^6.0|^7.0||^8.0
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- dev-main
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.9
- 0.0.8
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This package is auto-updated.
Last update: 2024-09-24 14:48:42 UTC
README
这是一个适用于所有支付服务提供商的简单Laravel实现。此包支持Paystack、Monnify、Pay4Me Pay、Seerbit Flutterwave、Klasha和Stripe。
用例
你是否需要在移动应用程序中实现有限的SDK来接受支付?这正是这个包解决的问题。
使用这个包,你可以生成一个支付链接,并将其返回到移动应用程序API调用,支付可以在应用内浏览器中完成。
当客户完成支付时,这个包会验证支付并执行你在自定义闭包中定义的代码。
闭包应该看起来像这样
use Stephenjude\PaymentGateway\DataObjects\TransactionData; function (TransactionData $payment){ $order->update([ 'status' => $payment->status, 'amount' => $payment->amount, 'currency' => $payment->currency ]); $customer->notify(new OrderPaymentNotification($order)); }
如果你在Web上使用这个包,这个闭包是你在更新客户订单或发送通知后返回重定向的地方。
安装
您可以通过Composer安装此包
composer require stephenjude/laravel-payment-gateways
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="payment-gateways-config"
可选地,您可以使用以下命令发布视图
php artisan vendor:publish --tag="payment-gateways-views"
用法
此包目前支持 paystack
、monnify
、pay4me
、seerbit
、flutterwave
、klasha
和 stripe
。
如何初始化支付会话
use Stephenjude\PaymentGateway\PaymentGateway; use Stephenjude\PaymentGateway\DataObjects\TransactionData; $provider = PaymentGateway::make('paystack') $paymentSession = $provider->initializeCheckout([ 'currency' => 'NGN', // required 'amount' => 100, // required 'email' => 'customer@email.com', // required 'meta' => [ 'name' => 'Stephen Jude', 'phone' => '081xxxxxxxxx'], 'closure' => function (TransactionData $payment){ /* * Payment verification happens immediately after the customer makes payment. * The payment data obtained from the verification will be injected into this closure. */ logger('payment details', [ 'currency' => $payment->currency, 'amount' => $payment->amount, 'status' => $payment->status, 'reference' => $payment->reference, 'provider' => $payment->provider, 'date' => $payment->date, ]); }, ]); $paymentSession->provider; $paymentSession->checkoutUrl; $paymentSession->expires;
访问支付事务数据
$provider = PaymentGateway::make('paystack'); $transactions = $provider->listTransactions(); // Returns array $transaction = $provider->findTransaction(REFERENCE); // Returns Stephenjude\PaymentGateway\DataObjects\TransactionData $transaction->provider; $transaction->email; $transaction->amount; $transaction->currency; $transaction->reference; $transaction->status; $transaction->date;
Pawapay 设置
必需的环境变量
PAWAPAY_SECRET=
结账
use \Stephenjude\PaymentGateway\Enums\Provider; use \Stephenjude\PaymentGateway\PaymentGateway; $pawapay = PaymentGateway::make(Provider::PAWAPAY())->initializeCheckout([ "amount" => 15, "country" => "ZMB", 'meta' => [ "description" => "Note of 4 to 22 chars", "reason" => "Ticket to festival" ] ]);
Pay4Me 设置
PAY4ME_PUBLIC=
PAY4ME_SECRET=
Monnify 设置
MONNIFY_PUBLIC=
MONNIFY_SECRET=
MONNIFY_CONTRACT_CODE=
Pay4Me 设置
SEERBIT_PUBLIC=
SEERBIT_SECRET=
Paystack 设置
PAYSTACK_PUBLIC=
PAYSTACK_SECRET=
Flutterwave 设置
FLUTTERWAVE_PUBLIC=
FLUTTERWAVE_SECRET=
Klasha 设置
KLASHA_PUBLIC=
KLASHA_SECRET=
Stripe 设置
STRIPE_PUBLIC=
STRIPE_SECRET=
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
贡献
有关详细信息,请参阅 CONTRIBUTING。
安全漏洞
有关如何报告安全漏洞的详细信息,请参阅 我们的安全策略。
致谢
许可
MIT许可(MIT)。有关更多信息,请参阅 许可文件。