Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $data = $data['data'];
- $key = $data['key'];
- $jsondata = json_decode(base64_decode($data));
- $vrfsign = hash('sha256', hash('sha256', $data) . hash('sha256', $this->signature));
- if ($key == $vrfsign) {
- if ((string)$jsondata->comand == "check") {
- if (empty($order)) {
- $log_data = array(
- 'status' => 404,
- 'log' => json_encode(array('error' => 'Order not exist'))
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 50,
- 'text' => 'not exist'
- ];
- echo json_encode($json_answer);
- die();
- }
- } elseif ((string)$jsondata->comand == "pay") {
- $payment = $this->CI->db->where('order_nr',$jsondata->order_id)->get('payments')->row();
- if (empty($payment)) {
- $log_data = array(
- 'status' => 404,
- 'log' => json_encode($jsondata)
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 30,
- 'text' => 'unknown method'
- ];
- echo json_encode($json_answer);
- die();
- }
- $pay_id = $payment->id;
- $payments = array(
- 'info' => $data['qrExtensionUUID'] = $data['paymentDetails']['receipt'],
- 'status' => 'completed',
- 'update_datetime' => date("Y-m-d H:i:s"),
- );
- if (!$this->websocket->where('id', $pay_id)->update('payments', $payments)) {
- $log_data = array(
- 'pay_id' => $pay_id,
- 'status' => 406,
- 'log' => json_encode($jsondata),
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 30,
- 'text' => 'unknown method'
- ];
- echo json_encode($json_answer);
- die();
- } else {
- $log_data = array(
- 'pay_id' => $pay_id,
- 'status' => 200,
- 'log' => json_encode($jsondata)
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 100,
- 'text' => 'success'
- ];
- echo json_encode($json_answer);
- die();
- }
- } else {
- $log_data = array(
- 'status' => 405,
- 'log' => json_encode(array('error' => 'unknown method'))
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 30,
- 'text' => 'unknown method'
- ];
- echo json_encode($json_answer);
- die();
- }
- $log_data = array(
- 'status' => 405,
- 'log' => json_encode(array('error' => 'unknown method'))
- );
- $this->CI->db->insert('mia_logs', $log_data);
- $json_answer = [
- 'code' => 30,
- 'text' => 'unknown method'
- ];
- echo json_encode($json_answer);
- die();
- } else {
- $log_data = array(
- 'status' => 405,
- 'log' => json_encode($data)
- );
- $this->CI->db->insert('mia_logs', $log_data);
- }
- $this->CI->db->insert('mia_logs', array('log'=>json_encode($data), 'pay_id'=> 0));
Add Comment
Please, Sign In to add comment