id = 'wpl_airsuggest'; $this->method_title = __('Airsuggest Checkout', 'wpl_woocommerce_airsuggest'); $this->method_description = __('This Plugin provides you feature for custom checkout option for all types of discount.', 'wpl_woocommerce_airsuggest'); $this->icon = $this->wpl_plugin_url() . '/images/icon.png'; $this->has_fields = true; $this->url = 'https://www.airsuggest.com/controller/api_checkout.php'; $this->init_form_fields(); $this->init_settings(); $this->responseVal = ''; $uploads = wp_upload_dir(); $this->txn_log = $uploads['basedir'] . "/txn_log/airsuggest"; wp_mkdir_p($this->txn_log); /// Create IPN Log files for backup transaction details $this->enabled = $this->settings['enabled']; ; if (isset($this->settings['thank_you_message'])) $this->thank_you_message = sanitize_text_field($this->settings['thank_you_message']); $this->title = sanitize_text_field($this->settings['title']); $this->description = sanitize_text_field($this->settings['description']); $this->api_key = sanitize_text_field($this->settings['api_key']); if (isset($_GET['wpl_airsuggest_callback']) && isset($_GET['results']) && esc_attr($_GET['wpl_airsuggest_callback']) == 1 && esc_attr($_GET['results']) != '') { $this->responseVal = $_GET['results']; add_filter(' ', array($this, 'wpl_airsuggest_thankyou')); } add_action('init', array(&$this, 'wpl_airsuggest_transaction')); add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'wpl_airsuggest_transaction')); add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_receipt_' . $this->id, array($this, 'wpl_airsuggest_receipt_page')); } // End Constructor /** * init Gateway Form Fields * * @since 1.0 */ function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => __('Enable/Disable:', 'wpl_woocommerce_airsuggest'), 'type' => 'checkbox', 'label' => __('Enable Airsuggest', 'wpl_woocommerce_airsuggest'), 'default' => 'yes' ), 'title' => array( 'title' => __('Title:', 'wpl_woocommerce_airsuggest'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'wpl_woocommerce_airsuggest'), 'default' => __('Airsuggest', 'wpl_woocommerce_airsuggest') ), 'description' => array( 'title' => __('Description:', 'wpl_woocommerce_airsuggest'), 'type' => 'textarea', 'description' => __('This controls the title which the user sees during checkout.', 'wpl_woocommerce_airsuggest'), 'default' => __('Airsuggest Checkout gives you automatic discount.', 'wpl_woocommerce_airsuggest'), ), 'api_key' => array( 'title' => __('Api Key:', 'wpl_woocommerce_airsuggest'), 'type' => 'text', 'custom_attributes' => array('required' => 'required'), 'description' => __('You can find Api key in your My Products section with Airsuggest', 'wpl_woocommerce_airsuggest'), 'default' => '' ), 'thank_you_message' => array( 'title' => __('Thank you page message:', 'wpl_woocommerce_airsuggest'), 'type' => 'textarea', 'description' => __('Thank you page order success message when order has been received', 'wpl_woocommerce_airsuggest'), 'default' => __('Thank you. Your order has been received.', 'wpl_woocommerce_airsuggest'), ), ); } // function init_form_fields() end /** * Get running plugin URL * * @since 1.0 */ private function wpl_plugin_url() { if (isset($this->wpl_plugin_url)) return $this->wpl_plugin_url; if (is_ssl()) { return $this->wpl_plugin_url = str_replace('http://', 'https://', WP_PLUGIN_URL) . '/' . plugin_basename(dirname(dirname(__FILE__))); } else { return $this->wpl_plugin_url = WP_PLUGIN_URL . '/' . plugin_basename(dirname(dirname(__FILE__))); } } // function wpl_plugin_url() end /** * WP Admin Options * * @since 1.0 */ public function admin_options() { ?>
";print_r($hash_data);echo"";die; update_post_meta($order_id, '_transaction_id', $txnid); $returnURL = $woocommerce->api_request_url(strtolower(get_class($this))); $hash_data['success_url'] = $returnURL; $payuform = ''; foreach ($hash_data as $key => $value) { if ($value) { // echo $key." : ".$value."
"; // print_r($hash_data); // echo""; // die; $posturl = $this->url; return ''; } // function wpl_generate_airsuggest_form() end /** * Process the payment for checkout. * * @since 1.0 */ function process_payment($order_id) { $this->wpl_airsuggest_clear_cache(); global $woocommerce; $order = new WC_Order($order_id); return array( 'result' => 'success', 'redirect' => $order->get_checkout_payment_url(true) ); } // function process_payment() end /** * Page after cheout button and redirect to PayU payment page. * * @since 1.0 */ function wpl_airsuggest_receipt_page($order_id) { $this->wpl_airsuggest_clear_cache(); global $woocommerce; $order = new WC_Order($order_id); echo '
' . __('Thank you for your order, please click the button below to pay.', 'wpl_woocommerce_airsuggest') . '
'; echo $this->wpl_generate_airsuggest_form($order_id); } // function wpl_airsuggest_receipt_page() end /** * Clear the cache data for browser * * @since 1.0 */ private function wpl_airsuggest_clear_cache() { header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); } // function wpl_airsuggest_clear_cache() end /** * Check the status of current transaction and get response with $_POST * * @since 1.0 */ function wpl_airsuggest_transaction() { global $woocommerce; $order_id = absint(WC()->session->get('order_awaiting_payment')); $order = new WC_Order($order_id); if (!empty($_POST)) { $apiKey = $this->api_key; if ($apiKey != $_POST['key']) { die('invalid Api key!'); } else { $postData = $_POST; } } else { die('No transaction data was passed!'); } $status = sanitize_text_field($postData['status']); $msg = sanitize_text_field($postData['msg']); // print_r($status); // echo "status" . $status. "| Transaction id: | ' . $wpl_airsuggest_response['transactionID'] . ' |
|---|---|
| Total Amount Paid: | $' . $wpl_airsuggest_response['totalCost'] . ' |