load->model('Panel_Model'); $this->load->model('Payment_Model'); if($this->session->has_userdata('user')) { $this->user = $this->Panel_Model->getUserById($this->session->userdata('user')); if(!isset($this->user['id'])) { session_destroy(); redirect(base_url('login')); exit; } } else { redirect(base_url('login')); exit; } } public function card() { if(!empty($this->input->post('amount')) && !empty($this->input->post('phone'))) { $order_id = $this->Payment_Model->insertPayment($this->user['id'], $this->input->post('amount')); $order_amount = floatval($this->input->post('amount')) + (floatval($this->input->post('amount'))/100)*floatval($this->config->item('payment_commission')); switch($this->config->item('payment_method')) { case 'shopier': require 'application/libraries/Shopier.php'; $shopier = new Shopier($this->config->item('shopier_api_key'), $this->config->item('shopier_api_secret'), $this->config->item('shopier_site_index')); $shopier->setBuyer([ 'id' => $this->user['id'], 'first_name' => explode(' ', $this->user['name'])[0], 'last_name' => count(explode(' ', $this->user['name'])) > 1 ? explode(' ', $this->user['name'])[1] : 'A', 'email' => $this->user['email'], 'phone' => $this->input->post('phone') ]); $shopier->setOrderBilling([ 'billing_address' => 'N/A - Dijital Ürün', 'billing_city' => 'Istanbul', 'billing_country' => 'Turkey', 'billing_postcode' => '34200', ]); $shopier->setOrderShipping([ 'shipping_address' => 'N/A - Dijital Ürün', 'shipping_city' => 'Istanbul', 'shipping_country' => 'Turkey', 'shipping_postcode' => '34200', ]); die($shopier->run($order_id, $order_amount, base_url('payment-card/callback'))); break; case 'weepay': $weepayArray = array(); $weepayArray['Aut'] = array( 'bayi-id' => $this->config->item('weepay_seller_id'), 'api-key' => $this->config->item('weepay_api_key'), 'secret-key' => $this->config->item('weepay_secret_key') ); $currency = 'TL'; switch($this->config->item('site_money_sign')) { case '$': $currency = 'USD'; break; case '€': $currency = 'EUR'; break; } $weepayArray['Data'] = array( 'CallBackUrl' => base_url('payment-card/callback'), 'Price' => $order_amount, 'Locale' => $this->config->item('site_lang'), 'IpAddress' => $_SERVER['REMOTE_ADDR'], 'CustomerNameSurname' => $this->user['name'], 'CustomerPhone' => $this->input->post('phone'), 'CustomerEmail' => $this->user['email'], 'OutSourceID' => $order_id, 'Description' => $this->config->item('site_name'), 'Currency' => $currency, 'Channel' => 'Module' ); $endPointUrl = 'https://api.weepay.co/Payment/PaymentCheckoutFormCreate/'; $payload = json_encode($weepayArray); $ch = curl_init($endPointUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($payload)) ); $response = json_decode(curl_exec($ch), true); curl_close($ch); if($response["status"] == "Success"): ?>