Settings
Payment settings and configuration.
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:
Format
Default currency format is en_US
.
To update default currency format, go to .env
file:
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:
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
.
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:
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:
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).
Free trials
To enable free trials set PAYMENT_TRIAL_DAYS
to the number of days.
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:
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.
You can also check if user is subscribed to specific price or product:
Unsubscribed users will be redirected and shown a corresponding toast notification.