think.studio / laravel-cashier-tools

一组未添加到主 Laravel Cashier Stripe 包中的工具。

2.2.1 2023-09-20 11:25 UTC

This package is auto-updated.

Last update: 2024-09-20 13:49:15 UTC


README

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

安装

通过 composer 安装包

composer require think.studio/laravel-cashier-tools

用法

创建促销代码命令

php artisan cashier-tools:api:create:promotion-codes COUPON_ID_2021 -P "2021$" >> codes.txt
php artisan cashier-tools:api:create:promotion-codes COUPON_ID_2021 -S 20 -C 100 --p_max_redemptions=10 --stripe-secret=sk_live_4FL... >> codes.txt

使用助手函数生成结账重定向 URL

支持重定向 URL 参数的构建器:(例如 '{CHECKOUT_SESSION_ID}')

$url = route('cpd.account.index');

$subscription->allowPromotionCodes()
             ->checkout([
                 'success_url' => StripeCheckoutUrlBuilder::prepareSuccessUrl($url),
                 'cancel_url'  => StripeCheckoutUrlBuilder::prepareCancelUrl($url),
             ]);

$subscription->checkout([
    'success_url' => StripeCheckoutUrlBuilder::make($url)
                                             ->withSessionId()
                                             ->useResultStatus('foo')
                                             ->url(),
    'cancel_url'  => StripeCheckoutUrlBuilder::make($url)
                                             ->useResultStatus('bar')
                                             ->url(),
]);

使用仪表板路由器

DashboardRouter::fromConfig()->productsUrl()
DashboardRouter::fromConfig()->productsUrl($stripeProduct->id)
(new DashboardRouter(true))->promotionCodesUrl($promotionCode->id)

致谢

  • Think Studio