starfolksoftware / paystack-subscription
v0.2.1
2023-02-15 11:28 UTC
Requires
- php: ^7.3|^8.0
- ext-json: *
- doctrine/dbal: 2.11.*
- dompdf/dompdf: ^0.8.0
- friendsofphp/php-cs-fixer: ^2.18
- illuminate/contracts: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/database: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/http: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/log: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/notifications: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/routing: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/view: ^6.0|^7.0|^8.0|^9.0|^10.0
- moneyphp/money: ^3.2
- nesbot/carbon: ^2.0
- php-curl-class/php-curl-class: ^8.9
- staudenmeir/belongs-to-through: ^2.5
- symfony/http-kernel: ^4.3|^5.0|^6.0
- symfony/intl: ^4.3|^5.0|^6.0
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.1
- mockery/mockery: ^1.0
- orchestra/testbench: ^6.0
- phpcompatibility/php-compatibility: *
- phpunit/phpunit: ^9.3
- vimeo/psalm: ^4.7
README
Paysub 为 Laravel 应用程序提供基本的订阅管理。目前仅支持 paystack 支付。
开发者预览 [不要在生产环境中使用]
此项目处于开发者预览阶段,所有 API 可能会无警告更改,并且不提供关于稳定性的保证。请勿在生产环境中使用。
安装
您可以通过 composer 安装此包
composer require starfolksoftware/paysub
使用以下命令运行迁移
php artisan migrate
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="StarfolkSoftware\Paysub\PaysubServiceProvider" --tag="config"
这是已发布配置文件的内容
<?php return [ /* |-------------------------------------------------------------------------- | Paystack Keys |-------------------------------------------------------------------------- | | The Paystack publishable key and secret key give you access to Paystack's | API. The "publishable" key is typically used when interacting with | Paystack.js while the "secret" key accesses private API endpoints. | */ 'key' => env('PAYSTACK_KEY'), 'secret' => env('PAYSTACK_SECRET'), /* |-------------------------------------------------------------------------- | Paystack Subscription Path |-------------------------------------------------------------------------- | | This is the base URI path where Paystack Subscription's views, such as the payment | verification screen, will be available from. You're free to tweak | this path according to your preferences and application design. | */ 'path' => env('PAYSUB_SUBSCRIPTION_PATH', 'paysub'), /* |-------------------------------------------------------------------------- | Paystack Subscription Model |-------------------------------------------------------------------------- | | This is the model in your application that implements the Billable trait | provided by Paystack Subscription. It will serve as the primary model you use while | interacting with Paystack Subscription related methods, subscriptions, and so on. | */ 'subscriber_model' => env('PAYSUB_SUBSCRIPTION_MODEL', class_exists(App\Models\User::class) ? App\Models\User::class : App\User::class), /* |-------------------------------------------------------------------------- | Tables' names |-------------------------------------------------------------------------- | | Define the package's table names here | */ 'subscriber_table_name' => env('PAYSUB_SUBSCRIBER_TABLE', 'users'), 'subscription_table_name' => env('PAYSUB_SUBSCRIPTION_TABLE', 'paysub_subscriptions'), 'plan_table_name' => env('PAYSUB_PLAN_TABLE', 'paysub_plans'), 'authorization_table_name' => env('PAYSUB_AUTHORIZATION_TABLE', 'paysub_authorizations'), 'invoice_table_name' => env('PAYSUB_INVOICE_TABLE', 'paysub_invoices'), 'payment_table_name' => env('PAYSUB_PAYMENT_TABLE', 'paysub_payments'), 'card_table_name' => env('PAYSUB_CARD_TABLE', 'paysub_cards'), 'auth_table_name' => env('PAYSUB_AUTH_TABLE', 'paysub_authorizations'), /* |-------------------------------------------------------------------------- | Currency |-------------------------------------------------------------------------- | | This is the default currency that will be used when generating charges | from your application. Of course, you are welcome to use any of the | various world currencies that are currently supported via Paystack. | */ 'currency' => env('PAYSUB_CURRENCY', 'NGN'), /* |-------------------------------------------------------------------------- | Taxes |-------------------------------------------------------------------------- | | Tax definitions for invoice. | */ 'invoice_taxes' => [ // ['name' => 'VAT', 'percentage' => 7.5] ], /* |-------------------------------------------------------------------------- | Company Contact Detail |-------------------------------------------------------------------------- | | Contact details for the billable. This will be shown in invoices sent | to billables. | */ 'contact_detail' => [ 'vendor' => '', 'street' => '', 'location' => '', 'phone' => '', 'url' => '', 'vatInfo' => '', ], /* |-------------------------------------------------------------------------- | Invoice Paper Size |-------------------------------------------------------------------------- | | This option is the default paper size for all invoices generated using | Paystack Subscription. You are free to customize this settings based on the usual | paper size used by the customers using your Laravel applications. | | Supported sizes: 'letter', 'legal', 'A4' | */ 'paper' => env('PAYSUB_PAPER', 'letter'), /* |-------------------------------------------------------------------------- | Paystack Logger |-------------------------------------------------------------------------- | | This setting defines which logging channel will be used by the Paystack | library to write log messages. You are free to specify any of your | logging channels listed inside the "logging" configuration file. | */ 'logger' => env('PAYSUB_LOGGER'), ];
使用方法
<?php ... StarfolkSoftware\Paysub\Traits\CanBeBilled; class User extends Model { use CanBeBilled; public function paystackEmail(): string { return 'user@example.com'; } public function invoiceMailables(): array { return [ 'user@example.com' ]; } }
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近的变化。
路线图
- 支持多个计划
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全漏洞
请查看 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。