Skip to content

Commit 22b76af

Browse files
committed
fix: price formatting updated to have a callback
1 parent 000d826 commit 22b76af

6 files changed

Lines changed: 23 additions & 11 deletions

File tree

Assets/PlayroomKit/PlayroomKit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ public void GetDiscordEntitlements(Action<List<DiscordEntitlement>> callback)
371371
CheckPlayRoomInitialized();
372372
_playroomService.GetDiscordEntitlements(callback);
373373
}
374-
375-
public string DiscordPriceFormat(float price, string currency, string locale = "en-US")
374+
375+
public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback)
376376
{
377377
CheckPlayRoomInitialized();
378-
return _playroomService.DiscordPriceFormat(price, currency, locale);
378+
_playroomService.DiscordPriceFormat(price, currency, locale, callback);
379379
}
380380
#endregion
381381
}

Assets/PlayroomKit/modules/Headers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private static extern string GetPersistentDataInternal(string key,
180180
private static extern void GetDiscordEntitlementsInternal(Action<string> callback);
181181

182182
[DllImport("__Internal")]
183-
private static extern string DiscordPriceFormatInternal(float price, string currency, string locale = "en-US");
183+
private static extern string DiscordPriceFormatInternal(float price, string currency, string locale, Action<string> callback);
184184

185185
#endregion
186186
}

Assets/PlayroomKit/modules/Interfaces/IPlayroomBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void InsertCoin(InitOptions options = null, Action onLaunchCallBack = nul
7676
public void StartDiscordPurchase(string skuId, Action<string> callback = null);
7777
public void GetDiscordSkus(Action<List<DiscordSku>> callback);
7878
public void GetDiscordEntitlements(Action<List<DiscordEntitlement>> callback);
79-
public string DiscordPriceFormat(float price, string currency, string locale = "en-US");
79+
public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback);
8080
#endregion
8181

8282

Assets/PlayroomKit/modules/MockMode/BrowserMode/BrowserMockService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ public void GetDiscordEntitlements(Action<List<DiscordEntitlement>> callback)
338338
callback?.Invoke(new List<DiscordEntitlement>());
339339
}
340340

341-
public string DiscordPriceFormat(float price, string currency, string locale = "en-US")
341+
public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback)
342342
{
343343
DebugLogger.LogWarning("[MockMode] Discord SKUs are currently not supported in browser mock mode!");
344-
return default;
344+
callback?.Invoke("");
345345
}
346346
#endregion
347347
}

Assets/PlayroomKit/modules/MockMode/LocalPlayroomService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ public void GetDiscordEntitlements(Action<List<DiscordEntitlement>> callback)
238238
callback?.Invoke(new List<DiscordEntitlement>());
239239
}
240240

241-
public string DiscordPriceFormat(float price, string currency, string locale = "en-US")
241+
public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback)
242242
{
243243
DebugLogger.LogWarning("[MockMode] Discord SKUs are currently not supported in local mode!");
244-
return default;
244+
callback?.Invoke($"${price}");
245245
}
246246
#endregion
247247
}

Assets/PlayroomKit/modules/PlayroomBuildService.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,22 @@ private static void DiscordEntitlementsCallback(string data)
497497
}
498498
}
499499

500-
public string DiscordPriceFormat(float price, string currency, string locale = "en-US")
500+
public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback)
501501
{
502502
CheckPlayRoomInitialized();
503-
return DiscordPriceFormatInternal(price, currency, locale);
503+
504+
Debug.Log($"[Unity]: price {price}, currency {currency}, locale {locale}");
505+
506+
CallbackManager.RegisterCallback(callback, "formattedPrice");
507+
DiscordPriceFormatInternal(price, currency, locale, DiscordPriceFormatCallbackInvoker);
508+
}
509+
510+
[MonoPInvokeCallback(typeof(Action<string>))]
511+
private static void DiscordPriceFormatCallbackInvoker(string formattedPrice)
512+
{
513+
Debug.LogWarning($"UNITY: {formattedPrice}");
514+
515+
CallbackManager.InvokeCallback("formattedPrice", formattedPrice);
504516
}
505517
#endregion
506518

0 commit comments

Comments
 (0)