hinet/laravel-payment
Composer 安装命令:
composer require hinet/laravel-payment
包简介
Omnipay ServiceProvider for Laravel.
README 文档
README
💳 Omnipay ServiceProvider for Laravel.
Installing
$ composer require Hinet/laravel-payment
After updated composer, if you are using laravel version < 5.5, you need to register service provider:
// config/app.php 'providers' => [ //... Hinet\LaravelPayment\ServiceProvider::class, ],
And publish the config file:
$ php artisan vendor:publish --provider=Hinet\\LaravelPayment\\ServiceProvider
if you want to use facade mode, you can register a facade name what you want to use, for example LaravelPayment:
// config/app.php 'aliases' => [ 'LaravelPayment' => Hinet\LaravelPayment\Facade::class, // This is default in laravel 5.5 ],
configuration
// config/payments.php // The default gateway name which configured in `gateways` section. 'default_gateway' => 'paypal', // The default options for every gateways. 'default_options' => [ 'test_mode' => true, // ... ], /* * The gateways, you can config option by camel case or snake_case name. * * the option name is followed from gateway class, for example: * * $gateway->setMchId('overtrue'); * * you can configured as: * 'mch_id' => 'overtrue', * or: * 'mchId' => 'overtrue', */ 'gateways' => [ 'paypal' => [ 'driver' => 'PayPal_Express', 'options' => [ 'username' => env('PAYPAL_USERNAME'), 'password' => env('PAYPAL_PASSWORD'), 'signature' => env('PAYPAL_SIGNATURE'), 'test_mode' => env('PAYPAL_TEST_MODE'), ], ], // other gateways ],
install payment gateways
You need to install the gateway you want to use: omnipay#payment-gateways
Usage
Gateway instance:
LaravelPayment::gateway('GATEWAY NAME'); // GATEWAY NAME is key name of `gateways` configuration. LaravelPayment::gateway('alipay'); LaravelPayment::gateway('paypal');
Using default gateway:
LaravelPayment::purchase(...);
Example:
$formData = [ 'number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '123' ]; $response = LaravelPayment::purchase([ 'amount' => '10.00', 'currency' => 'USD', 'card' => $formData, ))->send(); if ($response->isRedirect()) { // redirect to offsite payment gateway $response->redirect(); } elseif ($response->isSuccessful()) { // payment was successful: update database print_r($response); } else { // payment failed: display message to customer echo $response->getMessage(); }
For more use about Omnipay, please refer to Omnipay Official Home Page
PHP 扩展包开发
想知道如何从零开始构建 PHP 扩展包?
请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》
License
MIT
hinet/laravel-payment 适用场景与选型建议
hinet/laravel-payment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 235 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hinet/laravel-payment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hinet/laravel-payment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 235
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-02