Ejemplo n.º 1
0
        public async Task Retrieve_an_existing_payment()
        {
            var request = new AuthoriseRequest()
            {
                CardDetails = new CardDetails()
                {
                    CardNumber   = "424242424242",
                    ExpiryDate   = "0129",
                    SecurityCode = "111"
                },
                MerchantAccount = "CheckoutCom",
                Amount          = 25.00m,
                CurrencyCode    = "GBP"
            };

            var authoriseResponse = await PaymentServiceClient.Authorise(request);

            var paymentResponse = await PaymentServiceClient.GetPayment(authoriseResponse.Content.Id, "CheckoutCom");

            Assert.That(paymentResponse.HttpStatusCode, Is.EqualTo(HttpStatusCode.OK));

            Assert.That(paymentResponse.Content.Id, Is.EqualTo(paymentResponse.Content.Id));
            Assert.That(paymentResponse.Content.Amount, Is.EqualTo(paymentResponse.Content.Amount));
            Assert.That(paymentResponse.Content.CurrencyCode, Is.EqualTo(paymentResponse.Content.CurrencyCode));
            Assert.That(paymentResponse.Content.Status, Is.EqualTo(paymentResponse.Content.Status));
            Assert.That(paymentResponse.Content.CardDetails.CardNumber, Is.EqualTo(paymentResponse.Content.CardDetails.CardNumber));
            Assert.That(paymentResponse.Content.CardDetails.ExpiryDate, Is.EqualTo(paymentResponse.Content.CardDetails.ExpiryDate));
            Assert.That(paymentResponse.Content.CardDetails.SecurityCode, Is.EqualTo(paymentResponse.Content.CardDetails.SecurityCode));
        }
        public async Task Payment_authorisation_failed()
        {
            var expectedRejectionRequest = new AuthoriseRequest()
            {
                CardDetails = new CardDetails()
                {
                    CardNumber   = "424242424242",
                    ExpiryDate   = "0129",
                    SecurityCode = "222"
                },
                MerchantAccount = "CheckoutCom",
                Amount          = 25.00m,
                CurrencyCode    = "GBP"
            };

            var response = await PaymentServiceClient.Authorise(expectedRejectionRequest);

            Assert.That(response.HttpStatusCode, Is.EqualTo(HttpStatusCode.UnprocessableEntity));
            Assert.NotNull(response.Content.Id);
            Assert.That(response.Content.Id, Is.Not.EqualTo("psp_reference_id"));
            Assert.That(response.Content.Status, Is.EqualTo("Failed"));
            Assert.IsNotEmpty(response.Content.Errors);

            ThenValidPaymentAndOrderBody(expectedRejectionRequest, response.Content);
        }
        public async Task Payment_authorisation_with_invalid_payment()
        {
            var invalidRequest = new AuthoriseRequest();

            var response = await PaymentServiceClient.Authorise(invalidRequest);

            Assert.That(response.HttpStatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            Assert.IsNotEmpty(response.Content.Errors);
        }
        public async Task Authorise_a_payment_successfully()
        {
            var expectedSuccessRequest = new AuthoriseRequest()
            {
                CardDetails = new CardDetails()
                {
                    CardNumber   = "424242424242",
                    ExpiryDate   = "0129",
                    SecurityCode = "111"
                },
                MerchantAccount = "CheckoutCom",
                Amount          = 25.00m,
                CurrencyCode    = "GBP"
            };

            var response = await PaymentServiceClient.Authorise(expectedSuccessRequest);

            Assert.That(response.HttpStatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.NotNull(response.Content.Id);
            Assert.That(response.Content.Id, Is.Not.EqualTo("psp_reference_id"));
            Assert.That(response.Content.Status, Is.EqualTo("Accepted"));

            ThenValidPaymentAndOrderBody(expectedSuccessRequest, response.Content);
        }