Ejemplo n.º 1
0
 /**
  * Check for subscription renewal
  */
 function renew_subscription($order_id, $die = true)
 {
     $product_id = get_post_meta($order_id, '_acp_order_product_id', true);
     if (!$product_id) {
         return false;
     }
     $order_details = array('_acp_order_member_id' => get_post_meta($order_id, '_acp_order_member_id', true), '_acp_order_product_id' => $product_id, '_acp_order_price' => get_post_meta($product_id, '_acp_product_price', true), '_acp_order_time' => get_post_meta($order_id, '_acp_order_time', true), '_acp_order_renewal_time' => get_post_meta($order_id, '_acp_order_renewal_time', true));
     $args = array('product_id' => $product_id, 'order_details' => $order_details, 'cc_profile_id' => get_user_option('memberaccess_cc_profile_id', $order_details['_acp_order_member_id']), 'cc_payment_profile_id' => get_user_option('memberaccess_cc_payment_' . $product_id, $order_details['_acp_order_member_id']));
     $gateway = new AccessPress_AuthorizeNet_Gateway();
     $result = $gateway->process_order($args);
     if (is_wp_error($result)) {
         if ($die) {
             wp_die($result->get_error_message());
         }
         return $result;
     }
     foreach (array('_acp_order_price', '_acp_order_renewal_time', '_acp_order_anet_transaction_id') as $key) {
         if (isset($result[$key])) {
             update_post_meta($order_id, $key, $result[$key]);
         }
     }
     /** this is ugly but it's in a new window, so user still has original window */
     if ($die) {
         die(__('Subscription renewed. You can close the window.', 'premise'));
     }
     return $args;
 }
Ejemplo n.º 2
0
 /**
  * Display notices on the save or reset of settings.
  *
  * @since 0.1.0
  *
  * @return type
  */
 public function notices()
 {
     if (!accesspress_is_menu_page($this->page_id)) {
         return;
     }
     if (isset($_REQUEST['test-paypal']) && 'true' == $_REQUEST['test-paypal']) {
         $gateway = new AccessPress_Paypal_Gateway();
         $gateway->test();
         if (is_wp_error($gateway->response)) {
             $message = $gateway->response->get_error_message();
         } else {
             $message = __('Paypal Gateway test passed.', 'premise');
         }
         echo '<div id="message" class="updated"><p><strong>' . $message . '</strong></p></div>';
         return;
     }
     /** test the gateway by requesting info on a non-existent customer */
     if (isset($_REQUEST['test-cc']) && 'true' == $_REQUEST['test-cc']) {
         $gateway = new AccessPress_AuthorizeNet_Gateway();
         $result = $gateway->test();
         if (!$result && is_wp_error($gateway->response) && 'cc-error' == $gateway->response->get_error_code()) {
             $message = __('Authorize.Net Gateway test passed.', 'premise');
         } elseif (is_wp_error($gateway->response)) {
             $message = $gateway->response->get_error_message();
         } else {
             $message = __('Authorize.Net Gateway test failed.', 'premise');
         }
         echo '<div id="message" class="updated"><p><strong>' . $message . '</strong></p></div>';
         return;
     }
     return parent::notices();
 }