public override void FinishPurchase(string resultCode, string transactionId, string gameFieldsJson, string dataSignature) { UpdateCommonProps(); androidApi.Call("KongregateAPIAnalyticsFinishPurchase", resultCode, transactionId, gameFieldsJson, dataSignature); Dictionary <string, object> gameFields = Json.Deserialize(gameFieldsJson) as Dictionary <string, object>; IabResultType result = (IabResultType)Enum.Parse(typeof(IabResultType), resultCode); FinishPurchase(result, transactionId, gameFields, dataSignature); }
protected void FinishPurchase(IabResultType resultCode, string responseInfo, Dictionary <string, object> gameFields, string dataSignture) { Dictionary <string, object> iapFields = new Dictionary <string, object>(); Debug.LogWarning("IAP FLOW STEP: finishPurchase(): " + resultCode); // parse json info if success or receipt fail. when value is fail, response info will just be // an error message string. Dictionary <string, object> purchaseInfoJson = null; string resultReason = null; if (IabResultType.SUCCESS.Equals(resultCode) || IabResultType.RECEIPT_FAIL.Equals(resultCode)) { purchaseInfoJson = Json.Deserialize(responseInfo) as Dictionary <string, object>; string orderId = optStringWarn(purchaseInfoJson, "orderId", "", "unable to parse orderId from responseInfo in finishPurchase()"); iapFields.Add(Analytics.RECEIPT_ID, orderId); } else { // receipt ids aren't available for failed purchases iapFields.Add(Analytics.RECEIPT_ID, null); } // fire appropriate event based on result if (IabResultType.SUCCESS.Equals(resultCode)) { String productId = optStringWarn(purchaseInfoJson, "productId", "", "unable to parse productId from responseInfo in finishPurchase()"); if (!String.IsNullOrEmpty(resultReason)) { // use to see how many success do to bad connections come in (hopefully, it'll stay low) iapFields.Add(Analytics.SUCCESS_REASON, resultReason); } base.iapTransaction(productId, iapFields, gameFields, responseInfo, dataSignture); } else if (IabResultType.RECEIPT_FAIL.Equals(resultCode)) { base.iapFails(resultReason, iapFields, gameFields); } else if (IabResultType.FAIL.Equals(resultCode)) { base.iapFails(responseInfo, iapFields, gameFields); } else { Debug.LogWarning("invalid result code passed to finishPurchase: " + resultCode); } }