1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* NOTICE OF LICENSE |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2019 B2BinPay |
6
|
|
|
* |
7
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
8
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
9
|
|
|
* in the Software without restriction, including without limitation the rights |
10
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
12
|
|
|
* furnished to do so, subject to the following conditions: |
13
|
|
|
* |
14
|
|
|
* The above copyright notice and this permission notice shall be included in all |
15
|
|
|
* copies or substantial portions of the Software. |
16
|
|
|
* |
17
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23
|
|
|
* SOFTWARE. |
24
|
|
|
* |
25
|
|
|
* @author B2BINPAY <[email protected]> |
26
|
|
|
* @copyright 2019 B2BinPay |
27
|
|
|
* @license https://github.com/b2binpay/prestashop/blob/master/LICENSE The MIT License (MIT) |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
class B2binpayCallbackModuleFrontController extends ModuleFrontController |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
public function postProcess() |
33
|
|
|
{ |
34
|
|
|
if (Tools::isSubmit('tracking_id') == false |
|
|
|
|
35
|
|
|
|| Tools::isSubmit('status') == false |
36
|
|
|
|| Tools::isSubmit('amount') == false |
37
|
|
|
|| Tools::isSubmit('actual_amount') == false |
38
|
|
|
) { |
39
|
|
|
header('HTTP/1.1 400 Bad Request'); |
40
|
|
|
exit(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$headers = getallheaders(); |
44
|
|
|
$b2binpay_auth = $this->module->provider->getAuthorization(); |
45
|
|
|
|
46
|
|
|
if (empty($headers['Authorization']) || ($headers['Authorization'] !== $b2binpay_auth)) { |
47
|
|
|
header('HTTP/1.1 401 Unauthorized'); |
48
|
|
|
exit(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$tracking_id = Tools::getValue('tracking_id'); |
52
|
|
|
$status = (string)Tools::getValue('status'); |
53
|
|
|
|
54
|
|
|
$cart = new Cart((int)$tracking_id); |
|
|
|
|
55
|
|
|
$order = Order::getByCartId((int)$cart->id); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$status_list = $this->getStatus(); |
58
|
|
|
|
59
|
|
|
$amount = Tools::getValue('amount'); |
60
|
|
|
$actual_amount = Tools::getValue('actual_amount'); |
61
|
|
|
|
62
|
|
|
$history = new OrderHistory(); |
|
|
|
|
63
|
|
|
$history->id_order = $order->id; |
64
|
|
|
|
65
|
|
|
if (($status === '2') && ($amount === $actual_amount)) { |
66
|
|
|
$payment_status = Configuration::get('PS_OS_PAYMENT'); |
|
|
|
|
67
|
|
|
} else { |
68
|
|
|
$payment_status = $status_list[$status]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$history->changeIdOrderState( |
72
|
|
|
$payment_status, |
73
|
|
|
$order, |
74
|
|
|
true |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
$history->add(); |
78
|
|
|
$order->save(); |
79
|
|
|
|
80
|
|
|
exit("OK"); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
private function getStatus() |
84
|
|
|
{ |
85
|
|
|
return array( |
86
|
|
|
'-2' => Configuration::get('PS_OS_ERROR'), |
87
|
|
|
'-1' => Configuration::get('PS_OS_ERROR'), |
88
|
|
|
'1' => Configuration::get('PS_OS_BANKWIRE'), |
89
|
|
|
'2' => Configuration::get('PS_OS_BANKWIRE'), |
90
|
|
|
'3' => Configuration::get('PS_OS_ERROR'), |
91
|
|
|
'4' => Configuration::get('PS_OS_PAYMENT'), |
92
|
|
|
); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths