Troubleshooting
Common issues and solutions when integrating Stash Pay mobile SDK, including callback handling, purchase verification, and edge cases.
This guide addresses common questions and issues when integrating Stash Pay's mobile SDK (iOS/Android Unity integration).
Success Callback Not Firing
Problem
The successCallback in your Unity integration doesn't fire after a successful purchase, even though the payment completed.
Common Causes
Browser Mode Limitations
When using browser mode (SFSafariViewController on iOS or Chrome Custom Tabs on Android), callbacks are not available. Browser mode only supports the dismissCallback.
Solution: Use Stash Pay Dialog mode if you need success/failure callbacks, or handle purchase verification via webhooks and deep links.
App Backgrounded During Checkout
If the app is backgrounded or the system kills the app during checkout, callbacks may not fire when the user returns.
Solution: Always verify purchases server-side using webhooks. Never rely solely on client-side callbacks for purchase verification.
Deep Link Not Configured
If deep links aren't properly configured, the app may not receive the callback when returning from browser mode.
Solution: Ensure deep links are properly configured in both Unity and Stash Studio. See Unity Integration - Configure Deeplinks.
Verifying Purchases When Callbacks Fail
Always implement server-side purchase verification as your primary method. Client-side callbacks should only be used for immediate UI feedback.
void OnPaymentSuccess()
{
// Show immediate feedback to user
ShowSuccessMessage("Payment processing...");
// Always verify on server - don't grant items here
StartCoroutine(VerifyPurchaseOnServer());
}
IEnumerator VerifyPurchaseOnServer()
{
// Query your server to verify the purchase
// Your server should check webhooks or query Stash API
var request = UnityWebRequest.Get($"https://your-server.com/verify-purchase/{orderId}");
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success)
{
// Server confirmed purchase - now grant items
GrantItemsToPlayer();
}
else
{
// Purchase not yet confirmed - show pending message
ShowPendingMessage("Verifying purchase...");
}
}Critical: Never grant items to players based solely on client-side callbacks. Always verify purchases on your backend using webhooks or the Stash API before granting items.
How Do I Know If a Purchase Worked?
Verifying Successful Purchases
Use multiple verification methods to ensure purchase completion:
Check Webhooks (Recommended)
Your backend should receive a PURCHASE_SUCCEEDED webhook event when a purchase completes. This is the most reliable method.
Verify:
- Check your webhook endpoint logs
- Ensure webhook signature verification is working
- Confirm your server is processing webhook events correctly
Query Payment Status
Use the Get Payment Event API to check payment status:
GET https://api.stash.gg/sdk/server/payment/<payment_id>This is useful for:
- Polling when webhooks aren't available
- Verifying purchases after callback failures
- Debugging purchase issues
Check Client Callbacks (If Available)
If using Stash Pay Dialog mode, the successCallback provides immediate feedback. However, this should only be used for UI updates, not for granting items.
Remember: Browser mode doesn't support success callbacks - use webhooks or deep link handling instead.
Is This a Real Charge?
Test Environment: If you're using test cards in the test environment, no real charges occur. Test transactions are completely isolated and never process through payment networks.
Production Environment: In production, all transactions using real payment methods result in actual charges. Always verify you're in the correct environment before testing.
App Backgrounding During Checkout
What Happens When App Backgrounds
If a user backgrounds your app during checkout (switches to another app, receives a phone call, etc.), the checkout flow continues in the browser or dialog. When the user returns:
- Browser Mode: User returns via deep link after completing purchase
- Dialog Mode: Dialog may be dismissed or may persist depending on system behavior
Handling Deep Link Returns
When using browser mode, implement deep link handling to detect when users return after purchase:
void OnEnable()
{
// Unity's deep link event
Application.deepLinkActivated += OnDeepLinkActivated;
}
void OnDeepLinkActivated(string url)
{
// Check if this is a purchase return
if (url.Contains("purchase") || url.Contains("checkout"))
{
// Query server to verify purchase status
VerifyPurchaseOnServer();
}
}
void OnDisable()
{
Application.deepLinkActivated -= OnDeepLinkActivated;
}Best Practices
- Always verify on return - When the app resumes, check for pending purchases
- Use webhooks as source of truth - Don't rely on deep link parameters alone
- Handle timeout scenarios - Purchases may complete after the user returns to the app
Low-RAM Device Considerations
Performance Best Practices
On low-RAM devices, consider the following:
Use Browser Mode for Lower Memory
Browser mode (SFSafariViewController/Chrome Custom Tabs) uses less memory than the native dialog, as the browser runs in a separate process.
Minimize In-App Resources
If using Stash Pay Dialog, ensure your game releases unnecessary resources before opening checkout to prevent memory pressure.
Handle Memory Warnings
Implement proper memory warning handlers to gracefully handle system memory pressure:
void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
// App is being backgrounded - save state
SaveCheckoutState();
}
else
{
// App resumed - check for completed purchases
CheckForPendingPurchases();
}
}Common Integration Issues
Deep Link Not Working
Symptoms: App doesn't return after browser checkout, or callbacks don't fire.
Solutions:
- Verify deep link schema is registered in Unity project settings
- Confirm deep link is configured in Stash Studio
- Test deep link manually:
your-app-scheme://test - Check platform-specific deep link requirements (iOS Info.plist, Android manifest)
Webhook Not Receiving Events
Symptoms: Purchases complete but webhooks never arrive.
Solutions:
- Verify webhook URL is accessible from the internet
- Check webhook signature verification is working
- Review webhook logs in Stash Studio
- Ensure webhook endpoint returns 200 status code
- Check firewall/network configuration
Purchase Verification Fails
Symptoms: Purchase completes but server verification fails.
Solutions:
- Verify API keys are correct for the environment (test vs production)
- Check payment ID is being passed correctly
- Ensure server is querying the correct Stash API endpoint
- Verify authentication headers are included in API requests
Getting Help
If you're still experiencing issues:
- Check logs - Review Unity console logs and server logs for error messages
- Verify configuration - Double-check API keys, deep links, and webhook URLs
- Test in isolation - Test each component (callbacks, webhooks, deep links) separately
- Contact support - Reach out to Stash support with:
- Error messages from logs
- Steps to reproduce the issue
- Environment details (test vs production)
- Payment IDs or order IDs for failed transactions
How is this guide?
Unity Integration
Learn how to integrate Stash Pay into your Unity project for iOS and Android platforms. Follow this guide to install the Unity SDK, configure deep links, and display the Stash checkout in your game.
Dialog Presentations
Browse screenshots of Stash Pay SDK dialog running on various Android & iOS devices.