123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- using System;
- using Pico.Platform.Models;
- using UnityEngine;
- namespace Pico.Platform
- {
-
- public static class IAPService
- {
-
-
-
-
-
- public static Task ConsumePurchase(string sku)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task(CLIB.ppf_IAP_ConsumePurchase(sku));
- }
-
-
-
- public static Task<ProductList> GetProductsBySKU(string[] skus)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- if (skus == null)
- {
- skus = Array.Empty<string>();
- }
- return new Task<ProductList>(CLIB.ppf_IAP_GetProductsBySKU(skus));
- }
-
-
- public static Task<PurchaseList> GetViewerPurchases()
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<PurchaseList>(CLIB.ppf_IAP_GetViewerPurchases());
- }
-
-
-
-
-
-
-
-
-
-
-
- [Obsolete("Please use LaunchCheckoutFlow2(Product product)", false)]
- public static Task<Purchase> LaunchCheckoutFlow(string sku, string price, string currency)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<Purchase>(CLIB.ppf_IAP_LaunchCheckoutFlow(sku, price, currency));
- }
-
-
-
-
-
-
-
-
- public static Task<Purchase> LaunchCheckoutFlow2(Product product)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<Purchase>(CLIB.ppf_IAP_LaunchCheckoutFlowV2(product.SKU, product.Price, product.Currency, product.OuterId));
- }
-
-
-
-
-
-
-
-
-
-
-
- public static Task<Purchase> LaunchCheckoutFlow3(Product product, string orderComment)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<Purchase>(CLIB.ppf_IAP_LaunchCheckoutFlowV3(product.SKU, product.Price, product.Currency, product.OuterId, orderComment));
- }
-
-
-
-
-
-
-
- public static Task<SubscriptionStatus> GetSubscriptionStatus(string sku)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- return new Task<SubscriptionStatus>(CLIB.ppf_IAP_GetSubscriptionStatus(sku));
- }
-
-
-
-
-
- public static Task<ProductList> GetNextProductListPage(ProductList list)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- if (!list.HasNextPage)
- {
- Debug.LogWarning("Pico.Platform.GetNextProductListPage: List has no next page");
- return null;
- }
- return new Task<ProductList>(
- CLIB.ppf_IAP_GetNextProductArrayPage(list.NextPageParam)
- );
- }
-
-
-
-
-
- public static Task<PurchaseList> GetNextPurchaseListPage(PurchaseList list)
- {
- if (!CoreService.Initialized)
- {
- Debug.LogError(CoreService.NotInitializedError);
- return null;
- }
- if (!list.HasNextPage)
- {
- Debug.LogWarning("Pico.Platform.GetNextPurchaseListPage: List has no next page");
- return null;
- }
- return new Task<PurchaseList>(CLIB.ppf_IAP_GetNextPurchaseArrayPage(list.NextPageParam));
- }
- }
- }
|