public static void Run(string ApiLoginID, string ApiTransactionKey) { Console.WriteLine("CreateCustomerProfileFromTransaction Sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; var request = new createCustomerProfileFromTransactionRequest { transId = "2238147175" }; var controller = new createCustomerProfileFromTransactionController(request); controller.Execute(); createCustomerProfileResponse response = controller.GetApiResponse(); //validate if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response != null && 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 { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); } }
public void SampleCodeCreateCustomerProfileFromTransaction() { LogHelper.info(Logger, "Sample createCustomerProfileFromTransaction"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; //setup transaction to use var transactionId = GetTransactionId(); var createRequest = new createCustomerProfileFromTransactionRequest { refId = RefId, transId = transactionId.ToString(CultureInfo.InvariantCulture), }; //execute and get response var createController = new createCustomerProfileFromTransactionController(createRequest); var createResponse = createController.ExecuteWithApiResponse(); //validate Assert.NotNull(createResponse); Assert.NotNull(createResponse.messages); Assert.AreEqual(messageTypeEnum.Ok, createResponse.messages.resultCode); Assert.NotNull(createResponse.customerProfileId); Assert.NotNull(createResponse.customerPaymentProfileIdList); Assert.AreNotEqual(0, createResponse.customerPaymentProfileIdList.Length); long customerProfileId; long.TryParse(createResponse.customerProfileId, out customerProfileId); Assert.AreNotEqual(0, customerProfileId); long customerPaymentProfileId; long.TryParse(createResponse.customerPaymentProfileIdList[0], out customerPaymentProfileId); Assert.AreNotEqual(0, customerPaymentProfileId); //if shipping profile is added, shipping profile id will be retrieved too }
public void MockcreateCustomerProfileFromTransactionTest() { //define all mocked objects as final var mockController = GetMockController<createCustomerProfileFromTransactionRequest, createCustomerProfileResponse>(); var mockRequest = new createCustomerProfileFromTransactionRequest { merchantAuthentication = new merchantAuthenticationType() {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey}, transId = CounterStr, }; var mockResponse = new createCustomerProfileResponse { refId = "1234", sessionToken = "sessiontoken", customerProfileId = CounterStr, customerPaymentProfileIdList = new [] {CounterStr}, customerShippingAddressIdList = new [] {CounterStr}, }; var errorResponse = new ANetApiResponse(); var results = new List<String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations<createCustomerProfileFromTransactionRequest, createCustomerProfileResponse, createCustomerProfileFromTransactionController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.customerProfileId); LogHelper.info(Logger, "createCustomerProfileFromTransaction: Details:{0}", controllerResponse.customerProfileId); }
public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string transactionId) { Console.WriteLine("CreateCustomerProfileFromTransaction Sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; var customerProfile = new customerProfileBaseType { merchantCustomerId = "123212", email = "*****@*****.**", description = "This is a sample customer profile" }; var request = new createCustomerProfileFromTransactionRequest { transId = transactionId, // You can either specify the customer information in form of customerProfileBaseType object customer = customerProfile // OR // You can just provide the customer Profile ID // customerProfileId = "123343" }; var controller = new createCustomerProfileFromTransactionController(request); controller.Execute(); createCustomerProfileResponse response = controller.GetApiResponse(); //validate if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response != null && 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); } return response; }
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 createCustomerProfileFromTransactionRequest(createCustomerProfileFromTransactionRequest argument) { if (null != argument) { } }
public static void createCustomerProfileFromTransactionRequest(createCustomerProfileFromTransactionRequest argument) { if (null != argument) { customerProfileBaseType(argument.customer); } }