public void ReportPayment(string trxId, string amount, string currency) { OKTransaction transaction = new OKTransaction(trxId, amount, currency); paymentTransactionQueue.AddFirst(transaction); UpdateUnprocessedPaymentList(); ReportPaymentSendInternal(); }
protected void ReportPaymentSendInternal() { // Check if we have any unsent transactions. if (paymentTransactionQueue.Count == 0) { return; } if (paymentTransactionInProgress) { return; } if (!IsInitialized) { return; } paymentTransactionInProgress = true; OKTransaction transaction = paymentTransactionQueue.First.Value; Api(OKMethod.SDK.reportPayment, transaction.ToDictionary(), delegate(HTTP.Response response) { try { Hashtable json = (Hashtable)JSON.Decode(response.Text); bool result = json.Contains("result") && (bool)json["result"]; transaction.RetryCountUp(); if (result || transaction.TooManyRetries()) { // Remove sent transaction from list, if successful or too many retries. paymentTransactionQueue.Remove(transaction); UpdateUnprocessedPaymentList(); paymentTransactionInProgress = false; // Try sending next transaction, if we have any remaining in queue. ReportPaymentSendInternal(); } else { // Update retry count. UpdateUnprocessedPaymentList(); paymentTransactionInProgress = false; } } catch (Exception e) { paymentTransactionInProgress = false; Debug.LogError("Error response on sdk.reportPayment, transaction id: " + transaction.GetId() + " error: " + e.Message); } }); }