예제 #1
0
        public async Task <object> RequestReconciliationReportAsync(int daysAgo, String productSPCode)
        {
            daysAgo = -1 * daysAgo;

            GepgUtility gepg = new GepgUtility(_hostingEnvironment, config, _loggerFactory);

            ReconcRequest Reconciliation = new ReconcRequest();

            gepgSpReconcReq request = new gepgSpReconcReq();

            request.SpReconcReqId = Math.Abs(Guid.NewGuid().GetHashCode());//Convert.ToInt32(DateTime.UtcNow.Year.ToString() + DateTime.UtcNow.Month.ToString() + DateTime.UtcNow.Day.ToString());
            request.SpCode        = productSPCode;
            request.SpSysId       = Configuration["PaymentGateWay:GePG:SystemId"];
            request.TnxDt         = DateTime.Now.AddDays(daysAgo).ToString("yyyy-MM-dd");
            request.ReconcOpt     = 1;

            var    requestString = gepg.SerializeClean(request, typeof(gepgSpReconcReq));
            string signature     = gepg.GenerateSignature(requestString);
            var    signedRequest = gepg.FinaliseSignedMsg(new ReconcRequest()
            {
                gepgSpReconcReq = request, gepgSignature = signature
            }, typeof(ReconcRequest));

            var result = await gepg.SendHttpRequest("/api/reconciliations/sig_sp_qrequest", signedRequest, productSPCode, "default.sp.in");

            var content = signedRequest + "********************" + result;

            _gepgFileLogger.Log(productSPCode + "_GepGReconRequest", content);

            return(new { reconcId = request.SpReconcReqId, resp = result });
        }
예제 #2
0
        public override async Task <PostReqCNResponse> PostReqControlNumberAsync(string OfficerCode, int PaymentId, string PhoneNumber, decimal ExpectedAmount, List <PaymentDetail> products, string controlNumber = null, bool acknowledge = false, bool error = false, string rejectedReason = "")
        {
            GepgUtility gepg = new GepgUtility(_hostingEnvironment, config, _loggerFactory);

            ExpectedAmount = Math.Round(ExpectedAmount, 2);
            //send request only when we have amount > 0
            if (ExpectedAmount > 0)
            {
                var bill = gepg.CreateBill(Configuration, OfficerCode, PhoneNumber, PaymentId, ExpectedAmount, GetPaymentDetails(PaymentId));

                if (bill != "-2: error - no policy")
                {
                    var signature = gepg.GenerateSignature(bill);

                    var signedMesg = gepg.FinaliseSignedMsg(signature);
                    var billAck    = await gepg.SendHttpRequest("/api/bill/sigqrequest", signedMesg, gepg.GetAccountCodeByProductCode(InsureeProducts.FirstOrDefault().ProductCode), "default.sp.in");

                    string billAckRequest = JsonConvert.SerializeObject(billAck);
                    string sentbill       = JsonConvert.SerializeObject(bill);

                    _gepgFileLogger.Log(PaymentId, "CN_Request", sentbill + "********************" + billAckRequest);

                    //check if timeout in GePG server
                    if (billAck == "The operation has timed out.")
                    {
                        var rejectedReasonText = "Timeout when requesting control number";
                        return(await base.PostReqControlNumberAsync(OfficerCode, PaymentId, PhoneNumber, ExpectedAmount, products, null, true, true, rejectedReasonText));
                    }

                    //get the error code from ackn GePG request
                    var errorCodes = LoadResponseCodeFromXmlAkn(billAck);
                    if (errorCodes == "7101")
                    {
                        return(await base.PostReqControlNumberAsync(OfficerCode, PaymentId, PhoneNumber, ExpectedAmount, products, null, true, false));
                    }
                    else
                    {
                        //we have an error from GePG ackn - then save rejected reason
                        var rejectedReasonText = PrepareRejectedReason(PaymentId, errorCodes);
                        return(await base.PostReqControlNumberAsync(OfficerCode, PaymentId, PhoneNumber, ExpectedAmount, products, null, true, true, rejectedReasonText));
                    }
                }
                else
                {
                    return(await base.PostReqControlNumberAsync(OfficerCode, PaymentId, PhoneNumber, ExpectedAmount, products, null, true, true));
                }
            }
            else
            {
                //do not send any request to GePG when we have 0 or negative amount
                return(await base.PostReqControlNumberAsync(OfficerCode, PaymentId, PhoneNumber, ExpectedAmount, products, null, true, true));
            }
        }
예제 #3
0
        public string ReconciliationResp(int code)
        {
            GepgUtility gepg = new GepgUtility(_hostingEnvironment, config, _loggerFactory);

            gepgSpReconcRespAck ReconcAck = new gepgSpReconcRespAck();

            ReconcAck.ReconcStsCode = code;

            var    ReconcAckString = gepg.SerializeClean(ReconcAck, typeof(gepgSpReconcRespAck));
            string signature       = gepg.GenerateSignature(ReconcAckString);
            var    signedReconcAck = gepg.FinaliseSignedAcks(new GepgReconcRespAck()
            {
                gepgSpReconcRespAck = ReconcAck, gepgSignature = signature
            }, typeof(GepgReconcRespAck));

            return(signedReconcAck);
        }
예제 #4
0
        public string PaymentResp(int code)
        {
            GepgUtility gepg = new GepgUtility(_hostingEnvironment, config, _loggerFactory);

            gepgPmtSpInfoAck PayAck = new gepgPmtSpInfoAck();

            PayAck.TrxStsCode = code;

            var    PayAckString = gepg.SerializeClean(PayAck, typeof(gepgPmtSpInfoAck));
            string signature    = gepg.GenerateSignature(PayAckString);
            var    signedPayAck = gepg.FinaliseSignedAcks(new GepgPaymentAck()
            {
                gepgPmtSpInfoAck = PayAck, gepgSignature = signature
            }, typeof(GepgPaymentAck));

            return(signedPayAck);
        }
예제 #5
0
        public string ControlNumberResp(int code)
        {
            GepgUtility gepg = new GepgUtility(_hostingEnvironment, config, _loggerFactory);

            gepgBillSubRespAck CnAck = new gepgBillSubRespAck();

            CnAck.TrxStsCode = code;

            var    CnAckString = gepg.SerializeClean(CnAck, typeof(gepgBillSubRespAck));
            string signature   = gepg.GenerateSignature(CnAckString);
            var    signedCnAck = gepg.FinaliseSignedAcks(new GepgBillResponseAck()
            {
                gepgBillSubRespAck = CnAck, gepgSignature = signature
            }, typeof(GepgBillResponseAck));

            return(signedCnAck);
        }
예제 #6
0
        public override async Task <string> RequestBulkControlNumbers(RequestBulkControlNumbersModel model)
        {
            var gepg  = new GepgUtility(_hostingEnvironment, Configuration, _loggerFactory);
            var bills = await gepg.CreateBulkBills(Configuration, model);

            var signature  = gepg.GenerateSignature(bills);
            var signedMesg = gepg.FinaliseSignedMsg(signature);

            string accountCode = gepg.GetAccountCodeByProductCode(model.ProductCode);

            var billAck = await gepg.SendHttpRequest("/api/bill/sigqrequest", signedMesg, accountCode, "default.sp.in");

            string sentbill = JsonConvert.SerializeObject(bills);

            _gepgFileLogger.Log("Bulk_CN_Request", sentbill + "********************" + billAck);

            // if the response is not 7101(SUCCESS) then delete all the entries from DB
            if (!billAck.Contains("7101"))
            {
                _ = DeleteFailedControlNumberRequests(bills);
            }

            return(billAck);
        }