public void ConfirmBooking_IfParametersAreSet_IfAgentBooking_CallsApiWithRightParameters(
            string agentId,
            string agentPassword,
            string reference,
            ConfirmBookingParameters parameters,
            string requestBody)
        {
            var encoder = new Base64Encoder();

            mockers.SetupAnyExecution <ApiResponseWithResultsBlock <string> >();

            try
            {
                ConfirmBooking(agentId, agentPassword, reference, parameters);
            }
            catch
            {
                // ignored
            }

            mockers.VerifyExecution <ApiResponseWithResultsBlock <string> >(
                BaseUrl,
                $"v{ApiVersion}/bookings/{reference}/confirm",
                Method.POST,
                bodyInJson: requestBody,
                expectedHeaders: new Dictionary <string, object>
            {
                { "X-AGENT-ID", encoder.Encode(agentId) },
                { "X-AGENT-PASSWORD", encoder.Encode(agentPassword) },
            },
                expectedQueryParameters: null);
        }
Пример #2
0
        public void ConfirmBooking_IfUsualBooking_Successful()
        {
            var reference  = configuration["Checkout:TestBookingReference"];
            var parameters = new ConfirmBookingParameters
            {
                ChannelId = configuration["Checkout:TestChannelId"],
                PaymentId = configuration["Checkout:TestPaymentId"],
            };

            var result = service.ConfirmBooking(reference, parameters);

            Assert.IsTrue(result);
        }
Пример #3
0
        public void ConfirmBooking_IfChannelIsNotSet_Exception400()
        {
            var(agentId, agentPassword, agentChannel) = GetAgentInfoFromConfig();
            var reference  = configuration["Checkout:TestBookingReferenceForAgentConfirmation"];
            var parameters = new ConfirmBookingParameters {
            };

            var exception = Assert.Catch <ApiException>(() =>
            {
                var result = service.ConfirmBooking(agentId, agentPassword, reference, parameters);
            });

            Assert.AreEqual(HttpStatusCode.BadRequest, exception.ResponseCode);
        }
Пример #4
0
        public void ConfirmBooking_IfAgentBooking_Successful()
        {
            var(agentId, agentPassword, agentChannel) = GetAgentInfoFromConfig();
            var reference  = configuration["Checkout:TestBookingReferenceForAgentConfirmation"];
            var parameters = new ConfirmBookingParameters
            {
                ChannelId = agentChannel,
                PaymentId = "agent_payment",
            };

            var result = service.ConfirmBooking(agentId, agentPassword, reference, parameters);

            Assert.IsTrue(result);
        }
Пример #5
0
        /// <inheritdoc />
        public bool ConfirmBooking(
            string agentId,
            string agentPassword,
            string bookingReference,
            ConfirmBookingParameters bookingParameters)
        {
            var encoder = new Base64Encoder();

            Context.AgentCredentials = new Credentials
            {
                Username = encoder.Encode(agentId),
                Password = encoder.Encode(agentPassword),
            };
            return(ConfirmBooking(bookingReference, bookingParameters));
        }
Пример #6
0
        /// <inheritdoc />
        public bool ConfirmBooking(string bookingReference, ConfirmBookingParameters bookingParameters)
        {
            if (string.IsNullOrWhiteSpace(bookingReference))
            {
                throw new ArgumentException("booking reference must not be empty");
            }

            if (bookingParameters == null)
            {
                throw new ArgumentException("parameters must be set");
            }

            var requestParameters = new ExecuteApiRequestParameters
            {
                Endpoint = $"v{ApiVersion}/bookings/{bookingReference}/confirm",
                Method   = RequestMethod.Post,
                Body     = bookingParameters,
            };
            var result = Executor.ExecuteApiWithWrappedResultsInResponse <string>(requestParameters);

            return(result.DataOrException.Equals(ActionResultStatuses.Success, StringComparison.InvariantCultureIgnoreCase));
        }
        public void ConfirmBooking_IfParametersAreSet_IfNotAgentBooking_CallsApiWithRightParameters(
            string reference,
            ConfirmBookingParameters parameters,
            string requestBody)
        {
            mockers.SetupAnyExecution <ApiResponseWithResultsBlock <string> >();

            try
            {
                ConfirmBooking(reference, parameters);
            }
            catch
            {
                // ignored
            }

            mockers.VerifyExecution <ApiResponseWithResultsBlock <string> >(
                BaseUrl,
                $"v{ApiVersion}/bookings/{reference}/confirm",
                Method.POST,
                bodyInJson: requestBody,
                expectedHeaders: null,
                expectedQueryParameters: null);
        }