コード例 #1
0
        public void WebhookCreateAndGetTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var webhook = WebhookTest.GetWebhook();
                var url     = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
                webhook.url = url;
                var createdWebhook = webhook.Create(apiContext);
                this.RecordConnectionDetails();

                Assert.IsNotNull(createdWebhook);
                Assert.IsTrue(!string.IsNullOrEmpty(createdWebhook.id));

                var webhookId        = createdWebhook.id;
                var retrievedWebhook = Webhook.Get(apiContext, webhookId);
                this.RecordConnectionDetails();

                Assert.IsNotNull(retrievedWebhook);
                Assert.AreEqual(webhookId, retrievedWebhook.id);
                Assert.AreEqual(url, retrievedWebhook.url);

                // Cleanup
                retrievedWebhook.Delete(apiContext);
                this.RecordConnectionDetails();
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
コード例 #2
0
        public void WebhookUpdateTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var webhook = WebhookTest.GetWebhook();
                webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
                var createdWebhook = webhook.Create(apiContext);
                this.RecordConnectionDetails();

                var newUrl           = "https://update.com/paypal_webhooks/" + Guid.NewGuid().ToString();
                var newEventTypeName = "PAYMENT.SALE.REFUNDED";

                var patchRequest = new PatchRequest
                {
                    new Patch
                    {
                        op    = "replace",
                        path  = "/url",
                        value = newUrl
                    },
                    new Patch
                    {
                        op    = "replace",
                        path  = "/event_types",
                        value = new List <WebhookEventType>
                        {
                            new WebhookEventType
                            {
                                name = newEventTypeName
                            }
                        }
                    }
                };

                var updatedWebhook = createdWebhook.Update(apiContext, patchRequest);
                this.RecordConnectionDetails();

                Assert.IsNotNull(updatedWebhook);
                Assert.AreEqual(createdWebhook.id, updatedWebhook.id);
                Assert.AreEqual(newUrl, updatedWebhook.url);
                Assert.IsNotNull(updatedWebhook.event_types);
                Assert.AreEqual(1, updatedWebhook.event_types.Count);
                Assert.AreEqual(newEventTypeName, updatedWebhook.event_types[0].name);

                // Cleanup
                updatedWebhook.Delete(apiContext);
                this.RecordConnectionDetails();
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }
コード例 #3
0
        public void WebhookDeleteTest()
        {
            var webhook = WebhookTest.GetWebhook();

            webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
            var createdWebhook = webhook.Create(TestingUtil.GetApiContext());

            createdWebhook.Delete(TestingUtil.GetApiContext());
            TestingUtil.AssertThrownException <HttpException>(() => Webhook.Get(TestingUtil.GetApiContext(), createdWebhook.id));
        }
コード例 #4
0
        public void WebhookCreateTest()
        {
            var webhook = WebhookTest.GetWebhook();

            webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
            var createdWebhook = webhook.Create(TestingUtil.GetApiContext());

            Assert.IsNotNull(createdWebhook);
            Assert.IsTrue(!string.IsNullOrEmpty(createdWebhook.id));

            // Cleanup
            createdWebhook.Delete(TestingUtil.GetApiContext());
        }
コード例 #5
0
 public void WebhookDeleteTest()
 {
     try
     {
         var webhook = WebhookTest.GetWebhook();
         webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
         var createdWebhook = webhook.Create(TestingUtil.GetApiContext());
         createdWebhook.Delete(TestingUtil.GetApiContext());
         Assert.AreEqual(204, (int)PayPalResource.LastResponseDetails.Value.StatusCode);
     }
     finally
     {
         TestingUtil.RecordConnectionDetails();
     }
 }
コード例 #6
0
 public void WebhookDeleteTest()
 {
     try
     {
         var webhook = WebhookTest.GetWebhook();
         webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
         var createdWebhook = webhook.Create(TestingUtil.GetApiContext());
         createdWebhook.Delete(TestingUtil.GetApiContext());
         TestingUtil.AssertThrownException <HttpException>(() => Webhook.Get(TestingUtil.GetApiContext(), createdWebhook.id));
     }
     catch (ConnectionException ex)
     {
         TestingUtil.WriteConnectionExceptionDetails(ex);
         throw;
     }
 }
コード例 #7
0
        public void WebhookGetTest()
        {
            var webhook = WebhookTest.GetWebhook();

            webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
            var createdWebhook = webhook.Create(TestingUtil.GetApiContext());

            var webhookId        = createdWebhook.id;
            var retrievedWebhook = Webhook.Get(TestingUtil.GetApiContext(), webhookId);

            Assert.IsNotNull(retrievedWebhook);
            Assert.AreEqual(webhookId, retrievedWebhook.id);

            // Cleanup
            createdWebhook.Delete(TestingUtil.GetApiContext());
        }
コード例 #8
0
ファイル: WebhookTest.cs プロジェクト: tucaz/PayPal-NET-SDK
        public void WebhookDeleteTest()
        {
            try
            {
                var apiContext = TestingUtil.GetApiContext();
                this.RecordConnectionDetails();

                var webhook = WebhookTest.GetWebhook();
                webhook.url = "https://" + Guid.NewGuid().ToString() + ".com/paypal_webhooks";
                var createdWebhook = webhook.Create(apiContext);
                this.RecordConnectionDetails();

                createdWebhook.Delete(apiContext);
                this.RecordConnectionDetails();

                Assert.Equal(204, (int)PayPalResource.LastResponseDetails.Value.StatusCode);
            }
            catch (ConnectionException)
            {
                this.RecordConnectionDetails(false);
                throw;
            }
        }