think.studio / laravel-cashier-tools
Set of utils what not added to main laravel cashier stripe package.
2.2.1
2023-09-20 11:25 UTC
Requires
- php: ^8.1
- laravel/cashier: ^14.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.1
- psalm/plugin-laravel: ^2.8
- vimeo/psalm: ^5.11
README
Installation
Install the package via composer:
composer require think.studio/laravel-cashier-tools
Usage
Create promotion codes command
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
Use helper for checkout redirect url
Builder to support redirect url params: (Like '{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(), ]);
Use dashboard router
DashboardRouter::fromConfig()->productsUrl() DashboardRouter::fromConfig()->productsUrl($stripeProduct->id) (new DashboardRouter(true))->promotionCodesUrl($promotionCode->id)