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

This package is auto-updated.

Last update: 2024-12-20 14:19:58 UTC


README

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

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)

Credits

  • Think Studio