ptuchik / billing
Laravel 5.5支持的账单包,包括套餐、计划、优惠券、附加组件、支付和订阅
1.9.5
2024-07-04 13:15 UTC
Requires
- illuminate/support: ^5.5|^5.6|^5.7|^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- league/omnipay: ^3.0
- ptuchik/braintree: 1.1.6
- ptuchik/core-utilities: ^1.0
- torann/currency: ^1.0
- ucraft-com/detection: ^1.2
- dev-master
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.9
- 1.8.8
- 1.8.7
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.9
- 1.7.8
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 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
- dev-develop
- dev-hotfix/1.0_subscription_autorenew_cancel_reason
- dev-1x-develop
- dev-paymentMethodsImplementation
This package is auto-updated.
Last update: 2024-09-04 13:38:10 UTC
README
警告!!! 如果您已经在使用v1.x版本,请继续使用它,v2.x可能存在一些向后不兼容性...
为一切卖任何东西...
Laravel 5.5+支持的账单包,包括多货币的套餐、计划、优惠券、附加组件、支付和订阅
结构
结构如下
- Billable - 将支付所有费用的模型
- Hostable - 可以购买所有内容的模型
- Package - 可以购买的模型
- Plan - 将出售Package的模型
- Reference - 可以是任何模型,将随Package一起购买
- Coupon - 可以应用于Plan购买的折扣
概念
概念如下:为了能够使用此包,首先需要将Billable
特征添加到您的账单模型,并实现Billable
接口(通常是User模型)。可托管模型必须实现Hostable
接口并使用Hostable
特征,这将向模型添加Purchases关系。所有包都必须从PackageModel抽象类扩展。就是这样!
备注:包提供的配置中可以覆盖一切
安装
composer require ptuchik/billing
在Composer安装后,只需像往常一样运行php artisan migrate
,将额外的表添加到数据库中,并通过执行以下操作发布配置:
php artisan vendor:publish --provider="Torann\Currency\CurrencyServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\Billing\Providers\BillingServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\CoreUtilities\Providers\CoreUtilitiesServiceProvider" --tag=config
重要!您的账单模型必须具有以下属性
balance
- 转换:numericpaymentGateway
- 转换:stringpaymentProfiles
- 转换:arraycurrency
- 转换:stringparams
- 转换:array
以及isTester()
方法,该方法将指示您的账单模型是测试者还是客户,以设置正确的支付网关环境模式。如果您不需要测试者,只需在您的账单模型中创建以下方法即可
public function isTester() { return false; }
使用方法
要获取当前主机上当前用户的计划详情,包括试用天数计算和摘要(应用所有优惠券和可用余额折扣),只需调用
$plan->prepare($hostable); // Will return plan with all calculations applied for logged in user
要购买计划,只需调用
$plan->purchase($hostable); // It will do the rest automagically
文档
即将推出...
特别感谢
- Taylor Otwell,他提供了最好的框架 - Laravel
- Daniel Stainback aka Torann,他为Currencies做出了贡献
- Spatie,他为Translatable package做出了贡献
- The League of Extraordinary Packages,他为Omnipay - 多网关支付处理库做出了贡献