예제 #1
0
        // ==== Helper methods

        private async void performTransactionAsync()
        {
            if (drpMoto.SelectedIndex > 0)
            {
                transaction.request.moto = "true";
            }
            if (!String.IsNullOrEmpty(txtEchoData.Text.Trim()))
            {
                transaction.request.echoData = txtEchoData.Text.Trim();
            }
            SetEntryMethod();
            transaction.merchantId = txtMerchantId.Text.Trim();
            transaction.terminalId = txtTerminalID.Text.Trim();
            transaction.apiToken   = txtToken.Text.Trim();
            jsonRequest            = JsonConvert.SerializeObject(transaction, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            txtRequest.Text  = jsonRequest;
            lblReqUrl.Text   = postUrl;
            lblTestCase.Text = txtTestCase.Text;
            var content = new StringContent(jsonRequest, Encoding.UTF8, "application/json");

            if (!string.IsNullOrEmpty(txtAsyncResponse.Text))
            {
                txtAsyncResponse.Text = ""; //btnSaveDB.Visible = false; lblDbSave.Text = "";
            }
            try
            {
                using (var client = new HttpClient())
                {
                    HttpResponseMessage result = await client.PostAsync(postUrl, content);

                    resultContent = await result.Content.ReadAsStringAsync();

                    syncRecpt        = JsonConvert.DeserializeObject <CloudPoolingResponse.RootObject>(resultContent);
                    txtResposne.Text = JsonConvert.SerializeObject(syncRecpt, Formatting.Indented, new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                    HttpCookie myCookie = new HttpCookie("TransactionCookie");
                    //myCookie.Values["Request"] = lblRequest.Text;
                    myCookie.Values["Request"]      = txtRequest.Text;
                    myCookie.Values["SyncResponse"] = syncRecpt.ToString();
                    Response.Cookies.Add(myCookie);
                    Session["PoolRcpt"] = syncRecpt;
                }
            }
            catch (Exception clouse)
            {
                resultContent = clouse.InnerException.Message.ToString();
            }
            finally
            {
            }
        }
예제 #2
0
        private static string postUrlIntranlQA = "https://ippostest.moneris.com/Terminal/";                   // internal QA
        public async Task <string> PerformTransaction(IPGateCloudTransaction transaction, string environment)
        {
            string Url = string.Empty;

            if (environment.Trim() == "QA1" || environment.Trim() == "QA2")
            {
                Url = postUrl;
            }
            else if (environment.Trim().ToUpper() == "INTERNAL QA")
            {
                Url = postUrlIntranlQA;
            }
            string jsonRequest = JsonConvert.SerializeObject(transaction, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var    content = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
            string resultContent;

            try
            {
                using (var client = new HttpClient())
                {
                    HttpResponseMessage result = await client.PostAsync(Url, content);

                    resultContent = await result.Content.ReadAsStringAsync();

                    CloudPoolingResponse.RootObject syncRecpt = JsonConvert.DeserializeObject <CloudPoolingResponse.RootObject>(resultContent);
                    string syncResponse = JsonConvert.SerializeObject(syncRecpt, Formatting.Indented, new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                }
            }
            catch (Exception clouse)
            {
                resultContent = clouse.InnerException.Message.ToString();
            }
            finally
            {
            }
            return(resultContent);
        }
예제 #3
0
        /// Helper Methods
        ///
        private async Task performTransactionAsync()
        {
            if (lblFollowOn.Visible == true)
            {
                lblFollowOn.Visible = false;
            }
            transaction.storeId    = txtStoreID.Text.Trim();
            transaction.apiToken   = txtAPIToken.Text.Trim();
            transaction.terminalId = txtTerminalId.Text.Trim();
            if (!string.IsNullOrEmpty(txtEchoData.Text))
            {
                transaction.request.echoData = txtEchoData.Text.Trim();
            }

            if (rdEnv.SelectedItem.Value == "0")
            {
                postUrl = "http://ec2-52-73-55-162.compute-1.amazonaws.com/Terminal/";
            }

            if (rdEnv.SelectedItem.Value == "1")
            {
                postUrl = "https://ippostest.moneris.com/Terminal";
            }

            if (chkMoto.Checked)
            {
                transaction.request.moto = true;
            }

            txtRequest.Text = JsonConvert.SerializeObject(
                transaction,
                Formatting.Indented,
                new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });
            jsonRequest = JsonConvert.SerializeObject(transaction, Formatting.Indented);
            //lblRequestUrl.Text = postUrl;
            StringContent content = new StringContent(jsonRequest, Encoding.UTF8, "application/json");

            if (!string.IsNullOrEmpty(txtPollingReceipt.Text))
            {
                txtPollingReceipt.Text = "";
                //btnSaveDB.Visible = false;
                //lblDbSave.Text = "";
            }
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage result = await client.PostAsync(postUrl, content);

                    resultContent = await result.Content.ReadAsStringAsync();

                    //lblRes.Text = Server.HtmlDecode("<pre>"+ resultContent +"</pre>");
                    txtRespose.Text     = JsonConvert.SerializeObject(resultContent, Formatting.Indented);;
                    syncRecpt           = JsonConvert.DeserializeObject <CloudPoolingResponse.RootObject>(resultContent);
                    Session["PoolRcpt"] = syncRecpt;
                }
                await getReceiptAsync();
            }
            catch (Exception clouse)
            {
                resultContent = clouse.InnerException.Message.ToString();
            }
        }