Пример #1
0
        public string ReversePayment(MetaDataViewDto metaData, PaymentViewDto payment)
        {
            ReverseRequestFactory reverseRequestFactory = new ReverseRequestFactory();
            RestClientTool <ReverseRequest, ReverseResponse> restClient = new RestClientTool <ReverseRequest, ReverseResponse>();

            ReverseRequest reverseRequest = reverseRequestFactory
                                            .AddOriginalPaymentReferenceNumber(payment.PaymentReferenceNumber).AddMsisdn(metaData.Msisdn)
                                            .AddClientIPAddress(metaData.ClientIPAddress).Build();

            ReverseResponse reverseResponse = restClient.RestClientRequest(Constants.REVERSE_URL, reverseRequest);

            if (reverseResponse.ResponseHeader.ResponseCode != null && reverseResponse.ResponseHeader.ResponseCode == "0")
            {
                return(reverseResponse.ApprovalCode);
            }
            else if (reverseResponse.ResponseHeader != null)
            {
                string errorMessage = "Reverse payment was not successful: [%s], %s" + reverseResponse.ResponseHeader.ResponseCode + reverseResponse.ResponseHeader.ResponseDescription;
                throw new Exception(errorMessage);
            }
            else
            {
                string errorMessage = "Reverse payment was not successful, response status info is empty.";
                throw new Exception(errorMessage);
            }
        }
Пример #2
0
        public override ReverseResponse Reverse(string transactionId)
        {
            try
            {
                this._action = "/reversePayment";

                var package = new XElement("internalReference",
                                           transactionId
                                           );

                XElement reverse = new XElement(p2p + "reversePayment", package);

                string response = this.CallWebService(reverse);

                JObject res  = JObject.Parse(response);
                var     data = res["ns1:reversePaymentResponse"]["reversePaymentResult"];

                return(JsonConvert.DeserializeObject <ReverseResponse>(data.ToString()));
            }
            catch (Exception ex)
            {
                Status          status          = new Status("ERROR", "WR", PlacetoPayException.ReadException(ex), (DateTime.Now).ToString("yyyy-MM-ddTHH\\:mm\\:sszzz"));
                ReverseResponse reverseResponse = new ReverseResponse(null, status);

                return(reverseResponse);
            }
        }
Пример #3
0
        public ReverseResponse Reverse(ReverseRequest request)
        {
            var response = new ReverseResponse();

            response.Success();

            return(response);
        }
        public override ReverseResponse Reverse(string transactionId)
        {
            try
            {
                Object internalReference = new { internalReference = transactionId };
                string endpoint          = "api/reverse";
                string method            = "POST";
                var    response          = this.MakeRequest(method, endpoint, internalReference);

                return(JsonConvert.DeserializeObject <ReverseResponse>(response));
            }
            catch (Exception ex)
            {
                Status          status          = new Status("ERROR", "WR", PlacetoPayException.ReadException(ex), (DateTime.Now).ToString("yyyy-MM-ddTHH\\:mm\\:sszzz"));
                ReverseResponse reverseResponse = new ReverseResponse(null, status);

                return(reverseResponse);
            }
        }
Пример #5
0
        protected override ReverseCallbackResponse GetCallback(ResultResponse request)
        {
            if (request.Result == null)
            {
                throw new ArgumentNullException(nameof(request.Result));
            }

            var callback = new ReverseCallbackResponse();

            if (request.Result.ResultCode == 0)
            {
                callback.Data = ReverseResponse.From(request.Result);
            }
            else
            {
                callback.Error = AccountError.From(request.Result);
            }

            return(callback);
        }
Пример #6
0
        public ReverseResponse GetResult(string Email, Int64 ApplicationNo, string ScreeningStatus, string MedicalStatus)
        {
            string     url   = "https://api.nopaperforms.com/post-application/344/1713";
            string     DOJ   = DateTime.Now.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            string     data  = "{\"secret_key\":\"8944bacfb52da67bac5a1ba3e5a20d94\", \"form_id\":\"1713\",\"email\":\"" + Email + "\",\"application_no\":\"" + ApplicationNo + "\",\"enrolled_campus\":\"" + MedicalStatus + "\",\"application_stage\":\"Enrolled\",\"enrolled_department\":\"" + ScreeningStatus + "\",\"mode\":\"update\",\"field_190095\":\"" + DOJ + "\"}";
            WebRequest myReq = WebRequest.Create(url);

            myReq.Method        = "POST";
            myReq.ContentLength = data.Length;
            myReq.ContentType   = "application/json; charset=UTF-8";
            UTF8Encoding enc = new UTF8Encoding();

            using (Stream ds = myReq.GetRequestStream())
            {
                ds.Write(enc.GetBytes(data), 0, data.Length);
            }
            WebResponse     wr            = myReq.GetResponse();
            Stream          receiveStream = wr.GetResponseStream();
            StreamReader    reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string          content       = reader.ReadToEnd();
            ReverseResponse obj           = JsonConvert.DeserializeObject <ReverseResponse>(content);

            return(obj);
        }
Пример #7
0
        public void Reverse_Response_With_Status()
        {
            string result =
                "{\n" +
                "  \"status\": {\n" +
                "    \"status\": \"APPROVED\",\n" +
                "    \"reason\": \"00\",\n" +
                "    \"message\": \"Se ha reversado el pago correctamente\",\n" +
                "    \"date\": \"2020-08-02T02:30:21-05:00\"\n" +
                "  },\n" +
                "  \"payment\": {\n" +
                "    \"reference\": \"TEST_20200802_022754\",\n" +
                "    \"amount\": {\n" +
                "      \"currency\": \"COP\"\n" +
                "    },\n" +
                "    \"allowPartial\": false,\n" +
                "    \"subscribe\": false\n" +
                "  }\n" +
                "}";

            var reverseResponse = new ReverseResponse(result);

            Assert.True(reverseResponse.IsSuccessful());
        }