private void Authorize(ref CreditCard card1) { try { // create request object RequestMessage request = new RequestMessage(); BillTo billTo = new BillTo(); configure(); // add general fields if (!(null == Session["OrderNumber"])) { request.merchantReferenceCode = (string)Session["OrderNumber"]; } request.ccAuthService = new CCAuthService(); request.ccAuthService.run = "true"; // add purchasing info PurchaseTotals purchaseTotals = new PurchaseTotals(); purchaseTotals.currency = "USD"; request.purchaseTotals = purchaseTotals; // add shopper info Shopper shopper = (Shopper)Session["Shopper"]; Global1.AddShopperFields(ref billTo, shopper); request.billTo = billTo; //add item info Items items = (Items)Session["ShoppingCart"]; Global1.AddItemFields(ref request, items); // add card info Card card = new Card(); card.accountNumber = card1.accountNumber; card.expirationMonth = card1.expirationMonth; card.expirationYear = card1.expirationYear; card.cvNumber = card1.cvNumber; request.card = card; // send request now reply = SoapClient.RunTransaction(config, request); // process the transaction as per response. HandleReply(); } catch (BugException e) { Session["Exception"] = e; HandleReply(); } catch (NonCriticalTransactionException e) { Session["Exception"] = e; HandleReply(); } catch (CriticalTransactionException e) { // The transaction may have been successfully processed by // CyberSource. Aside from redirecting to an error page, you should // make sure that someone gets notified of the occurrence of this // exception so that they could check the outcome of the transaction // on the CyberSource Support Screens. For example, you could // post an event log or send an email to a monitored address. Session["Exception"] = e; HandleReply(); } }
protected void btnSubmitInfo_Click(object sender, EventArgs e) { string email = ConfigurationManager.AppSettings["FromEmail"].ToString(); string ToEmail = ConfigurationManager.AppSettings["ToEmail"].ToString(); RevenueCost = txtRevenueCost.Text != "" ? Convert.ToDecimal(txtRevenueCost.Text) : 0; PriorRevenueCost = txtPriorRevenueCost.Text != "" ? Convert.ToDecimal(txtPriorRevenueCost.Text) : 0; TipCost = txtTipCost.Text != "" ? Convert.ToDecimal(txtTipCost.Text) : 0; totalAmount = Convert.ToDecimal(RevenueCost) + Convert.ToDecimal(TipCost) + Convert.ToDecimal(PriorRevenueCost); if (totalAmount <= (-1)) { lblerrormsg.Visible = true; txtTipCost.Focus(); return; } else { if (Page.IsValid.Equals(true)) { //check to avoid duplicate transactions. if (!(null == Session["IsExecuted"])) { if (Session["IsExecuted"].Equals("0")) { if (!(null == Session["GId"])) { btnSubmitInfo.Enabled = false; // set up Order number uniquely. string OrderRefNo = GetOrderRefNumber(); Session["OrderNumber"] = OrderRefNo; //update new tip and revenue for appointment log page DataTable dtdetails = (DataTable)Session["AppointmentDetails"]; #region Forloop foreach (DataRow dr in dtdetails.Rows) { #region Start #region Rowstart dr["AppStartTime"] = dr["AppStartTime"]; dr["AppEndTime"] = dr["AppEndTime"]; dr["AppDateTime"] = dr["AppDateTime"]; dr["Description"] = dr["Description"]; dr["CustumerName"] = dr["CustumerName"]; dr["Date"] = dr["Date"]; dr["LastName"] = dr["LastName"]; dr["JobMileage"] = dr["JobMileage"]; dr["ZipCode"] = dr["ZipCode"]; dr["Pets"] = dr["Pets"]; dr["NextAppointmentTime"] = dr["NextAppointmentTime"]; dr["ExpStartTime"] = dr["ExpStartTime"]; dr["ExpEndTime"] = dr["ExpEndTime"]; dr["Rebook"] = dr["Rebook"]; dr["FromRebook"] = dr["FromRebook"]; dr["NextStartTime"] = dr["NextStartTime"]; dr["NextEndTime"] = dr["NextEndTime"]; #endregion Rowstart #region hidden services dr["ServicesforPet1"] = dr["ServicesforPet1"]; dr["ServicesforPet2"] = dr["ServicesforPet2"]; dr["ServicesforPet3"] = dr["ServicesforPet3"]; dr["ServicesforPet4"] = dr["ServicesforPet4"]; dr["ServicesforPet5"] = dr["ServicesforPet5"]; dr["ServicesforPet6"] = dr["ServicesforPet6"]; dr["NewRadio"] = dr["NewRadio"]; #endregion hidden services #region supplies dr["FleaandTick22"] = dr["FleaandTick22"]; dr["FleaandTick44"] = dr["FleaandTick44"]; dr["FleaandTick88"] = dr["FleaandTick88"]; dr["FleaandTick132"] = dr["FleaandTick132"]; dr["FleaandTickCat"] = dr["FleaandTickCat"]; dr["TB"] = dr["TB"]; dr["Wham"] = dr["Wham"]; #endregion supplies #region Revenue dr["RevenueType"] = dr["RevenueType"]; dr["RevenueAmount"] = RevenueCost.ToString(); dr["ApptChanges"] = dr["ApptChanges"]; dr["CommentDiv"] = dr["CommentDiv"]; dr["PetTimeGoodBad1"] = dr["PetTimeGoodBad1"]; dr["PetTimeGoodBad2"] = dr["PetTimeGoodBad2"]; #endregion Revenue #region Product dr["ProductPrice"] = dr["ProductPrice"]; dr["ProductSalesTax"] = dr["ProductSalesTax"]; #endregion Product #region Tip dr["Tiptype"] = dr["Tiptype"]; dr["TipAmount"] = TipCost.ToString(); #endregion Tip #region Prior Revenue dr["PriorType"] = dr["PriorType"]; dr["PriorAmount"] = PriorRevenueCost.ToString(); #endregion Prior Revenue #region CheckDetail dr["NameOnCheck"] = dr["NameOnCheck"]; dr["AddressOnCheck"] = dr["AddressOnCheck"]; #endregion CheckDetail #endregion Start } #endregion Forloop Session["AppointmentDetails"] = dtdetails; objGroomer.GetShopperInfo(GId, txtFirstName.Text.Trim(), txtLastName.Text.Trim(), txtAddress1.Text.Trim(), txtCity.Text.Trim(), txtState.Text.Trim(), txtZip.Text.Trim(), txtCountry.Text.Trim(), txtPhone.Text.Trim(), email, drpCardType.SelectedItem.Text, txtCardNumber.Text.Trim(), txtExpYear.Text.Trim(), drpMonth.SelectedValue, "", Convert.ToDecimal(lblTotalCost.Text), decimal.Parse("0"), decimal.Parse("0"), OrderRefNo, Convert.ToInt32(Session["GroomerAppointmentId"].ToString()), txtVerificationNo.Text.Trim()); Session["emailid"] = email; Session["totalprice"] = lblTotalCost.Text.Trim().ToString(); Session["CC_Name"] = txtFirstName.Text.Trim().ToString(); Session["CC_Name1"] = txtLastName.Text.Trim().ToString(); string errorMessage = (string)Session["ErrorMessage"]; // set up Items info Items shoppingCart = new Items(); shoppingCart.productName = "Pets Treatment"; shoppingCart.unitPrice = totalAmount; shoppingCart.quantity = 1; Session["ShoppingCart"] = shoppingCart; // set up customer info. Shopper shopper; shopper.firstName = txtFirstName.Text.Trim(); shopper.lastName = txtLastName.Text.Trim(); shopper.email = ToEmail; shopper.street1 = txtAddress1.Text.Trim(); shopper.city = txtCity.Text.Trim(); shopper.state = txtState.Text.Trim(); shopper.postalCode = txtZip.Text.Trim(); shopper.country = txtCountry.Text.Trim(); Session["Shopper"] = shopper; // set up credit card info. CreditCard card; card.accountNumber = txtCardNumber.Text.Trim(); card.expirationMonth = drpMonth.SelectedValue.ToString(); card.expirationYear = txtExpYear.Text.Trim(); card.cvNumber = txtVerificationNo.Text.Trim(); Global1 global = ((Global1)this.Context.ApplicationInstance); // CalculateTax(global.icsClient); Authorize(ref card); Session["IsExecuted"] = "1"; } } } } } }