Integration overview
1
Display available plans
Fetch plans from the API and show them to players.
2
Create subscription checkout When a player selects a plan, create a
subscription checkout link.
3
Handle webhooks Process subscription lifecycle events on your backend.
4
Manage subscriptions
Let players view, cancel, or reactivate their subscriptions.
Display available plans
Fetch available subscription plans using the List Plans endpoint.List Plans Request
Plan response
List Plans Response
Use the
code field (e.g., monthly_premium) to identify plans in your game
logic. The id is Stash’s internal identifier.Create subscription checkout
When a player selects a plan, create a subscription checkout link using the Create Subscription Checkout Link endpoint.Create Subscription Checkout Link
Checkout Link Response
Initial payment discounts
You can customize the first payment amount using theinitialPayment field. This is useful for offering promotional pricing, trials with reduced cost, or custom first-month deals.
Discount by fixed amount:
Initial Payment with Fixed Discount
Initial Payment with Percentage Discount
Initial Payment with Custom Amount
The
initialPayment only affects the first billing cycle. Subsequent renewals
will be charged at the plan’s regular price.subscription.created webhook to your backend.
Subscription change (upgrade) checkout
To change an existing subscription (plan upgrade and/or payment method), create a subscription change checkout link with Create a subscription change checkout link:Create Subscription Change Checkout Link
url and id (for example a checkout URL like https://checkout.stash.gg/subscription/change/{checkoutLinkId}). At least one of newPlan or updatePaymentMethod must be set; see the API reference for optional fields such as billingAnchor, initialPayment, and paymentMethod.
Eligibility: active, trialing, or canceled with current_period_end still in the future (canceled but still in the paid window). If the subscription is canceled after that paid window, create a new subscription with Create Subscription Checkout Link instead.
Behavior: Creating the link only validates eligibility and stores the link—it does not reactivate a canceled subscription or apply the plan change. If the buyer abandons checkout, the subscription stays as-is (for example, still canceled). When checkout completes successfully, Stash applies the upgrade and, if the subscription was canceled-but-not-expired, reactivates it as part of that update.
See the API reference for full request and response fields.
Handle webhooks
Set up a webhook endpoint to receive subscription lifecycle events. See the Webhooks guide for general webhook setup.Subscription webhook events
Webhook payload (v2)
Subscription webhooks use a v2 payload format:subscription.created Webhook
Handling subscription.created
When you receivesubscription.created:
- Store the subscription ID and player mapping
- Grant the player access to subscription benefits
- Update your game’s subscription UI
Handle subscription.created
Handling subscription.expired
When you receivesubscription.expired:
- Revoke the player’s subscription benefits
- Update your game’s subscription UI
- Optionally prompt the player to resubscribe
Payment webhook events
Payment webhooks (payment.succeeded, payment.failed, payment.refunded, dispute.opened, dispute.closed) use the same v2 payload format as subscription events. See Payment Events in the webhook list for event types and payload schemas.
Manage subscriptions
Check subscription status
Use List Subscriptions to check a player’s active subscriptions:List Player Subscriptions
List Active Subscriptions
Cancel a subscription
Allow players to cancel their subscription using Cancel Subscription:Cancel Subscription
cancel_at_period_endbecomestrue- Player keeps access until
current_period_end - Webhook
subscription.canceledis sent
Reactivate a subscription
If a player changes their mind before the period ends, reactivate with Reactivate Subscription:Reactivate Subscription
Testing renewal scenarios
In the test environment, Stash supports simulation cards that return scripted payment outcomes for subscription initial payments and renewals. Use these cards to exercise grace periods, retry recovery, declines, and system errors without waiting on a real PSP.Simulation cards only apply in the test environment. Use any future expiration
date and a valid CVC (for example,
03/30 and 737) with the card numbers
below. For one-off checkout testing, see Test Card
Numbers.How simulation works
Each simulation card defines a sequence of outcomes keyed by billing period and retry attempt:
Within each period, retry count tracks payment attempts during that billing cycle:
Simulation test cards
Testing payment declines and reasons
The simulation cards above exercise subscription lifecycle transitions but do not producepayment.* webhooks. To test the payment-failure webhooks themselves, and the reason they carry, use the decline cards below. Each is declined with a specific reason, and Stash delivers a payment.failed webhook (and, when a renewal on an existing subscription is declined, a subscription.payment_failed webhook) whose reason field is set to the value shown.
These test cards need the payment implementation that reports decline reasons
to be enabled on your account. If a card below doesn’t produce the expected
decline, ask your Stash representative to confirm it is enabled.
03/30) and any valid CVC — the card number alone decides the outcome.
Treat any
reason value you don’t recognize as declined_other — new values
may be added over time.card_expired, use any card number above with an expiration date in the past; the payment is declined as an expired card and reason is card_expired. A failed first-time payment delivers payment.failed only; subscription.payment_failed is sent when a renewal on an existing subscription fails.
Best practices
Validate access server-side
Always validate subscription access on your game server, not just the client. Check the subscription status andaccess_end_date before granting premium features.
Handle payment failures gracefully
When you receivesubscription.payment_failed, don’t immediately revoke access. The player is in a grace period and Stash is retrying the payment. Only revoke access when you receive subscription.expired.
Cache subscription status
Cache subscription status locally to avoid API calls on every game action. Update the cache when you receive webhook events or when the player opens subscription UI.Provide clear subscription UI
Show players:- Their current plan and status
- Next billing date
- Option to cancel or manage payment method
- Clear indication if they’re in a trial period