CreatePaymentForSale() public static method

public static CreatePaymentForSale ( APIContext apiContext ) : Payment
apiContext APIContext
return PayPal.Api.Payment
Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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;
            }
        }