-
Notifications
You must be signed in to change notification settings - Fork 17
/
pagseguro.php
44 lines (33 loc) · 1.64 KB
/
pagseguro.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
<?php
class ControllerExtensionPaymentPagSeguro extends Controller
{
const EXTENSION_PREFIX = 'payment_pagseguro_';
public function callback()
{
$this->load->model('extension/payment/pagseguro');
$this->load->model('checkout/order');
$notificationCode = $this->request->post['notificationCode'] ?? 0;
$transaction = $this->model_extension_payment_pagseguro->checkStatusByNotificationCode($notificationCode);
var_dump($transaction);
die();
// Logger
$status = $transaction->getStatus();
$statuses = [
0 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_pending'),
1 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_pending'),
2 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_analysing'),
3 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_paid'),
4 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_available'),
5 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_disputed'),
6 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_returned'),
7 => $this->config->get(self::EXTENSION_PREFIX . 'order_status_cancelled')
];
if (array_key_exists($status, $statuses)) {
$statusId = $statuses[$status];
} else {
$statusId = reset($statuses);
}
$customer_notify = !!$this->config->get(self::EXTENSION_PREFIX . 'customer_notify');
$this->model_checkout_order->addOrderHistory($transaction['order_id'], $statusId, '', $customer_notify);
}
}