示例#1
0
        public void TestWebhooks_Create_Get_Verify_Get_List_Delete()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Webhook    webhook    = new Webhook();

            webhook.Url = "http://postcatcher.in/catchers/54ed226514a1a60300001ab8";
            webhook.AddEventType("charge.refunded");
            webhook.AddEventType("charge.failed");

            Webhook webhookCreated = openpayAPI.WebhooksService.Create(webhook);

            Assert.IsNotNull(webhookCreated.Id);
            Assert.IsNotNull(webhookCreated.Status);
            Assert.AreEqual("verified", webhookCreated.Status);

            Webhook webhookGet = openpayAPI.WebhooksService.Get(webhookCreated.Id);

            Assert.IsNotNull(webhookGet.Id);
            Assert.IsNotNull(webhookGet.Status);
            Assert.AreEqual("verified", webhookGet.Status);
            Assert.AreEqual(2, webhookGet.EventTypes.Count);

            //openpayAPI.WebhooksService.Verify(webhookGet.Id, this.GetVerificationCode(webhookGet.Url));

            webhookGet = openpayAPI.WebhooksService.Get(webhookCreated.Id);
            Assert.IsNotNull(webhookGet.Id);
            Assert.IsNotNull(webhookGet.Status);
            Assert.AreEqual("verified", webhookGet.Status);
            Assert.AreEqual(2, webhookGet.EventTypes.Count);

            List <Webhook> webhooksList = openpayAPI.WebhooksService.List();

            Assert.AreEqual(2, webhooksList.Count);

            openpayAPI.WebhooksService.Delete(webhookGet.Id);
        }