protected async void btnVoid_Click(object sender, EventArgs e) { transaction.storeId = txtStoreID.Text.Trim(); transaction.apiToken = txtAPIToken.Text.Trim(); transaction.terminalId = txtTerminalId.Text.Trim(); if (Session["FollowOn"] != null) { string s = Session["FollowOn"].ToString(); cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(s); transaction.txnType = "purchaseCorrection"; transaction.request = new CloudTransaction.Request() { //orderId = cloudRece.receipt.ReceiptId, orderId = txtOrderID.Text.Trim(), amount = txtAmount.Text.ToString().Trim(), txnNumber = cloudRece.receipt.TransId, echoData = txtEchoData.Text.Trim() }; if (drpEntryMethod.SelectedItem.Value != "A") { transaction.request.entryMethod = drpEntryMethod.SelectedItem.Value.ToString(); } await performTransactionAsync(); } }
private void SetupGiftFollowon() { if (Session["FollowOn"] != null) { string s = Session["FollowOn"].ToString(); cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(s); transaction.request.amount = txtGLAmount.Text.Trim(); transaction.request.referenceNumber = cloudRece.receipt.ReferenceNumber; } }
private async Task getReceiptAsync() { WebClient client = new WebClient(); if (syncRecpt.Receipt.Error == "false" && !string.IsNullOrEmpty(syncRecpt.Receipt.receiptUrl)) { CloudReceipt.Rootobject pollingReceipt = new CloudReceipt.Rootobject(); do { pollingReceipt = await Task.Run(() => poolReceipt(syncRecpt.Receipt.receiptUrl)); if (pollingReceipt.receipt.Error == "true") { break; } } while (pollingReceipt.receipt.Completed != "true" || pollingReceipt.receipt.Error != "false"); txtPollingReceipt.Text = JsonConvert.SerializeObject(pollingReceipt , Formatting.Indented , new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (!string.IsNullOrEmpty(txtPollingReceipt.Text.Trim())) { Session["FollowOn"] = txtPollingReceipt.Text; } CloudReceipt.Rootobject cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(txtPollingReceipt.Text.Trim()); if (Request.QueryString.AllKeys.Count() == 0) { if (cloudRece != null && (cloudRece.receipt.TxnName.ToLower().Trim() == "purchase" || cloudRece.receipt.TxnName.ToLower().Trim() == "preauth")) { lblFollowOn.Visible = true; lblFollowOn.Text = Request.Url.ToString() + "?orderid=" + cloudRece.receipt.ReceiptId + "&txnNumber=" + cloudRece.receipt.TransId + "&storeId=" + txtStoreID.Text.Trim() + "&apiToken=" + txtAPIToken.Text.Trim() + "&terminalId=" + txtTerminalId.Text.Trim() + "&amount=" + cloudRece.receipt.Amount; } else { lblFollowOn.Visible = false; } } else { lblFollowOn.Text = ""; } //if (!string.IsNullOrEmpty(txtRequest.Text) && !string.IsNullOrEmpty(txtRespose.Text) && !string.IsNullOrEmpty(txtPollingReceipt.Text)) // db.SaveToDb(txtRequest.Text.Trim(), txtRespose.Text.Trim(), txtPollingReceipt.Text.Trim()); } else { } }
public CloudReceipt.Rootobject poolReceipt(string URL) { var request = (HttpWebRequest)WebRequest.Create(URL); var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (!string.IsNullOrEmpty(responseString)) { cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(responseString); } return(cloudRece); }
protected void btnRefundCorrections_Click(object sender, EventArgs e) { if (Session["FollowOn"] != null) { string s = Session["FollowOn"].ToString(); cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(s); transaction.txnType = "refundCorrection"; transaction.request.amount = txtAmount.Text.Trim(); transaction.request.originalApprovalNumber = cloudRece.receipt.AuthCode; performTransactionAsync(); } }
public bool InsertToCloudTransactions(string request, string res, string receipt) { bool flag = false; CloudReceipt.Rootobject cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(receipt); try { { using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("INSERT INTO CloudTransactions(Request,Response, Receipt, Complete,ResponseCode,TransactionType,ErrorCode,Error,Note) VALUES (@request,@response,@receipt,@complete,@responseCode,@tType,@errorCode,@error,@note)", conn)) { cmd.Parameters.AddWithValue("@request", request); cmd.Parameters.AddWithValue("@response", res); cmd.Parameters.AddWithValue("@receipt", receipt); if (cloudRece != null) { cmd.Parameters.AddWithValue("@complete", cloudRece.receipt.Completed ?? "null"); cmd.Parameters.AddWithValue("@responseCode", cloudRece.receipt.ResponseCode ?? "null"); cmd.Parameters.AddWithValue("@tType", cloudRece.receipt.TransType ?? "null"); cmd.Parameters.AddWithValue("@errorCode", cloudRece.receipt.ErrorCode ?? "null"); cmd.Parameters.AddWithValue("@error", cloudRece.receipt.Error ?? "null"); } else { cmd.Parameters.AddWithValue("@complete", "null"); cmd.Parameters.AddWithValue("@responseCode", "null"); cmd.Parameters.AddWithValue("@tType", "null"); cmd.Parameters.AddWithValue("@errorCode", "null"); cmd.Parameters.AddWithValue("@error", "null"); } // cmd.Parameters.AddWithValue("@note", txtTranNote.Text ?? "null"); cmd.Parameters.AddWithValue("@note", "" ?? "null"); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { flag = true; } //rows number of record got inserted } } } } catch { flag = false; //lblDbSave.Visible = true; //lblDbSave.Text = rr.Message.ToString(); } return(flag); }
protected async void btnCompletion_Click(object sender, EventArgs e) { transaction.storeId = txtStoreID.Text.Trim(); transaction.apiToken = txtAPIToken.Text.Trim(); transaction.terminalId = txtTerminalId.Text.Trim(); if (Session["FollowOn"] != null) { string s = Session["FollowOn"].ToString(); cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(s); transaction.txnType = "completion"; transaction.request = new CloudTransaction.Request() { // Change request to send a diffrent order ID in completion //orderId = cloudRece.receipt.ReceiptId, orderId = txtOrderID.Text.Trim(), amount = txtAmount.Text.ToString().Trim(), txnNumber = cloudRece.receipt.TransId, echoData = txtEchoData.Text.Trim() }; await performTransactionAsync(); } }
private async Task getReceiptAsyncParrallel() { WebClient client = new WebClient(); if (syncRecpt.Receipt.Error == "false" && !string.IsNullOrEmpty(syncRecpt.Receipt.receiptUrl)) { CloudReceipt.Rootobject pollingReceipt = new CloudReceipt.Rootobject(); do { pollingReceipt = await Task.Run(() => poolReceipt(syncRecpt.Receipt.receiptUrl)); } while (pollingReceipt.receipt.Completed != "true"); txtPollingReceipt.Text = JsonConvert.SerializeObject(pollingReceipt , Formatting.Indented , new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } else { } }
protected void btnCapture_Click(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["PollingCookie"]; string followon = cookie != null?cookie.Value.Split('=')[1] : "undifined"; //transaction.txnType = "completion"; if (Session["FollowOn"] != null) { string s = Session["FollowOn"].ToString(); cloudRece = JsonConvert.DeserializeObject <CloudReceipt.Rootobject>(s); transaction.txnType = "completion"; transaction.request.amount = txtAmount.Text.Trim(); transaction.request.cardType = cloudRece.receipt.CardType; transaction.request.originalApprovalNumber = cloudRece.receipt.AuthCode; transaction.request.originalPreauthAmount = cloudRece.receipt.Amount; transaction.request.pan = cloudRece.receipt.Pan; transaction.request.swipeIndicator = cloudRece.receipt.SwipeIndicator; transaction.request.accountType = cloudRece.receipt.AccountType; transaction.request.aid = cloudRece.receipt.Aid; transaction.request.encryptedTrack2 = cloudRece.receipt.EncryptedTrack2; transaction.request.synchronizationData = cloudRece.receipt.synchronizationData; performTransactionAsync(); } }
public void InsertDateToDB(CloudReceipt.Rootobject response, string RequestJSON, string SyncResponse, string PollingResponse, String TestCase, string MerchantID, string APIToken) { try { { using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("INSERT INTO[dbo].[IPGateTransaction]([TestCase],[TxnName],[Amount],[TransType],[TransDate],[TransTime],[ReferenceNumber],[CloudTicket],[Completed],[Error],[InitRequired],[SafIndicator],[ResponseCode],[ISO],[LanguageCode],[PartialAuthAmount],[AvailableBalance],[TipAmount],[EMVCashBackAmount],[SurchargeAmount],[ForeignCurrencyAmount],[ForeignCurrencyCode],[BaseRate],[ExchangeRate],[Pan],[CardType],[CardName],[AccountType],[SwipeIndicator],[FormFactor],[CvmIndicator],[ReservedField1],[ReservedField2],[AuthCode],[InvoiceNumber],[EMVEchoDataq],[ReservedField3],[ReservedField4],[Aid],[AppLabel],[AppPreferredName],[Arqc],[TvrArqc],[Tcacc],[TvrTcacc],[Tsi],[TokenResponseCode],[Token],[LogonRequired],[EncryptedCardInfo],[EncryptedTrack2] , [EncryptedPan],[BatchNumber],[TerminalNumber],[MerchantID], [RequestJSON],[SyncResposne] ,[PollingResponse],[AvailableForComp], [SynchronizationData], [APIToken]) VALUES (@TestCase,@TxnName,@Amount,@TransType,@TransDate,@TransTime,@ReferenceNumber,@CloudTicket,@Completed,@Error,@InitRequired,@SafIndicator,@ResponseCode, @ISO,@LanguageCode,@PartialAuthAmount,@AvailableBalance,@TipAmount,@EMVCashBackAmount,@SurchargeAmount,@ForeignCurrencyAmount, @ForeignCurrencyCode,@BaseRate,@ExchangeRate,@Pan,@CardType,@CardName,@AccountType,@SwipeIndicator,@FormFactor,@CvmIndicator, @ReservedField1,@ReservedField2,@AuthCode,@InvoiceNumber,@EMVEchoDataq,@VReservedField3,@ReservedField4,@Aid,@AppLabel,@AppPreferredName, @Arqc,@TvrArqc,@Tcacc,@TvrTcacc,@Tsi,@TokenResponseCode,@Token,@LogonRequired,@EncryptedCardInfo, @EncryptedTrack2, @EncryptedPan,@BatchNumber,@TerminalNumber,@MerchantID,@ReqJSON, @SyncResponse, @PollingResponse,@AvailableForComp,@synchronizationData,@APIToken)", conn)) { cmd.Parameters.AddWithValue("@TestCase", CheckForNull(TestCase)); cmd.Parameters.AddWithValue("@TxnName", CheckForNull(response.receipt.TxnName)); cmd.Parameters.AddWithValue("@Amount", CheckForNull(response.receipt.Amount)); cmd.Parameters.AddWithValue("@TransType", CheckForNull(response.receipt.TransType)); cmd.Parameters.AddWithValue("@TransDate", CheckForNull(response.receipt.TransDate)); cmd.Parameters.AddWithValue("@TransTime", CheckForNull(response.receipt.TransTime)); cmd.Parameters.AddWithValue("@ReferenceNumber", CheckForNull(response.receipt.ReferenceNumber)); cmd.Parameters.AddWithValue("@CloudTicket", CheckForNull(response.receipt.CloudTicket)); cmd.Parameters.AddWithValue("@Completed", CheckForNull(response.receipt.Completed)); cmd.Parameters.AddWithValue("@Error", CheckForNull(response.receipt.Error)); cmd.Parameters.AddWithValue("@InitRequired", CheckForNull(response.receipt.InitRequired)); cmd.Parameters.AddWithValue("@SafIndicator", CheckForNull(response.receipt.SafIndicator)); cmd.Parameters.AddWithValue("@ResponseCode", CheckForNull(response.receipt.ResponseCode)); cmd.Parameters.AddWithValue("@ISO", CheckForNull(response.receipt.ISO)); cmd.Parameters.AddWithValue("@LanguageCode", CheckForNull(response.receipt.LanguageCode)); cmd.Parameters.AddWithValue("@PartialAuthAmount", CheckForNull(response.receipt.PartialAuthAmount)); cmd.Parameters.AddWithValue("@AvailableBalance", CheckForNull(response.receipt.AvailableBalance)); cmd.Parameters.AddWithValue("@TipAmount", CheckForNull(response.receipt.TipAmount)); cmd.Parameters.AddWithValue("@EMVCashBackAmount", CheckForNull(response.receipt.EMVCashBackAmount)); cmd.Parameters.AddWithValue("@SurchargeAmount", CheckForNull(response.receipt.SurchargeAmount)); cmd.Parameters.AddWithValue("@ForeignCurrencyAmount", CheckForNull(response.receipt.ForeignCurrencyAmount)); cmd.Parameters.AddWithValue("@ForeignCurrencyCode", CheckForNull(response.receipt.ForeignCurrencyCode)); cmd.Parameters.AddWithValue("@BaseRate", CheckForNull(response.receipt.BaseRate)); cmd.Parameters.AddWithValue("@ExchangeRate", CheckForNull(response.receipt.ExchangeRate)); cmd.Parameters.AddWithValue("@Pan", CheckForNull(response.receipt.Pan)); cmd.Parameters.AddWithValue("@CardType", CheckForNull(response.receipt.CardType)); cmd.Parameters.AddWithValue("@CardName", CheckForNull(response.receipt.CardName)); cmd.Parameters.AddWithValue("@AccountType", CheckForNull(response.receipt.AccountType)); cmd.Parameters.AddWithValue("@SwipeIndicator", CheckForNull(response.receipt.SwipeIndicator)); cmd.Parameters.AddWithValue("@FormFactor", CheckForNull(response.receipt.FormFactor)); cmd.Parameters.AddWithValue("@CvmIndicator", CheckForNull(response.receipt.CvmIndicator)); cmd.Parameters.AddWithValue("@ReservedField1", CheckForNull(response.receipt.ReservedField1)); cmd.Parameters.AddWithValue("@ReservedField2", CheckForNull(response.receipt.ReservedField2)); cmd.Parameters.AddWithValue("@AuthCode", CheckForNull(response.receipt.AuthCode)); cmd.Parameters.AddWithValue("@InvoiceNumber", CheckForNull(response.receipt.InvoiceNumber)); cmd.Parameters.AddWithValue("@EMVEchoDataq", CheckForNull(response.receipt.EMVEchoData)); cmd.Parameters.AddWithValue("@VReservedField3", CheckForNull(response.receipt.ReservedField3)); cmd.Parameters.AddWithValue("@ReservedField4", CheckForNull(response.receipt.ReservedField4)); cmd.Parameters.AddWithValue("@Aid", CheckForNull(response.receipt.Aid)); cmd.Parameters.AddWithValue("@AppLabel", CheckForNull(response.receipt.AppLabel)); cmd.Parameters.AddWithValue("@AppPreferredName", CheckForNull(response.receipt.AppPreferredName)); cmd.Parameters.AddWithValue("@Arqc", CheckForNull(response.receipt.Arqc)); cmd.Parameters.AddWithValue("@TvrArqc", CheckForNull(response.receipt.TvrArqc)); cmd.Parameters.AddWithValue("@Tcacc", CheckForNull(response.receipt.Tcacc)); cmd.Parameters.AddWithValue("@TvrTcacc", CheckForNull(response.receipt.TvrTcacc)); cmd.Parameters.AddWithValue("@Tsi", CheckForNull(response.receipt.Tsi)); cmd.Parameters.AddWithValue("@TokenResponseCode", CheckForNull(response.receipt.TokenResponseCode)); cmd.Parameters.AddWithValue("@Token", CheckForNull(response.receipt.Token)); cmd.Parameters.AddWithValue("@LogonRequired", CheckForNull(response.receipt.LogonRequired)); cmd.Parameters.AddWithValue("@EncryptedCardInfo", CheckForNull(response.receipt.EncryptedCardInfo)); cmd.Parameters.AddWithValue("@EncryptedTrack2", CheckForNull(response.receipt.EncryptedTrack2)); cmd.Parameters.AddWithValue("@EncryptedPan", CheckForNull(response.receipt.EncryptedPan)); cmd.Parameters.AddWithValue("@MerchantID", CheckForNull(MerchantID)); cmd.Parameters.AddWithValue("@APIToken", CheckForNull(APIToken)); //string synchronizationDate = null; if (response.receipt.synchronizationData != null) { string synchronizationDate = JsonConvert.SerializeObject(response.receipt.synchronizationData, Formatting.Indented); cmd.Parameters.AddWithValue("@synchronizationData", synchronizationDate); } else { cmd.Parameters.AddWithValue("@synchronizationData", DBNull.Value); } if (!string.IsNullOrEmpty(response.receipt.ReferenceNumber)) { string refrenceNumber = response.receipt.ReferenceNumber; string host = refrenceNumber.Substring(8, 3); string seq = refrenceNumber.Substring(14, 3); string saf = refrenceNumber.Substring(17, 1); cmd.Parameters.AddWithValue("@BatchNumber", refrenceNumber.Substring(11, 3)); cmd.Parameters.AddWithValue("@TerminalNumber", refrenceNumber.Substring(0, 8)); } else { cmd.Parameters.AddWithValue("@BatchNumber", DBNull.Value); cmd.Parameters.AddWithValue("@TerminalNumber", DBNull.Value); } cmd.Parameters.AddWithValue("@ReqJSON", CheckForNull(RequestJSON)); cmd.Parameters.AddWithValue("@SyncResponse", CheckForNull(SyncResponse)); cmd.Parameters.AddWithValue("@PollingResponse", CheckForNull(PollingResponse)); if (response.receipt.Completed == "true" && (response.receipt.TxnName == "Preauth" || response.receipt.TxnName == "Purchase")) { cmd.Parameters.AddWithValue("@AvailableForComp", "Y"); } else { cmd.Parameters.AddWithValue("@AvailableForComp", "N"); } int rows = cmd.ExecuteNonQuery(); //rows number of record got inserted } } } } catch (Exception c) { } finally { } }