Esempio n. 1
0
        public void TestDeserializingPayment()
        {
            var paymentInfo = GetValidPaymentInfoVisa();

            ServicesMockHelper.MockPaymentResponse(paymentInfo);

            var payment = Payment.Fetch("some-random-id");

            Assert.Equal(paymentInfo.Amount, payment.Amount);
            Assert.Equal(paymentInfo.Currency, payment.Currency);
            Assert.Equal(paymentInfo.Description, payment.Description);
            Assert.Equal(paymentInfo.CallbackUrl, payment.CallbackUrl);

            Assert.IsType <CreditCard>(payment.Source);
            Assert.Equal(((CreditCardSource)paymentInfo.Source).Name, ((CreditCard)payment.Source).Name);
        }
Esempio n. 2
0
        public async void RefundHigherAmountMustThrowException()
        {
            var paymentInfo = GetValidPaymentInfoVisa();

            ServicesMockHelper.MockPaymentResponse(paymentInfo);

            var payment = Payment.Fetch("some-id");
            var id      = payment.Id;
            var amount  = payment.Amount;

            ServicesMockHelper.MockPaymentResponse
            (
                paymentInfo,
                id: id,
                status: "refunded",
                refunded: amount
            );

            await Assert.ThrowsAsync <ValidationException>
            (
                async() => await Task.Run(() => payment.Refund(amount + 1))
            );
        }
Esempio n. 3
0
        public void TestRefundPayment()
        {
            var paymentInfo = GetValidPaymentInfoVisa();

            ServicesMockHelper.MockPaymentResponse(paymentInfo);

            var payment = Payment.Fetch("some-id");
            var id      = payment.Id;
            var amount  = payment.Amount;

            ServicesMockHelper.MockPaymentResponse
            (
                paymentInfo,
                id: id,
                status: "refunded",
                refunded: amount
            );

            payment.Refund();

            Assert.Equal(id, payment.Id);
            Assert.Equal("refunded", payment.Status);
            Assert.Equal(amount, payment.RefundedAmount);
        }