samsin33/laravel-razorpay
Composer 安装命令:
composer require samsin33/laravel-razorpay
包简介
Laravel razorpay provides support for Laravel with Razorpay.
README 文档
README
Razorpay package for laravel. Supports razorpay integration with laravel version 8.
Installation
Just install samsin33/laravel-razorpay package with composer.
$ composer require samsin33/laravel-razorpay
It uses razorpay/razorpay package and will be installed automatically.
Database Migration
Razorpay service provider registers its own database migration directory, so remember to migrate your database after installing the package. The Razorpay migrations will add several columns to your customers and orders table as well as create new plans and subscriptions table to hold all of your customer's subscriptions:
$ php artisan migrate
If you need to overwrite the migrations that ship with this package, you can publish them using the vendor:publish Artisan command:
$ php artisan vendor:publish --tag="razorpay-migrations"
If you would like to prevent Razorpay's migrations from running entirely, you may use the ignoreMigrations method provided by Razorpay. Typically, this method should be called in the register method of your AppServiceProvider:
use Laravel\Razorpay\Razorpay; /** * Register any application services. * * @return void */ public function register() { Razorpay::ignoreMigrations(); }
Env Configuration
Razorpay assumes your customer model will be the App\Models\User class that ships with Laravel. If you wish to change this you can specify a different model in your .env file:
RAZORPAY_MODEL=App\Models\User
Razorpay assumes your order model will be the App\Models\Order class that ships with Laravel. If you wish to change this you can specify a different model in your .env file:
RAZORPAY_ORDER_MODEL=App\Models\Order
Next, you should configure your Razorpay API keys in your application's .env file. You can retrieve your Razorpay API keys from the Razorpay control panel:
RAZORPAY_KEY=your-razorpay-key RAZORPAY_SECRET=your-razorpay-secret
The default razorpay currency is Indian Rupee (INR). You can change the default currency by setting the RAZORPAY_CURRENCY environment variable within your application's .env file:
RAZORPAY_CURRENCY=INR
Model Configuration
Before using Razorpay, add the Billable trait to your customer model definition. Typically, this will be the App\Models\User model. This trait provides various methods to allow you to perform common tasks, such as fatching, creating and updating customer method information:
use Laravel\Razorpay\Billable; class User extends Authenticatable { use Billable; }
Before using Razorpay, add the Orderable trait to your order model definition. Typically, this will be the App\Models\Order model. This trait provides various methods to allow you to perform common tasks, such as fatching, creating and updating order method information:
use Laravel\Razorpay\Orderable; class Order extends Model { use Orderable; }
Customers
Retrieving Customers
You can retrieve a customer by their Razorpay ID using the Razorpay::findBillable method. This method will return an instance of the billable model:
use Laravel\Razorpay\Razorpay; $user = Razorpay::findBillable($razorpayId);
Creating Customers
You can create a Razorpay customer by using the createRazorpayCustomer method in a billable model:
$razorpay_customer = $user->createRazorpayCustomer($options);
You may use the getRazorpayCustomer method if you want to return the Razorpay customer object for a billable model:
$razorpay_customer = $user->getRazorpayCustomer();
Orders
Creating Orders
You can create a Razorpay order by using the createRazorpayOrder method in a orderable model:
$razorpay_order = $user->createRazorpayOrder($options);
You may use the getRazorpayOrder method if you want to return the Razorpay orders for a orderable model:
$razorpay_customer = $user->getRazorpayOrder();
You may use the getRazorpayOrderPayments method if you want to return the Razorpay order payments for a orderable model:
$razorpay_customer = $user->getRazorpayOrderPayments();
samsin33/laravel-razorpay 适用场景与选型建议
samsin33/laravel-razorpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「billing」 「razorpay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 samsin33/laravel-razorpay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 samsin33/laravel-razorpay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 samsin33/laravel-razorpay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Razorpay PHP Client Library
Laravel Cashier provides an expressive, fluent interface to Braintree's subscription billing services.
Metamel Addresses is a polymorphic Laravel package, for address book management. You can add addresses to any eloquent model with ease.
Razorpay PHP Client Library
Razorpay Omnipay 3.0 plugin for accepting payments
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-22