function fetch_orders()
 {
     if (!current_user_can('edit_others_posts')) {
         return;
     }
     $request = $_REQUEST;
     if (isset($request['search']) && $request['search'] != '') {
         /**
          * search post with keyword
          */
         $posts = new WP_Query(array('s' => $request['search'], 'meta_key' => 'et_ad_order', 'showposts' => -1, 'post_status' => array('publish', 'pending', 'draft', 'archive', 'reject')));
         /**
          * build orders id param
          */
         $order_ids = array();
         while ($posts->have_posts()) {
             $posts->the_post();
             $order_id = get_post_meta(get_the_ID(), 'et_ad_order', true);
             if ($order_id) {
                 $order = get_post($order_id);
                 $order_ids = array_merge($order_ids, (array) $order->ID);
             }
         }
         // add args post__in to query order
         if (!empty($order_ids)) {
             $request['post__in'] = $order_ids;
         }
     }
     /**
      * get orders
      */
     $orders = AE_Order::get_orders($request);
     $content = '';
     ob_start();
     while ($orders->have_posts()) {
         $orders->the_post();
         global $post;
         ae_get_template_part('order', 'item');
     }
     $content = ob_get_clean();
     $response = array();
     $response['pages'] = $orders->max_num_pages;
     $response['page'] = $_REQUEST['paged'] + 1;
     $response['data'] = $content;
     if (!$orders->have_posts()) {
         $response['msg'] = __("No order found by your query.", 'aecore-fields-backend');
     }
     wp_send_json($response);
 }
Exemplo n.º 2
0
 /**
  * request a payment process et-setup-payment
  */
 function setup_payment()
 {
     global $user_ID;
     // remember to check isset or empty here
     $adID = isset($_POST['ID']) ? $_POST['ID'] : '';
     $author = isset($_POST['author']) ? $_POST['author'] : $user_ID;
     $packageID = isset($_POST['packageID']) ? $_POST['packageID'] : '';
     $paymentType = isset($_POST['paymentType']) ? $_POST['paymentType'] : '';
     $job_error = '';
     $author_error = '';
     $package_error = '';
     $errors = array();
     // job id invalid
     // author does not authorize job
     $job = get_post($adID);
     if ($author != $job->post_author && !current_user_can('manage_options')) {
         $author_error = __("Post author information is incorrect!", 'aecore-membership-backend');
         $errors[] = $author_error;
     }
     $plans = $this->get_plans();
     if (empty($plans)) {
         wp_send_json($response);
     }
     // input data error
     if (!empty($errors)) {
         $response = array('success' => false, 'errors' => $errors);
         wp_send_json($response);
     }
     ////////////////////////////////////////////////
     ////////////// process payment//////////////////
     ////////////////////////////////////////////////
     $order_data = array('payer' => $author, 'total' => '', 'status' => 'draft', 'payment' => $paymentType, 'paid_date' => '', 'payment_plan' => $packageID, 'post_parent' => $adID);
     foreach ($plans as $key => $value) {
         if ($value->sku == $packageID) {
             $plan = $value;
             break;
         }
     }
     $plan->ID = $adID;
     // $ship    =   array( 'street_address' => isset($company_location['full_location']) ? $company_location['full_location'] : __("No location", 'aecore-membership-backend'));
     // filter shipping
     $ship = apply_filters('ae_payment_ship', array());
     /**
      * filter order data
      */
     $order_data = apply_filters('ae_payment_order_data', $order_data);
     // insert order into database
     $order = new AE_Order($order_data, $ship);
     $order->add_product((array) $plan);
     $order_data = $order->generate_data_to_pay();
     et_write_session('order_id', $order_data['ID']);
     et_write_session('ad_id', $adID);
     $arg = apply_filters('ae_payment_links', array('return' => et_get_page_link('process-payment'), 'cancel' => et_get_page_link('process-payment')));
     /**
      * process payment
      */
     $paymentType = strtoupper($paymentType);
     /**
      * factory create payment visitor
      */
     $visitor = AE_Payment_Factory::createPaymentVisitor($paymentType, $order);
     $visitor->set_settings($arg);
     $nvp = $order->accept($visitor);
     if ($nvp['ACK']) {
         $response = array('success' => $nvp['ACK'], 'data' => $nvp, 'paymentType' => $paymentType);
     } else {
         $response = array('success' => false, 'paymentType' => $paymentType, 'msg' => __("Invalid payment gateway", 'aecore-membership-backend'));
     }
     $response = apply_filters('ae_setup_payment', $response, $paymentType, $order);
     wp_send_json($response);
 }
Exemplo n.º 3
0
 /**
  * catch ajax et-setup-payment and process order generate json send back to clien
  * json data: array
  *             - 'success' => $nvp['ACK']
  *             - 'data' => array('data' , 'url'  => 'the payment gateway url')
  *             - 'paymentType' => $paymentType
  *
  * @package AE Payment
  * @category payment
  *
  * @since  1.0
  * @author  Dakachi
  */
 function setup_payment()
 {
     global $user_ID;
     $order_data = $this->setup_orderdata($_POST);
     $plans = $this->get_plans();
     if (empty($plans)) {
         wp_send_json(array('success' => false, 'msg' => __("There is no payment plan.", ET_DOMAIN)));
     }
     $adID = isset($_POST['ID']) ? $_POST['ID'] : '';
     $author = isset($_POST['author']) ? $_POST['author'] : $user_ID;
     $packageID = isset($_POST['packageID']) ? $_POST['packageID'] : '';
     $paymentType = isset($_POST['paymentType']) ? $_POST['paymentType'] : '';
     foreach ($plans as $key => $value) {
         if ($value->sku == $packageID) {
             $plan = $value;
             break;
         }
     }
     $plan->ID = $plan->sku;
     // if($adID) $plan->post_id = $adID;
     // $ship    =   array( 'street_address' => isset($company_location['full_location']) ? $company_location['full_location'] : __("No location", ET_DOMAIN));
     // filter shipping
     $ship = apply_filters('ae_payment_ship', array(), $order_data, $_POST);
     /**
      * filter order data
      *
      * @param Array $order_data
      * @param Array $_POST Client submitted data
      *
      * @since  1.0
      * @author  Dakachi
      */
     $order_data = apply_filters('ae_payment_order_data', $order_data, $_POST);
     // insert order into database
     $order = new AE_Order($order_data, $ship);
     $order->add_product((array) $plan);
     $order_data = $order->generate_data_to_pay();
     // write session
     et_write_session('order_id', $order_data['ID']);
     et_write_session('ad_id', $adID);
     $arg = apply_filters('ae_payment_links', array('return' => et_get_page_link('process-payment'), 'cancel' => et_get_page_link('process-payment')));
     /**
      * process payment
      */
     $paymentType_raw = $paymentType;
     $paymentType = strtoupper($paymentType);
     /**
      * factory create payment visitor
      */
     $visitor = AE_Payment_Factory::createPaymentVisitor($paymentType, $order, $paymentType_raw);
     // setup visitor setting
     $visitor->set_settings($arg);
     // accept visitor process payment
     $nvp = $order->accept($visitor);
     if ($nvp['ACK']) {
         $response = array('success' => $nvp['ACK'], 'data' => $nvp, 'paymentType' => $paymentType);
     } else {
         $response = array('success' => false, 'paymentType' => $paymentType, 'msg' => __("Invalid payment gateway", ET_DOMAIN));
     }
     /**
      * filter $response send to client after process payment
      *
      * @param Array $response
      * @param String $paymentType  The payment gateway user select
      * @param Array $order The order data
      *
      * @package  AE Payment
      * @category payment
      *
      * @since  1.0
      * @author  Dakachi
      */
     $response = apply_filters('ae_setup_payment', $response, $paymentType, $order);
     wp_send_json($response);
 }
Exemplo n.º 4
0
<?php

global $post;
$order_object = new AE_Order($post->ID);
$order_data = $order_object->get_order_data();
$products = $order_data['products'];
$package = array_pop($products);
$post_parent = '';
if ($post->post_parent) {
    $post_parent = get_post($post->post_parent);
}
$support_gateway = apply_filters('ae_support_gateway', array('cash' => __("Cash", ET_DOMAIN), 'paypal' => __("Paypal", ET_DOMAIN), '2checkout' => __("2Checkout", ET_DOMAIN)));
?>
<li>
	<div class="method">
		<?php 
echo isset($support_gateway[$order_data['payment']]) ? $support_gateway[$order_data['payment']] : $order_data['payment'];
if ($post->post_status == 'pending') {
    ?>
 
				<a title="<?php 
    _e("Approve", ET_DOMAIN);
    ?>
" class="color-green action publish" data-id="<?php 
    echo $post->ID;
    ?>
" href="#">
					<span class="icon" data-icon="3"></span>
				</a>
				<a title="<?php 
    _e("Decline", ET_DOMAIN);
Exemplo n.º 5
0
 /**
  * description 
  * @param snippet
  * @since snippet.
  * @author Duocnv
  */
 public function successful_request($posted)
 {
     // Insert the post into the database
     $posted = stripslashes_deep($posted);
     if (!empty($posted['invoice'])) {
         $order_pay = new AE_Order($posted['invoice']);
         $order_pay->set_payment_code($_POST['txn_id']);
         $order_pay->set_payer_id($_POST['payer_id']);
         $posted['payment_status'] = strtolower($posted['payment_status']);
         $posted['txn_type'] = strtolower($posted['txn_type']);
         if (1 == $posted['test_ipn'] && 'pending' == $posted['payment_status']) {
             $posted['payment_status'] = 'completed';
         }
         switch ($posted['payment_status']) {
             case 'completed':
                 $order_pay->set_status('publish');
                 break;
             case 'pending':
                 $order_pay->set_status('pending');
                 break;
             case 'denied':
             case 'expired':
             case 'failed':
             case 'voided':
                 $order_pay->set_status('draft');
                 break;
         }
         $order_pay->update_order();
         exit;
     }
 }
Exemplo n.º 6
0
function cash_upproved($post_ID, $post)
{
    if (current_user_can('manage_options')) {
        if ($post->post_type == 'order' && $post->post_status == 'publish') {
            $order = new AE_Order($post_ID);
            $order_pay = $order->get_order_data();
            if (isset($order_pay['payment']) && $order_pay['payment'] == 'cash') {
                $products = $order_pay['products'];
                $sku = $order_pay['payment_package'];
                $packs = AE_Package::get_instance();
                $pack = $packs->get_pack($sku, 'bid_plan');
                if (isset($pack->et_number_posts) && (int) $pack->et_number_posts > 0) {
                    update_credit_number($post->post_author, (int) $pack->et_number_posts);
                }
            }
        }
    }
}