forked from agustinfrancesconi/mp-ecommerce-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhook.php
More file actions
executable file
·29 lines (28 loc) · 963 Bytes
/
webhook.php
File metadata and controls
executable file
·29 lines (28 loc) · 963 Bytes
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
<?php
require 'vendor/autoload.php';
$AccessToken = 'APP_USR-1159009372558727-072921-8d0b9980c7494985a5abd19fbe921a3d-617633181';
MercadoPago\SDK::setAccessToken($AccessToken);
$body = @file_get_contents('php://input');
$data = json_decode($body);
file_put_contents('notificaciones/' . $data->id . ".json", $body);
switch ($data->type) {
case "payment":
//$payment = MercadoPago\Payment::find_by_id($_POST["data"]["id"]);
$payment = MercadoPago\Payment::find_by_id($data->data->id);
http_response_code(201);
// var_dump($payment);
break;
case "test":
echo "ok";
break;
case "plan":
$plan = MercadoPago\Plan::find_by_id($_POST["data"]["id"]);
break;
case "subscription":
$plan = MercadoPago\Subscription::find_by_id($_POST["data"]["id"]);
break;
case "invoice":
$plan = MercadoPago\Invoice::find_by_id($_POST["data"]["id"]);
break;
}
?>