Stripe
Last updated
Take payments in Deskply with Stripe: add your key in the admin panel, register the webhook, and check a subscription from checkout to invoice.
Add your keys
The keys are in the Stripe dashboard under Developers → API keys. Use test mode until you go live. Stripe's own guides: API keys, Webhooks, Stripe Tax and the Stripe CLI. Checkout runs on Stripe's hosted page, so the publishable key (pk_) is not needed.
Create a restricted key
Stripe recommends a restricted key (
rk_): it can do only what you allow, so a leaked key does far less harm than a secret key (sk_), which can do anything in your account. Give it write access to customers, Checkout Sessions, the customer portal, subscriptions and their schedules, products, prices, coupons, promotion codes, invoices, refunds and SetupIntents, and read access to charges, PaymentIntents and the balance. If you collect tax with Stripe Tax, add read access to Tax settings as well.Paste it in the admin panel
Open Settings → Payment methods, paste the key and press Test. Enter your password and save. The key is stored encrypted and takes effect at once, without a restart. The page shows whether the key is in test or live mode.
If Test reports a missing permission, or a payment fails with a permission error, open the key's request logs in Stripe (Developers → API keys → the key's menu → View request logs): Stripe's error names the permission to add.
Switching from test to live mode
Plans, coupons and customers belong to the mode, and the account, of the key that created them. After a switch from a test key to a live key, or to another Stripe account, Stripe no longer finds them and checkout fails. Once the new key is saved, open Plans in this Stripe account on the same page, press Check, then Create the missing ones. It creates the plans, discounts and promo codes again in the new account and points them at it. On a server you can run sudo bash server/artisan.sh stripe:sync-catalog instead (--dry-run only lists).
Subscriptions made with the old key cannot move: those customers start a new subscription at their next checkout. Register a webhook in the new mode too, with its own signing secret.
Keeping the keys in .env instead
With a deployment pipeline or a secret manager, you can keep the keys out of the database: set them in the API's .env and turn on STRIPE_SETTINGS_FROM_ENV. Settings → Payment methods then shows them read-only. Without that switch, the .env values apply only while nothing is saved in the panel.
STRIPE_SETTINGS_FROM_ENV=true
STRIPE_SECRET_KEY=rk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...The saved keys are encrypted with the API's APP_KEY. Keep APP_KEY in your backups: if it changes, the panel asks you to enter the keys again.

Settings → Payment methods: the key on top, the webhook below it.
Register the webhook
Stripe tells the API when a payment succeeds or a subscription changes. Without the webhook, a customer pays and their plan never activates.
Add an endpoint in Stripe
Under Developers → Webhooks, add the address of the API followed by
/api/v1/admin/webhooks/stripe. Settings → Payment methods shows the full address, ready to copy.When Stripe asks, choose the Snapshot payload (not Thin) and the API version that Settings → Payment methods shows: the version of the Stripe library in the API.
Choose the events
Send these 19 events to it. Settings → Payment methods lists them with a copy button:
Events What the app does with them checkout.session.completedcheckout.session.async_payment_succeededcheckout.session.async_payment_failedStarts the plan, or the credit pack, once the payment is through customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedcustomer.subscription.trial_will_endFollows the subscription: plan changes, cancellations, the end of a trial invoice.paidinvoice.payment_succeededinvoice.payment_failedinvoice.payment_action_requiredinvoice.upcomingRenews the plan and its limits, records the payment, and tells the customer about a failed payment or the next renewal invoice.finalization_failedcustomer.updatedNotices when Stripe Tax cannot finalize an invoice for want of the customer's address, and when the customer corrects it subscription_schedule.updatedsubscription_schedule.canceledApplies a plan change planned for the next renewal refund.createdcharge.dispute.createdcharge.dispute.closedEnds or keeps the plan after a refund or a dispute A missing event fails quietly: without the refund and dispute events, for example, a refunded customer keeps their plan. Compare the endpoint with the list in Settings → Payment methods after every update.
Copy the signing secret
Stripe shows a secret that starts with
whsec_. Paste it under Settings → Payment methods and save. Test mode and live mode each have their own webhook and secret.
The API stores every event it receives and handles it on the queue worker, so the worker must run. An event whose handling fails is tried again every hour, and every night each running subscription is compared with Stripe and corrected.
Tax and currencies
Plans, credit packs and fixed discounts are priced in one platform currency: STRIPE_CURRENCY in the API's .env, a lower-case code such as usd (the default), eur or gbp. Choose it before you create the first plan: a Stripe price keeps its currency, so plans created before a change keep charging the old one. Three settings then change what customers pay at checkout.
| Setting | Where | What it does |
|---|---|---|
| Collect tax with Stripe Tax | Settings → Billing rules | Checkout asks for the customer's address and adds sales tax, VAT or GST. Turn on Stripe Tax in the Stripe Dashboard first: give it your business address, choose whether your prices include tax, and add a registration for each place where you are registered to collect tax. Without a registration Stripe collects nothing. |
| Charge in the customer's local currency | Settings → Billing rules | Stripe converts the prices into the customer's currency at checkout (Adaptive Pricing). |
| Prices in other currencies | Subscription → Packages, on each package | Your own fixed price per currency, which Checkout shows to customers in that currency. A fixed-amount discount then needs an amount in each of those currencies. |
Tax is your decision
Which taxes you must collect depends on where your business and your customers are. Ask a tax adviser before you add registrations; the app only passes your choice on to Stripe.
Test the checkout
- Create a plan in the admin panel. See Plans and billing.
- Sign in as a customer, open Billing & Usage → Adjust Plan and choose the plan.
- Pay with the Stripe test card
4242 4242 4242 4242, any future date and any CVC. The other test cards stand for declines and extra checks. - Back in the app, the plan is active and the payment is listed under Payments, and under Payment History in the admin panel.