-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebhook.php
43 lines (40 loc) · 1.16 KB
/
webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/init.php';
use \WHMCS\Module\Addon\Moneybird\Models\Invoice;
//
// For incoming webhooks the idea is:
// Get the payload--we need the entity part in our transaction
// $payload = file_get_contents("php://input");
// $payload = json_encode($payload);
// if ($payload->action == 'payment_registered') ...
// processMoneybirdTransaction($payload->entity);
// ...
//
// The problem with webhooks is that there are cases where they WILL fail and
// you cannot debug them if they do.
//
// A cronjob is much more reliable
//
// To create a webhook we need to patch the moneybird class and we can then
// use the following code or similar.
//
// $moneybird = createMoneybirdConnection();
// $all = $moneybird->Webhook()->getAll();
// foreach ($all as $key => $webhook) {
// if ($recreate) {
// $webhook->delete();
// }
// }
//
// if ($recreate) {
// $webhook = $moneybird->Webhook();
// $webhook->url = $endpoint;
// $webhook->events = [
// 'payment',
// ];
// $webhook->save();
// }
//