/// <remarks/> public void FDGGWSApiOrderAsync(FDGGWSApiOrderRequest FDGGWSApiOrderRequest) { this.FDGGWSApiOrderAsync(FDGGWSApiOrderRequest, null); }
/// <remarks/> public void FDGGWSApiOrderAsync(FDGGWSApiOrderRequest FDGGWSApiOrderRequest, object userState) { if ((this.FDGGWSApiOrderOperationCompleted == null)) { this.FDGGWSApiOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFDGGWSApiOrderOperationCompleted); } this.InvokeAsync("FDGGWSApiOrder", new object[] { FDGGWSApiOrderRequest}, this.FDGGWSApiOrderOperationCompleted, userState); }
public void SubmitButton_Click(object sender, System.EventArgs e) { // Grab current Date and Time DateTime oPaymentDate = DateTime.Now; string sPaymentDate = oPaymentDate.ToString("M/d/yyyy hh:mm:ss tt"); // Hide the Payment Panel Payment.Visible = false; // Show the Processing Panel Processing.Visible = true; System.Net.ServicePointManager.Expect100Continue = false; System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3; // Initialize Service Object FDGGWSApiOrderService.FDGGWSApiOrderService oFDGGWSApiOrderService = new FDGGWSApiOrderService.FDGGWSApiOrderService(); // Set the WSDL URL oFDGGWSApiOrderService.Url = @"https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl"; // Get the Application Root Directory string appRoot = HttpRuntime.AppDomainAppPath; // Configure Client Certificate string certPath = "~/usercontrols/BillPaymentForm/WS1001304227._.1.pem"; oFDGGWSApiOrderService.ClientCertificates.Add(X509Certificate.CreateFromCertFile(certPath.Replace("~/", appRoot))); // Set the Authentication Credentials NetworkCredential nc = new NetworkCredential("WS1001304227._.1", "jGmv8uJF"); oFDGGWSApiOrderService.Credentials = nc; // Create Sale Transaction Request FDGGWSApiOrderService.FDGGWSApiOrderRequest oOrderRequest = new FDGGWSApiOrderService.FDGGWSApiOrderRequest(); // Create a New Transaction FDGGWSApiOrderService.Transaction oTransaction = new FDGGWSApiOrderService.Transaction(); // Create the Credit Card Type FDGGWSApiOrderService.CreditCardTxType oCreditCardTxType = new FDGGWSApiOrderService.CreditCardTxType(); oCreditCardTxType.Type = FDGGWSApiOrderService.CreditCardTxTypeType.sale; // Create the Credit Card Data FDGGWSApiOrderService.CreditCardData oCreditCardData = new FDGGWSApiOrderService.CreditCardData(); oCreditCardData.ItemsElementName = new FDGGWSApiOrderService.ItemsChoiceType[] { FDGGWSApiOrderService.ItemsChoiceType.CardNumber, FDGGWSApiOrderService.ItemsChoiceType.ExpMonth, FDGGWSApiOrderService.ItemsChoiceType.ExpYear, FDGGWSApiOrderService.ItemsChoiceType.CardCodeValue }; oCreditCardData.Items = new string[] { txtCCNumber.Text, drpExpMonth.SelectedItem.Value, drpExpYear.SelectedItem.Value, txtCardCodeValue.Text }; // Set the Credit Card Number to a variable for later usage string sCreditCardNumber = txtCCNumber.Text; string sCreditCardLast4 = "************" + sCreditCardNumber.Substring(12, 4); // Add the Credit Card Data to the Transaction oTransaction.Items = new object[] { oCreditCardTxType, oCreditCardData }; // Create the Payment FDGGWSApiOrderService.Payment oPayment = new FDGGWSApiOrderService.Payment(); oPayment.ChargeTotal = Convert.ToDecimal(txtChargeTotal.Text); // Set the Payment to a variable for later usage string sPayment = txtChargeTotal.Text; // Add the Payment to the Transaction oTransaction.Payment = oPayment; // Create the Transaction Details FDGGWSApiOrderService.TransactionDetails oTransactionDetails = new FDGGWSApiOrderService.TransactionDetails(); string sCustomerLastName = txtCustomerLastName.Text; string sCustomerFirstName = txtCustomerFirstName.Text; string sCustomerID = txtCustomerID.Text; string sCustomerFull = sCustomerLastName + "," + sCustomerFirstName + "-" + sCustomerID; oTransactionDetails.UserID = sCustomerFull; // Add the Transaction Details to the Transaction oTransaction.TransactionDetails = oTransactionDetails; // Create the Billing Information FDGGWSApiOrderService.Billing oBilling = new FDGGWSApiOrderService.Billing(); //oBilling.CustomerID = txtCustomerLastName.Text + "," + txtCustomerFirstName.Text + "-" + txtCustomerID.Text; oBilling.Name = txtName.Text; oBilling.Address1 = txtAddress.Text; oBilling.City = txtCity.Text; oBilling.State = txtState.Text; oBilling.Zip = txtZip.Text; oBilling.Country = "United States of America"; oBilling.Email = txtEmail.Text; // Set the Billing Information to variables for later usage string sName = txtName.Text; string sAddress1 = txtAddress.Text; string sCity = txtCity.Text; string sState = txtState.Text; string sZip = txtZip.Text; string sCountry = "United States of America"; string sEmail = txtEmail.Text; // Add the Billing to the Transaction oTransaction.Billing = oBilling; // Add the Transaction to the Order Request oOrderRequest.Item = oTransaction; // Get First Data's Response FDGGWSApiOrderService.FDGGWSApiOrderResponse oResponse = null; try { // Create the Response sequence oResponse = oFDGGWSApiOrderService.FDGGWSApiOrder(oOrderRequest); // Grab the Transaction Responses string sTransactionResult = oResponse.TransactionResult; string sTransactionTime = oResponse.TransactionTime; string sProcessorResponseMessage = oResponse.ProcessorResponseMessage; string sOrderID = oResponse.OrderId; // Grab the Tranaction Error Message string sErrorMessage = oResponse.ErrorMessage; string sErrorCode = null; if (!String.IsNullOrEmpty(sErrorMessage)) { sErrorCode = sErrorMessage.Substring(4, 6); } // If the transaction is Approved, show the success panel if (sTransactionResult == "APPROVED") { Processing.Visible = false; Success.Visible = true; // Set the Reference Number Label lblReferenceNumber.Text = sOrderID; // Set the Payment Label lblPayment.Text = sPayment; // Set the Billing Information Labels lblName.Text = sName; lblAddress1.Text = sAddress1; lblCity.Text = sCity; lblState.Text = sState; lblZip.Text = sZip; lblCountry.Text = sCountry; lblEmail.Text = sEmail; // Create the Confirmation Email to the Payer Content string sEmailContentPayer = "<tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Payment Date:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sPaymentDate + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Name:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerFirstName + " " + sCustomerLastName + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Chart Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Reference #:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sOrderID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Total Payment:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>$" + sPayment + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Credit Card Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCreditCardLast4 + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Billed To:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sName + "<br />" + sAddress1 + "<br />" + sCity + ", " + sState + " " + sZip + "<br />" + sCountry + "</p>" + "</td></tr>"; // Create the Admin Email string sEmailContentAdmin = "<tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Payment Date:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sPaymentDate + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Name:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerFirstName + " " + sCustomerLastName + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Chart Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Information:<br /><i>As it is seen in gateway</i></b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerFull + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Reference #:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sOrderID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Total Payment:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>$" + sPayment + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Credit Card Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCreditCardLast4 + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Billed To:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sName + "<br />" + sAddress1 + "<br />" + sCity + ", " + sState + " " + sZip + "<br />" + sCountry + "<br />" + sEmail + "</p>" + "</td></tr>"; // Set up the SMTP Server SmtpClient oSmtpServer = new SmtpClient(sEmailServer); oSmtpServer.Credentials = new System.Net.NetworkCredential(sEmailServerUser, sEmailServerPass); // Send the Confirmation Email to the Payer MailMessage oMail = new MailMessage(); oMail.From = new MailAddress(sEmailFrom); oMail.To.Add(sEmail); oMail.Subject = sEmailSubjectToPayer; oMail.IsBodyHtml = true; oMail.Body = sEmailHeaderBeginning + sEmailStyles + sEmailHeaderEnding + sEmailBodyBeginning + sEmailBodyHeader + sEmailBodyPayer + sEmailContentPayer + sEmailFooterPayer; oSmtpServer.Send(oMail); // Send the Email to the Administrator MailMessage oMail2 = new MailMessage(); oMail2.From = new MailAddress(sEmailFrom); oMail2.To.Add(sEmailAdmin); oMail2.To.Add(sEmailAdmin2); oMail2.Subject = sEmailSubjectToAdmin; oMail2.IsBodyHtml = true; oMail2.Body = sEmailHeaderBeginning + sEmailStyles + sEmailHeaderEnding + sEmailBodyBeginning + sEmailBodyHeader + sEmailBodyAdmin + sEmailContentAdmin + sEmailFooterAdmin; oSmtpServer.Send(oMail2); } else { Processing.Visible = false; Fail.Visible = true; // Set up the back button lblBackButton.Text = "<p class='bottom'><a onclick='goBack()' style='background-color: transparent; cursor:pointer;'><img src='/media/6156/backbutton.png' alt='Go Back' width='112' height='31' /></a></p>"; // Set the Error Message Label if (sErrorCode == "000002") { lblErrorMessage.Text = "Please contact your financial institution. Your transaction will require a voice authorization."; } else if (sErrorCode == "000100") { lblErrorMessage.Text = "There has been an internal error with the payment gateway. Please try your payment transaction again at a later time."; } else if (sErrorCode == "002000") { lblErrorMessage.Text = "There has been an error with the payment gateway. This error could be one of the following: (1) The transaction was declined due to insufficient funds, (2) you tried to use an unsupported card type or (3) there was simply a general processing error. Please try your payment transaction again at a later time."; } else if (sErrorCode == "002302") { lblErrorMessage.Text = "The expiration date that you entered is invalid. Please return to the Payment form to correct the error and resubmit your transaction."; // Show the back button lblBackButton.Visible = true; } else if (sErrorCode == "002303") { lblErrorMessage.Text = "The credit card number that you provided is invalid. Please return to the Payment form to correct the error and resubmit your transaction."; // Show the back button lblBackButton.Visible = true; } else if (sErrorCode == "002304") { lblErrorMessage.Text = "The credit card that you provided has expired. Please return to the Payment form to enter in a new card and resubmit your transaction."; // Show the back button lblBackButton.Visible = true; } else { lblErrorMessage.Text = "Your transaction has been declined by our payment gateway. Please try your payment transaction again at a later time."; } // Set the Reference Number Label lblReferenceNumber.Text = sOrderID; // Set the Payment Label lblPayment.Text = sPayment; // Set the Billing Information Labels lblName.Text = sName; lblAddress1.Text = sAddress1; lblCity.Text = sCity; lblState.Text = sState; lblZip.Text = sZip; lblCountry.Text = sCountry; lblEmail.Text = sEmail; // Create the Web Admin Email string sEmailContentWebAdmin = "<tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Payment Date:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sPaymentDate + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Error Code:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sErrorCode + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Error Message:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sErrorMessage + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Name:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerFirstName + " " + sCustomerLastName + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Chart Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Patient Information:<br /><i>As it is seen in gateway</i></b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCustomerFull + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Reference #:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sOrderID + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Total Payment:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>$" + sPayment + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Credit Card Number:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sCreditCardLast4 + "</p>" + "</td></tr><tr style='border-collapse:collapse;'><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'><b>Billed To:</b></p>" + "</td><td align='left' valign='top' style='border-collapse:collapse;'>" + "<p style='padding:0; margin:0;'>" + sName + "<br />" + sAddress1 + "<br />" + sCity + ", " + sState + " " + sZip + "<br />" + sCountry + "<br />" + sEmail + "</p>" + "</td></tr>"; // Set up the SMTP Server SmtpClient oSmtpServer = new SmtpClient(sEmailServer); oSmtpServer.Credentials = new System.Net.NetworkCredential(sEmailServerUser, sEmailServerPass); // Send the Email to the Web Administrator MailMessage oMail3 = new MailMessage(); oMail3.From = new MailAddress(sEmailFrom); oMail3.To.Add(sEmailWebAdmin); oMail3.Subject = sEmailSubjectToAdmin; oMail3.IsBodyHtml = true; oMail3.Body = sEmailHeaderBeginning + sEmailStyles + sEmailHeaderEnding + sEmailBodyBeginning + sEmailBodyHeader + sEmailBodyAdmin + sEmailContentWebAdmin + sEmailFooterAdmin; oSmtpServer.Send(oMail3); } } catch (System.Web.Services.Protocols.SoapException ex) { // Catch the exception } }