public async Task SubmitPayment_GivenCorrectPaymentInfo_ShouldReturnSuccess()
        {
            // Arrange
            var client = await _factory.GetAuthenticatedClientAsync(TestMerchantID, TestApiKey);

            var generatedPaymentOrderID = await GeneratePayment(client);

            var submitCommand = new SubmitPaymentCommand()
            {
                CardName    = "Test CardName",
                CvvCode     = "545",
                CardNumber  = "5555555555554444",
                ExpiryMonth = 12,
                ExpiryYear  = 2024,
                PaymentID   = generatedPaymentOrderID
            };

            // Act
            var submittedResponse = await client.PostAsync($"/api/submit-payment", Utils.GetRequestContent(submitCommand));

            var payment = await Utils.GetResponseContent <SubmitPaymentResultWm>(submittedResponse);

            // Assert
            payment.OrderID.Should().NotBeNullOrEmpty();
            payment.ResponseCode.Should().BeOneOf(
                PaymentProcessEnum.RequestFuturePayment.Id,
                PaymentProcessEnum.PaymentFailed.Id,
                PaymentProcessEnum.PaymentSucceeded.Id);
            submittedResponse.StatusCode.Should().Be(HttpStatusCode.OK);
        }
示例#2
0
        public async Task GetPaymentQuery_GivenCorrectPaymentID_ShouldReturnCorrectPayment()
        {
            // Arrange
            var client = await _factory.GetAuthenticatedClientAsync(TestMerchantID, TestApiKey);

            var generatedPaymentOrderID = await GeneratePayment(client);

            // Act
            var submittedResponse = await client.GetAsync($"/api/get-payment/{generatedPaymentOrderID}");

            var payment = await Utils.GetResponseContent <GetPaymentDetailVm>(submittedResponse);

            // Assert
            payment.Should().NotBeNull();
            payment.OrderID.Should().NotBeNull();
        }
        public async Task CreatePayment_GivenCorrectUser_ShouldReturnAuthToken()
        {
            // Arrange
            var client = await _factory.GetAuthenticatedClientAsync(TestMerchantID, TestApiKey);

            var command = new CreatePaymentCommand()
            {
                Amount   = 10,
                Currency = "EUR",
                OrderID  = "TESTORDERID"
            };

            // Act
            var response = await client.PostAsync($"/api/create-payment", Utils.GetRequestContent(command));

            var payment = await Utils.GetResponseContent <CreatePaymentResultWm>(response);

            // Assert
            payment.OrderID.Should().NotBeEmpty();
            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }