/** * Response * * @param string $system_gid * @param array $data * @return boolean */ public function response() { $system_gid = $this->input->post('system_gid', true); if (!$system_gid) { log_message('error', 'payments API: Empty system gid'); $this->set_api_content('errors', l('error_system_gid_incorrect', 'payments')); return false; } $data = $this->input->post('data', true); $this->load->helper('payments'); $return = receive_payment($system_gid, $data); if ($return['type'] == 'html') { if (!empty($return['info'])) { $this->set_api_content('messages', $return['info']); } if (!empty($return['errors'])) { $this->set_api_content('errors', $return['errors']); return false; } $this->load->model('Payments_model'); $payment = $this->Payments_model->get_payment_by_id($return['data']['id_payment']); $temp = $this->Payments_model->format_payments(array(0 => $payment)); $this->set_api_content('data', array('payment' => $temp[0])); } }
function ajax_add_funds() { $this->load->model('payments/models/Payment_currency_model'); $amount = abs(floatval($this->input->post('amount', true))); $user_ids = $this->input->post('user_ids', true); if (empty($amount)) { $return['error'] = l('error_empty_amount', 'users_payments'); } elseif (empty($user_ids)) { $return['error'] = l('error_empty_users_list', 'users_payments'); } else { $this->load->helper('payments'); foreach ($user_ids as $id_user) { $payment_data = send_payment('account', $id_user, $amount, $this->Payment_currency_model->default_currency["gid"], 'manual', array('name' => l('added_by_admin', 'users_payments'), 'lang' => 'added_by_admin', 'module' => 'users_payments')); $payment_data['data']['status'] = 1; receive_payment('manual', $payment_data['data']); } $return['success'] = ''; $this->system_messages->add_message('success', l('success_add_funds', 'users_payments')); } echo json_encode($return); return; }
/** * Process response from payment system * * @param string $system_gid system guid * @return void */ public function response($system_gid) { if (empty($system_gid)) { return false; } $data = $_REQUEST; log_message('error', $system_gid . ': ' . json_encode($data), 'response', 'log'); $this->load->helper('payments'); $return = receive_payment($system_gid, $data); if ($return["type"] == "html") { if (!empty($return["errors"])) { $this->system_messages->add_message('error', $return["errors"]); } if (!empty($return["info"])) { $this->system_messages->add_message('success', $return["info"]); } $this->load->model("Payments_model"); $payment = $this->Payments_model->get_payment_by_id($return["data"]["id_payment"]); $temp = $this->Payments_model->format_payments(array(0 => $payment)); $this->template_lite->assign('payment', $temp[0]); $this->template_lite->view('payment_return'); } }
public function payment_status($status_txt, $id_payment) { $this->load->model("Payments_model"); $payment_data = $this->Payments_model->get_payment_by_id($id_payment); switch ($status_txt) { case "approve": $payment_data["status"] = 1; $message = l('success_approve_payment', 'payments'); if ($payment_data['system_gid'] == 'offline') { $this->load->model('Users_model'); $user = $this->Users_model->get_user_by_id($payment_data['id_user']); $user = $this->Users_model->format_user($user); $mail_data['user'] = $user['output_name']; $mail_data['payment'] = $payment_data['payment_data']['name']; $mail_data['status'] = l('payment_status_approved', 'payments', $user['lang_id']); $this->load->model("Notifications_model"); $this->Notifications_model->send_notification($user['email'], "payment_status_updated", $mail_data, '', $user['lang_id']); } break; case "decline": $payment_data["status"] = -1; $message = l('success_decline_payment', 'payments'); if ($payment_data['system_gid'] == 'offline') { $this->load->model('Users_model'); $user = $this->Users_model->get_user_by_id($payment_data['id_user']); $user = $this->Users_model->format_user($user); $mail_data['user'] = $user['output_name']; $mail_data['payment'] = $payment_data['payment_data']['name']; $mail_data['status'] = l('payment_status_declined', 'payments'); $this->load->model("Notifications_model"); $this->Notifications_model->send_notification($user['email'], "payment_status_updated", $mail_data, '', $user['lang_id']); } break; default: $payment_data["status"] = 0; $message = ""; } $this->load->helper('payments'); receive_payment('manual', $payment_data); if ($message) { $this->system_messages->add_message('success', $message); } $cur_set = $_SESSION["pay_list"]; $url = site_url() . "admin/payments/index/" . $cur_set["filter"] . "/" . $cur_set["payment_type_gid"] . "/" . $cur_set["system_gid"] . "/" . $cur_set["order"] . "/" . $cur_set["order_direction"] . "/"; redirect($url); }