Пример #1
0
        //BankDraft Payment
        public static PaymentResponse FrontierCheckPayment(CheckInfo request)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var    payResponse = new PaymentResponse();
            string batchCode   = System.Configuration.ConfigurationManager.AppSettings["CheckPaymantBatchCode"];

            try
            {
                FrontierPayClient objFrontierPay = new FrontierPayClient();
                WebEnrollmentNewDesign.PayService.FrontierPayResponse frontierPayResponse = new WebEnrollmentNewDesign.PayService.FrontierPayResponse();
                var payObject = new WebEnrollmentNewDesign.PayService.FrontierPayRequest()
                {
                    AuthKey          = request.AuthKey,
                    CustomerNumber   = request.CustomerNumber,
                    BatchCode        = batchCode,
                    SetupAutoPay     = "N",
                    PostReceipt      = "Y",
                    ConfirmationType = request.ConfirmationType,

                    AccountName       = request.BankAccountName,
                    BankAccountNumber = Encrypt(request.BankAccountNumber),
                    AccountType       = request.AccountType,
                    BankRoutingNumber = request.BankRoutingNumber,

                    Amount         = Convert.ToString(request.Amount),
                    Email          = request.Email,
                    PhoneNumber    = request.ContactNumber,
                    Source         = request.Source,
                    SiteIdentifier = request.SiteIdentifier
                };
                List <WebEnrollmentNewDesign.PayService.AddAdjustmentRequest> lstAdj = new List <WebEnrollmentNewDesign.PayService.AddAdjustmentRequest>();
                if (request.IsWriteoffAmount == 1)
                {
                    if (payObject.AddAdjustment != "Y")
                    {
                        payObject.AddAdjustment = "Y";
                    }

                    WebEnrollmentNewDesign.PayService.AddAdjustmentRequest adjbaddebit = new WebEnrollmentNewDesign.PayService.AddAdjustmentRequest();
                    adjbaddebit.AdjustmentAmount = Convert.ToString(request.Amount);
                    adjbaddebit.ReasonCode       = System.Configuration.ConfigurationManager.AppSettings["BadDebtReversal_ReasonCode"].ToString();
                    adjbaddebit.Note             = "";
                    lstAdj.Add(adjbaddebit);
                    //  payObject.AddAdjustmentRequestDetails = lstAdj;
                }
                else
                {
                    //IS Settled Amount
                    if (request.IsSettledAmount == 1 && request.IsWriteoffAmount == 0 && request.ARBalanceAmount > request.Amount)
                    {
                        if (payObject.AddAdjustment != "Y")
                        {
                            payObject.AddAdjustment = "Y";
                        }
                        WebEnrollmentNewDesign.PayService.AddAdjustmentRequest adjsettledamtreq = new WebEnrollmentNewDesign.PayService.AddAdjustmentRequest();
                        adjsettledamtreq.AdjustmentAmount = Convert.ToString(request.ARBalanceAmount - request.Amount);
                        adjsettledamtreq.ReasonCode       = System.Configuration.ConfigurationManager.AppSettings["IsSettled_ReasonCode"].ToString();
                        adjsettledamtreq.Note             = "";
                        lstAdj.Add(adjsettledamtreq);
                        //    payObject.AddAdjustmentRequestDetails = lstAdj;
                    }
                }
                try
                {
                    frontierPayResponse = objFrontierPay.PayByCheck(payObject);
                }
                catch (Exception ex)
                {
                    InsertClientErrorLog(request.CustomerNumber, batchCode, request.Source, ex, "Common_FrontierCheckPayment");
                }

                payResponse.ResultMessage = frontierPayResponse.ResponseMessage;
                payResponse.ResultCode    = Convert.ToInt32(frontierPayResponse.StatusCode);
                payResponse.AuthCode      = frontierPayResponse.ConfirmationNo;

                return(payResponse);
            }
            catch (Exception ex)
            {
                payResponse.ResultCode    = -3;
                payResponse.ResultMessage = ex.Message;
                InsertClientErrorLog(request.CustomerNumber, batchCode, request.Source, ex, "Common_FrontierCheckPayment");
                return(payResponse);
            }
        }