private scpQueryRequest CreateCapitaQueryRequest(
            int customerSiteId,
            int customerScpId,
            int hmacKeyId,
            string secretKey,
            string scpUniqueReference,
            string callingApplicationTransactionReference)
        {
            scpQueryRequest queryRequest = new scpQueryRequest
            {
                siteId       = customerSiteId,
                scpReference = scpUniqueReference,
                credentials  = new credentials
                {
                    subject = new subject()
                    {
                        subjectType = subjectType.CapitaPortal,
                        identifier  = customerScpId,
                        systemCode  = systemCode.SCP
                    },
                    requestIdentification = new requestIdentification()
                    {
                        uniqueReference = callingApplicationTransactionReference,
                        timeStamp       = DateTime.UtcNow.ToString("yyyyMMddhhmmss")
                    },
                    signature = new signature()
                    {
                        algorithm = algorithm.Original,
                        hmacKeyID = hmacKeyId
                    }
                }
            };



            string credentialsToHash = CapitaApiHelpers.GetCredentialsToHash(queryRequest.credentials);

            queryRequest.credentials.signature.digest = CapitaApiHelpers.CalculateDigest(secretKey, credentialsToHash);


            return(queryRequest);
        }
        private scpSimpleInvokeRequest CreateCapitaInvokeRequest(CapitaInvokeRequest request)
        {
            scpSimpleInvokeRequest invokeRequest = new scpSimpleInvokeRequest
            {
                credentials = new credentials
                {
                    subject = new subject()
                    {
                        subjectType = subjectType.CapitaPortal,
                        identifier  = request.ScpId,
                        systemCode  = systemCode.SCP
                    },
                    requestIdentification = new requestIdentification()
                    {
                        uniqueReference = Guid.NewGuid().ToString(),
                        timeStamp       = DateTime.UtcNow.ToString("yyyyMMddHHmmss")
                    },
                    signature = new signature()
                    {
                        algorithm = algorithm.Original,
                        hmacKeyID = request.HmacKeyId
                    }
                }
            };

            string credentialsToHash = CapitaApiHelpers.GetCredentialsToHash(invokeRequest.credentials);

            invokeRequest.credentials.signature.digest = CapitaApiHelpers.CalculateDigest(request.HmacKey, credentialsToHash);
            invokeRequest.requestType = request.SaveCard ? requestType.payAndAutoStore : requestType.payOnly;

            //store card details
            if (request.SaveCard)
            {
                invokeRequest.additionalInstructions = new additionalInstructions()
                {
                    cardholderID = request.CardHolderId
                };
            }

            invokeRequest.requestId = request.UniqueReference;

            //ECOM – Indicates that the cardholder will be interacting directly with the web pages displayed by the SCP.
            //CNP – Indicates that the transaction is being processed by a third party(e.g.a telesales operative) on behalf of the cardholder.
            //N.B. In order to comply with bank rules and to ensure that 3 - D Secure authentication is processed correctly it is important to set this element correctly.
            invokeRequest.panEntryMethod = request.IsMediated ? panEntryMethod.CNP : panEntryMethod.ECOM;

            invokeRequest.routing = new routing()
            {
                siteId    = request.SiteId,
                scpId     = request.ScpId,
                returnUrl = request.ReturnUrl
            };

            invokeRequest.sale = new simpleSale()
            {
                saleSummary = new summaryData()
                {
                    description          = request.PurchaseDescription,
                    reference            = request.IntegraCode,
                    amountInMinorUnits   = request.PaymentTotal,
                    displayableReference = $"Booking reference : {request.BookingRef}"
                },
                items = new[]
                {
                    new simpleItem()
                    {
                        itemSummary = new summaryData()
                        {
                            description          = request.PurchaseDescription,
                            amountInMinorUnits   = request.PaymentTotal,
                            reference            = request.IntegraCode,
                            displayableReference = $"Booking reference : {request.BookingRef}"
                        },
                        lgItemDetails = new lgItemDetails()
                        {
                            additionalReference = request.PurchaseId,
                            fundCode            = string.IsNullOrEmpty(request.FundCode) ? null : request.FundCode,
                            isFundItem          = string.IsNullOrEmpty(request.FundCode) ? false : true
                        },
                        lineId = request.PurchaseId,
                        tax    = string.IsNullOrEmpty(request.VatCode) ? null :
                                 new taxItem()
                        {
                            vat = new vatItem()
                            {
                                vatCode = request.VatCode,
                                vatRate = request.VatRate
                            }
                        }
                    }
                }
            };

            return(invokeRequest);
        }