Example #1
0
        Promise<PurchasedProduct> IStore.LaunchPurchaseFlow(Gamer gamer, ProductInfo product)
        {
            // Already in progress? Refuse immediately.
            lock (this) {
                if (LastLaunchProductPromise != null) {
                    return Promise<PurchasedProduct>.Rejected(new CotcException(ErrorCode.AlreadyInProgress, "Launching purchase"));
                }
                LastLaunchProductPromise = new Promise<PurchasedProduct>();
            }

            Bundle interop = product.AsBundle().Clone();
            interop["userName"] = gamer.GamerId;

            // Will call back the CotcInappPurchaseGameObject
            CotcInappPurchase_launchPurchase(interop.ToJson());
            return LastLaunchProductPromise;
        }
        Promise<PurchasedProduct> IStore.LaunchPurchaseFlow(Gamer gamer, ProductInfo product)
        {
            // Already in progress? Refuse immediately.
            lock (this) {
                if (LastLaunchProductPromise != null) {
                    return Promise<PurchasedProduct>.Rejected(new CotcException(ErrorCode.AlreadyInProgress, "Launching purchase"));
                }
                LastLaunchProductPromise = new Promise<PurchasedProduct>();
            }

            // Will call back the CotcInappPurchaseGameObject
            JavaClass.CallStatic("launchPurchase", product.ToJson());
            return LastLaunchProductPromise;
        }
 /// <summary>
 /// Launches a purchase process for a given product. The purchase process is asynchronous,
 /// may take a lot of time and may not necessarily ever finish (i.e. the application may be
 /// killed before it actually finishes). That said, only one purchase process is running at
 /// at a time.
 /// </summary>
 /// <returns>promise resolved when the purchase completes with information about the purchased
 /// item. In order to validate the transaction, you need to call
 /// #CotcSdk.GamerStore.ValidateReceipt. More important, you MUST then call
 /// #CloseTransaction in case of success!</returns>
 /// <param name="gamer">gamer to associate with the purchase</param>
 /// <param name="info">information about the product to be purchased. Obtained via #FetchProductInfo.</param>
 public Promise<PurchasedProduct> LaunchPurchase(Gamer gamer, ProductInfo info)
 {
     return Store.LaunchPurchaseFlow(gamer, info);
 }