public static void VendorSettlement(TransferFunds transferFunds, string OriTxnDate, string suspenseAcct, string Narration)
        {
            var serviceBusTransferRequest = new SettlementRequest()
            {
                Amount      = transferFunds.amount,
                ChannelId   = transferFunds.ChannelId,
                ClientKey   = transferFunds.ClientKey,
                CodedString = transferFunds.CodedString,
                DestinationAccountNumber = suspenseAcct,
                Narration    = Narration,
                OriginalStan = transferFunds.TransactionStan,
                OriginalTransactionDateTime = OriTxnDate,
                PlatformReference           = transferFunds.ResponseTransferReference,
                SourceAccountNumber         = transferFunds.destinationAccountNumber,
                TransactionReference        = transferFunds.transactionReference,
                TransactionType             = transferFunds.TransactionType
            };

            var serviceBusCall = new ServiceBusManagement(AirtimeDomainAppsettingManager.GetSettlementQueueConnectionString()).PushToQueue(serviceBusTransferRequest, AirtimeDomainAppsettingManager.GetSettlementQueueName());
        }
        public async Task <Result <Airtime> > BuyAirtime()
        {
            _logger.LogInformation($"Airtime log is working");

            string GlobalAccount = AppsettingsManager.GetConfig("GlobalAccount");
            // string Clientid = AppsettingsManager.GetConfig("ClientId");
            string Clientkey = AppsettingsManager.GetConfig("ClientKey");

            this.Narration = $"Airtime Recharge {this.ChannelId} {this.vendCode} {this.phoneNumber.Value}";

            var transferFunds = new TransferFunds(transferService, transferManager).Create(this, Narration, cif, GlobalAccount, DebitaccountNumber);

            await transferManager.InsertTransferTransaction(transferFunds);

            if (AirtimeDomainAppsettingManager.UseServiceBus())
            {
                var serviceBusTransferRequest = transferFunds.MapTo <ClientIntrabankRequest>();
                serviceBusTransferRequest.ClientKey = Clientkey;

                var serviceBusCall = new ServiceBusManagement(AirtimeDomainAppsettingManager.GetAirtimeTransferQueueConnectionString()).PushToQueue(serviceBusTransferRequest, AirtimeDomainAppsettingManager.GetAirtimeQueueName());
                ResponseStatus  = TransactionStatus.Processing.ToString();
                ResponseMessage = AirtimeValidationMessages.ConstantMessages.TransactionProcessing;
            }
            else
            {
                var transferResponse = transferFunds.ExecuteTransfer();

                //var transferResponse = new TransferResponse<TransferResult>()
                //{
                //    result = new TransferResult()
                //};

                //transferResponse.hasError = false;
                //transferResponse.result.Status = TransactionStatus.Success.ToString();

                if (transferResponse == null)
                {
                    ResponseStatus  = TransactionStatus.Failed.ToString();
                    ResponseMessage = AirtimeValidationMessages.ErrorMessages.TransferError;
                }
                else if (transferResponse.hasError == true)
                {
                    ResponseStatus = TransactionStatus.Failed.ToString();

                    if (transferResponse?.errorMessage?.ToString() == null)
                    {
                        string response = "";
                        foreach (var err in transferResponse.errorMessages)
                        {
                            response += err;
                        }
                        ResponseMessage = response;
                    }
                    else
                    {
                        ResponseMessage = transferResponse.errorMessage.ToString();
                    }
                }
                else
                {
                    if (transferResponse.result.Status == TransactionStatus.Success.ToString() || transferResponse.result.Status == TransactionStatus.Pending.ToString())
                    {
                        TransferReference = transferResponse?.result?.PlatformTransactionReference;
                        TransactionStan   = transferResponse?.result?.TransactionStan;
                        TransferNarration = transferResponse?.result?.Narration;

                        var AirtimeserviceResponse = SwitchAirtimeVendors(airtimeServices);

                        this.vendorId = AirtimeserviceResponse.ProccedByVendorId;

                        if (AirtimeserviceResponse.ResponseStatus == TransactionStatus.Success.ToString())
                        {
                            ResponseStatus             = TransactionStatus.Success.ToString();
                            ResponseMessage            = AirtimeValidationMessages.ConstantMessages.AirtimeTransactionSuccessful;
                            airtimeRequestStatus       = true;
                            transferFunds.IsSettlement = true;
                            var vendorDetails = this.Vendors.getSingleVendorAgent(int.Parse(AirtimeserviceResponse.ProccedByVendorId));

                            string SettlementNarration = $"Airtime Recharge {this.ChannelId} {this.vendCode} {this.phoneNumber.Value} {transferResponse.result.TransactionStan}";

                            TransferFunds.VendorSettlement(transferFunds, transferFunds.DateCreated.ToString(), vendorDetails.suspenseAccount, SettlementNarration);
                        }
                        else if (AirtimeserviceResponse.ResponseStatus == TransactionStatus.Pending.ToString())
                        {
                            ResponseStatus  = TransactionStatus.Pending.ToString();
                            ResponseMessage = AirtimeValidationMessages.ConstantMessages.TransactionProcessing;
                        }
                        else
                        {
                            ResponseStatus           = TransactionStatus.Failed.ToString();
                            ResponseMessage          = AirtimeserviceResponse?.ResponseMessage;
                            airtimeRequestStatus     = false;
                            transferFunds.IsReversal = true;
                            TransferFunds.InitiateTransferReversal(transferFunds.DateCreated.ToString(), transferResponse.result.TransactionStan, transferResponse.result.PlatformTransactionReference);
                        }
                    }
                    else
                    {
                        ResponseStatus       = transferResponse?.result?.Status.ToString();
                        ResponseMessage      = transferResponse?.result?.Message?.ToString();
                        airtimeRequestStatus = false;
                    }
                }
            }
            return(Result.Ok(this));
        }