· 5 years ago · Jul 13, 2020, 08:14 PM
1<?php
2
3function upSign($method, $params, $secretKey) {
4 ksort($params);
5 unset($params['sign']);
6 unset($params['signature']);
7 array_push($params, $secretKey);
8 array_unshift($params, $method);
9
10 return hash('sha256', join('{up}', $params));
11}
12
13$method = $_GET['method'];
14$params = $_GET['params'];
15
16if ($params == null || $params['signature'] != upSign($method, $params, $tableconf['unitpay']['secret_key'])) {
17 exit('{"error": {"message": "Некорректная цифровая подпись"}}');
18}
19
20if ($method != 'pay'){
21 exit('{"result": {"message":"Запрос успешно обработан [actionCheck]"}}');
22}
23
24$payment = new payment();
25$status = $payment->checkPayment($_GET['params']['account'], $params['orderSum']);
26
27if ($status !== true) {
28 exit('{"error": {"message": "{' . $status . '}"}}');
29}
30
31$status = $payment->givePayment();
32
33if ($status !== true) {
34 exit('{"error": {"message": "{' . $status . '}"}}');
35}
36
37exit('{"result": {"message":"Запрос успешно обработан [actionPay]"}}');