Esempio n. 1
0
        public void CaptureIdTest()
        {
            Payment       pay             = GetPayment();
            string        authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            Authorization authorization   = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);
            Capture       cap             = new Capture();
            Amount        amt             = new Amount();

            amt.total    = "1";
            amt.currency = "USD";
            cap.amount   = amt;
            Capture responseCapture = authorization.Capture(UnitTestUtil.GetApiContext(), cap);
            Capture returnCapture   = Capture.Get(UnitTestUtil.GetApiContext(), responseCapture.id);

            Assert.AreEqual(responseCapture.id, returnCapture.id);
        }
Esempio n. 2
0
        public void AgreementCreateTest()
        {
            var apiContext = UnitTestUtil.GetApiContext();
            var agreement  = GetAgreement();

            agreement.plan = new Plan()
            {
                id = "P-0V2939118D268823YFYLVH4Y"
            };
            agreement.shipping_address = null;
            var createdAgreement = agreement.Create(apiContext);

            Assert.IsNull(createdAgreement.id);
            Assert.IsNotNull(createdAgreement.token);
            Assert.AreEqual(agreement.name, createdAgreement.name);
        }
Esempio n. 3
0
        public void CaptureIdTest()
        {
            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 responseCapture = authorization.Capture(UnitTestUtil.GetApiContext(), cap);
            var returnCapture   = Capture.Get(UnitTestUtil.GetApiContext(), responseCapture.id);

            Assert.AreEqual(responseCapture.id, returnCapture.id);
        }
Esempio n. 4
0
        public void WebProfileDeleteTest()
        {
            // 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);

            // Delete the profile
            profile.Delete(UnitTestUtil.GetApiContext());

            // Attempt to get the profile. This should result in an exception.
            UnitTestUtil.AssertThrownException <PayPal.Exception.HttpException>(() => { WebProfile.Get(UnitTestUtil.GetApiContext(), profile.id); });
        }
Esempio n. 5
0
        public void WebProfilePartialUpdateTest()
        {
            // 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);

            // Partially update the profile
            var newName = "New " + profileName;
            var patch1  = new Patch();

            patch1.op    = "add";
            patch1.path  = "/presentation/brand_name";
            patch1.value = newName;

            var patch2 = new Patch();

            patch2.op   = "remove";
            patch2.path = "/flow_config/landing_page_type";

            var patchRequest = new PatchRequest();

            patchRequest.Add(patch1);
            patchRequest.Add(patch2);

            profile.PartialUpdate(UnitTestUtil.GetApiContext(), patchRequest);

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

            Assert.AreEqual(newName, retrievedProfile.presentation.brand_name);
            Assert.IsTrue(string.IsNullOrEmpty(retrievedProfile.flow_config.landing_page_type));

            // Delete the profile
            profile.Delete(UnitTestUtil.GetApiContext());
        }
Esempio n. 6
0
        public void CaptureRefundTest()
        {
            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 amnt            = new Amount();

            amnt.total    = "1";
            amnt.currency = "USD";
            cap.amount    = amnt;
            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);

            Assert.AreEqual("completed", responseRefund.state);
        }
Esempio n. 7
0
        public void RefundCaptureTest()
        {
            Payment       pay             = GetPayment();
            string        authorizationId = pay.transactions[0].related_resources[0].authorization.id;
            Authorization authorization   = Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId);
            Capture       cap             = new Capture();
            Amount        amnt            = new Amount();

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

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

            Assert.AreEqual("completed", responseRefund.state);
        }
Esempio n. 8
0
        private Payment GetPayment()
        {
            Payment target = new Payment();

            target.intent = "authorize";
            CreditCard card = 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> transacts = new List <Transaction>();
            Transaction        trans     = new Transaction();

            trans.amount = GetAmount();
            transacts.Add(trans);
            target.transactions = transacts;
            target.payer        = payer;
            return(target.Create(UnitTestUtil.GetApiContext()));
        }
Esempio n. 9
0
 public static Payment CreatePaymentOrder()
 {
     return(GetPaymentOrder().Create(UnitTestUtil.GetApiContext()));
 }
Esempio n. 10
0
 public static Payment CreatePaymentAuthorization()
 {
     return(GetPaymentAuthorization().Create(UnitTestUtil.GetApiContext()));
 }
Esempio n. 11
0
 public void NullRefundIdTest()
 {
     UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => Refund.Get(UnitTestUtil.GetApiContext(), null));
 }
Esempio n. 12
0
 public void CreditCardNullIdTest()
 {
     UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => CreditCard.Get(UnitTestUtil.GetApiContext(), null));
 }
Esempio n. 13
0
 public static CreditCard CreateCreditCard()
 {
     return(GetCreditCard().Create(UnitTestUtil.GetApiContext()));
 }
Esempio n. 14
0
        public void NullAuthorizationIdTest()
        {
            string authorizationId = null;

            UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => Authorization.Get(UnitTestUtil.GetApiContext(), authorizationId));
        }
Esempio n. 15
0
 public void AuthorizationNullIdTest()
 {
     UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => Authorization.Get(UnitTestUtil.GetApiContext(), null));
 }
Esempio n. 16
0
        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()));
        }
Esempio n. 17
0
 public void SaleNullIdTest()
 {
     UnitTestUtil.AssertThrownException <System.ArgumentNullException>(() => Sale.Get(UnitTestUtil.GetApiContext(), null));
 }