/** * User::pay_new() * * New payment * * @access public * @param int $id User ID * @param int $gate_id Gateway ID * @return void */ public function pay_new($id = '', $gate_id = '') { if (intval($id) == 0 or intval($gate_id) == 0) { show_404(); } $user = $this->db->get_where('users', array('id' => $id))->row(); if (!$user or $user->status != 0) { show_404(); } $group = $this->db->get_where('groups', array('id' => $user->group))->row(); if (!$group) { show_404(); } $gate = $this->db->get_where('gateways', array('id' => $gate_id))->row(); if (!$gate) { show_404(); } // get payment gateway settings $gate_conf = unserialize($gate->settings); // load payment libs include_once APPPATH . 'libraries/payment/PaymentGateway.php'; // which payment system to use? if ($gate->name == 'paypal') { // Include the paypal library include_once APPPATH . 'libraries/payment/Paypal.php'; // Create an instance of the paypal library $my_paypal = new Paypal(); // Specify your paypal email $my_paypal->add_field('business', $gate_conf['email']); // Specify the currency $my_paypal->add_field('currency_code', $gate_conf['currency']); // Specify the url where paypal will send the user on success/failure $my_paypal->add_field('return', site_url('user/pay_complete')); $my_paypal->add_field('cancel_return', site_url('user/pay_cancel')); // Specify the url where paypal will send the IPN $my_paypal->add_field('notify_url', site_url('payment/ipn/paypal')); // Specify the product information $my_paypal->add_field('item_name', $this->startup->site_config->sitename . ' ' . lang('Account Registration')); $my_paypal->add_field('amount', $group->price); $my_paypal->add_field('item_number', rand(1, 1000) . '-' . $user->id); // Specify any custom value $my_paypal->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my_paypal->enable_test_mode(); } // Let's start the train! $data['form'] = $my_paypal->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } else { if ($gate->name == 'authorize') { // Include the paypal library include_once APPPATH . 'libraries/payment/Authorize.php'; // Create an instance of the authorize.net library $my_authorize = new Authorize(); // Specify your authorize.net login and secret $my_authorize->set_user_info($gate_conf['login'], $gate_conf['secret']); // Specify the url where authorize.net will send the user on success/failure $my_authorize->add_field('x_Receipt_Link_URL', site_url('user/pay_complete')); // Specify the url where authorize.net will send the IPN $my_authorize->add_field('x_Relay_URL', site_url('payment/ipn/authorize')); // Specify the product information $my_authorize->add_field('x_Description', $this->startup->site_config->sitename . ' ' . lang('Account Registration')); $my_authorize->add_field('x_Amount', $group->price); $my_authorize->add_field('x_Invoice_num', rand(1, 1000) . '-' . $user->id); $my_authorize->add_field('x_Cust_ID', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my_authorize->enable_test_mode(); } // Let's start the train! $data['form'] = $my_authorize->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } else { if ($gate->name = '2co') { // Include the paypal library include_once APPPATH . 'libraries/payment/TwoCo.php'; // Create an instance of the authorize.net library $my2_co = new TwoCo(); // Specify your 2CheckOut vendor id $my2_co->add_field('sid', $gate_conf['vendor_id']); // Specify the order information $my2_co->add_field('cart_order_id', rand(1, 1000) . '-' . $user->id); $my2_co->add_field('total', $group->price); // Specify the url where authorize.net will send the IPN $my2_co->add_field('x_Receipt_Link_URL', site_url('payment/ipn/two_checkout')); $my2_co->add_field('tco_currency', $gate_conf['currency']); $my2_co->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my2_co->enable_test_mode(); } // Let's start the train! $data['form'] = $my2_co->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } } } $this->load->view($this->startup->skin . '/header', array('header_title' => lang('Make Payment'))); $this->load->view($this->startup->skin . '/user/register/pay_new', array('ammount' => $group, 'user' => $id, 'form' => $data['form'])); $this->load->view($this->startup->skin . '/footer'); }