Intro
Due the limitations of Laravel Cashier for Stripe and Paddle to work with each other by default, there have been some adjustments and modifications:- updated table names:
stripe_subscriptions
stripe_subscription_items
stripe_orders
- custom models:
App\Models\Payments\Stripe\Subscription
App\Models\Payments\Stripe\SubscriptionItem
App\Models\Payments\Stripe\Order
- custom trait:
App\Traits\Billable
- custom URL for webhooks
/payment/webhook
namedcashier.webhook
Create Stripe account
Create Stripe account and add keys… Docs coming soon…Migrations
Docs coming soon…Generate products
Go toconfig/payments.php
and setup your products and plans.
You can update product name, description and features.
It is not recommended to update product IDs of existing products and prices.
Stripe does not allow updating the price amount, currency or interval for
existing prices.
payments
file and run the sync
command. Command will create a new price (or use the archived one if parameters match), set it as default (if specified) and deactivate the old price. Upon update, it’s recommended to manually delete any unused old prices. Sync command can’t delete them due the Stripe API restrictions.
Regardless of all the automatic tasks the
sync
command is doing, you should
always check the Stripe Dashboard to make sure everything is setup correctly.Sync products
To sync Stripe products with thepayments
file go to your terminal and run this command:
If you set the data manually, make sure to clear products cache when you
update them in Stripe.
Get products
To get products from Stripe, call this method:Webhooks
Stripe can notify your application of a variety of events via webhooks to sync data from Stripe with your database.It’s highly recommended to enable webhooks.
Local
- To make local webhook URL publicly accessible install Stripe CLI
- Follow the provided steps to login to stripe via stripe-cli
- Once you’re logged in, run this in your terminal:
stripe listen --forward-to localhost:8000/payment/webhook
orstripe listen --forward-to https://butchr.test/payment/webhook
- Copy webhook secret provided by stripe-cli listener to
STRIPE_WEBHOOK_SECRET
in.env
file. - CSRF should be disabled for webhooks (this is already included with boilerplate)
Resend event for testing
If you forgot to run webhooks locally or want to make some updates and additional testing, you can resend events from terminal. You can find event IDs in Stripe dashboard and then run this command.customer.subscription.updated
event.
For one-time payments you should resend checkout.session.completed
event.
Production
Once you setup the live keysSTRIPE_KEY
and STRIPE_SECRET
on your server, run this command:
STRIPE_WEBHOOK_SECRET
.
Now you are ready to use webhooks in production.
Don’t forget to optimize (cache) your application files on .env update!
Update webhooks
If you need to add new event handlers go toapp/Listeners/StripeEventListener.php
and update it accordingly.
Billing settings
Go to Billing settings in your Stripe Dashboard and setup the settings according to your requirements. If your application is using recurring payments (subscriptions) you can use Stripe invoicing system. Go to Invoicing settings and setup the settings according to your requirements.For Single payments Stripe is not creating automatic invoices as for
subscriptions. You can use their Invoicing service (which could trigger some
additional fees), custom solution via webhooks or external service. More
details here.