Skip to content

Commit be8faf3

Browse files
committed
added getPaymentNotification for notification API 1.3
1 parent e55549d commit be8faf3

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/Khipu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public static function getAllServicesName() {
137137
'PaymentStatus' => TRUE,
138138
'UpdatePaymentNotificationUrl' => TRUE,
139139
'ReceiverBanks' => TRUE,
140+
'GetPaymentNotification' => TRUE,
140141
);
141142
}
142143

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/**
4+
* (c) Emilio Davis <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
require_once 'KhipuService.php';
11+
12+
/**
13+
* Servicio GetPaymentNotification extiende de KhipuService
14+
*
15+
* Este servicio consulta una notificacion de pago
16+
*/
17+
class KhipuServiceGetPaymentNotification extends KhipuService {
18+
/**
19+
* Iniciamos el servicio
20+
*/
21+
public function __construct($receiver_id, $secret) {
22+
parent::__construct($receiver_id, $secret);
23+
// Asignamos la url del servicio
24+
$this->apiUrl = Khipu::getUrlService('GetPaymentNotification');
25+
$this->data = array(
26+
'notification_token' => '',
27+
);
28+
}
29+
30+
/**
31+
* Método que consulta por la notificacion de pago
32+
*/
33+
public function consult() {
34+
$string_data = $this->dataToString();
35+
36+
$data_to_send = array(
37+
'hash' => $this->doHash($string_data),
38+
'receiver_id' => $this->receiver_id,
39+
'notification_token' => $this->data['notification_token'],
40+
);
41+
$data_to_send['agent'] = $this->agent;
42+
$ch = curl_init();
43+
curl_setopt($ch, CURLOPT_URL, $this->apiUrl);
44+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
45+
curl_setopt($ch, CURLOPT_POST, TRUE);
46+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_to_send);
47+
$output = curl_exec($ch);
48+
$info = curl_getinfo($ch);
49+
curl_close($ch);
50+
51+
return $output;
52+
}
53+
54+
protected function dataToString() {
55+
$string = '';
56+
$string .= 'receiver_id=' . $this->receiver_id;
57+
$string .= '&notification_token=' . $this->data['notification_token'];
58+
return trim($string);
59+
}
60+
}

0 commit comments

Comments
 (0)