shabayek/laravel-payment
Composer 安装命令:
composer require shabayek/laravel-payment
包简介
Laravel Package For Payment Methods
README 文档
README
This is a Laravel Package for Payment Gateway Integration. It has a clear and consistent API, is fully unit tested, and even comes with an example application to get you started.
Note this package under development Don't use it in production.
Usage
- Install laravel payment package with composer
composer require shabayek/laravel-payment
- Publish the config file with following command
php artisan vendor:publish --provider="Shabayek\Payment\PaymentServiceProvider" --tag=config
- Initiate a payment with the following code:
$method_id = 1; // payment method id from the config file $payment = Payment::via($method_id);
- Implement customer details contracts on user model by adding Billable trait
use Shabayek\Payment\Concerns\Billable; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Billable, Notifiable; }
- Following columns is default for billable user
- first_name
- last_name
- phone
if you want to change the column name you can do add public methods on your model with convention name CamelCase like firstName + Column FirstNameColumn
/** * Get the first name. * * @return string|null */ public function firstNameColumn() { return $this->name; // OR $this->first_name; }
- Implement address details with relation to address model
The default relation is address if you want change the relation name you can do add public methods on your user model
/** * Get the billable billing relations. * * @return Model */ public function billingRelation() { return $this->address_relation; // OR $this->address; }
- Pass the user model to payment gateway
$payment->customer($user);
- Add items with loop array of data items
$items = [ [ "name" => "item1", "price" => 100, "quantity" => 2, "description" => "item1 description", ], [ "name" => "item2", "price" => 200, "quantity" => 1, "description" => "item2 description", ], ]; $payment->items($items); // OR By One $name = "item1"; $price = 100; $quantity = 2; // Default 1 $description = "item1 description"; // Default null $payment->addItem($name, $price, $quantity, $description);
- Set transaction id will send to gateway
$payment->transaction($transaction_id);
- Check the payment is online to get pay url
if ($payment->isOnline()) { $url = $payment->purchase(); }
- The MasterCard method adds a new way to get the checkout form
pass the transaction model will update successIndicator and return view with checkout form
$payment->checkoutForm(Transaction $transaction);
- Print the errors messages
$payment->getErrors(); $payment->isSuccess();
- When callback from payment gateway, you can use the following code to verify the payment
$payment = $payment->pay($request); // function array with payment status and message // return [ // 'success' => $isSuccess, // 'message' => $message, // 'data' => [] // ];
- Check the payment status
$method_id = 1; // payment method id from the config file $payment_order_id = 111; // payment order id $payment_status = Payment::via($method_id)->verify($payment_order_id);
Change log
Please see CHANGELOG for more information on what has been changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you've found a bug regarding security please mail esmail.shabayek@gmail.com instead of using the issue tracker.
License
The Laravel payment methods package is open-sourced software licensed under the MIT license.
shabayek/laravel-payment 适用场景与选型建议
shabayek/laravel-payment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「gateway」 「laravel」 「method」 「cod」 「paymob」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shabayek/laravel-payment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shabayek/laravel-payment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shabayek/laravel-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
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-06