Package Repository
github.com/stashgg/stash-unity
Package Readme
Detailed usage patterns.
The Unity package is a wrapper around stash-native. We recommend reading the native SDK docs to understand the full capability set and platform-specific behavior.
Requirements
- Unity 2021.3+ (LTS recommended)
- iOS 13.0+
- Android API 21+
Install with UPM
1
Add from Git URL (recommended)
In Unity:
- Open Window -> Package Manager
- Select + -> Add package from git URL
- Enter:
2
Add via manifest.json (alternative)
In
Packages/manifest.json, add:3
(Optional) Import sample
From Package Manager, open Stash for Unity -> Samples -> Stash Integration Sample -> Import.
Android dependency recommendation
For browser flows and to ensure compatibility since some older Unity versions may bundle outdated Android libraries add these dependencies in yourAssets/Plugins/Android/mainTemplate.gradle:
androidx.browser is optional but recommended for Chrome Custom Tabs. androidx.core:1.12.0+ helps avoid compatibility issues when older plugin trees pin outdated AndroidX versions.Presentation modes
UseStashNative.Instance from Stash.Native to call one of the checkout presentation methods offered by the native package.

OpenCard
OpenModal
OpenBrowser
Landscape games and portrait checkout
If your game is landscape-locked but you want checkout in portrait, enableforcePortrait for Stash SDK to swizzle the screen rotation logic at the runtime.
- Save current
Screen.orientationand autorotation settings. - Lock orientation in Unity while card is presented.
- Restore settings in dismiss/success/failure callbacks after the checkout is over.
Android Backdrop
On Android, to avoid visual glitches (black or stretched Unity surface) when rotating from landscape to portrait checkout, you should capture a screenshot of the game and set it as the checkout backdrop by callingsetBackdropBytes(...) before OpenCard(...). Use the simply use the following snippet to do this:
If you see JNI warnings for
byte[] on specific Unity/Android stacks, convert to sbyte[] before calling setBackdropBytes.Android keep-alive service
Use keep-alive for checkout flows where users temporarily leave the Unity surface (It can be different payment methods, verification or browser absed checkout). On some Android devices, Unity can be suspended or killed while checkout runs in Custom Tabs or the system browser, and keep-alive reduces that risk by running a short foreground service during the payment window.Unity Editor simulator
OpenCard and OpenModal so you can test flow and callbacks without deploying to a device.
- Supported editor platforms: Windows and macOS
OpenBrowseris not simulated (it opens the system browser)
Detailed references
- Unity package docs and API: stash-unity README
- Native SDK behavior underneath Unity: stash-native
- Stash Pay server integration flow: /guides/stash-pay/integration