public override void Purchase(IAP iap) { try { if (!iapManager.isInitialized || controller == null) { LogError("IAP - Purchase Failed. Not initialized"); iapManager.PurchaseFailed(); return; } var product = controller.products.WithID(iap.sku); if (product == null || !product.availableToPurchase) { Log("IAP - Purchase Failed. Not purchasing product, either is not found or is not available for purchase"); iapManager.PurchaseFailed(); return; } controller.InitiatePurchase(product); } catch (Exception e) { Log("IAP - Purchase Failed. Exception: " + e); iapManager.PurchaseFailed(); return; } }
public void Purchase(IAP iap, Action <bool> callback) { if (build.parentGate && ui.parentGate != null) { ui.parentGate.Show(() => { purchaseCallback = callback; ui.LoadingShow(); if (store != null) { store.Purchase(iap); } else { PurchaseSucceed(new PurchaseData(iap.sku)); } }, () => { callback(false); }); return; } purchaseCallback = callback; ui.LoadingShow(); if (store != null) { store.Purchase(iap); } else { PurchaseSucceed(new PurchaseData(iap.sku)); } }
public override void Buy(SG.IAP iap) { base.Buy(iap); achievements.OnGetRevenue(); if (iap == iapManager.catboxPremium) { GetPremiumCatbox(); } else if (iap == iapManager.catboxPremiumSale) { GetPremiumCatbox(); } else if (iap == iapManager.catboxSimple) { GetSimpleCatbox(); } else if (iap == iapManager.goldfishes) { UpdateCoins(ui.shop.aquarium * ui.shop.xGoldfishes, false); } else if (iap == iapManager.sausages) { UpdateSpins(balance.shop.sausages * ui.shop.xSausages, false); } else if (iap == iapManager.skipMissions) { LevelUp(); } else if (iap == iapManager.cat) { GetRentCat(); } else if (iapManager.hats && iap == iapManager.hats) { newYearHats += balance.events.hatsPurchase; } else if (iapManager.valentines && iap == iapManager.valentines) { stValentinHearts += balance.events.heartsPurchase; } else if (iapManager.bats && iap == iapManager.bats) { halloweenBats += balance.events.batsPurchase; } SyncServer(force: true); }
public virtual void Buy(IAP iap) { revenue += Convert.ToSingle(iap.priceUSD); }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { var iap = IAP.FromSKU(args.purchasedProduct.definition.id); if (iap == null) { Log("IAP - Purchase Failed. Unrecognized product: " + args.purchasedProduct.definition.id); iapManager.PurchaseFailed(); return(PurchaseProcessingResult.Complete); } Log($"IAP - Purchase Success: {args.purchasedProduct.definition.id}, Purchase Receipt: {args.purchasedProduct.receipt}"); // {"Store":"GooglePlay","TransactionID":"GPA.1365-0610-5320-80591","Payload":"{\"json\":\"{\\\"orderId\\\":\\\"GPA.1365-0610-5320-80591\\\",\\\"packageName\\\":\\\"com.sundaygames.rhymes\\\",\\\"productId\\\":\\\"com.sundaygames.rhymes.coins2\\\",\\\"purchaseTime\\\":1457679428830,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"plfjeknfmgggeeoeplhcpccb.AO-J1Oyr-sBdnVXmUwD9JWdvYMXYsjQVVUbJ11HCIf5R6f6E0smmAVj4Lq_LoR79it8MBIc3j7FTN5i97f56UoViJ95k-R6ddJ-OjAxjoYybOsXzBoGGXuHbRBglLf1bJURFTNhYvBME8IbH0YS5Iags61ojxu1oIw\\\"}\",\"signature\":\"1GWVO1alYCTdu0Xxv+bNBNWtXiXX2XVyR+P6ItxWVPI0w7+a2c68AzpGpAVTRg6yXRTPdXX1NPt8pUlQW0vxhNEc2yRX\\/agEGx1CorFMBtNj1xJxiYyoZC85BD6+RU\\/2QnfbJXyPy\\/GzXARsdbFJMwGWmVw7ZzRMLFSEghIAjVCVHcammxgugpkzZcwEaipX6rb9G6ZsETvlBa3EosX+WukzGxiL0w1V4H0mb\\/VTcNqtejdD6akqrsbR\\/UvHcjETJQm1MKqv0K2UEog22HX4CxGCD1saFzxU0fhUTTjxYturLp8z312Qu3FmwTff+6QlPv9QwgPLRsiXC+0UmS9KvA==\"}"} var purchaseData = new PurchaseData(iap, transaction: args.purchasedProduct.transactionID); var payload = (Json.Deserialize(args.purchasedProduct.receipt) as Dictionary <string, object>)["Payload"] as string; if (platform == Platform.AppStore || platform == Platform.tvOS) { purchaseData.receipt = payload; } else if (platform == Platform.GooglePlay) { purchaseData.receipt = (Json.Deserialize(payload) as Dictionary <string, object>)["json"] as string; purchaseData.signature = (Json.Deserialize(payload) as Dictionary <string, object>)["signature"] as string; } else if (platform == Platform.WindowsPhone) { // Payload is an XML string as specified by Microsoft https://msdn.microsoft.com/en-US/library/windows/apps/windows.applicationmodel.store.currentapp.getappreceiptasync.aspx } if (build.serverPurchaseVerification) { server.VerifyPurchase(purchaseData, result => { if (result == true) { iapManager.PurchaseSucceed(purchaseData); } else if (result == false) { iapManager.PurchaseFailed(); } else { if (build.localPurchaseVerification) { LocalPurchaseVerification.Validate(args.purchasedProduct.receipt, purchaseData, success => { if (success) { iapManager.PurchaseSucceed(purchaseData); } else { iapManager.PurchaseFailed(); } }); } else { iapManager.PurchaseFailed(); } } }); return(PurchaseProcessingResult.Complete); } if (build.localPurchaseVerification) { LocalPurchaseVerification.Validate(args.purchasedProduct.receipt, purchaseData, success => { if (success) { iapManager.PurchaseSucceed(purchaseData); } else { iapManager.PurchaseFailed(); } }); return(PurchaseProcessingResult.Complete); } iapManager.PurchaseSucceed(purchaseData); return(PurchaseProcessingResult.Complete); }
public PurchaseData(IAP iap, string transaction = null, string receipt = null) { this.iap = iap; this.transaction = transaction; this.receipt = receipt; }
public PurchaseData(string product, string transaction = null, string receipt = null) { this.iap = IAP.FromSKU(product); this.transaction = transaction; this.receipt = receipt; }
public abstract void Purchase(IAP iap);