コード例 #1
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);
        }
コード例 #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));
            }
        }