Exemple #1
0
        public void CapturePaymentTest_InvalidTransaction_PaymentNotCaptured()
        {
            var responseMessage = "Invalid transaction";

            var checkoutService = new Mock <IHelcimCheckoutService>();
            var paymentService  = new Mock <IHelcimPaymentService>();

            paymentService.Setup(x => x.CapturePayment(It.IsAny <HelcimTransactionRequest>())).Returns((HelcimTransactionRequest request) => new HelcimPaymentResponse()
            {
                ResponseMessage = responseMessage
            });

            var paymentMethod = new HelcimCheckoutPaymentMethod(checkoutService.Object, s => paymentService.Object);

            paymentMethod.Settings = GetTestSettings("");

            var context = new CaptureProcessPaymentEvaluationContext()
            {
                Payment = new PaymentIn()
                {
                    PaymentStatus = PaymentStatus.Authorized,
                    Transactions  = new List <PaymentGatewayTransaction>()
                }
            };
            var result = paymentMethod.CaptureProcessPayment(context);

            Assert.False(result.IsSuccess);
            Assert.Equal(responseMessage, result.ErrorMessage);
        }
Exemple #2
0
        public void CapturePaymentTest_ValidTransaction_PaymentCaptured()
        {
            var transactionId = "123";

            var checkoutService = new Mock <IHelcimCheckoutService>();
            var paymentService  = new Mock <IHelcimPaymentService>();

            paymentService.Setup(x => x.CapturePayment(It.IsAny <HelcimTransactionRequest>())).Returns((HelcimTransactionRequest request) => new HelcimPaymentResponse()
            {
                Response    = 1,
                Transaction = new HelcimPaymentTransaction()
                {
                    TransactionId = transactionId
                }
            });

            var paymentMethod = new HelcimCheckoutPaymentMethod(checkoutService.Object, s => paymentService.Object);

            paymentMethod.Settings = GetTestSettings("");

            var context = new CaptureProcessPaymentEvaluationContext()
            {
                Payment = new PaymentIn()
                {
                    PaymentStatus = PaymentStatus.Authorized,
                    OuterId       = transactionId,
                    Transactions  = new List <PaymentGatewayTransaction>()
                }
            };
            var result = paymentMethod.CaptureProcessPayment(context);

            Assert.True(result.IsSuccess);
            Assert.True(context.Payment.IsApproved);
            Assert.Equal(PaymentStatus.Paid, result.NewPaymentStatus);
            Assert.Equal(PaymentStatus.Paid, context.Payment.PaymentStatus);
        }