private BankPaymentBuilder AddRemittanceRef(BankPaymentBuilder gatewayRequest, JsonDoc json)
        {
            var REF_TYPE  = json.GetValue <string>("HPP_OB_REMITTANCE_REF_TYPE");
            var REF_VALUE = json.GetValue <string>("HPP_OB_REMITTANCE_REF_VALUE");

            return(gatewayRequest.WithRemittanceReference(
                       (RemittanceReferenceType)Enum.Parse(typeof(RemittanceReferenceType), REF_TYPE),
                       REF_VALUE
                       ));
        }
        public Transaction ProcessOpenBanking(BankPaymentBuilder builder)
        {
            string timestamp = builder.Timestamp ?? GenerationUtils.GenerateTimestamp();
            string orderId   = builder.OrderId ?? GenerationUtils.GenerateOrderId();
            var    amount    = builder.Amount != null?builder.Amount.ToNumericCurrencyString() : null;

            JsonDoc request = new JsonDoc();

            var paymentMethod = builder.PaymentMethod as BankPayment;

            switch (builder.TransactionType)
            {
            case TransactionType.Sale:
                var bankPaymentType = paymentMethod.BankPaymentType != null ?
                                      paymentMethod.BankPaymentType : GetBankPaymentType(builder.Currency);
                string hash = GenerationUtils.GenerateHash(SharedSecret, ShaHashType, timestamp, MerchantId, orderId, amount, builder.Currency,
                                                           !string.IsNullOrEmpty(paymentMethod.SortCode) && bankPaymentType.Equals(BankPaymentType.FASTERPAYMENTS) ?
                                                           paymentMethod.SortCode : "",
                                                           !string.IsNullOrEmpty(paymentMethod.AccountNumber) && bankPaymentType.Equals(BankPaymentType.FASTERPAYMENTS) ?
                                                           paymentMethod.AccountNumber : "",
                                                           !string.IsNullOrEmpty(paymentMethod.Iban) && bankPaymentType.Equals(BankPaymentType.SEPA) ? paymentMethod.Iban : "");
                SetAuthorizationHeader(hash);

                request.Set("request_timestamp", timestamp)
                .Set("merchant_id", MerchantId)
                .Set("account_id", AccountId);

                JsonDoc order = new JsonDoc();
                order.Set("id", orderId)
                .Set("currency", builder.Currency)
                .Set("amount", amount)
                .Set("description", builder.Description);

                JsonDoc payment = new JsonDoc();

                JsonDoc destination = new JsonDoc();
                destination.Set("account_number", bankPaymentType.Equals(BankPaymentType.FASTERPAYMENTS) ? paymentMethod.AccountNumber : null)
                .Set("sort_code", bankPaymentType.Equals(BankPaymentType.FASTERPAYMENTS) ? paymentMethod.SortCode : null)
                .Set("iban", bankPaymentType.Equals(BankPaymentType.SEPA) ? paymentMethod.Iban : null)
                .Set("name", paymentMethod.AccountName);


                JsonDoc remittance_reference = new JsonDoc();
                remittance_reference.Set("type", builder.RemittanceReferenceType != null ? builder.RemittanceReferenceType.ToString() : null)
                .Set("value", builder.RemittanceReferenceValue);

                payment.Set("scheme", bankPaymentType.ToString())
                .Set("destination", destination);

                if (remittance_reference.HasKeys())
                {
                    payment.Set("remittance_reference", remittance_reference);
                }

                request.Set("order", order)
                .Set("payment", payment)
                .Set("return_url", paymentMethod.ReturnUrl)
                .Set("status_url", paymentMethod.StatusUpdateUrl);

                break;

            default:
                break;
            }

            try
            {
                string rawResponse = DoTransaction(HttpMethod.Post, "/payments", request.ToString());
                return(OpenBankingMapping.MapResponse(rawResponse));
            }
            catch (GatewayException gatewayException)
            {
                throw gatewayException;
            }
        }
 public string SerializeRequest(BankPaymentBuilder builder)
 {
     throw new UnsupportedTransactionException();
 }