2018-06-07 10:56:13 +00:00
|
|
|
<?php
|
|
|
|
|
2018-06-07 15:40:52 +00:00
|
|
|
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
2018-06-07 10:56:13 +00:00
|
|
|
|
2018-06-07 15:40:52 +00:00
|
|
|
$App = new \Slim\App([
|
|
|
|
"settings" =>
|
|
|
|
[
|
|
|
|
"displayErrorDetails" => true
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
2018-06-07 10:56:13 +00:00
|
|
|
|
2019-01-25 14:17:48 +00:00
|
|
|
//TODO: rearrange endpoints
|
2018-06-07 15:40:52 +00:00
|
|
|
|
2019-01-25 14:17:48 +00:00
|
|
|
// detects the intent on the app's post load
|
2018-06-07 15:40:52 +00:00
|
|
|
$App->post
|
|
|
|
(
|
2019-01-25 14:17:48 +00:00
|
|
|
"/api/woocommerce/{authkey}/detectIntent",
|
2018-06-07 15:40:52 +00:00
|
|
|
Hookmanager::class, ':detectPayloadIntent'
|
|
|
|
);
|
|
|
|
|
2019-01-25 14:17:48 +00:00
|
|
|
// hooks into the EventSubscriptionCreated class, so that stuff can be done with it.
|
|
|
|
// the request is redirected by the detectIntent endpoint.
|
2018-06-07 15:40:52 +00:00
|
|
|
$App->post
|
|
|
|
(
|
2019-01-25 14:17:48 +00:00
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionCreatead",
|
2018-06-07 15:40:52 +00:00
|
|
|
Hookmanager::class, ':EventSubscriptionCreatead'
|
|
|
|
|
2018-06-08 14:48:18 +00:00
|
|
|
);
|
2019-01-25 14:17:48 +00:00
|
|
|
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
|
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionCancelled",
|
|
|
|
Hookmanager::class, ':EventSubscriptionCancelled'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionUpdated",
|
|
|
|
Hookmanager::class, ':EventSubscriptionUpdated'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionPaymentSuccess",
|
|
|
|
Hookmanager::class, ':EventSubscriptionPaymentSuccess'
|
|
|
|
);
|
|
|
|
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionPaymentFailed",
|
|
|
|
Hookmanager::class, ':EventSubscriptionPaymentFailed'
|
|
|
|
);
|
|
|
|
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
|
|
|
|
"/api/woocommerce/{authkey}/hooks/SubscriptionPaymentRefunded",
|
|
|
|
Hookmanager::class, ':EventSubscriptionPaymentRefunded'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
// TODO: deploy route
|
|
|
|
$App->post
|
|
|
|
(
|
|
|
|
|
|
|
|
"/api/wocommerce/{authkey}/requests/customer/{customerID}",
|
|
|
|
Hookmanager::class, ':GetCustomerByID'
|
|
|
|
|
|
|
|
);
|
2018-06-08 14:48:18 +00:00
|
|
|
|
|
|
|
$App->run();
|