File tree Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -130,15 +130,31 @@ A continuación un ejemplo:
130
130
131
131
$Khipu = new Khipu();
132
132
// No necesitamos identificar al cobrador para usar este servicio.
133
- $khipu_service = $Khipu->loadService('VerifyPaymentNotification');
134
- // Adjuntamos los valores del $_POST en el servicio.
135
- $khipu_service->setDataFromPost();
136
- // Hacemos una solicitud a Khipu para verificar.
137
- $response = $khipu_service->verify();
138
- if ($response['response'] == 'VERIFIED') {
139
- // Hacemos algo al respecto...
133
+
134
+ $api_version = $_POST['api_version'];
135
+
136
+ if($api_version == '1.2') {
137
+ $khipu_service = $Khipu->loadService('VerifyPaymentNotification');
138
+ $khipu_service->setDataFromPost();
139
+ $response = $khipu_service->verify();
140
+ if($response['response'] == 'VERIFIED'){
141
+ //el pago esta verificado, hacemos algo al respecto
142
+ }
143
+
144
+ } else if ($api_version == '1.3') {
145
+
146
+ $khipu_service = $Khipu->loadService('GetPaymentNotification');
147
+ $khipu_service->setDataFromPost();
148
+ $response = $khipu_service->consult();
149
+
150
+ //validamos que la notificacion de pago corresponda con una solicitud de pago esperada
151
+
152
+
153
+ } else {
154
+ // api de notificacion no soportada
140
155
}
141
156
157
+
142
158
```
143
159
144
160
### 4) Verificar Estado de una cuenta Khipu
Original file line number Diff line number Diff line change @@ -51,6 +51,22 @@ public function consult() {
51
51
return $ output ;
52
52
}
53
53
54
+ /**
55
+ * Esta funcion es para asignar los valores recibidos por POST.
56
+ *
57
+ * Puede usarse en reemplazo del metodo setParameter().
58
+ */
59
+ public function setDataFromPost () {
60
+ // Recorremos el arreglo $data
61
+ foreach ($ this ->data as $ key => $ value ) {
62
+ // Si existe la llave en $_POST entonces asignamos su valor
63
+ // a $data
64
+ if (isset ($ _POST [$ key ])) {
65
+ $ this ->data [$ key ] = $ _POST [$ key ];
66
+ }
67
+ }
68
+ }
69
+
54
70
protected function dataToString () {
55
71
$ string = '' ;
56
72
$ string .= 'receiver_id= ' . $ this ->receiver_id ;
You can’t perform that action at this time.
0 commit comments