Intro

To set payment provider other than Stripe, define PAYMENT_PROVIDER variable in your .env.

Default and currently only supported payment provider is Stripe.

One-time payments

To use one-time payments set PAYMENT_PRODUCTS_TYPE to single in your .env.

Subscriptions

To use one-time payments set PAYMENT_PRODUCTS_TYPE to recurring in your .env.
This is the default setup.

Trial

To enable trial periods set PAYMENT_TRIAL_DAYS to number of days.

Currency

Default currency is set to USD.

To update default currency for your plans and application, go to .env file and update this variable:

CASHIER_CURRENCY='eur'
Currency must be defined with lowercased ISO 4217 code.

Format

Default currency format is en_US.

To update default currency format, go to .env file:

CASHIER_CURRENCY_LOCALE=de_DE
// Formatting using en_US:
// $1,000.00
// €500.00
// £19.99

// Formatting using de_DE:
// 1.000,00 $
// 500,00 €
// 19,99 £

// Formatting using nl_BE:
// US$ 1.000,00
// € 500,00
// £ 19,99

Highlighted plan

If you want to highlight specific plan, for example the best value plan, set PAYMENT_HIGHLIGHTED_PRODUCT_ID to the ID of the plan.

Cache

Some payment data, like products and coupons, is cached upon update. Cache keys are defined in config/payments.php under settings.cache_keys. Feel free to update those keys as you wish.

To delete data from cache manually you can call this command in your terminal:

php artisan cache:forget payment_products
php artisan cache:forget payment_coupons

Authenticated payments

When using one-time payments you can allow your users to buy products without registering their account.

To enable this set PAYMENT_MUST_BE_AUTHENTICATED to false.

Subscriptions require user authentication.

Address

To enforce address calculation at checkout set PAYMENT_COLLECT_ADDRESS to true.

Taxes

To enable tax calculation at checkout set PAYMENT_CALCULATE_TAXES to true.

Tax IDs

To disable customer tax IDs at checkout set PAYMENT_COLLECT_TAX_IDS to false.

Enabled by default.

Discounts

To disable discount and coupons at checkout set PAYMENT_ALLOW_DISCOUNTS to false.

Enabled by default.

Coupons

To create a coupon go to Stripe dashboard, click Product catalog in sidebar, and then click Coupons in subnav, and then click Create coupon button.

There you can set information about a percent-off or amount-off discount you might want to apply to a product, limitations, expiration, etc.

To apply coupons to products, run this command and follow the prompts:

php artisan payments:coupon

You can apply different coupon to different product, or use single coupon for all products.

Applied coupons reduce the price and cannot be removed during checkout by user. This is the Stripe feature.

To remove applied coupons from your products, run this command:

php artisan payments:remove-coupons

Promotion codes

To create a promotion code go to Stripe dashboard, click Product catalog in sidebar, then click Coupons in subnav, then create or select an existing coupon.

On coupon page, look for Promotion Codes section and create new promotion codes for this coupon.

Promotion Code represents a customer-redeemable code for a coupon.

You can also apply promotion codes to your products using the same artisan command.

To apply a promo code, you must use promotion code ID (API ID), not code (Promotion code).

Customers must apply the code (30), and not ID (promo_1Q5p…).

Free trials

To enable free trials set PAYMENT_TRIAL_DAYS to the number of days.

PAYMENT_TRIAL_DAYS=3
Free trials work only with subscriptions.

Without payment method up front

If you would like to offer trial periods without collecting the user’s payment method information up front, you may set the trial_ends_at column on the user record to your desired trial ending date.

This is typically done during user registration:

$user = User::create([
  // ...
  'trial_ends_at' => now()->addDays(3),
]);

Check if subscribed

To check if user is subscribed you can use middleware subscribed defined here app/Http/Middleware/Subscribed.php.

This will check if user has any purchased product when using single payments or valid subscription when using recurring payments.

Route::middleware(['subscribed'])->group(function () {
  Route::get('/secret-page', fn () => dd('You are subscribed'));
});

You can also check if user is subscribed to specific price or product:

Route::middleware(['subscribed:some_price_id'])->group(function () {
  Route::get('/secret-page', fn () => dd('You are subscribed to this price'));
});

Route::middleware(['subscribed:some_product_id'])->group(function () {
  Route::get('/secret-page', fn () => dd('You are subscribed to this product'));
});

Unsubscribed users will be redirected and shown a corresponding toast notification.