id = 'AIRPAYVN'; $this -> medthod_title = 'Airpay (Airpay.vn)'; $this -> has_fields = false; $this -> init_form_fields(); $this -> init_settings(); $this -> title = $this -> settings['title']; $this -> description = $this -> settings['description']; $this -> merchant_id = $this -> settings['merchant_id']; $this->rate = $this->settings['rate']; // $this -> redirect_page_id = $this -> settings['redirect_page_id']; $this -> liveurl = 'http://airpay.vn/payment'; $this->notify_url = add_query_arg( 'wc-api', 'WC_AIRPAYVN', home_url( '/' )); $this -> msg['message'] = ""; $this -> msg['class'] = ""; if ( version_compare( WOOCOMMERCE_VERSION, '2.0.8', '>=' ) ) { add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); } else { add_action( 'woocommerce_update_options_payment_gateways', array( &$this, 'process_admin_options' ) ); } add_action('woocommerce_receipt_AIRPAYVN', array(&$this, 'receipt_page')); add_action('woocommerce_api_wc_airpayvn', array( $this, 'check_ipn_response' ) ); } function init_form_fields(){ $this -> form_fields = array( 'enabled' => array( 'title' => __('Bật / Tắt', 'mAIRPAYVN'), 'type' => 'checkbox', 'label' => __('Kích hoạt cổng thanh toán Airpay cho Woocommerce', 'mAIRPAYVN'), 'default' => 'no'), 'title' => array( 'title' => __('Tên:', 'mAIRPAYVN'), 'type'=> 'text', 'description' => __('Hiển thị phương thức thanh toán ( khi khách hàng chọn phương thức thanh toán )', 'mAIRPAYVN'), 'default' => __('Cổng thanh toán Airpay', 'mAIRPAYVN')), 'description' => array( 'title' => __('Mô tả:', 'mAIRPAYVN'), 'type' => 'textarea', 'description' => __('Mô tả phương thức thanh toán.', 'mAIRPAYVN'), 'default' => __('Cổng thanh toán trực tuyến an toàn và đơn giản, nhanh chóng.', 'mAIRPAYVN')), 'merchant_id' => array( 'title' => __('Tài khoản Airpay', 'mAIRPAYVN'), 'type' => 'text', 'description' => __('Đây là mã Merchant_id tài khoản airpay của bạn.')), 'rate' => array( 'title' => __('Tỷ giá đồng Dollar', 'mAIRPAYVN'), 'type' => 'text', 'description' => __('Đây là quy đổi tỷ lệ của 1 đồng Dollar ra vnđ.')), /**/ 'redirect_page_id' => array( 'title' => __('Trang trả về'), 'type' => 'select', 'options' => $this -> get_pages('Hãy chọn...'), 'description' => "Hãy chọn trang/url để chuyển đến sau khi khách hàng đã thanh toán tại Airpay thành công." ) ); } public function admin_options(){ echo '
'.__('Airpay.vn - Thanh toán trực tuyến an toàn, đơn giản và nhanh chóng với Airpay').'
'; echo ''.__('Đơn hàng đã được xử lý thành công!').'
'; echo $this -> generate_AIRPAYVN_form($order); } /** * Generate AIRPAYVN button link **/ public function generate_AIRPAYVN_form($order_id){ global $woocommerce; $order = new WC_Order( $order_id ); $item_names = array(); if(sizeof($order->get_items()) > 0){ foreach($order->get_items() as $item){ if($item['qty']){ $item_names[] = array('name' => $item['name'], 'des' => '', 'price' =>($item['line_subtotal']/$item['qty']*$this->rate), 'quantity' => $item['qty']); } } } $redirect_url = ($this->redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id); return ''; } /** * Process the payment and return the result **/ function process_payment( $order_id ) { global $woocommerce; $order = new WC_Order( $order_id ); return array( 'result' => 'success', 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay' )))) ); } function showMessage($content){ return '