private void Acknowledge(AN_Purchase purchase) { var paramsBuilder = AN_AcknowledgePurchaseParams.NewBuilder(); paramsBuilder.SetPurchaseToken(purchase.PurchaseToken); m_BillingClient.AcknowledgePurchase(paramsBuilder.Build(), result => { }); }
private void Consume(AN_Purchase purchase) { var paramsBuilder = AN_ConsumeParams.NewBuilder(); paramsBuilder.SetPurchaseToken(purchase.PurchaseToken); m_BillingClient.ConsumeAsync(paramsBuilder.Build(), this); }
public void Purchase(AN_VendingLib.AN_PurchaseRequest request, Action <AN_BillingPurchaseResult> callback) { SA_Coroutine.WaitForSeconds(1, () => { AN_Purchase purchase = new AN_Purchase(request.m_product.ProductId, request.m_product.Type.ToString(), request.m_developerPayload); callback.Invoke(new AN_BillingPurchaseResult(purchase)); }); }
private void ProcessCompletedTransaction(UM_iTransaction transaction) { Debug.Log("ProcessCompletedTransaction"); //Our product has been successfully purchased or restored //So we need to provide content to our user depends on productIdentifier //Before we will provide content to the user we might want //to make sure that purchase is valid, using server-side validation //let's see check the current platform switch (Application.platform) { case RuntimePlatform.Android: //On android all the info we need is inside the ordinal android transaction //So let's get one. string productId = transaction.ProductId; AN_Inventory inventory = AN_Billing.Inventory; AN_Purchase an_purchase = inventory.GetPurchaseByProductId(productId); //Now you have asses to the all data from the original goal transaction object //That you can send to your server side and validate the purchase. Debug.Log(an_purchase.OriginalJson); break; case RuntimePlatform.IPhonePlayer: Debug.Log("go IOS"); //In case this transaction was restored, we might want to validate an original transaction. var iosTransaction = (transaction as UM_IOSTransaction).IosTransaction; if (transaction.State == UM_TransactionState.Restored) { iosTransaction = iosTransaction.OriginalTransaction; } Debug.Log("iOS Transaction Id:" + iosTransaction.TransactionIdentifier); //For iOS we need to validate the AppStoreReceipt. //So we need to get it using iOS Native var receipt = ISN_SKPaymentQueue.AppStoreReceipt; //You can now send receipt to your server side Debug.Log("Receipt loaded, byte array length: " + receipt.Data.Length); Debug.Log("Receipt As Base64 String" + receipt.AsBase64String); break; } UnlockProduct(transaction); //Once product is successfully unlocked we can finish the transaction UM_InAppService.Client.FinishTransaction(transaction); }
private void PrintPurchaseInfo(AN_Purchase purchase) { AN_Logger.Log("purchase.Sku: " + purchase.Sku); AN_Logger.Log("purchase.Type: " + purchase.Type); AN_Logger.Log("purchase.PurchaseToken: " + purchase.PurchaseToken); AN_Logger.Log("purchase.IsAcknowledged: " + purchase.IsAcknowledged); AN_Logger.Log("purchase.IsAutoRenewing: " + purchase.IsAutoRenewing); AN_Logger.Log("purchase.Signature: " + purchase.Signature); AN_Logger.Log("purchase.OrderId: " + purchase.OrderId); AN_Logger.Log("purchase.PackageName: " + purchase.PackageName); AN_Logger.Log("purchase.PurchaseState: " + purchase.PurchaseState); AN_Logger.Log("purchase.DeveloperPayload: " + purchase.DeveloperPayload); }
private void PrintPurchaseInfo(AN_Purchase purchase) { AN_Logger.Log("purchase.OrderId" + purchase.OrderId); AN_Logger.Log("purchase.ProductId" + purchase.ProductId); AN_Logger.Log("purchase.PackageName" + purchase.PackageName); AN_Logger.Log("purchase.PurchaseState" + purchase.PurchaseState); AN_Logger.Log("purchase.PurchaseTime" + purchase.PurchaseTime); AN_Logger.Log("purchase.Signature" + purchase.Signature); AN_Logger.Log("purchase.Token" + purchase.Token); AN_Logger.Log("purchase.Type" + purchase.Type); AN_Logger.Log("purchase.DeveloperPayload" + purchase.DeveloperPayload); AN_Logger.Log("purchase.AutoRenewing" + purchase.AutoRenewing); AN_Logger.Log("purchase.OriginalJson" + purchase.OriginalJson); AN_Logger.Log("----------------------------------------------------"); }
private void SetPurchase(AN_Purchase purchase, bool isRestored) { m_purchase = purchase; m_id = m_purchase.OrderId; m_productId = m_purchase.ProductId; m_unitxTimestamp = m_purchase.PurchaseTime; if (isRestored) { m_state = UM_TransactionState.Restored; } else { m_state = UM_TransactionState.Purchased; } }
//-------------------------------------- // AN_iConsumeResponseListener //-------------------------------------- public void OnConsumeResponse(SA_iResult billingResult, string purchaseToken) { Assert.IsTrue(billingResult.IsSucceeded); AN_Purchase consumePurchase = null; foreach (var purchase in m_Purchases) { if (purchase.PurchaseToken.Equals(purchaseToken)) { consumePurchase = purchase; } } if (consumePurchase != null) { m_Purchases.Remove(consumePurchase); } }
public UM_AndroidTransaction(AN_Purchase purchase, bool isRestored) { SetPurchase(purchase, isRestored); }
public void OnTransactionUpdated(UM_iTransaction transaction) { //Transactions have been updated. //Let's act accordingly PrintTransactionInfo(transaction); switch (transaction.State) { case UM_TransactionState.Purchased: case UM_TransactionState.Restored: //Our product has been successfully purchased or restored //So we need to provide content to our user depends on productIdentifier //Before we will provide content to the user we might want //to make sure that purchase is valid, using server-side validation //let's see check the current platform switch (Application.platform) { case RuntimePlatform.Android: //On android all the info we need is inside the ordinal android transaction //So let's get one. string productId = transaction.ProductId; AN_Inventory inventory = AN_Billing.Inventory; AN_Purchase an_purchase = inventory.GetPurchaseByProductId(productId); //Now you have asses to the all data from the original goal transaction object //That you can send to your server side and validate the purchase. Debug.Log(an_purchase.OriginalJson); break; case RuntimePlatform.IPhonePlayer: //For iOS we need to validate the AppStoreReceipt. //So we need to get it using iOS Native var receipt = ISN_SKPaymentQueue.AppStoreReceipt; //You can now send receipt to your server side Debug.Log("Receipt loaded, byte array length: " + receipt.Data.Length); Debug.Log("Receipt As Base64 String" + receipt.AsBase64String); break; } UnlockProduct(transaction); //Once product is successfully unlocked we can finish the transaction UM_InAppService.Client.FinishTransaction(transaction); break; case UM_TransactionState.Deferred: //Only fir iOS //iOS 8 introduces Ask to Buy, which lets parents approve any //purchases initiated by children //You should update your UI to reflect this deferred state, //and expect another Transaction Complete to be called again //with a new transaction state //reflecting the parent’s decision or after the transaction times out. //Avoid blocking your UI or gameplay while waiting //for the transaction to be updated. break; case UM_TransactionState.Failed: //Our purchase flow is failed. //We can unlock interface and tell user that the purchase is failed. UM_InAppService.Client.FinishTransaction(transaction); break; } }
public void Consume(AN_Purchase purchase, Action <SA_Result> callback) { AN_Java.Bridge.CallStaticWithCallback <SA_Result>( AN_BILLING_CLASS, "Consume", callback, purchase); }
private void RestartTransaction(AN_Purchase purchase) { var transaction = new UM_AndroidTransaction(new SA_Result(), purchase); UpdateTransaction(transaction); }
public void Consume(AN_Purchase purchase, Action <SA_Result> callback) { SA_Coroutine.WaitForSeconds(1, () => { callback.Invoke(new SA_Result()); }); }