Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions Assets/StashLinkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,43 @@ public void RequestCheckoutUrl(Action<string> onUrl, Action<string> onError)

private IEnumerator RequestCheckoutUrlCoroutine(Action<string> onUrl, Action<string> onError)
{
// Determine purchase platform dynamically
string platformValue;
var item = new QuickPayItem
{
id = "test_item_id",
pricePerItem = "0.99",
quantity = 1,
imageUrl = "https://storage.googleapis.com/stash_assets/stash_logo_128.png",
name = "Test Item",
description = "A description of the test item"
};

// The platform enum only knows IOS and ANDROID. Desktop players omit the field (UNDEFINED, the
// web channel with every wallet enabled); an unknown value would be dropped anyway.
string json;
#if UNITY_IOS || UNITY_ANDROID
#if UNITY_IOS
platformValue = "IOS";
#elif UNITY_ANDROID
platformValue = "ANDROID";
const string platformValue = "IOS";
#else
platformValue = Application.platform.ToString().ToUpper();
const string platformValue = "ANDROID";
#endif

var request = new QuickPayRequest
json = JsonUtility.ToJson(new QuickPayRequest
{
regionCode = "USA",
currency = "USD",
item = new QuickPayItem
{
id = "test_item_id",
pricePerItem = "0.99",
quantity = 1,
imageUrl = "https://storage.googleapis.com/stash_assets/stash_logo_128.png",
name = "Test Item",
description = "A description of the test item"
},
user = new QuickPayUser
{
id = "test_user_id",
validatedEmail = "test@domain.com",
platform = platformValue
}
};
item = item,
user = new QuickPayUser { id = "test_user_id", validatedEmail = "test@domain.com", platform = platformValue }
});
#else
json = JsonUtility.ToJson(new QuickPayDesktopRequest
{
regionCode = "USA",
currency = "USD",
item = item,
user = new QuickPayDesktopUser { id = "test_user_id", validatedEmail = "test@domain.com" }
});
#endif

byte[] body = Encoding.UTF8.GetBytes(JsonUtility.ToJson(request));
byte[] body = Encoding.UTF8.GetBytes(json);
using (var www = new UnityWebRequest(QUICK_PAY_ENDPOINT, "POST"))
{
www.uploadHandler = new UploadHandlerRaw(body);
Expand Down Expand Up @@ -181,6 +186,8 @@ private static string FormatRequestError(UnityWebRequest www)
[Serializable] private class QuickPayRequest { public string regionCode; public string currency; public QuickPayItem item; public QuickPayUser user; }
[Serializable] private class QuickPayItem { public string id; public string pricePerItem; public int quantity; public string imageUrl; public string name; public string description; }
[Serializable] private class QuickPayUser { public string id; public string validatedEmail; public string regionCode; public string platform; }
[Serializable] private class QuickPayDesktopRequest { public string regionCode; public string currency; public QuickPayItem item; public QuickPayDesktopUser user; }
[Serializable] private class QuickPayDesktopUser { public string id; public string validatedEmail; public string regionCode; }
[Serializable] private class QuickPayResponse { public string id; public string url; public string regionCode; }
[Serializable] private class AuthenticatedUrlRequest { public AuthenticatedUrlUser user; public string target; }
[Serializable] private class AuthenticatedUrlUser { public string id; }
Expand Down
3 changes: 3 additions & 0 deletions Assets/StashSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class StashSample : MonoBehaviour

private void Awake()
{
// Desktop players: start the browser processes now so the first checkout opens instantly (no-op on mobile).
StashNative.Instance.Prewarm();

StashNative.Instance.OnExternalPayment += url =>
SetStatus("External payment" + url);

Expand Down
19 changes: 19 additions & 0 deletions Packages/gg.stash.unity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [2.4.0] - 2026-08-26

### Added

- **Windows and macOS players.** `OpenCard`, `OpenModal` and `OpenBrowser` now work in Standalone Windows (x64, WebView2 Evergreen runtime) and macOS (11+, universal) players through the **Embedded Stash Native SDK [2.4.0](https://github.com/stashgg/stash-native/releases/tag/2.4.0)** desktop hosts (`Plugins/Windows/x86_64/StashNativeDesktop.dll`, `Plugins/macOS/StashNativeDesktop.bundle`). The checkout is a card over the game window; the same callbacks, per-call callbacks and config structs apply. Ratio fields are ignored on desktop (fixed 480 x 720 pt card, 480 x 600 pt modal). `OnBrowserClosed` is not raised on desktop.
- **`StashNative.Prewarm()`** (desktop: creates the browser processes ahead of the first checkout) and **`StashNative.SetInspectableWebViewsEnabled(bool)`** (desktop: Safari Web Inspector / Edge DevTools on the checkout webview). No-ops elsewhere.
- Exclusive fullscreen on Windows is switched to borderless for the checkout and restored afterwards.
- EditMode tests (`Tests/Editor`) and a `test.yml` workflow; `main.yml` builds `StandaloneWindows64` and `StandaloneOSX`.

### Changed

- **Editor simulator** presents card and modal flows through the desktop host in a standalone window (device presets kept, card config no longer dropped, callbacks routed like on a device). Play mode with a Standalone build target opens the desktop host with the desktop sizing.
- **Sample**: `StashLinkGenerator` omits `platform` for desktop players (the API enum only knows `IOS` / `ANDROID`); `StashSample` calls `Prewarm()` at startup.
- Package now targets Android, iOS, Windows and macOS (`package.json` description and keywords).

### Removed

- The editor-only WebView natives `Editor/Windows` (WebView2 launcher DLL) and `Editor/macOS` (WKWebView launcher bundle) and their `Stash.Editor.Windows.WebViewLauncher` / `Stash.Editor.macOS.WebViewLauncher` types. The simulator uses the shipped desktop hosts instead.

## [2.3.0] - 2026-07-28

### Changed
Expand Down
57 changes: 32 additions & 25 deletions Packages/gg.stash.unity/Samples~/StashSample/StashLinkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,43 @@ public void RequestCheckoutUrl(Action<string> onUrl, Action<string> onError)

private IEnumerator RequestCheckoutUrlCoroutine(Action<string> onUrl, Action<string> onError)
{
// Determine purchase platform dynamically
string platformValue;
var item = new QuickPayItem
{
id = "test_item_id",
pricePerItem = "0.99",
quantity = 1,
imageUrl = "https://storage.googleapis.com/stash_assets/stash_logo_128.png",
name = "Test Item",
description = "A description of the test item"
};

// The platform enum only knows IOS and ANDROID. Desktop players omit the field (UNDEFINED, the
// web channel with every wallet enabled); an unknown value would be dropped anyway.
string json;
#if UNITY_IOS || UNITY_ANDROID
#if UNITY_IOS
platformValue = "IOS";
#elif UNITY_ANDROID
platformValue = "ANDROID";
const string platformValue = "IOS";
#else
platformValue = Application.platform.ToString().ToUpper();
const string platformValue = "ANDROID";
#endif

var request = new QuickPayRequest
json = JsonUtility.ToJson(new QuickPayRequest
{
regionCode = "USA",
currency = "USD",
item = new QuickPayItem
{
id = "test_item_id",
pricePerItem = "0.99",
quantity = 1,
imageUrl = "https://storage.googleapis.com/stash_assets/stash_logo_128.png",
name = "Test Item",
description = "A description of the test item"
},
user = new QuickPayUser
{
id = "test_user_id",
validatedEmail = "test@domain.com",
platform = platformValue
}
};
item = item,
user = new QuickPayUser { id = "test_user_id", validatedEmail = "test@domain.com", platform = platformValue }
});
#else
json = JsonUtility.ToJson(new QuickPayDesktopRequest
{
regionCode = "USA",
currency = "USD",
item = item,
user = new QuickPayDesktopUser { id = "test_user_id", validatedEmail = "test@domain.com" }
});
#endif

byte[] body = Encoding.UTF8.GetBytes(JsonUtility.ToJson(request));
byte[] body = Encoding.UTF8.GetBytes(json);
using (var www = new UnityWebRequest(QUICK_PAY_ENDPOINT, "POST"))
{
www.uploadHandler = new UploadHandlerRaw(body);
Expand Down Expand Up @@ -181,6 +186,8 @@ private static string FormatRequestError(UnityWebRequest www)
[Serializable] private class QuickPayRequest { public string regionCode; public string currency; public QuickPayItem item; public QuickPayUser user; }
[Serializable] private class QuickPayItem { public string id; public string pricePerItem; public int quantity; public string imageUrl; public string name; public string description; }
[Serializable] private class QuickPayUser { public string id; public string validatedEmail; public string regionCode; public string platform; }
[Serializable] private class QuickPayDesktopRequest { public string regionCode; public string currency; public QuickPayItem item; public QuickPayDesktopUser user; }
[Serializable] private class QuickPayDesktopUser { public string id; public string validatedEmail; public string regionCode; }
[Serializable] private class QuickPayResponse { public string id; public string url; public string regionCode; }
[Serializable] private class AuthenticatedUrlRequest { public AuthenticatedUrlUser user; public string target; }
[Serializable] private class AuthenticatedUrlUser { public string id; }
Expand Down
3 changes: 3 additions & 0 deletions Packages/gg.stash.unity/Samples~/StashSample/StashSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class StashSample : MonoBehaviour

private void Awake()
{
// Desktop players: start the browser processes now so the first checkout opens instantly (no-op on mobile).
StashNative.Instance.Prewarm();

StashNative.Instance.OnExternalPayment += url =>
SetStatus("External payment" + url);
}
Expand Down
9 changes: 6 additions & 3 deletions Packages/gg.stash.unity/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"name": "gg.stash.unity",
"displayName": "Stash for Unity",
"version": "2.3.0",
"version": "2.4.0",
"unity": "2021.3",
"unityRelease": "0f1",
"description": "Native-feeling Stash Pay IAP checkout and webshop presentation directly inside your Unity game (Android/iOS).",
"description": "Native-feeling Stash Pay IAP checkout and webshop presentation directly inside your Unity game (Android, iOS, Windows, macOS).",
"keywords": [
"stash",
"iap",
"d2c",
"checkout",
"webshop",
"payments"
"payments",
"desktop",
"windows",
"macos"
],
"author": {
"name": "Stash",
Expand Down
Loading
Loading