public ActionResult Update([FromBody] WebhookPut webhookPut)
        {
            var webhook = Webhook.Create(webhookPut.Id, tenant.Id, webhookPut.EventIds, webhookPut.PostbackUrl, webhookPut.Secret);

            webhooksRepository.Update(webhook);

            return(Ok());
        }
Exemplo n.º 2
0
        private void SeedWebhooks(APIContext apiContext)
        {
            var callbackUrl = Url.Action("Receive", "WebhookEvents", null, Request.Url.Scheme);

            if (Request.Url.Host == "localhost")
            {
                // Replace with your Ngrok tunnel url
                callbackUrl = "https://65857d5f.ngrok.io/WebhookEvents/Receive";
            }

            var everythingWebhook = new Webhook()
            {
                url         = callbackUrl,
                event_types = new List <WebhookEventType>
                {
                    new WebhookEventType
                    {
                        name = "PAYMENT.SALE.REFUNDED"
                    },
                    new WebhookEventType
                    {
                        name = "PAYMENT.SALE.REVERSED"
                    },
                    new WebhookEventType
                    {
                        name = "CUSTOMER.DISPUTE.CREATED"
                    },
                    new WebhookEventType
                    {
                        name = "BILLING.SUBSCRIPTION.CANCELLED"
                    },
                    new WebhookEventType
                    {
                        name = "BILLING.SUBSCRIPTION.SUSPENDED"
                    },
                    new WebhookEventType
                    {
                        name = "BILLING.SUBSCRIPTION.RE-ACTIVATED"
                    },
                }
            };

            Webhook.Create(apiContext, everythingWebhook);
        }
Exemplo n.º 3
0
        public void TestCRUD()
        {
            Webhook webhook = Webhook.Create(new Dictionary <string, object>()
            {
                { "url", "https://www.foobar.com" }
            });

            Assert.AreEqual(webhook.url, "https://www.foobar.com");

            webhook.Update();

            List <Webhook> webhooks = Webhook.List();

            CollectionAssert.Contains(webhooks.Select(w => w.id).ToList(), webhook.id);

            webhook.Destroy();
            try {
                User.Retrieve(webhook.id);
                Assert.Fail();
            }
            catch (HttpException) { }
        }