Beispiel #1
0
        public void PlanUpdateTest()
        {
            var apiContext = UnitTestUtil.GetApiContext();
            var planId     = "P-7R813789P6651091RFYXDDLY";

            // Get a test plan for updating purposes.
            var plan = Plan.Get(apiContext, planId);

            // Create the patch request and update the description to a random value.
            var updatedDescription = Guid.NewGuid().ToString();
            var patch = new Patch();

            patch.op    = "replace";
            patch.path  = "/";
            patch.value = new Plan()
            {
                description = updatedDescription
            };
            var patchRequest = new PatchRequest();

            patchRequest.Add(patch);

            // Update the plan.
            plan.Update(apiContext, patchRequest);

            // Verify the plan was updated successfully.
            var updatedPlan = Plan.Get(apiContext, planId);

            Assert.AreEqual(planId, updatedPlan.id);
            Assert.AreEqual(updatedDescription, updatedPlan.description);
        }
        public void WebProfileGetTest()
        {
            var profileId = "XP-5CQ3-3XSL-DDAA-MATK";
            var profile   = WebProfile.Get(UnitTestUtil.GetApiContext(), profileId);

            Assert.AreEqual(profileId, profile.id);
        }
        public void WebProfileGetTest()
        {
            var profileId = "XP-VKRN-ZPNE-AXGJ-YFZM";
            var profile   = WebProfile.Get(UnitTestUtil.GetApiContext(), profileId);

            Assert.AreEqual(profileId, profile.id);
        }
        public void WebProfileUpdateTest()
        {
            // Create a new profile
            var profileName = Guid.NewGuid().ToString();
            var profile     = WebProfileTest.GetWebProfile();

            profile.name = profileName;
            var createdProfile = profile.Create(UnitTestUtil.GetApiContext());

            // Get the profile object for the new profile
            profile = WebProfile.Get(UnitTestUtil.GetApiContext(), createdProfile.id);

            // Update the profile
            var newName = "New " + profileName;

            profile.name = newName;
            profile.Update(UnitTestUtil.GetApiContext());

            // Get the profile again and verify it was successfully updated.
            var retrievedProfile = WebProfile.Get(UnitTestUtil.GetApiContext(), profile.id);

            Assert.AreEqual(newName, retrievedProfile.name);

            // Delete the profile
            profile.Delete(UnitTestUtil.GetApiContext());
        }
Beispiel #5
0
        private Payment CreatePayment()
        {
            Payment pay = new Payment();

            pay.intent = "authorize";
            CreditCard card = GetCreditCard();
            List <FundingInstrument> fundingInstrumentList = new List <FundingInstrument>();
            FundingInstrument        instrument            = new FundingInstrument();

            instrument.credit_card = card;
            fundingInstrumentList.Add(instrument);
            Payer payr = new Payer();

            payr.payment_method      = "credit_card";
            payr.funding_instruments = fundingInstrumentList;
            List <Transaction> transactionList = new List <Transaction>();
            Transaction        trans           = new Transaction();

            trans.amount = GetAmount();
            transactionList.Add(trans);
            pay.transactions = transactionList;
            pay.payer        = payr;

            var apiContext = UnitTestUtil.GetApiContext();

            return(pay.Create(apiContext));
        }
        public void AgreementUpdateTest()
        {
            // Get the agreement to be used for verifying the update functionality
            var apiContext  = UnitTestUtil.GetApiContext();
            var agreementId = "I-HP4H4YJFCN07";
            var agreement   = Agreement.Get(apiContext, agreementId);

            // Create an update for the agreement
            var updatedDescription = Guid.NewGuid().ToString();
            var patch = new Patch();

            patch.op    = "replace";
            patch.path  = "/";
            patch.value = new Agreement()
            {
                description = updatedDescription
            };
            var patchRequest = new PatchRequest();

            patchRequest.Add(patch);

            // Update the agreement
            agreement.Update(apiContext, patchRequest);

            // Verify the agreement was successfully updated
            var updatedAgreement = Agreement.Get(apiContext, agreementId);

            Assert.AreEqual(agreementId, updatedAgreement.id);
            Assert.AreEqual(updatedDescription, updatedAgreement.description);
        }
Beispiel #7
0
        public void OrderGetTest()
        {
            var orderId = "O-2HT09787H36911800";
            var order   = Order.Get(UnitTestUtil.GetApiContext(), orderId);

            Assert.AreEqual(orderId, order.id);
        }
Beispiel #8
0
        public static Payment CreateFuturePayment()
        {
            FuturePayment pay = new FuturePayment();

            pay.intent = "sale";
            CreditCard card = CreditCardTest.GetCreditCard();
            List <FundingInstrument> fundingInstruments = new List <FundingInstrument>();
            FundingInstrument        fundingInstrument  = new FundingInstrument();

            fundingInstrument.credit_card = card;
            fundingInstruments.Add(fundingInstrument);
            Payer payer = new Payer();

            payer.payment_method      = "credit_card";
            payer.funding_instruments = fundingInstruments;
            List <Transaction> transactionList = new List <Transaction>();
            Transaction        trans           = new Transaction();

            trans.amount = AmountTest.GetAmount();
            transactionList.Add(trans);
            pay.transactions = transactionList;
            pay.payer        = payer;
            Payment paymnt = pay.Create(UnitTestUtil.GetApiContext());

            return(paymnt);
        }
        public void WebProfileGetListTest()
        {
            var profiles = WebProfile.GetList(UnitTestUtil.GetApiContext());

            Assert.IsNotNull(profiles);
            Assert.IsTrue(profiles.Count > 0);
        }
        public void PaymentStateTest()
        {
            Payment pay = new Payment();

            pay.intent = "sale";
            CreditCard card = GetCreditCard();
            List <FundingInstrument> fundingInstrumentList = new List <FundingInstrument>();
            FundingInstrument        instrument            = new FundingInstrument();

            instrument.credit_card = card;
            fundingInstrumentList.Add(instrument);
            Payer payer = new Payer();

            payer.payment_method      = "credit_card";
            payer.funding_instruments = fundingInstrumentList;
            List <Transaction> transacts = new List <Transaction>();
            Transaction        trans     = new Transaction();

            trans.amount = GetAmount();
            transacts.Add(trans);
            pay.transactions = transacts;
            pay.payer        = payer;
            Payment actual = new Payment();

            actual = pay.Create(UnitTestUtil.GetApiContext());
            Assert.AreEqual("approved", actual.state);
        }
Beispiel #11
0
        public void PlanCreateTest()
        {
            var plan        = GetPlan();
            var createdPlan = plan.Create(UnitTestUtil.GetApiContext());

            Assert.IsTrue(!string.IsNullOrEmpty(createdPlan.id));
            Assert.AreEqual(plan.name, createdPlan.name);
        }
Beispiel #12
0
        public void PlanListTest()
        {
            var planList = Plan.List(UnitTestUtil.GetApiContext());

            Assert.IsNotNull(planList);
            Assert.IsNotNull(planList.plans);
            Assert.IsTrue(planList.plans.Count > 0);
        }
        public void FuturePaymentTest()
        {
            APIContext context          = UnitTestUtil.GetApiContext();
            Payment    futurePayment    = GetFuturePayment();
            Payment    retrievedPayment = FuturePayment.Get(context, futurePayment.id);

            Assert.AreEqual(futurePayment.id, retrievedPayment.id);
        }
Beispiel #14
0
        public void AuthorizationGetTest()
        {
            Payment       pay             = CreatePayment();
            string        authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            Authorization authorize       = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);

            Assert.AreEqual(authorizationId, authorize.id);
        }
Beispiel #15
0
        public void FuturePaymentTest()
        {
            var context          = UnitTestUtil.GetApiContext();
            var futurePayment    = CreateFuturePayment();
            var retrievedPayment = FuturePayment.Get(context, futurePayment.id);

            Assert.AreEqual(futurePayment.id, retrievedPayment.id);
        }
        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);
        }
Beispiel #17
0
        public void PaymentObjectTest()
        {
            var context          = UnitTestUtil.GetApiContext();
            var pay              = CreatePaymentForSale();
            var retrievedPayment = Payment.Get(context, pay.id);

            Assert.AreEqual(pay.id, retrievedPayment.id);
        }
Beispiel #18
0
        public void CreditCardDeleteTest()
        {
            var card = GetCreditCard();
            var createdCreditCard   = card.Create(UnitTestUtil.GetApiContext());
            var retrievedCreditCard = CreditCard.Get(UnitTestUtil.GetApiContext(), createdCreditCard.id);

            retrievedCreditCard.Delete(UnitTestUtil.GetApiContext());
        }
Beispiel #19
0
        public void CreditCardGetTest()
        {
            var card = GetCreditCard();
            var createdCreditCard   = card.Create(UnitTestUtil.GetApiContext());
            var retrievedCreditCard = CreditCard.Get(UnitTestUtil.GetApiContext(), createdCreditCard.id);

            Assert.AreEqual(createdCreditCard.id, retrievedCreditCard.id);
        }
        public void TestPayment()
        {
            APIContext context          = UnitTestUtil.GetApiContext();
            Payment    pay              = GetPayment();
            Payment    retrievedPayment = Payment.Get(context, pay.id);

            Assert.AreEqual(pay.id, retrievedPayment.id);
        }
        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);
        }
Beispiel #22
0
        public void AgreementSearchTest()
        {
            DateTime startDate    = new DateTime(2014, 10, 1);
            DateTime endDate      = new DateTime(2014, 10, 14);
            var      transactions = Agreement.ListTransactions(UnitTestUtil.GetApiContext(), "I-9STXMKR58UNN", startDate, endDate);

            Assert.IsNotNull(transactions);
            Assert.IsNotNull(transactions.agreement_transaction_list);
        }
Beispiel #23
0
        public void AgreementGetTest()
        {
            var agreement = Agreement.Get(UnitTestUtil.GetApiContext(), "I-ASXCM9U5MJJV");

            Assert.AreEqual("I-ASXCM9U5MJJV", agreement.id);
            Assert.AreEqual("Agreement for T-Shirt of the Month Club Plan", agreement.description);
            Assert.AreEqual("2015-02-19T08:00:00Z", agreement.start_date);
            Assert.IsNotNull(agreement.plan);
        }
Beispiel #24
0
        public void PlanGetTest()
        {
            var plan = Plan.Get(UnitTestUtil.GetApiContext(), "P-0V2939118D268823YFYLVH4Y");

            Assert.IsNotNull(plan);
            Assert.AreEqual("T-Shirt of the Month Club Plan", plan.name);
            Assert.AreEqual("Template creation.", plan.description);
            Assert.AreEqual("FIXED", plan.type);
        }
        public void AuthroizationReauthorizeTest()
        {
            var authorization     = Authorization.Get(UnitTestUtil.GetApiContext(), "7GH53639GA425732B");
            var reauthorizeAmount = new Amount();

            reauthorizeAmount.currency = "USD";
            reauthorizeAmount.total    = "1";
            authorization.amount       = reauthorizeAmount;
            UnitTestUtil.AssertThrownException <PayPal.Exception.HttpException>(() => authorization.Reauthorize(UnitTestUtil.GetApiContext()));
        }
Beispiel #26
0
        public void PaymentListHistoryTest()
        {
            var context             = UnitTestUtil.GetApiContext();
            var containerDictionary = new Dictionary <string, string>();

            containerDictionary.Add("count", "10");
            var paymentHistory = Payment.List(context, containerDictionary);

            Assert.AreEqual(10, paymentHistory.count);
        }
Beispiel #27
0
        public void OrderDoVoidTest()
        {
            var apiContext = UnitTestUtil.GetApiContext();
            var order      = GetExecutedPaymentOrder(apiContext);

            // Void the order and verify it was successfully voided
            var response = order.Void(apiContext);

            Assert.AreEqual("voided", response.state);
        }
Beispiel #28
0
        public void OrderAuthorizeTest()
        {
            var apiContext = UnitTestUtil.GetApiContext();
            var order      = GetExecutedPaymentOrder(apiContext);

            // Authorize the order and verify it was successful (goes to 'Pending' state)
            var response = order.Authorize(apiContext);

            Assert.AreEqual("Pending", response.state);
        }
Beispiel #29
0
        public void AgreementExecuteTest()
        {
            var agreement = new Agreement()
            {
                token = "EC-2CD33889A9699491E"
            };
            var executedAgreement = agreement.Execute(UnitTestUtil.GetApiContext());

            Assert.AreEqual("I-ASXCM9U5MJJV", executedAgreement.id);
        }
Beispiel #30
0
        public void OrderCaptureTest()
        {
            var apiContext = UnitTestUtil.GetApiContext();
            var order      = GetExecutedPaymentOrder(apiContext);

            // Capture a payment for the order and verify it completed successfully
            var capture  = CaptureTest.GetCapture();
            var response = order.Capture(apiContext, capture);

            Assert.AreEqual("completed", response.state);
        }