public ResultImpl(NodeWrapper node, IBraintreeGateway gateway) { if (node.IsSuccess()) { Target = newInstanceFromResponse(node, gateway); } else { Errors = new ValidationErrors(node); NodeWrapper verificationNode = node.GetNode("verification"); if (verificationNode != null) { CreditCardVerification = new CreditCardVerification(verificationNode, gateway); } NodeWrapper transactionNode = node.GetNode("transaction"); if (transactionNode != null) { Transaction = new Transaction(transactionNode, gateway); } NodeWrapper subscriptionNode = node.GetNode("subscription"); if (subscriptionNode != null) { Subscription = new Subscription(subscriptionNode, gateway); } Parameters = node.GetNode("params").GetFormParameters(); Message = node.GetString("message"); } }
public void ConstructFromResponse() { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.Append("<api-error-response>"); builder.Append(" <verification>"); builder.Append(" <avs-error-response-code nil=\"true\"></avs-error-response-code>"); builder.Append(" <avs-postal-code-response-code>I</avs-postal-code-response-code>"); builder.Append(" <status>processor_declined</status>"); builder.Append(" <processor-response-code>2000</processor-response-code>"); builder.Append(" <avs-street-address-response-code>I</avs-street-address-response-code>"); builder.Append(" <processor-response-text>Do Not Honor</processor-response-text>"); builder.Append(" <cvv-response-code>M</cvv-response-code>"); builder.Append(" </verification>"); builder.Append(" <errors>"); builder.Append(" <errors type=\"array\"/>"); builder.Append(" </errors>"); builder.Append("</api-error-response>"); XmlDocument doc = new XmlDocument(); doc.LoadXml(builder.ToString()); CreditCardVerification verification = new CreditCardVerification(new NodeWrapper(doc).GetNode("//verification")); Assert.AreEqual(null, verification.AvsErrorResponseCode); Assert.AreEqual("I", verification.AvsPostalCodeResponseCode); Assert.AreEqual(VerificationStatus.PROCESSOR_DECLINED, verification.Status); Assert.AreEqual("2000", verification.ProcessorResponseCode); Assert.AreEqual("I", verification.AvsStreetAddressResponseCode); Assert.AreEqual("Do Not Honor", verification.ProcessorResponseText); Assert.AreEqual("M", verification.CvvResponseCode); }
public void ConstructFromResponseWithNoVerification() { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.Append("<api-error-response>"); builder.Append(" <errors>"); builder.Append(" <errors type=\"array\"/>"); builder.Append(" </errors>"); builder.Append("</api-error-response>"); XmlDocument doc = new XmlDocument(); doc.LoadXml(builder.ToString()); CreditCardVerification verification = new CreditCardVerification(new NodeWrapper(doc).GetNode("//verification")); Assert.AreEqual(null, verification.AvsErrorResponseCode); Assert.AreEqual(null, verification.AvsPostalCodeResponseCode); Assert.AreEqual(null, verification.Status); Assert.AreEqual(null, verification.ProcessorResponseCode); Assert.AreEqual(null, verification.AvsStreetAddressResponseCode); Assert.AreEqual(null, verification.ProcessorResponseText); Assert.AreEqual(null, verification.CvvResponseCode); }