public void CreateTransactionWithECheckAuth_Only() { //Common code to set for all requests ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; //set up data based on transaction decimal transactionAmount = SetValidTransactionAmount(Counter); var echeck = new bankAccountType { accountNumber = "123456", accountType = bankAccountTypeEnum.checking, checkNumber = "1234", bankName = "Bank of Seattle", routingNumber = "125000024", echeckType = echeckTypeEnum.WEB, nameOnAccount = "Joe Customer" }; //standard api call to retrieve response var paymentType = new paymentType { Item = echeck }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), payment = paymentType, amount = transactionAmount, }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); //validate Assert.AreEqual("1", response.transactionResponse.messages[0].code); }
public static void Run(String ApiLoginID, String ApiTransactionKey, string TransactionID) { Console.WriteLine("Credit Bank Account"); 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 bankAccount = new bankAccountType { accountNumber = "4111111", routingNumber = "325070760", echeckType = echeckTypeEnum.WEB, // change based on how you take the payment (web, telephone, etc) nameOnAccount = "Test Name" }; //standard api call to retrieve response var paymentType = new paymentType { Item = bankAccount }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.refundTransaction.ToString(), // refund type payment = paymentType, amount = 126.44m, refTransId = TransactionID }; 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(); //validate if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse != null) { Console.WriteLine("Success, Transaction Code : " + response.transactionResponse.transId); } } else { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); if (response.transactionResponse != null) { Console.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText); } } }
public static void bankAccountType(bankAccountType argument) { if (null != argument) { if (0 <= (int)argument.accountType) { argument.accountTypeSpecified = true; } if (0 <= (int)argument.echeckType) { argument.echeckTypeSpecified = true; } } }
public static void bankAccountType(bankAccountType request) { if (null != request) { if (0 <= (int)request.accountType) { request.accountTypeSpecified = true; } if (0 <= (int)request.echeckType) { request.echeckTypeSpecified = true; } } }
public static void Run(String ApiLoginID, String ApiTransactionKey) { Console.WriteLine("CreateCustomerPaymentProfile Sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; var bankAccount = new bankAccountType { accountNumber = "01245524321", routingNumber = "000000204", accountType = bankAccountTypeEnum.checking, echeckType = echeckTypeEnum.WEB, nameOnAccount = "test", bankName = "Bank Of America" }; paymentType echeck = new paymentType {Item = bankAccount}; customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType(); echeckPaymentProfile.payment = echeck; var request = new createCustomerPaymentProfileRequest { customerProfileId = "35772885", paymentProfile = echeckPaymentProfile, validationMode = validationModeEnum.none }; //Prepare Request var controller = new createCustomerPaymentProfileController(request); controller.Execute(); //Send Request to EndPoint createCustomerPaymentProfileResponse response = controller.GetApiResponse(); if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response != null && response.messages.message != null) { Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId); } } else { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); if (response.messages.message[0].code == "E00039") { Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId); } } }
public void CreateTransactionWithECheckCapturePriorAuth() { //Common code to set for all requests ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; var rnd = new AnetRandom(DateTime.Now.Millisecond); //Build and submit an Auth only transaction that can later be captured. //set up data based on transaction var transactionAmount = SetValidTransactionAmount(Counter); var echeck = new bankAccountType { accountNumber = "123456", accountType = bankAccountTypeEnum.checking, checkNumber = "1234", bankName = "Bank of Seattle", routingNumber = "125000024", echeckType = echeckTypeEnum.WEB, nameOnAccount = "Joe Customer" }; //standard api call to retrieve response var paymentType = new paymentType { Item = echeck }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), payment = paymentType, amount = transactionAmount, }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); //Get transaction details var getDetailsReq = new getTransactionDetailsRequest { transId = response.transactionResponse.transId }; var getDetailsCont = new getTransactionDetailsController(getDetailsReq); getDetailsCont.Execute(); var getDetailsResp = getDetailsCont.GetApiResponse(); //Build and execute the capture request. var capECheck = new bankAccountType { accountNumber = ((AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType)(getDetailsResp.transaction.payment.Item)).accountNumber.TrimStart(new char[] { 'X' }), routingNumber = "XXXX", nameOnAccount = ((AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType)(getDetailsResp.transaction.payment.Item)).nameOnAccount, bankName = ((AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType)(getDetailsResp.transaction.payment.Item)).bankName, echeckType = ((AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType)(getDetailsResp.transaction.payment.Item)).echeckType, }; var capPayment = new paymentType { Item = capECheck }; var capTransactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.priorAuthCaptureTransaction.ToString(), refTransId = getDetailsResp.transaction.transId, }; request = new createTransactionRequest { transactionRequest = capTransactionRequest }; controller = new createTransactionController(request); controller.Execute(); var capResponse = controller.GetApiResponse(); //validate Assert.AreEqual("1", capResponse.transactionResponse.messages[0].code); }
public void CreateCustomerProfileFromECheckTransaction() { var rnd = new AnetRandom(DateTime.Now.Millisecond); string customerIndx = rnd.Next(99999).ToString(); ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; //set up data based on transaction var transactionAmount = SetValidTransactionAmount(Counter); var echeck = new bankAccountType { accountNumber = "123456", accountType = bankAccountTypeEnum.checking, checkNumber = "1234", bankName = "Bank of Seattle", routingNumber = "125000024", echeckType = echeckTypeEnum.WEB, nameOnAccount = "Joe Customer" }; //Create and submit transaction with customer info to create profile from. var paymentType = new paymentType { Item = echeck }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), payment = paymentType, amount = (decimal)transactionAmount, customer = new customerDataType { email = string.Format("Customer{0}@visa.com", customerIndx), taxId = string.Format("{0}{1}{2}", rnd.Next(999).ToString("000"), rnd.Next(99).ToString("00"), rnd.Next(9999).ToString("0000")) }, billTo = new customerAddressType { firstName = "New", lastName = string.Format("Customer{0}", customerIndx), company = "New Company", address = "1234 Sample St NE", city = "Bellevue", state = "WA", zip = "98001" }, shipTo = new customerAddressType { firstName = "New", lastName = string.Format("Customer{0}", customerIndx), company = "New Company", address = "1234 Sample St NE", city = "Bellevue", state = "WA", zip = "98001" } }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); //Verify that transaction was accepted and save the transaction ID Assert.AreEqual(messageTypeEnum.Ok, response.messages.resultCode); string txnID = response.transactionResponse.transId; //Build and submit request to create Customer Profile based on the accepted transaction createCustomerProfileFromTransactionRequest profileFromTransReq = new createCustomerProfileFromTransactionRequest(); profileFromTransReq.transId = txnID; createCustomerProfileFromTransactionController profileFromTrxnController = new createCustomerProfileFromTransactionController(profileFromTransReq); profileFromTrxnController.Execute(); createCustomerProfileResponse createProfResp = profileFromTrxnController.GetApiResponse(); Assert.AreEqual(messageTypeEnum.Ok, createProfResp.messages.resultCode); //Get customer profile and verify that profile data matches the data submitted with the transaction getCustomerProfileRequest profileReq = new getCustomerProfileRequest { customerProfileId = createProfResp.customerProfileId }; getCustomerProfileController getCustContr = new getCustomerProfileController(profileReq); getCustContr.Execute(); var getCustResp = getCustContr.GetApiResponse(); //validate Assert.AreEqual("1", response.transactionResponse.messages[0].code); }
public static void Run(string apiLoginId, string apiTransactionKey) { Console.WriteLine("CreateCustomerProfile Sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = apiLoginId, ItemElementName = ItemChoiceType.transactionKey, Item = apiTransactionKey, }; var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0718" }; var bankAccount = new bankAccountType { accountNumber = "0123454321", routingNumber = "000000204", accountType = bankAccountTypeEnum.checking, echeckType = echeckTypeEnum.WEB, nameOnAccount = "test", bankName = "Bank Of America" }; //standard api call to retrieve response paymentType cc = new paymentType { Item = creditCard }; paymentType echeck = new paymentType {Item = bankAccount}; List<customerPaymentProfileType> paymentProfileList = new List<customerPaymentProfileType>(); customerPaymentProfileType ccPaymentProfile = new customerPaymentProfileType(); ccPaymentProfile.payment = cc; customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType(); echeckPaymentProfile.payment = echeck; paymentProfileList.Add(ccPaymentProfile); paymentProfileList.Add(echeckPaymentProfile); List<customerAddressType> addressInfoList = new List<customerAddressType>(); customerAddressType homeAddress = new customerAddressType(); homeAddress.address = "10900 NE 8th St"; homeAddress.city = "Seattle"; homeAddress.zip = "98006"; customerAddressType officeAddress = new customerAddressType(); officeAddress.address = "1200 148th AVE NE"; officeAddress.city = "NorthBend"; officeAddress.zip = "92101"; addressInfoList.Add(homeAddress); addressInfoList.Add(officeAddress); customerProfileType customerProfile = new customerProfileType(); customerProfile.merchantCustomerId = "Test CustomerID"; customerProfile.email = "*****@*****.**"; customerProfile.paymentProfiles = paymentProfileList.ToArray(); customerProfile.shipToList = addressInfoList.ToArray(); var request = new createCustomerProfileRequest{ profile = customerProfile, validationMode = validationModeEnum.none}; var controller = new createCustomerProfileController(request); // instantiate the contoller that will call the service controller.Execute(); createCustomerProfileResponse response = controller.GetApiResponse(); // get the response from the service (errors contained if any) //validate if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response.messages.message != null) { Console.WriteLine("Success, CustomerProfileID : " + response.customerProfileId); Console.WriteLine("Success, CustomerPaymentProfileID : " + response.customerPaymentProfileIdList[0]); Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]); } } else { if (response != null) Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); } }