示例#1
0
        public void PostProcessPaymentTest_CallbackSuccessInvalidTransaction_PaymentNotProcessed()
        {
            var responseMessage = "Invalid transaction";

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

            paymentService.Setup(x => x.GetTransaction(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 PostProcessPaymentEvaluationContext()
            {
                Payment = new PaymentIn {
                    Transactions = new List <PaymentGatewayTransaction>()
                },
                Parameters = new NameValueCollection()
                {
                    { "response", "1" }
                }
            };
            var result = paymentMethod.PostProcessPayment(context);

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

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

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

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

            paymentMethod.Settings = GetTestSettings("Authorize");

            var context = new PostProcessPaymentEvaluationContext()
            {
                Payment = new PaymentIn {
                    Transactions = new List <PaymentGatewayTransaction>()
                },
                Parameters = new NameValueCollection()
                {
                    { "response", "1" },
                    { "transactionId", transactionId }
                }
            };
            var result = paymentMethod.PostProcessPayment(context);

            Assert.True(result.IsSuccess);
            Assert.Equal(PaymentStatus.Authorized, result.NewPaymentStatus);
            Assert.Equal(transactionId, result.OuterId);
            Assert.Equal(transactionId, context.Payment.OuterId);
            Assert.False(context.Payment.IsApproved);
        }