public void TestCheckForErrorscreateCustomerProfileTransactionResponse() { const string profileId = "24231938"; const string paymentProfileId = "22219473"; var gateway = new CustomerGateway(ApiLogin, TransactionKey); var order = new Order(profileId, paymentProfileId, "") { Amount = (decimal)25.10 }; var response = gateway.AuthorizeAndCapture(order); Assert.IsNotNull(response); }
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 AuthorizeAndCaptureTest_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.,0PI2II,Y,2210620905,,,25.10,CC,auth_capture,Testing Extra Option,Sue,Zhu,Visa,123 Elm Street,Bellevue,WA,98006,US,,,[email protected],,,,,,,,,,,,,,070CC74A6FDD5EA7951444C547FE7829,,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.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.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.IsTrue(actual.AuthorizationCode.Trim().Length > 0); Assert.IsTrue(actual.TransactionID.Trim().Length > 0); Assert.IsTrue(long.Parse(actual.TransactionID) > 0); }
public TransactionResponse PayWithVault(int peopleId, decimal amt, string description, int tranid, string type) { var paymentInfo = db.PaymentInfos.Single(pp => pp.PeopleId == peopleId); if (paymentInfo == null) { return new TransactionResponse { Approved = false, Message = "missing payment info", } } ; string paymentProfileId; if (type == PaymentType.Ach) { paymentProfileId = paymentInfo.AuNetCustPayBankId.ToString(); } else if (type == PaymentType.CreditCard) { paymentProfileId = paymentInfo.AuNetCustPayId.ToString(); } else { throw new ArgumentException($"Type {type} not supported", nameof(type)); } var order = new Order(paymentInfo.AuNetCustId.ToString(), paymentProfileId, null) { Description = description, Amount = amt, InvoiceNumber = tranid.ToString() }; var response = CustomerGateway.AuthorizeAndCapture(order); return(new TransactionResponse { Approved = response.Approved, AuthCode = response.AuthorizationCode, Message = response.Message, TransactionId = response.TransactionID }); }