示例#1
0
        public Transaction MapResponse(PayFacBuilder builder, string rawResponse)
        {
            var root         = new ElementTree(rawResponse).Get("XMLResponse");
            var responseCode = root.GetValue <string>("status");

            if (responseCode != "00")
            {
                throw new GatewayException($"Unexpected Gateway Response: {responseCode}", responseCode);
            }

            var proPayResponse = PopulateProPayResponse(builder, root);

            var response = new Transaction()
            {
                PayFacData   = proPayResponse,
                ResponseCode = responseCode
            };

            return(response);
        }
        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")
                }
            };

            // 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);
                }
            }

            return(result);
        }