|
@@ -28,7 +28,8 @@ class CoinPayments {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- public function pay($order) {
|
|
|
+ public function pay($order)
|
|
|
+ {
|
|
|
|
|
|
|
|
|
$parseUrl = parse_url($order['return_url']);
|
|
@@ -53,12 +54,12 @@ class CoinPayments {
|
|
|
|
|
|
return [
|
|
|
'type' => 1,
|
|
|
- 'data' => 'https://www.coinpayments.net/index.php?' . $params_string,
|
|
|
- 'custom_result' => 'IPN OK'
|
|
|
+ 'data' => 'https://www.coinpayments.net/index.php?' . $params_string
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- public function notify($params) {
|
|
|
+ public function notify($params)
|
|
|
+ {
|
|
|
|
|
|
if (!isset($params['merchant']) || $params['merchant'] != trim($this->config['coinpayments_merchant_id'])) {
|
|
|
abort(500, 'No or incorrect Merchant ID passed');
|
|
@@ -75,24 +76,22 @@ class CoinPayments {
|
|
|
|
|
|
$hmac = hash_hmac("sha512", $request, trim($this->config['coinpayments_ipn_secret']));
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- if ($hmac != $signHeader) {
|
|
|
+ if (!hash_equals($hmac, $signHeader)) {
|
|
|
abort(400, 'HMAC signature does not match');
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
$status = $params['status'];
|
|
|
-
|
|
|
if ($status >= 100 || $status == 2) {
|
|
|
|
|
|
return [
|
|
|
'trade_no' => $params['item_number'],
|
|
|
- 'callback_no' => $params['txn_id']
|
|
|
+ 'callback_no' => $params['txn_id'],
|
|
|
+ 'custom_result' => 'IPN OK'
|
|
|
];
|
|
|
} else if ($status < 0) {
|
|
|
|
|
@@ -101,7 +100,5 @@ class CoinPayments {
|
|
|
|
|
|
die('IPN OK: pending');
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|