Integrating Stash Pay
Learn how to integrate Stash Pay into your game or app with minimum setup. This guide covers creating checkout links, displaying checkouts in browser or in-app, and handling webhook events for secure payment processing.
Stash Pay is a direct-to-consumer payment system for games and apps.
This guide shows how to integrate it with the minimum setup, whether for a browser based or in-app purchases.
The video below walks you through the process.
Before you start
Before integrating Stash Pay, make sure you have:
- Access to Stash Studio, our developer portal.
- An API key created in Stash Studio.
- A webshop or game client where you want to trigger purchases.
Create a checkout link
Send a POST request to the /sdk/server/checkout_links/generate_quick_pay_url endpoint from your backend to start a Stash Pay purchase.
Include your API key in the request header as X-Stash-Api-Key: YOUR_API_KEY.
Ensure that this request is made server-side to keep your Stash API key secure.
Checkout link request
Here's a sample payload for creating a checkout link:
{
"item": {
"id": "",
"pricePerItem": "",
"quantity": 1,
"imageUrl": "",
"name": "",
"description": ""
},
"user": {
"id": "",
"validatedEmail": "",
"profileImageUrl": "",
"displayName": "",
"regionCode": "",
"platform": "UNDEFINED"
},
"transactionId": "",
"regionCode": "",
"currency": ""
}| Parameter | Type | Description |
|---|---|---|
| item | object | The item being purchased. Fields: - id: Unique identifier for the item.- pricePerItem: Price per item in the smallest currency unit (e.g., cents).- quantity: Number of items being purchased.- imageUrl: Optional image representing the item.- name: Name of the item.- description: Short description of the item. |
| user | object | Information about the purchasing user. Fields: - id: Unique user ID (from your system).- validatedEmail: (optional) Email address if available and validated.- profileImageUrl: (optional) Link to the user's avatar image.- displayName: User display name.- regionCode: (optional) User's region code for localization.- platform: Platform string, e.g., IOS, ANDROID, or UNDEFINED. |
| transactionId | string | Unique transaction identifier generated by your backend for idempotency and tracking. |
| regionCode | string | (optional) Region/country code for payment localization (e.g., "US"). |
| currency | string | ISO 4217 currency code for the transaction (e.g., "USD", "EUR"). |
Checkout link response
If the request succeeds, send the url or id to your game client to present the checkout to the user.
{
"url": "https://store.example.com/order/abc123",
"id": "abc123",
"regionCode": "US"
}Displaying the checkout
You can display the checkout in a browser or in-app. Choose the option that works best for your integration.
Browser Purchase
Display the URL on the user's device.
window.open(stash_pay_url, '_blank');Example in Unity using Application.OpenURL.
public class CheckoutHandler : MonoBehaviour
{
public void OpenCheckoutURL(string stash_pay_url)
{
Application.OpenURL(stash_pay_url);
}
}In-App purchase
Use this option for in-app purchases. See Apple iOS Integration section for presentation options and how Stash Pay communicates with your game client.
Handle Webhook Events
After a purchase is completed, Stash sends webhook notifications to your backend to confirm the transaction. This webhook-based messaging system ensures reliable communication between Stash and your game server, allowing you to grant items to players only after payment is confirmed.
Webhook Setup and Implementation
To handle webhook events, you need to:
Configure webhooks
Configure webhooks in Stash Studio (Settings → Webhooks)
Create a webhook listener
Create a webhook listener on your backend to receive notifications
Verify webhook signatures
Verify webhook signatures for security
Process the webhook payload
Process the webhook payload and grant items to players
For complete webhook implementation details, see our Webhooks Overview and Webhook List documentation.
How is this guide?