상속: PayPal.Testing.BaseTest
예제 #1
0
 public void CaptureRefundTest()
 {
     try
     {
         var pay             = PaymentTest.CreatePaymentAuthorization();
         var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
         var authorization   = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
         var cap             = new Capture();
         var amnt            = new Amount();
         amnt.total    = "1";
         amnt.currency = "USD";
         cap.amount    = amnt;
         var response     = authorization.Capture(TestingUtil.GetApiContext(), cap);
         var fund         = new Refund();
         var refundAmount = new Amount();
         refundAmount.total    = "1";
         refundAmount.currency = "USD";
         fund.amount           = refundAmount;
         var responseRefund = response.Refund(TestingUtil.GetApiContext(), fund);
         Assert.AreEqual("completed", responseRefund.state);
     }
     finally
     {
         TestingUtil.RecordConnectionDetails();
     }
 }
예제 #2
0
        public void SaleRefundTest()
        {
            try
            {
                // Create a credit card sale payment
                var payment = PaymentTest.CreatePaymentForSale();

                // Get the sale resource
                var sale = payment.transactions[0].related_resources[0].sale;

                var refund = new Refund
                {
                    amount = new Amount
                    {
                        currency = "USD",
                        total    = "0.01"
                    }
                };

                var response = sale.Refund(TestingUtil.GetApiContext(), refund);
                Assert.IsNotNull(response);
                Assert.AreEqual("completed", response.state);
            }
            finally
            {
                TestingUtil.RecordConnectionDetails();
            }
        }
예제 #3
0
 public void RefundIdTest()
 {
     try
     {
         var pay             = PaymentTest.CreatePaymentAuthorization();
         var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
         var authorization   = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
         var cap             = new Capture();
         var amt             = new Amount();
         amt.total    = "1";
         amt.currency = "USD";
         cap.amount   = amt;
         var response     = authorization.Capture(TestingUtil.GetApiContext(), cap);
         var fund         = new Refund();
         var refundAmount = new Amount();
         refundAmount.total    = "1";
         refundAmount.currency = "USD";
         fund.amount           = refundAmount;
         var responseRefund  = response.Refund(TestingUtil.GetApiContext(), fund);
         var retrievedRefund = Refund.Get(TestingUtil.GetApiContext(), responseRefund.id);
         Assert.AreEqual(responseRefund.id, retrievedRefund.id);
     }
     catch (ConnectionException ex)
     {
         TestingUtil.WriteConnectionExceptionDetails(ex);
         throw;
     }
 }
예제 #4
0
        public void AuthorizationGetTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var pay = PaymentTest.CreatePaymentAuthorization(apiContext);
                this.RecordConnectionDetails();

                Assert.NotNull(pay);
                Assert.NotNull(pay.transactions);
                Assert.True(pay.transactions.Count > 0);
                var transaction = pay.transactions[0];

                Assert.NotNull(transaction.related_resources);
                Assert.True(transaction.related_resources.Count > 0);

                var resource = transaction.related_resources[0];
                Assert.NotNull(resource.authorization);

                var authorizationId = resource.authorization.id;
                var authorize       = Authorization.Get(apiContext, authorizationId);
                this.RecordConnectionDetails();

                Assert.Equal(authorizationId, authorize.id);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
예제 #5
0
        public void AuthorizationVoidTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var pay = PaymentTest.CreatePaymentAuthorization(apiContext);
                this.RecordConnectionDetails();

                Assert.IsNotNull(pay);
                Assert.IsNotNull(pay.transactions);
                Assert.IsTrue(pay.transactions.Count > 0);
                var transaction = pay.transactions[0];

                Assert.IsNotNull(transaction.related_resources);
                Assert.IsTrue(transaction.related_resources.Count > 0);

                var resource = transaction.related_resources[0];
                Assert.IsNotNull(resource.authorization);

                var authorize = Authorization.Get(apiContext, resource.authorization.id);
                this.RecordConnectionDetails();

                var authorizationResponse = authorize.Void(apiContext);
                this.RecordConnectionDetails();

                Assert.AreEqual("voided", authorizationResponse.state);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
예제 #6
0
        public void RefundIdTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var pay = PaymentTest.CreatePaymentAuthorization(apiContext);
                this.RecordConnectionDetails();

                Assert.IsNotNull(pay);
                Assert.IsNotNull(pay.transactions);
                Assert.IsTrue(pay.transactions.Count > 0);
                var transaction = pay.transactions[0];

                Assert.IsNotNull(transaction.related_resources);
                Assert.IsTrue(transaction.related_resources.Count > 0);

                var resource = transaction.related_resources[0];
                Assert.IsNotNull(resource.authorization);

                var authorization = Authorization.Get(apiContext, resource.authorization.id);
                this.RecordConnectionDetails();

                var cap = new Capture
                {
                    amount = new Amount
                    {
                        total    = "1",
                        currency = "USD"
                    }
                };
                var response = authorization.Capture(apiContext, cap);
                this.RecordConnectionDetails();

                var fund = new Refund
                {
                    amount = new Amount
                    {
                        total    = "1",
                        currency = "USD"
                    }
                };

                apiContext.ResetRequestId();
                var responseRefund = response.Refund(apiContext, fund);
                this.RecordConnectionDetails();

                var retrievedRefund = Refund.Get(apiContext, responseRefund.id);
                this.RecordConnectionDetails();

                Assert.AreEqual(responseRefund.id, retrievedRefund.id);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
예제 #7
0
        public void AuthorizationGetTest()
        {
            var pay             = PaymentTest.CreatePaymentAuthorization();
            var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            var authorize       = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);

            Assert.AreEqual(authorizationId, authorize.id);
        }
예제 #8
0
        public void AuthorizationVoidTest()
        {
            var pay                   = PaymentTest.CreatePaymentAuthorization();
            var authorizationId       = pay.transactions[0].related_resources[0].authorization.id;
            var authorize             = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
            var authorizationResponse = authorize.Void(TestingUtil.GetApiContext());

            Assert.AreEqual("voided", authorizationResponse.state);
        }
예제 #9
0
        public static PaymentHistory GetPaymentHistory()
        {
            List <Payment> paymentList = new List <Payment>();

            paymentList.Add(PaymentTest.GetPaymentForSale());
            PaymentHistory history = new PaymentHistory();

            history.count    = 1;
            history.payments = paymentList;
            history.next_id  = "1";
            return(history);
        }
예제 #10
0
        /// <summary>
        /// Tests that use this method must be ignored when run in an automated environment because executing an order
        /// will require approval via the executed payment's approval_url.
        /// </summary>
        /// <returns></returns>
        private Order GetExecutedPaymentOrder(PayPal.Api.APIContext apiContext)
        {
            var pay = PaymentTest.CreatePaymentOrder(apiContext);
            var paymentExecution = PaymentExecutionTest.GetPaymentExecution();

            paymentExecution.payer_id = pay.id;
            paymentExecution.transactions[0].amount.details = null;
            var executedPayment = pay.Execute(apiContext, paymentExecution);
            var orderId         = executedPayment.transactions[0].related_resources[0].order.id;

            return(Order.Get(apiContext, orderId));
        }
예제 #11
0
        public void AuthorizationCaptureTest()
        {
            var pay             = PaymentTest.CreatePaymentAuthorization();
            var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            var authorize       = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
            var cap             = new Capture();
            var amt             = new Amount();

            amt.total    = "1";
            amt.currency = "USD";
            cap.amount   = amt;
            var response = authorize.Capture(TestingUtil.GetApiContext(), cap);

            Assert.AreEqual("completed", response.state);
        }
예제 #12
0
 public void AuthorizationGetTest()
 {
     try
     {
         var pay             = PaymentTest.CreatePaymentAuthorization();
         var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
         var authorize       = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
         Assert.AreEqual(authorizationId, authorize.id);
     }
     catch (ConnectionException ex)
     {
         TestingUtil.WriteConnectionExceptionDetails(ex);
         throw;
     }
 }
예제 #13
0
        public void CaptureIdTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var pay = PaymentTest.CreatePaymentAuthorization(apiContext);
                this.RecordConnectionDetails();

                Assert.NotNull(pay);
                Assert.NotNull(pay.transactions);
                Assert.True(pay.transactions.Count > 0);
                var transaction = pay.transactions[0];

                Assert.NotNull(transaction.related_resources);
                Assert.True(transaction.related_resources.Count > 0);

                var resource = transaction.related_resources[0];
                Assert.NotNull(resource.authorization);

                var authorization = Authorization.Get(apiContext, resource.authorization.id);
                this.RecordConnectionDetails();

                var cap = new Capture
                {
                    amount = new Amount
                    {
                        total    = "1",
                        currency = "USD"
                    }
                };
                var responseCapture = authorization.Capture(apiContext, cap);
                this.RecordConnectionDetails();

                Assert.NotNull(responseCapture);

                var returnCapture = Capture.Get(apiContext, responseCapture.id);
                this.RecordConnectionDetails();

                Assert.Equal(responseCapture.id, returnCapture.id);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
예제 #14
0
 public void CaptureIdTest()
 {
     try
     {
         var pay             = PaymentTest.CreatePaymentAuthorization();
         var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
         var authorization   = Authorization.Get(TestingUtil.GetApiContext(), authorizationId);
         var cap             = new Capture();
         var amt             = new Amount();
         amt.total    = "1";
         amt.currency = "USD";
         cap.amount   = amt;
         var responseCapture = authorization.Capture(TestingUtil.GetApiContext(), cap);
         var returnCapture   = Capture.Get(TestingUtil.GetApiContext(), responseCapture.id);
         Assert.AreEqual(responseCapture.id, returnCapture.id);
     }
     finally
     {
         TestingUtil.RecordConnectionDetails();
     }
 }
예제 #15
0
        public void SaleRefundTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                // Create a credit card sale payment
                var payment = PaymentTest.CreatePaymentForSale(apiContext);
                this.RecordConnectionDetails();

                // Get the sale resource
                var sale = payment.transactions[0].related_resources[0].sale;

                var refund = new Refund
                {
                    amount = new Amount
                    {
                        currency = "USD",
                        total    = "0.01"
                    }
                };

                apiContext.ResetRequestId();
                var response = sale.Refund(apiContext, refund);
                this.RecordConnectionDetails();

                Assert.IsNotNull(response);
                Assert.AreEqual("completed", response.state);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }