webwizo/cashier-authorizenet
Composer 安装命令:
composer require webwizo/cashier-authorizenet
包简介
Laravel Cashier-Authorize provides an expressive, fluent interface to Authorize.net's subscription billing services.
README 文档
README
Introduction
Laravel Cashier-Authorize provides an expressive, fluent interface to Authorize.net's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier-Authorize can handle cancellation grace periods, and even generate invoice PDFs.
Basic Setup
Please read the following for the basic setup.
.env
ADN_ENV= ADN_LOG=authorize.log
ADN_API_LOGIN_ID= ADN_TRANSACTION_KEY= ADN_SECRET_KEY=Simon
ADN_ENV should be one of: sandbox, production
Migrations
You will need to make migrations that include the following:
Schema::table('users', function ($table) { $table->string('authorize_id')->nullable(); $table->string('authorize_payment_id')->nullable(); $table->string('card_brand')->nullable(); $table->string('card_last_four')->nullable(); });
Schema::create('subscriptions', function ($table) { $table->increments('id'); $table->integer('user_id'); $table->string('name'); $table->string('authorize_id'); $table->string('authorize_payment_id'); $table->text('metadata'); $table->string('authorize_plan'); $table->integer('quantity'); $table->timestamp('trial_ends_at')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamps(); });
Publish
You will need to publish the assets of this package.
php artisan vendor:publish --provider="Laravel\CashierAuthorizeNet\CashierServiceProvider"
Config
Below is an example config for a subscription with Authorize.net compatibility. You can define your subscriptions in this config.
'monthly-10-1' => [ 'name' => 'main', 'interval' => [ 'length' => 1, // number of instances for billing 'unit' => 'months' //months, days, years ], 'total_occurances' => 9999, // 9999 means without end date 'trial_occurances' => 0, 'amount' => 9.99, 'trial_amount' => 0, 'trial_days' => 0, 'trial_delay' => 0, // days you wish to delay the start of billing ]
'config/services.php'
You will need to add the following to your 'config/services.php' file, please make sure that the model matches your app's User class:
'authorize' => [ 'model' => App\User::class, ],
You can also set this value with the following .env variable: ADN_MODEL
Basic Usage
There are differences with Authorize.net vs services like Stripe. Authorize.net is a slighly slower and more restricted subscription provider. This means you cannot do things like swap subscriptions, or change quantity of subscriptions. You need to cancel, and create new subscriptions to handle those variations.
You can perform the following actions:
User::
- charge($amount, array $options = [])
- hasCardOnFile
- newSubscription($subscription, $plan)
- onTrial($subscription = 'default', $plan = null)
- onGenericTrial()
- subscribed($subscription = 'default', $plan = null)
- subscription($subscription = 'default')
- subscriptions()
- updateCard($card) // $card = ['number' => '', 'expriation' => '']
- subscribedToPlan($plans, $subscription = 'default')
- onPlan($plan)
- hasAuthorizeId()
- createAsAuthorizeCustomer($creditCardDetails)
- upcomingInvoice($plan)
- findInvoice($invoiceId)
- findInvoiceOrFail($id)
- downloadInvoice($id, array $data, $storagePath = null)
- getSubscriptionFromAuthorize($subscriptionId)
- invoices($plan)
- deleteAuthorizeProfile()
- preferredCurrency()
- taxPercentage() (this method should be added to the User Model and define that user's tax percentage ie: return 10;)
Transaction Details
Enabling the API To enable the Transaction Details API:
- Log on to the Merchant Interface at https://account.authorize.net .
- Select Settings under Account in the main menu on the left.
- Click the Transaction Details API link in the Security Settings section. The Transaction Details API screen opens.
- If you have not already enabled the Transaction Details API, enter the answer to your Secret Question, then click Enable Transaction Details API.
- When you have successfully enabled the Transaction Details API, the Settings page displays.
CRON job
You need to enable the following CRON job to check the status of your user's subscriptions. This can run as often as you like, and will check to confirm that your user's subscription is active. If the status is changed to cancelled or suspended - the system will disable their subscription locally. Your team will need to resolve the payment issue with Authorize.net and then move forward.
protected $commands = [ \Laravel\CashierAuthorizeNet\Console\SubscriptionUpdates::class, ];
$schedule->command('subscription:update')->hourly();
Limitations
Another limitation is time related. Due to the fact that Authorize.net uses a SOAP structure for its APIs, there needs to be a time delay between adding a customer with a credit card to their system and then adding a subscription to that user. This could be done easily in your app by having the user enter their credit card information, and then allowing a confirmation of the subscription they wish to purchase as another action. This time can be as little as a second, but all tests thus far with immediate adding of subscriptions fails to work, so please be mindful of this limitation when designing your app.
License
Laravel Cashier-Authorize is open-sourced software licensed under the MIT license "# cashier-authorize"
webwizo/cashier-authorizenet 适用场景与选型建议
webwizo/cashier-authorizenet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「stripe」 「laravel」 「billing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webwizo/cashier-authorizenet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webwizo/cashier-authorizenet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webwizo/cashier-authorizenet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Flexible payment integration for Laravel, lunarphp, supporting multiple payment providers.
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.
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Alfabank REST API integration
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-03