Esempio n. 1
0
        public static ClientRequestResponseBase ThrowError(string error, ClientRequestResponseBase entity)
        {
            ClientRequestResponseBase response = new ClientRequestResponseBase();
            if (entity is PaymentNotificationRequest)
            {
                PaymentNotificationResponse apn = new PaymentNotificationResponse();
                apn.DistributorCostCenterId = entity.DistributorCostCenterId;
                apn.StatusCode = "Error";
                apn.StatusDetail = error;
                response = apn;
            }
            else if (entity is PaymentInstrumentRequest)
            {
                PaymentInstrumentResponse pi = new PaymentInstrumentResponse();
                pi.StatusCode = "Error";
                pi.StatusDetail = error;
                response = pi;
            }
            else if (entity is PaymentRequest)
            {
                PaymentResponse apr = new PaymentResponse();
                apr.StatusCode = "Error";
                apr.StatusDetail = error;
                response = apr;
            }
            else if(entity is DocSMSResponse)
            {
                DocSMSResponse sms = new DocSMSResponse();
                sms.SdpResponseCode = "Error";
                sms.SdpResponseStatus = error;
                response = sms;
            }

            return response;
        }
Esempio n. 2
0
        public async Task<PaymentInstrumentResponse> GetPaymentInstrumentListAsync(PaymentInstrumentRequest request)
        {
            PaymentInstrumentResponse _response = new PaymentInstrumentResponse();
            HttpClient httpClient = setupHttpClient();
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            string url = "api/bridge/payment/getpaymentinstrumentlist";
            try
            {
                var response = await httpClient.PostAsJsonAsync(url, request);
                _response = await response.Content.ReadAsAsync<PaymentInstrumentResponse>();
            }
            catch (Exception ex)
            {
                string error = "Failed to retrieve payment instrument list.\n" +
                               (ex.InnerException == null ? "" : ex.InnerException.Message);
                _log.Error(error);
                _response.StatusCode = "Error";
                _response.StatusDetail = error;
            }

            return _response;
        }
Esempio n. 3
0
        public ClientRequestResponseBase DeserializeSDPResponse(string jsonResponse, ClientRequestResponseType responseType)
        {
            ClientRequestResponseBase crr = null;
            try
            {
                JObject jo = JObject.Parse(jsonResponse);

                string statusCode = (string) jo["statusCode"];
                if (statusCode == "E1340" || statusCode == "E1304")
                    return null;

                switch (responseType)
                {
                    case ClientRequestResponseType.PaymentInstrument:
                        SDPPaymentInstrumentResponse sdppir = null;
                        _messageValidation.CanDeserializeMessage(jsonResponse, out sdppir);
                        PaymentInstrumentResponse pir = new PaymentInstrumentResponse();

                        pir.Id = Guid.NewGuid();
                        pir.DateCreated = DateTime.Now;
                        pir.ClientRequestResponseType = ClientRequestResponseType.PaymentInstrument;
                        pir.PaymentInstrumentList = sdppir.paymentInstrumentList;
                        pir.StatusCode = sdppir.statusCode;
                        pir.StatusDetail = sdppir.statusDetail;

                        crr = pir;
                        break;

                    case ClientRequestResponseType.AsynchronousPayment:
                        SDPPaymentResponse sdppr = null;
                        PaymentResponse apr = new PaymentResponse();
                        _messageValidation.CanDeserializeMessage(jsonResponse, out sdppr);

                        apr.ClientRequestResponseType = ClientRequestResponseType.AsynchronousPayment;
                        apr.Id = Guid.NewGuid();
                        apr.SDPTransactionRefId = sdppr.internalTrxId;
                        if (sdppr.externalTrxId != null)
                            apr.TransactionRefId = ConstructMyGuid(sdppr.externalTrxId).ToString();
                        apr.BusinessNumber = sdppr.businessNumber;
                        apr.DateCreated = sdppr.timeStamp;
                        apr.SDPReferenceId = sdppr.referenceId.ToString();
                        apr.StatusCode = sdppr.statusCode;
                        apr.StatusDetail = sdppr.statusDetail;
                        apr.ShortDescription = sdppr.statusDetail;
                        apr.LongDescription = sdppr.longDescription;
                        apr.TimeStamp = sdppr.timeStamp.ToString() == "1/1/0001 12:00:00 AM" ? DateTime.Now : sdppr.timeStamp;
                        apr.AmountDue = Convert.ToDouble(sdppr.amountDue);
                        crr = apr;
                        break;
                }
            }
            catch (Exception ex)
            {
                _auditLogRepository.AddLog(Guid.Empty, responseType.ToString(), "Client", "Error deserializing jsonResponse " + jsonResponse + " in DeserializeSDPResponse.\nException details: \n" +
                   ex.Message + ex.InnerException != null ? "\n" + ex.InnerException.Message : "");
                return null;
            }

            return crr;
        }
Esempio n. 4
0
        PaymentInstrumentResponse GetSamplePaymentList()
        {
            PaymentInstrumentResponse resp          = new PaymentInstrumentResponse();
            List<SDPPaymentInstrument> paymentInst     = SamplePaymentList();
            resp.PaymentInstrumentList              = paymentInst;
            resp.Id                                 = Guid.NewGuid();
            resp.TransactionRefId                   = Guid.NewGuid().ToString();
            resp.ClientRequestResponseType          = ClientRequestResponseType.PaymentInstrument;
            resp.DateCreated                        = DateTime.Now;
            resp.StatusDetail                       = "Success";

            return resp;
        }
Esempio n. 5
0
        ClientRequestResponseBase ThrowError(string error, ClientRequestResponseBase enitity)
        {
            ClientRequestResponseBase response = new ClientRequestResponseBase();
            if (enitity is PaymentNotificationRequest)
            {
                PaymentNotificationResponse apn = new PaymentNotificationResponse();
                apn.DistributorCostCenterId = enitity.DistributorCostCenterId;
                apn.StatusCode = "Failed";
                apn.StatusDetail = error;
                response = apn;
            }
            else if (enitity is PaymentInstrumentRequest)
            {
                PaymentInstrumentResponse pi = new PaymentInstrumentResponse();
                pi.StatusDetail = "Failed: " + error;
                response = pi;
            }
            else if (enitity is PaymentRequest)
            {
                PaymentResponse apr = new PaymentResponse();
                apr.StatusCode = "Failed";
                apr.StatusDetail = error;
                response = apr;
            }

            return response;
        }