private Transaction MapResponse(string rawResponse, List <string> acceptedCodes = null)
        {
            var root = new ElementTree(rawResponse).Get("response");

            CheckResponse(root, acceptedCodes);
            var result = new Transaction {
                ResponseCode         = root.GetValue <string>("result"),
                ResponseMessage      = root.GetValue <string>("message"),
                CvnResponseCode      = root.GetValue <string>("cvnresult"),
                AvsResponseCode      = root.GetValue <string>("avspostcoderesponse"),
                Timestamp            = root.GetAttribute <string>("timestamp"),
                TransactionReference = new TransactionReference {
                    AuthCode               = root.GetValue <string>("authcode"),
                    OrderId                = root.GetValue <string>("orderid"),
                    PaymentMethodType      = PaymentMethodType.Credit,
                    TransactionId          = root.GetValue <string>("pasref"),
                    AlternativePaymentType = root.GetValue <string>("paymentmethod"),
                    BatchNumber            = root.GetValue <string>("batchid")
                }
            };

            // 3d secure enrolled
            if (root.Has("enrolled"))
            {
                result.ThreeDSecure          = new ThreeDSecure();
                result.ThreeDSecure.Enrolled = root.GetValue <string>("enrolled");
                result.ThreeDSecure.PayerAuthenticationRequest = root.GetValue <string>("pareq");
                result.ThreeDSecure.Xid          = root.GetValue <string>("xid");
                result.ThreeDSecure.IssuerAcsUrl = root.GetValue <string>("url");
            }

            // threedsecure
            if (root.Has("threedsecure"))
            {
                result.ThreeDSecure        = new ThreeDSecure();
                result.ThreeDSecure.Status = root.GetValue <string>("status");
                result.ThreeDSecure.Xid    = root.GetValue <string>("xid");
                result.ThreeDSecure.Cavv   = root.GetValue <string>("cavv");

                var eci = root.GetValue <string>("eci");
                if (!string.IsNullOrEmpty(eci))
                {
                    result.ThreeDSecure.Eci = int.Parse(eci);
                }

                var algorithm = root.GetValue <string>("algorithm");
                if (!string.IsNullOrEmpty(algorithm))
                {
                    result.ThreeDSecure.Algorithm = int.Parse(algorithm);
                }
            }

            // stored credential
            result.SchemeId = root.GetValue <string>("srd");

            return(result);
        }