public void OnSuccess(Java.Lang.Object result) { if (result == null) { Log.Error(TAG, "result is null"); return; } PurchaseIntentResult inResult = (PurchaseIntentResult)result; if (inResult.Status == null) { Log.Error(TAG, "status is null"); return; } inResult.Status.StartResolutionForResult(CurrentActivity, Constants.REQ_CODE_BUY); }
void PurchaseInitentCreated(PurchaseIntentResult intentResult, ProductDefinition product) { if (intentResult == null) { storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.id, PurchaseFailureReason.Unknown, "IntentIsNull")); return; } var status = intentResult.Status; status.StartResolutionForResult((androidIntent) => { PurchaseResultInfo purchaseResultInfo = iapClient.ParsePurchaseResultInfoFromIntent(androidIntent); switch (purchaseResultInfo.ReturnCode) { case OrderStatusCode.ORDER_STATE_SUCCESS: var data = new InAppPurchaseData(purchaseResultInfo.InAppPurchaseData); this.purchasedData[product.storeSpecificId] = data; this.productsByID.TryGetValue(product.storeSpecificId, out var productInfo); var receipt = EncodeReceipt(purchaseResultInfo.InAppPurchaseData, purchaseResultInfo.InAppDataSignature, ProductToJson(productInfo)); storeEvents.OnPurchaseSucceeded(product.storeSpecificId, receipt, data.OrderID); break; case OrderStatusCode.ORDER_PRODUCT_OWNED: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.DuplicateTransaction, purchaseResultInfo.ErrMsg)); break; case OrderStatusCode.ORDER_STATE_CANCEL: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.UserCancelled, purchaseResultInfo.ErrMsg)); break; default: storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.Unknown, purchaseResultInfo.ErrMsg)); break; } }, (exception) => { storeEvents.OnPurchaseFailed(new PurchaseFailureDescription(product.id, PurchaseFailureReason.Unknown, exception.Message)); }); }