upgrade_ajax(); if ( !is_admin() ) { add_action( 'wp_head', array( $obj, 'ajax_js' ) ); } } function ajax_js() { wp_enqueue_script( 'gc_upgrade_listing', LIBRARYURL . 'js/dashboard-ajax.js', array( 'jquery' ) ); wp_localize_script( 'gc_upgrade_listing', 'gc_ajax', array( 'url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( "upgrade_listing_nonce" ), ) ); } function upgrade_ajax() { add_action( 'wp_ajax_gc_upgrade_listing', array( $this, 'listing_upgrade' ) ); add_action( 'wp_ajax_nopriv_gc_upgrade_listing', array( $this, 'listing_upgrade' ) ); } function listing_upgrade() { ob_clean(); check_ajax_referer( 'upgrade_listing_nonce', 'nonce' ); if ( false ) return; $data = ($_POST['listing_data']); parse_str( $data, $values ); //print_r($values); if (!empty($values)) { /** * Listing id */ $post_id = $values['listing_id']; $currency_code = get_option( 'currency_code' ); $billing_time = get_billingtime(); /** * Setting values before submit for payment */ $posted_value = array( 'listing_title' => $values['listing_title'], 'total_cost' => $values['total_price'], 'listing_id' => $post_id, 'p_method' => "paypal", 'f_period' => isset( $values['f_period'] ) ? $values['f_period'] : '', 'f_cycle' => isset( $values['f_cycle'] ) ? $values['f_cycle'] : '', 'installment' => isset( $values['installment'] ) ? $values['installment'] : '', 's_price' => isset( $values['s_price'] ) ? $values['s_price'] : '', 's_period' => isset( $values['s_period'] ) ? $values['s_period'] : '', 's_cycle' => isset( $values['s_cycle'] ) ? $values['s_cycle'] : '', 'billing_type' => isset( $values['billing'] ) ? $values['billing'] : '', 'package_type' => isset( $values['package_type'] ) ? $values['package_type'] : '', 'paypal_mode' => isset( $values['paypal_mode'] ) ? $values['paypal_mode'] : '', 'billing_time' => ($billing_time[0]->rebill_time) ? $billing_time[0]->rebill_time : null, 'currency_code' => ($currency_code) ? $currency_code : '' ); //For featuring category or homepage $featured_home = ''; $featured_cate = ''; if ( $values['f_home'] ) { $featured_home = 'on'; } if ( $values['f_cate'] ) { $featured_cat = 'on'; } /** * Getting payment options */ $paymentOpts = get_payment_optins1( 'paypal' ); $posted_value['merchant_email'] = $paymentOpts['merchantid']; //$is_recurring = $paymentOpts['is_recurring']; $return_page_id = get_option( 'geo_notify_page' ); //Current user details $current_user = wp_get_current_user(); /** * Returning values */ $return_values = array( 'page_id=' . $return_page_id, 'ptype=pstatus', 'pkg_type=' . $posted_value['package_type'], 'post_id=' . $posted_value['listing_id'], 'user_id=' . $current_user->ID, 'user_name=' . $current_user->user_login, 'post_title=' . $posted_value['listing_title'], 'pay_method=' . $posted_value['paypal_mode'], 'feature_home=' . $featured_home, 'feature_cat=' . $featured_cat, ); /** * Ipn values/notify values */ $notify_values = array( 'ptype=pstatus', 'pkg_type=' . $posted_value['package_type'], 'post_id=' . $posted_value['listing_id'], 'user_id=' . $current_user->ID, 'user_name=' . $current_user->user_login, 'post_title=' . $posted_value['listing_title'], 'pay_method=' . $posted_value['paypal_mode'], 'feature_home=' . $featured_home, 'feature_cat=' . $featured_cat, ); /** * Cancel values */ $cancel_values = array( 'ptype=pstatus', 'pkg_type=' . $posted_value['package_type'], 'post_id=' . $posted_value['listing_id'], 'user_id=' . $current_user->ID, 'user_name=' . $current_user->user_login, 'post_title=' . $posted_value['listing_title'], 'pay_method=' . $posted_value['paypal_mode'] ); /** * Setting notification values for payment */ $posted_value['return_url'] = home_url( "?" . implode( '&', $return_values ) ); $posted_value['notify_url'] = home_url( "?" . implode( '&', $notify_values ) ); $posted_value['cancel_url'] = home_url( "?" . implode( '&', $cancel_values ) ); /** * Accessing class palpal */ $paypal_obj = new GC_Paypal(); echo $paypal_obj->form( $posted_value ); } die(); } } GC_dashboard::init(); }