-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipn.php
137 lines (61 loc) · 2.54 KB
/
ipn.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
include("./library/core.php");
define("TOKEN", "APP_USR-xxxxxx-xxxx-xxxxxx-xxxxx");
$return = SAPIDK_MP\Action::IPN(120222853021, TOKEN);
$response = json_decode($return, true);
// Estado de pago, puede ver los manejadores de estos aqui https://www.mercadopago.com.ar/developers/es/guides/payments/api/handling-responses
$status = $response['collection']['status'];
// ID de la Transaccion, misma que se recibe en $_GET['id'];
$id = $response['collection']['id'];
// Referencia vinculada a el metodo de pago para identificarlo en nuestro sistema
$external_reference = $response['collection']['external_reference'];
// Metodo de Cobro recurring_payment: suscripcion, pos_payment: POINT, regular_payment: QR o Link
$method = $response['collection']['operation_type'];
// Fecha Pago Realizado
$date_created = $response['collection']['date_created'];
// Pago Realizado
$transaction_amount = $response['collection']['transaction_amount'];
// Ultimos 4 Digitos de la Tarjeta de Pago
$last_four_digits = $response['collection']['last_four_digits'];
$reason = $response['collection']['reason'];
if (isset($external_reference)) {
if ($method == "recurring_payment") {
if ($status == "approved") {
}
if ($status == "refunded") {
}
}
if (($method == "regular_payment") || ($method == "pos_payment")) {
if ($status == "approved") {
if ($reason == "Recurring payment validation") {
} else {
}
header("HTTP/1.1 200 OK");
}
if ($status == "in_process") {
if ($reason == "Recurring payment validation") {
} else {
}
header("HTTP/1.1 200 OK");
}
if ($status == "pending") {
if ($reason == "Recurring payment validation") {
} else {
}
header("HTTP/1.1 200 OK");
}
if ($status == "rejected") {
if ($reason == "Recurring payment validation") {
} else {
}
header("HTTP/1.1 200 OK");
}
if ($status == "refunded") {
if ($reason == "Recurring payment validation") {
} else {
}
header("HTTP/1.1 200 OK");
}
}
}
?>