protected void SubmitButton_Click(object sender, EventArgs e)
        {

            ContactDetails PayerInformation = new ContactDetails();
            AddressDetails address = new AddressDetails();
            AddPaymentProfileRequest requestDetails = new AddPaymentProfileRequest();
          

            if (string.Format("{0}", Request.Form["BillingAddressFirstName"]) != null)
            {

                if (string.Format("{0}", Request.Form["BillingAddressCity"]) != null)
                {
                    
                    //Address data of customer paying the bill


                    address.FirstName = string.Format("{0}", Request.Form["BillingAddressFirstName"]);
                    address.LastName = string.Format("{0}", Request.Form["BillingAddressLastName"]);
                    address.StreetAddress1 = string.Format("{0}", Request.Form["BillingAddressAddress"]);

                    if (string.Format("{0}", Request.Form["BillingAddressAddress2"]) == null)
                        address.StreetAddress2 = "";
                    else
                        address.StreetAddress2 = string.Format("{0}", Request.Form["BillingAddressAddress2"]);

                    address.City = string.Format("{0}", Request.Form["BillingAddressCity"]);
                    address.State = string.Format("{0}", Request.Form["BillingAddressState"]);
                    address.PostalCode = string.Format("{0}", Request.Form["BillingAddressZip"]);
                    address.Country = string.Format("{0}", Request.Form["BillingAddressCountry"]);

                    PayerInformation.AddressInfo = address; //Set the payers contact information in the Cntact details construct
                    //Phone numbe profileId and email of customer paying the bill  Set the other information in the contact details construct.
                    PayerInformation.EmailAddress = string.Format("{0}", Request.Form["BillingAddressPhone"]);
                    PayerInformation.PhoneNumber = string.Format("{0}", Request.Form["BillingAddressEmail"]);
                    PayerInformation.Id = string.Format("{0}", Request.Form["PaymentProfileId"]);

                    //Set the value of Account holder details
                    requestDetails.AccountHolderDetails = PayerInformation;
                    //Agency data
                    requestDetails.ProfileName = ""; //TODO figure out where this comes from
                    //This is the final page in the sequence so you want to indicate success or failure clearly page needs to process URI provided data.
                    requestDetails.ResponsePostUrl = "https://http://accela-sf-kla.cloudapp.net/testapps/YouSubmitted.aspx";
                    //This is an account Identifier that should be unique to your implementation.
                    requestDetails.PaymentGatewayAccountIdentifier = "";
                    //This should Identify who is submitting the payment for the client
                    requestDetails.PaymentProcessor = "";

                    requestDetails.UserToken = ""; //TODO figure out how to pupulate this locally
                    requestDetails.GatewayName = "NMI";
                    //The only payment gateway currently supported is NMI

                    //Currently hardcoded  TODO expose on form and put in a default value; 
                    //implementers should hardcode their agency Identifier and retrieve application ID from the application.
                    requestDetails.ApplicationIdentifier = "00000001";
                    requestDetails.AgencyIdentifier = "00000001";

                    WebPaymentsClient client = new WebPaymentsClient();
                    PaymentProfile AddPaymentProfile = new PaymentProfile(client);


                    AddPaymentProfile.AddPaymentProfileByRequest(requestDetails);

                }
                else
                { Response.Redirect("YouSubmitted.aspx?text=NOTHING"); }
            }
            else
            { Response.Redirect("YouSubmitted.aspx?text=Masterpage content Not Found"); }
        }//close button submit
Esempio n. 2
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //Designate variable to get ahold of the Masterpage controls
            ContentPlaceHolder MpContentPlaceHolder;
            //Set variables for each of the Masterpage textboxs' so they can each be addressed.
            TextBox MpCustomerVaultIdTextBox;
            TextBox MpBillingAddressFirstNameTextBox;
            TextBox MpBillingAddressLastNameTextBox;
            TextBox MpBillingAddressAddressTextBox;
            TextBox MpBillingAddressAddress2TextBox;
            TextBox MpBillingAddressCityTextBox;
            TextBox MpBillingAddressStateTextBox;
            TextBox MpBillingAddressZipTextBox;
            TextBox MpBillingAddressCountryTextBox;
            TextBox MpBillingAddressPhoneTextBox;
            TextBox MpBillingAddressEmailTextBox;


            ContactDetails PayerInformation = new ContactDetails();
            AddressDetails address = new AddressDetails();
            AddPaymentProfileRequest requestDetails = new AddPaymentProfileRequest();

            MpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("MainContent");

            if (MpContentPlaceHolder != null)
            {
                MpCustomerVaultIdTextBox = (TextBox)MpContentPlaceHolder.FindControl("CustomerVaultId"); //In web payments this ID is the same as PaymentProfileID
                MpBillingAddressFirstNameTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressFirstName");
                MpBillingAddressLastNameTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressLastName");
                MpBillingAddressAddressTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressAddress");
                MpBillingAddressAddress2TextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressAddress2");
                MpBillingAddressCityTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressCity");
                MpBillingAddressStateTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressState");
                MpBillingAddressZipTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressZip");
                MpBillingAddressCountryTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressCountry");
                MpBillingAddressPhoneTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressPhone");
                MpBillingAddressEmailTextBox = (TextBox)MpContentPlaceHolder.FindControl("BillingAddressEmail");

                if (MpBillingAddressFirstNameTextBox != null && MpBillingAddressCityTextBox != null)
                {
                    //Trouble shooting code allowed me to make sure that I was grabbing the correct data.
                    /*
                           string text = MpCustomerVaultIdTextBox.Text + 
                               MpBillingAddressFirstNameTextBox.Text + 
                               MpBillingAddressLastNameTextBox.Text +
                                MpBillingAddressAddressTextBox.Text + 
                                MpBillingAddressCityTextBox.Text + 
                                MpBillingAddressStateTextBox.Text + 
                                MpBillingAddressZipTextBox.Text +
                                MpBillingAddressCountryTextBox.Text + 
                                MpBillingAddressPhoneTextBox.Text + 
                                MpBillingAddressEmailTextBox.Text;
                           Response.Redirect("YouSubmitted.aspx?text=" + text);
                      */

                    //Address data of customer paying the bill


                    address.FirstName = MpBillingAddressFirstNameTextBox.Text;
                    address.LastName = MpBillingAddressLastNameTextBox.Text;
                    address.StreetAddress1 = MpBillingAddressAddressTextBox.Text;

                    if (MpBillingAddressAddress2TextBox.Text == null)
                        address.StreetAddress2 = "";
                    else
                        address.StreetAddress2 = MpBillingAddressAddress2TextBox.Text;

                    address.City = MpBillingAddressCityTextBox.Text;
                    address.State = MpBillingAddressStateTextBox.Text;
                    address.PostalCode = MpBillingAddressZipTextBox.Text;
                    address.Country = MpBillingAddressCountryTextBox.Text;

                    PayerInformation.AddressInfo = address; //Set the payers contact information in the Cntact details construct
                    //Phone numbe profileId and email of customer paying the bill  Set the other information in the contact details construct.
                    PayerInformation.EmailAddress = MpBillingAddressEmailTextBox.Text;
                    PayerInformation.PhoneNumber = MpBillingAddressPhoneTextBox.Text;
                    PayerInformation.Id = MpCustomerVaultIdTextBox.Text;

                    //Set the value of Account holder details
                    requestDetails.AccountHolderDetails = PayerInformation;
                    //Agency data
                    requestDetails.ProfileName = ""; //TODO figure out where this comes from
                    //This is the final page in the sequence so you want to indicate success or failure clearly page needs to process URI provided data.
                    requestDetails.ResponsePostUrl = "https://http://accela-sf-kla.cloudapp.net/testapps/YouSubmitted.aspx";
                    //This is an account Identifier that should be unique to your implementation.
                    requestDetails.PaymentGatewayAccountIdentifier = "";
                    //This should Identify who is processing the payment for the client  NMI etc..
                    requestDetails.PaymentProcessor = "";

                    requestDetails.UserToken = "token1"; //TODO figure out how to pupulate this locally
                    requestDetails.GatewayName = "NMI";
                    //The only payment gateway currently supported is NMI

                    //Currently hardcoded  TODO expose on form and put in a default value; 
                    //implementers should hardcode their agency Identifier and retrieve application ID from the application.
                    requestDetails.ApplicationIdentifier = "00000001";
                    requestDetails.AgencyIdentifier = "00000001";

                    //Initialize a webpayments client
                    WebPaymentsClient client = new WebPaymentsClient();
                    PaymentProfile AddPaymentProfile = new PaymentProfile(client);

                    //Blindly send out an addpayment request.
                    AddPaymentProfile.AddPaymentProfileByRequest(requestDetails);

                }
                else
                { Response.Redirect("YouSubmitted.aspx?text=NOTHING"); }
            }
            else
            { Response.Redirect("YouSubmitted.aspx?text=Masterpage content Not Found"); }
        }//close button submit