public void AuthorizeAndCaptureTest_InvoiceDescriptionPONumber() { //check login / password string sError = CheckLoginPassword(); Assert.IsTrue(sError == "", sError); string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,Q5G0UI,Y,2207641147,Invoice#123,Testing InvoiceDescriptionPONumber,25.10,CC,auth_capture,,,,,,,,,,,,[email protected],,,,,,,,,,,,,PO23456,BEEEB7C9F2F22B9955338A7E19427369,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>"; LocalRequestObject.ResponseString = responseString; XmlSerializer serializer = new XmlSerializer(typeof(createCustomerProfileTransactionResponse)); StringReader reader = new StringReader(responseString); createCustomerProfileTransactionResponse apiResponse = (createCustomerProfileTransactionResponse)serializer.Deserialize(reader); IGatewayResponse expected = new GatewayResponse(apiResponse.directResponse.Split(',')); CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey); string profileID = "24231938"; string paymentProfileID = "22219473"; Order order = new Order(profileID, paymentProfileID, ""); order.Amount = (decimal)25.10; order.InvoiceNumber = "Invoice#123"; order.Description = "Testing InvoiceDescriptionPONumber"; order.PONumber = "PO23456"; IGatewayResponse actual = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { actual = target.AuthorizeAndCapture(order); } catch (Exception e) { string s = e.Message; } Assert.AreEqual(expected.Amount, actual.Amount); Assert.AreEqual(expected.Approved, actual.Approved); Assert.AreEqual(expected.CardNumber, actual.CardNumber); Assert.AreEqual(expected.Message, actual.Message); Assert.AreEqual(expected.ResponseCode, actual.ResponseCode); Assert.AreEqual(expected.InvoiceNumber, actual.InvoiceNumber); Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0); Assert.IsTrue(actual.TransactionID.Trim().Length > 0); Assert.IsTrue(long.Parse(actual.TransactionID) > 0); }
public void SendTest_Capture_Approved() { //check login / password string sError = CheckLoginPassword(); Assert.IsTrue(sError == "", sError); //setup decimal amount = (decimal)25.12; string authCode = SendAuthOnly(amount + 1, false); Assert.IsTrue(authCode.Trim().Length > 0); //start testing string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,2JM6IE,P,2207702175,,,25.12,CC,capture_only,,,,,,,,,,,,[email protected],,,,,,,,,,,,,,5BB96CB66C1E0BCE123915E970D70166,,,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>"; LocalRequestObject.ResponseString = responseString; XmlSerializer serializer = new XmlSerializer(typeof(createCustomerProfileTransactionResponse)); StringReader reader = new StringReader(responseString); createCustomerProfileTransactionResponse apiResponse = (createCustomerProfileTransactionResponse)serializer.Deserialize(reader); IGatewayResponse expected = new GatewayResponse(apiResponse.directResponse.Split(',')); CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey); string profileID = "24231938"; string paymentProfileID = "22219473"; IGatewayResponse actual = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { actual = target.Capture(profileID, paymentProfileID, "", amount, authCode); } catch (Exception e) { string s = e.Message; } Assert.AreEqual(expected.Amount, actual.Amount); Assert.AreEqual(expected.Approved, actual.Approved); Assert.AreEqual(expected.CardNumber, actual.CardNumber); Assert.AreEqual(expected.Message, actual.Message); Assert.AreEqual(expected.ResponseCode, actual.ResponseCode); Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0); Assert.IsTrue(actual.TransactionID.Trim().Length > 0); Assert.IsTrue(long.Parse(actual.TransactionID) > 0); }
public void SendTest_PriorAuthCapture_Approved() { //check login / password string sError = CheckLoginPassword(); Assert.IsTrue(sError == "", sError); //setup decimal amount = (decimal)25.13; string transID = SendAuthOnly(amount + 1, true); Assert.IsTrue(transID.Trim().Length > 0); Assert.IsTrue(long.Parse(transID) > 0); //start testing string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,MFSOM8,P,2207702374,,,25.13,CC,prior_auth_capture,,,,,,,,,,,,,,,,,,,,,,,,,,E0DF3A88533C1F9CBE3B55159C514513,,,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>"; LocalRequestObject.ResponseString = responseString; XmlSerializer serializer = new XmlSerializer(typeof(createCustomerProfileTransactionResponse)); StringReader reader = new StringReader(responseString); createCustomerProfileTransactionResponse apiResponse = (createCustomerProfileTransactionResponse)serializer.Deserialize(reader); IGatewayResponse expected = new GatewayResponse(apiResponse.directResponse.Split(',')); CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey); IGatewayResponse actual = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { actual = target.PriorAuthCapture(transID, amount); } catch (Exception e) { string s = e.Message; } Assert.AreEqual(expected.Amount, actual.Amount); Assert.AreEqual(expected.Approved, actual.Approved); Assert.AreEqual(expected.CardNumber, actual.CardNumber); Assert.AreEqual(expected.Message, actual.Message); Assert.AreEqual(expected.ResponseCode, actual.ResponseCode); Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0); Assert.IsTrue(actual.TransactionID.Trim().Length > 0); Assert.IsTrue(long.Parse(actual.TransactionID) > 0); }
public void SendTest_AuthOnly_ExtraOptions() { //check login / password string sError = CheckLoginPassword(); Assert.IsTrue(sError == "", sError); string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,E4CGH9,Y,2210636215,,,25.15,CC,auth_only,Testing Extra Option,Sue,Zhu,Visa,123 Elm Street,Bellevue,WA,98006,US,,,[email protected],,,,,,,,,,,,,,3445C1C7DFFB2F32357A316DE94C13D1,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>"; LocalRequestObject.ResponseString = responseString; XmlSerializer serializer = new XmlSerializer(typeof(createCustomerProfileTransactionResponse)); StringReader reader = new StringReader(responseString); createCustomerProfileTransactionResponse apiResponse = (createCustomerProfileTransactionResponse)serializer.Deserialize(reader); IGatewayResponse expected = new GatewayResponse(apiResponse.directResponse.Split(',')); CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey); string profileID = "24231938"; string paymentProfileID = "22219473"; Order order = new Order(profileID, paymentProfileID, ""); order.Amount = (decimal)25.15; order.ExtraOptions = "x_customer_ip=100.0.0.1&x_cust_id=Testing Extra Options"; IGatewayResponse actual = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { actual = target.Authorize(order); } catch (Exception e) { string s = e.Message; } Assert.AreEqual(expected.Amount, actual.Amount); Assert.AreEqual(expected.Approved, actual.Approved); Assert.AreEqual(expected.CardNumber, actual.CardNumber); Assert.AreEqual(expected.Message, actual.Message); Assert.AreEqual(expected.ResponseCode, actual.ResponseCode); Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0); Assert.IsTrue(actual.TransactionID.Trim().Length > 0); Assert.IsTrue(long.Parse(actual.TransactionID) > 0); }
public void MockcreateCustomerProfileTransactionTest() { //define all mocked objects as final var mockController = GetMockController <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse>(); var mockRequest = new createCustomerProfileTransactionRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, transaction = new profileTransactionType { Item = new profileTransAuthCaptureType(), }, }; var transactionResponse = new transactionResponse() { accountNumber = "1234", }; var mockResponse = new createCustomerProfileTransactionResponse { refId = "1234", sessionToken = "sessiontoken", transactionResponse = transactionResponse, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse, createCustomerProfileTransactionController>( 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.transactionResponse); LogHelper.info(Logger, "createCustomerProfileTransaction: Details:{0}", controllerResponse.transactionResponse); }