public static void customerDataType(customerDataType request) { if (null != request) { if (0 <= (int)request.type) { request.typeSpecified = true; } } }
private long GetTransactionId() { //Creates a credit card transaction and returns the transactions ID. //Common code to set for all requests ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = TestEnvironment; //set up data based on transaction var transactionAmount = SetValidTransactionAmount(Counter); var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0622" }; var aCustomer = new customerDataType { email = string.Format("{0}@b.bla", Counter) }; //standard api call to retrieve response var paymentType = new paymentType { Item = creditCard }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), payment = paymentType, amount = transactionAmount, customer = aCustomer, }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); //validate Assert.NotNull(response); Assert.NotNull(response.messages); Assert.NotNull(response.transactionResponse); Assert.AreEqual(messageTypeEnum.Ok, response.messages.resultCode); Assert.False(string.IsNullOrEmpty(response.transactionResponse.transId)); long transactionId; long.TryParse(response.transactionResponse.transId, out transactionId); Assert.AreNotEqual(0, transactionId); return(transactionId); }
public void SetUp() { MockContext = new MockFactory(); //initialize counter Counter = _random.Next(1, (int)(Math.Pow(2, 24))); CounterStr = GetRandomString(""); _now = DateTime.UtcNow; _nowString = _now.ToString(DateFormat); _pastDate = _now.AddMonths(-1); _nowDate = _now; _futureDate = _now.AddMonths(1); CustomMerchantAuthenticationType = new merchantAuthenticationType { name = ApiLoginIdKey, ItemElementName = ItemChoiceType.transactionKey, Item = TransactionKey, }; // merchantAuthenticationType.setSessionToken(GetRandomString("SessionToken")); // merchantAuthenticationType.setPass_word(GetRandomString("Pass_word")); // merchantAuthenticationType.setMobileDeviceId(GetRandomString("MobileDevice")); // ImpersonationAuthenticationType impersonationAuthenticationType = new ImpersonationAuthenticationType(); // impersonationAuthenticationType.setPartnerLoginId(CnpApiLoginIdKey); // impersonationAuthenticationType.setPartnerTransactionKey(CnpTransactionKey); // merchantAuthenticationType.setImpersonationAuthentication(impersonationAuthenticationType); CustomerProfileType = new customerProfileType { merchantCustomerId = GetRandomString("Customer"), description = GetRandomString("CustomerDescription"), email = CounterStr + "*****@*****.**", }; //make sure these elements are initialized by calling get as it uses lazy initialization var paymentProfiles = CustomerProfileType.paymentProfiles; var addresses = CustomerProfileType.shipToList; CreditCardOne = new creditCardType { cardNumber = "4111111111111111", expirationDate = "2038-12", }; // creditCardOne.setCardCode(""); BankAccountOne = new bankAccountType { accountType = bankAccountTypeEnum.savings, routingNumber = "125000000", accountNumber = GetRandomString("A/C#"), nameOnAccount = GetRandomString("A/CName"), echeckType = echeckTypeEnum.WEB, bankName = GetRandomString("Bank"), checkNumber = CounterStr, }; TrackDataOne = new creditCardTrackType { ItemElementName = ItemChoiceType1.track1, Item = GetRandomString("Track1"), //trackDataOne.setTrack2(GetRandomString("Track2")); }; EncryptedTrackDataOne = new encryptedTrackDataType { FormOfPayment = new KeyBlock(), }; //keyBlock.setValue(value); PayPalOne = new payPalType { successUrl = GetRandomString("https://success.anet.net"), cancelUrl = GetRandomString("https://cancel.anet.net"), paypalLc = GetRandomString("Lc"), paypalHdrImg = GetRandomString("Hdr"), paypalPayflowcolor = GetRandomString("flowClr"), payerID = GetRandomString("PayerId"), }; PaymentOne = new paymentType { Item = CreditCardOne }; //paymentOne.setBankAccount(bankAccountOne); //paymentOne.setTrackData(trackDataOne); //paymentOne.setEncryptedTrackData(encryptedTrackDataOne); //paymentOne.setPayPal( payPalOne); // driversLicenseOne = new DriversLicenseType(); // driversLicenseOne.setNumber(GetRandomString("DLNumber")); // driversLicenseOne.setState(GetRandomString("WA")); // driversLicenseOne.setDateOfBirth(nowString); CustomerAddressOne = new customerAddressType { firstName = GetRandomString("FName"), lastName = GetRandomString("LName"), company = GetRandomString("Company"), address = GetRandomString("StreetAdd"), city = "Bellevue", state = "WA", zip = "98000", country = "USA", phoneNumber = FormatToPhone(Counter), faxNumber = FormatToPhone(Counter + 1), }; CustomerPaymentProfileOne = new customerPaymentProfileType { customerType = customerTypeEnum.individual, payment = PaymentOne, }; // customerPaymentProfileOne.setBillTo(customerAddressOne); // customerPaymentProfileOne.setDriversLicense(driversLicenseOne); // customerPaymentProfileOne.setTaxId(GetRandomString("XX")); CustomerOne = new customerType { type = customerTypeEnum.individual, id = GetRandomString("Id"), email = CounterStr + "*****@*****.**", phoneNumber = FormatToPhone(Counter), faxNumber = FormatToPhone(Counter + 1), driversLicense = DriversLicenseOne, taxId = "911011011", }; CustomerTwo = new customerType(); var interval = new paymentScheduleTypeInterval { length = 1, unit = ARBSubscriptionUnitEnum.months, }; OrderType = new orderType() { //TODO ADD VALIDATION ON INVOICE LENGTH invoiceNumber = GetRandomString("Inv:"), description = GetRandomString("Description"), }; NameAndAddressTypeOne = new nameAndAddressType { firstName = GetRandomString("FName"), lastName = GetRandomString("LName"), company = GetRandomString("Company"), address = GetRandomString("Address"), city = GetRandomString("City"), state = GetRandomString("State"), zip = "98004", country = "USA", }; NameAndAddressTypeTwo = new nameAndAddressType { firstName = GetRandomString("FName"), lastName = GetRandomString("LName"), company = GetRandomString("Company"), address = GetRandomString("Address"), city = GetRandomString("City"), state = GetRandomString("State"), zip = "98004", country = "USA", }; PaymentScheduleTypeOne = new paymentScheduleType { interval = interval, startDate = _nowDate, totalOccurrences = 5, trialOccurrences = 0, }; ArbSubscriptionOne = new ARBSubscriptionType { amount = SetValidSubscriptionAmount(Counter), billTo = NameAndAddressTypeOne, customer = CustomerOne, name = GetRandomString("Name"), order = OrderType, payment = PaymentOne, paymentSchedule = PaymentScheduleTypeOne, shipTo = NameAndAddressTypeOne, trialAmount = SetValidSubscriptionAmount(0), }; CustomerDataOne = new customerDataType { driversLicense = CustomerOne.driversLicense, email = CustomerOne.email, id = CustomerOne.id, taxId = CustomerOne.taxId, type = CustomerOne.type, }; RefId = CounterStr; }
public static Array PostPay(string AuthorizeLoginID, string AuthorizeTransactionKey, FetchResponse bookingDetails, PaymentViewModel payDetails, decimal AmountToBeCharged = 0) { string env = System.Configuration.ConfigurationManager.AppSettings["enviroment"].ToString(); if (env == "production") { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION; } else { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; } // define the merchant information (authentication / transaction id) ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = AuthorizeLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = AuthorizeTransactionKey, }; var orderType = new orderType { invoiceNumber = bookingDetails.lbkg.ToString(), description = "PreCheckIn payment", }; var customerData = new customerDataType { type = customerTypeEnum.individual, email = bookingDetails.guest.emai }; var creditCard = new creditCardType { cardNumber = payDetails.cardNumber.Replace(" ", ""), // bookingDetails.stay.card.numb.Replace(" ",""), expirationDate = payDetails.cardEndDate.Replace(" ", ""), // bookingDetails.stay.card.expy.Replace("/", ""), cardCode = payDetails.cardCode // bookingDetails.stay.card.auth }; var billingAddress = new customerAddressType { firstName = bookingDetails.guest.namf, lastName = bookingDetails.guest.naml, email = bookingDetails.guest.emai, address = bookingDetails.guest.addr.line1, city = bookingDetails.guest.addr.city, state = bookingDetails.guest.addr.stat, country = bookingDetails.guest.addr.cnty, company = bookingDetails.guest.comp, phoneNumber = bookingDetails.guest.phon, zip = bookingDetails.guest.addr.posc }; var retailType = new transRetailInfoType { marketType = "2", deviceType = "8" }; //standard api call to retrieve response var paymentType = new paymentType { Item = creditCard }; // Add line Items var lineItems = new lineItemType[1]; lineItems[0] = new lineItemType { itemId = "1", name = "PreCheckIn of booking " + bookingDetails.lbkg.ToString(), quantity = 1, unitPrice = bookingDetails.stay.fcst, totalAmount = AmountToBeCharged }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),// charge the card refTransId = bookingDetails.lbkg.ToString(), order = orderType, customer = customerData, lineItems = lineItems, payment = paymentType, amount = AmountToBeCharged, billTo = billingAddress, }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; // instantiate the controller that will call the service var controller = new createTransactionController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); Array response_array = new string[6]; // validate response if (response != null) { if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse.messages != null) { response_array.SetValue(response.transactionResponse.responseCode, 0); //Response Code response_array.SetValue(response.transactionResponse.messages[0].code, 1); //Message Code response_array.SetValue(response.transactionResponse.messages[0].description, 2); //Description response_array.SetValue(response.transactionResponse.authCode, 3); //Success, Auth Code response_array.SetValue(response.transactionResponse.transId, 4); //Transaction ID response_array.SetValue(bookingDetails.lbkg.ToString(), 5); //Reference ID Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId); Console.WriteLine("Response Code: " + response.transactionResponse.responseCode); Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code); Console.WriteLine("Description: " + response.transactionResponse.messages[0].description); Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode); } else { //Failed Transaction. if (response.transactionResponse.errors != null) { response_array.SetValue("2", 0); //Response Code response_array.SetValue(response.transactionResponse.errors[0].errorCode, 1); //Message Code response_array.SetValue(response.transactionResponse.errors[0].errorText, 2); //Description response_array.SetValue(response.transactionResponse.authCode, 3); //Success, Auth Code response_array.SetValue(response.transactionResponse.transId, 4); //Transaction ID response_array.SetValue(bookingDetails.lbkg.ToString(), 5); //Reference ID Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode); Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText); } } } else { //Failed Transaction. if (response.transactionResponse != null && response.transactionResponse.errors != null) { response_array.SetValue("2", 0); //Response Code response_array.SetValue(response.transactionResponse.errors[0].errorCode, 1); //Message Code response_array.SetValue(response.transactionResponse.errors[0].errorText, 2); //Description response_array.SetValue(response.transactionResponse.authCode, 3); //Success, Auth Code response_array.SetValue(response.transactionResponse.transId, 4); //Transaction ID response_array.SetValue(bookingDetails.lbkg.ToString(), 5); //Reference ID Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode); Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText); } else { response_array.SetValue("3", 0); //Response Code response_array.SetValue(response.messages.message[0].code, 1); //Message Code response_array.SetValue(response.messages.message[0].text, 2); //Description response_array.SetValue(response.transactionResponse.authCode, 3); //Success, Auth Code response_array.SetValue(response.transactionResponse.transId, 4); //Transaction ID response_array.SetValue(bookingDetails.lbkg.ToString(), 5); //Reference ID Console.WriteLine("Error Code: " + response.messages.message[0].code); Console.WriteLine("Error message: " + response.messages.message[0].text); } } } else { Console.WriteLine("Null Response."); response_array.SetValue("-1", 0); response_array.SetValue(bookingDetails.lbkg.ToString(), 5); //Reference ID } //return response; return(response_array); }
public async Task <ITransactionResponse> ChargeCreditCard(ICustomerPayment customerPayment) { var transactionResponse = new TransactionResponse(); var task = Task.Run(() => { if (Convert.ToBoolean(string.IsNullOrEmpty(ConfigurationManager.AppSettings["AuthNetIsProduction"]) ? "false" : ConfigurationManager.AppSettings["AuthNetIsProduction"])) { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION; } else { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; } // define the merchant information (authentication / transaction id) ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; var customerData = new customerDataType { id = customerPayment.Id, email = customerPayment.Email, type = customerTypeEnum.individual }; var creditCard = new creditCardType { cardNumber = customerPayment.CardNumber, expirationDate = customerPayment.ExpirationDate, cardCode = customerPayment.CardCode }; var billingAddress = new customerAddressType { company = customerPayment.Company, firstName = customerPayment.FirstName, lastName = customerPayment.LastName, address = customerPayment.Address, city = customerPayment.City, zip = customerPayment.Zip, email = customerPayment.Email }; //standard api call to retrieve response var paymentType = new paymentType { Item = creditCard }; // Add line Items var lineItems = new lineItemType[customerPayment.LineItems != null ? customerPayment.LineItems.Count : 0]; if (customerPayment.LineItems != null) { for (int i = 0; i < customerPayment.LineItems.Count; i++) { var lineItem = customerPayment.LineItems[i]; lineItems[i] = new lineItemType { itemId = lineItem.ItemId, description = lineItem.Description, name = lineItem.Name, quantity = lineItem.Quantity, unitPrice = lineItem.UnitPrice }; } } var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // charge the card customer = customerData, amount = customerPayment.Amount, payment = paymentType, billTo = billingAddress, lineItems = lineItems, customerIP = customerPayment.IpAddress, //refTransId = ? //used when voiding payments and should be an auth.net transId userFields = new userField[1] }; transactionRequest.userFields[0] = new userField() { name = "Customer Payment Id", value = customerPayment.Id }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; // instantiate the contoller that will call the service var controller = new createTransactionController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse != null) { transactionResponse.AuthCode = response.transactionResponse.authCode; transactionResponse.AccountNumber = response.transactionResponse.accountNumber; transactionResponse.AccountType = response.transactionResponse.accountType; transactionResponse.AvsResultCode = response.transactionResponse.avsResultCode; transactionResponse.CavvResultCode = response.transactionResponse.cavvResultCode; transactionResponse.CvvResultCode = response.transactionResponse.cvvResultCode; transactionResponse.Errors = null; transactionResponse.IsSuccess = true; transactionResponse.Messages = null; transactionResponse.RawResponseCode = response.transactionResponse.rawResponseCode; transactionResponse.RefTransID = response.transactionResponse.refTransID; transactionResponse.ResponseCode = response.transactionResponse.responseCode; transactionResponse.TestRequest = response.transactionResponse.testRequest; transactionResponse.TransHash = response.transactionResponse.transHash; transactionResponse.TransId = response.transactionResponse.transId; System.Diagnostics.Debug.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode); } } else if (response != null && response.messages.message != null) { transactionResponse.IsSuccess = false; System.Diagnostics.Debug.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); transactionResponse.Messages = new TransactionResponseMessage[] { new TransactionResponseMessage() { Code = response.messages.message[0].code, Description = response.messages.message[0].text } }; if (response.transactionResponse != null) { transactionResponse.AuthCode = response.transactionResponse.authCode; transactionResponse.AccountNumber = response.transactionResponse.accountNumber; transactionResponse.AccountType = response.transactionResponse.accountType; transactionResponse.AvsResultCode = response.transactionResponse.avsResultCode; transactionResponse.CavvResultCode = response.transactionResponse.cavvResultCode; transactionResponse.CvvResultCode = response.transactionResponse.cvvResultCode; transactionResponse.Errors = new TransactionResponseError[] { new TransactionResponseError() { ErrorCode = response.transactionResponse.errors[0].errorCode, ErrorText = response.transactionResponse.errors[0].errorText } }; transactionResponse.RawResponseCode = response.transactionResponse.rawResponseCode; transactionResponse.RefTransID = response.transactionResponse.refTransID; transactionResponse.ResponseCode = response.transactionResponse.responseCode; transactionResponse.TestRequest = response.transactionResponse.testRequest; transactionResponse.TransHash = response.transactionResponse.transHash; transactionResponse.TransId = response.transactionResponse.transId; System.Diagnostics.Debug.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } } return(response); }); await task; return(transactionResponse); }
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, decimal amount, Page p, out string token) { p.Response.Write("GetAnAcceptPaymentPage Sample\n"); ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; settingType[] settings = new settingType[3]; settings[0] = new settingType(); settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString(); settings[0].settingValue = "{\"text\": \"Pay\"}"; settings[1] = new settingType(); settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString(); settings[1].settingValue = "{\"show\": true}"; settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString(); settings[2].settingValue = "{\"showReceipt\": true, \"url\": \"http://*****:*****@test.com", taxId = "123" }; var order = new orderType(); order.invoiceNumber = "123123"; order.description = "234234"; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only amount = amount, lineItems = lineItems, billTo = billingAddress, customerIP = "192.1.1.1", order = order }; var request = new getHostedPaymentPageRequest(); request.transactionRequest = transactionRequest; request.hostedPaymentSettings = settings; request.refId = "11111111"; // instantiate the controller that will call the service var controller = new getHostedPaymentPageController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); // validate response if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { p.Response.Write("Message code : " + response.messages.message[0].code); p.Response.Write("Message text : " + response.messages.message[0].text); //p.Response.Write("Token : " + response.token); } else if (response != null) { p.Response.Write("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); p.Response.Write("Failed to get hosted payment page"); } token = response.token; return(response); }
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, decimal amount, Page p, out string token) { p.Response.Write("GetAnAcceptPaymentPage Sample\n"); ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; settingType[] settings = new settingType[3]; settings[0] = new settingType(); settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString(); settings[0].settingValue = "{\"text\": \"Pay\"}"; settings[1] = new settingType(); settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString(); settings[1].settingValue = "{\"show\": true}"; settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString(); settings[2].settingValue = "{\"url\": \"http://*****:*****@test.com", }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only amount = amount, lineItems = lineItems, billTo = billingAddress, refTransId = "123456", customer = customer, customerIP = "192.168.1.1", //payment = paymentType payment information should not be sent in hosted payment option this will not generate token }; var request = new getHostedPaymentPageRequest(); request.transactionRequest = transactionRequest; request.hostedPaymentSettings = settings; // instantiate the controller that will call the service var controller = new getHostedPaymentPageController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); // validate response if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { p.Response.Write("Message code : " + response.messages.message[0].code); p.Response.Write("Message text : " + response.messages.message[0].text); //p.Response.Write("Token : " + response.token); } else if (response != null) { p.Response.Write("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); p.Response.Write("Failed to get hosted payment page"); } token = response.token; return(response); }
private bool ProcessPayment() { RegistrationType regType = (RegistrationType)GetFromViewState(REG_TYPE_VIEW_STATE); // Create registration record int participantId = CreateRegistration(regType); ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION; ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { // Sandbox Account - Uncomment to run in sandbox mode //name = "3QeAr3WX7z", //Item = "9f896x36Uy242FQf", // ----------------------------------------------------- // Production Account - Uncomment to run in production mode name = "2B4f4zGR", Item = "98y32V6UX4kfStLz", // ----------------------------------------------------- ItemElementName = ItemChoiceType.transactionKey }; var creditCard = new creditCardType { cardNumber = txtCreditCardNumber.Text, expirationDate = (ddlExpirationMonth.SelectedValue + ddlExpirationYear.SelectedValue) }; var paymentType = new paymentType { Item = creditCard }; var billToType = new customerAddressType { firstName = txtFirstName.Text, lastName = txtLastName.Text, email = txtEmail.Text }; var customerType = new customerDataType { email = txtEmail.Text, type = customerTypeEnum.individual }; var orderType = new orderType { invoiceNumber = "2019 - " + participantId, description = "Preregistration for Ragnarok 2019" }; settingType[] settings = new settingType[] { new settingType { settingName = "emailCustomer", settingValue = "true" }, new settingType { settingName = "headerEmailReceipt", settingValue = "Receipt for your registration to attend Ragnarok 2019" }, new settingType { settingName = "footerEmailReceipt", settingValue = "Thank you for attending Ragnarok 2019, and we look forward to seeing you!" } }; var transcationSettingsType = new settingType { settingName = "emailCustomer", settingValue = "true" }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), amount = Convert.ToDecimal(regType.Cost), payment = paymentType, billTo = billToType, order = orderType, customer = customerType, transactionSettings = settings }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; try { var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); if (response.messages.resultCode == messageTypeEnum.Ok) { if (!regType.IsMinor) { SaveSignature(participantId); } CompleteRegistration(participantId, response.transactionResponse.authCode, response.transactionResponse.transId, regType); UpdateRegistration(participantId, "Paid"); } else { cardError.Text = "<br /><br />Error! " + response.messages.message[0].code + " " + response.messages.message[0].text; if (response.messages.message[0].code == "2") { UpdateRegistration(participantId, "Declined"); } else { UpdateRegistration(participantId, "Errored"); } return(false); } return(true); } catch (Exception ex) { cardError.Text = "<br /><br />Error! There was a problem submitting your payment. Please try again. If you are still unsuccessful, please contact Troll."; string errMessage = "Message: " + ex.Message; if (ex.InnerException != null) { errMessage += " | Inner Exception: " + ex.InnerException.Message; } AddError(errMessage); return(false); } }