Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function eupayment()
- {
- check_if_POST();
- $key = 'D47D****************************';
- $websocket_db = $this->load->database('websocket', true);
- $log_pay = json_encode($_POST);
- $data = array(
- 'post' => $log_pay,
- 'erorr' => 'POST YES',
- );
- $websocket_db->insert('log_pay', $data);
- $data = array(
- 'amount' => addslashes(trim(@$_POST['amount'])),
- 'curr' => addslashes(trim(@$_POST['curr'])),
- 'invoice_id' => addslashes(trim(@$_POST['invoice_id'])),
- 'ep_id' => addslashes(trim(@$_POST['ep_id'])),
- 'merch_id' => addslashes(trim(@$_POST['merch_id'])),
- 'action' => addslashes(trim(@$_POST['action'])),
- 'message' => addslashes(trim(@$_POST['message'])),
- 'approval' => addslashes(trim(@$_POST['approval'])),
- 'timestamp' => addslashes(trim(@$_POST['timestamp'])),
- 'nonce' => addslashes(trim(@$_POST['nonce'])),
- );
- $data['fp_hash'] = strtoupper($this->euplatesc_mac($data, $key));
- $fp_hash = addslashes(trim(@$_POST['fp_hash']));
- if ($data['fp_hash'] === $fp_hash) {
- if ($data['action'] == "0") {
- $payment = $websocket_db->where('id', $data['invoice_id'])->get('payments')->row();
- if (!empty($payment)) {
- $websocket_db->where('id', $payment->id);
- $websocket_db->update('payments', array('status' => 'completed'));
- $user = $this->db->where('id', $payment->contact_id)->get('users')->row();
- if (!empty($user)) {
- $amount = $user->amount + $data['amount'];
- $this->db->where('id', $user->id);
- $this->db->update('users', array('amount' => $amount));
- }
- }
- //Complete
- } else {
- $websocket_db = $this->load->database('websocket', true);
- $payment = $websocket_db->where('transaction_id', $data['nonce'])->get('payments')->row();
- if (!empty($payment)) {
- $websocket_db->where('id', $payment->id);
- $websocket_db->update('payments', array('status' => 'fault'));
- }
- //Failed
- }
- } else {
- $websocket_db = $this->load->database('websocket', true);
- $payment = $websocket_db->where('transaction_id', $data['nonce'])->get('payments')->row();
- if (!empty($payment)) {
- $websocket_db->where('id', $payment->id);
- $websocket_db->update('payments', array('status' => 'fault'));
- }
- //Invalid
- }
- echo "OK";//IMPORTANT to print OK
- }
- function euplatesc_mac($data, $key)
- {
- $str = NULL;
- foreach ($data as $d) {
- if ($d === NULL || strlen($d) == 0) {
- $str .= '-';
- } else {
- $str .= strlen($d) . $d;
- }
- }
- return hash_hmac('MD5', $str, pack('H*', $key));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement