public TransactionResponse AuthCreditCardVault(int peopleId, decimal amt, string description, int tranid) { var paymentInfo = db.PaymentInfos.Single(pp => pp.PeopleId == peopleId); if (paymentInfo?.AuNetCustPayId == null) { return new TransactionResponse { Approved = false, Message = "missing payment info", } } ; var paymentProfileId = paymentInfo.AuNetCustPayId.ToString(); var order = new Order(paymentInfo.AuNetCustId.ToString(), paymentProfileId, null) { Description = description, Amount = amt, InvoiceNumber = tranid.ToString() }; var response = CustomerGateway.Authorize(order); return(new TransactionResponse { Approved = response.Approved, AuthCode = response.AuthorizationCode, Message = response.Message, TransactionId = response.TransactionID }); }
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); }
private string SendAuthOnly(decimal amount, bool returnTransID) { 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,Y,2207702136,,,11.21,CC,auth_only,,,,,,,,,,,,[email protected],,,,,,,,,,,,,,C8E9860C9B9DF58A73FFD9D7A8BFB82F,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>"; LocalRequestObject.ResponseString = responseString; CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey); string profileID = "24231938"; string paymentProfileID = "22219473"; IGatewayResponse response = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { response = target.Authorize(profileID, paymentProfileID, amount); } catch (Exception e) { string s = e.Message; } if (response != null && response.Approved) { if (returnTransID) { return(response.TransactionID); } else { return(response.AuthorizationCode); } } else { return(""); } }