public void AuthorizationGetTest()
        {
            var pay             = PaymentTest.CreatePaymentAuthorization();
            var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            var authorize       = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);

            Assert.AreEqual(authorizationId, authorize.id);
        }
        public void AuthorizationNullAccessTokenTest()
        {
            string token           = null;
            var    pay             = PaymentTest.CreatePaymentAuthorization();
            var    authorizationId = pay.transactions[0].related_resources[0].authorization.id;

            UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => Authorization.Get(token, authorizationId));
        }
        public void AuthorizationVoidTest()
        {
            var pay                   = PaymentTest.CreatePaymentAuthorization();
            var authorizationId       = pay.transactions[0].related_resources[0].authorization.id;
            var authorize             = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);
            var authorizationResponse = authorize.Void(UnitTestUtil.GetApiContext());

            Assert.AreEqual("voided", authorizationResponse.state);
        }
示例#4
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.APIContext apiContext)
        {
            var pay = PaymentTest.CreatePaymentOrder();
            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));
        }
        public static PaymentHistory GetPaymentHistory()
        {
            List <Payment> paymentList = new List <Payment>();

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

            history.count    = 1;
            history.payments = paymentList;
            history.next_id  = "1";
            return(history);
        }
        public void AuthorizationCaptureTest()
        {
            var pay             = PaymentTest.CreatePaymentAuthorization();
            var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            var authorize       = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);
            var cap             = new Capture();
            var amt             = new Amount();

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

            Assert.AreEqual("completed", response.state);
        }
示例#7
0
        public void RefundIdTest()
        {
            var pay             = PaymentTest.CreatePaymentAuthorization();
            var authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            var authorization   = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);
            var cap             = new Capture();
            var amt             = new Amount();

            amt.total    = "1";
            amt.currency = "USD";
            cap.amount   = amt;
            var response     = authorization.Capture(UnitTestUtil.GetApiContext(), cap);
            var fund         = new Refund();
            var refundAmount = new Amount();

            refundAmount.total    = "1";
            refundAmount.currency = "USD";
            fund.amount           = refundAmount;
            var responseRefund  = response.Refund(UnitTestUtil.GetApiContext(), fund);
            var retrievedRefund = Refund.Get(UnitTestUtil.GetApiContext(), responseRefund.id);

            Assert.AreEqual(responseRefund.id, retrievedRefund.id);
        }