示例#1
0
function premise_recurring_payment_handler()
{
    global $premise_cron_args, $wpdb;
    if (is_user_logged_in() || !function_exists('memberaccess_get_cron_key')) {
        return;
    }
    if (!is_array($premise_cron_args) || empty($premise_cron_args['key']) || memberaccess_get_cron_key() != $premise_cron_args['key']) {
        return;
    }
    $now = time();
    // check for expired subscriptions
    $expired_subscriptions = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_acp_order_renewal_time' AND meta_value BETWEEN %s AND %s", $now - 259200, $now - 172800));
    if (!empty($expired_subscriptions)) {
        foreach ($expired_subscriptions as $order) {
            $order_status = get_post_meta($order, '_acp_order_status', true);
            if ($order_status == __('cancel', 'premise')) {
                continue;
            }
            AccessPress_Orders::cancel_subscription($order, false);
        }
    }
    // try renewing over a 3 day window
    $subscriptions = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_acp_order_renewal_time' AND meta_value BETWEEN %s AND %s", $now - 172800, $now + 86400));
    if (!empty($subscriptions)) {
        $orders = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'acp-orders' AND post_status = 'publish' AND ID IN (" . implode(',', $subscriptions) . ')');
    }
    if (empty($orders)) {
        premise_recurring_payment_notification(__('No subscriptions to renew.', 'premise'));
    }
    $results = array();
    foreach ($orders as $order) {
        $order_status = get_post_meta($order, '_acp_order_status', true);
        if ($order_status == __('cancel', 'premise')) {
            continue;
        }
        $order_post = get_post($order);
        $result = AccessPress_Orders::renew_subscription($order, false);
        if (!$result) {
            $results[] = sprintf(__('Could not find product on order # %s', 'premise'), $order_post->post_name);
            continue;
        }
        if (is_wp_error($result)) {
            $results[] = sprintf(__('Error on order # %s - %s', 'premise'), $order_post->post_name, $result->get_error_message());
            continue;
        }
        $product = get_post($result['product_id']);
        $results[] = sprintf(__('Processed order # %d - %s - %s - Amount %.2f', 'premise'), $order, $order_post->post_name, $product->post_title, $result['order_details']['_acp_order_price']);
    }
    premise_recurring_payment_notification(implode("\n", $results));
}
示例#2
0
文件: settings.php 项目: juslee/e27
    function authorize_net_settings_metabox()
    {
        $gateway_mode = MemberAccess_AuthorizeNet_Gateway::mode('gateway_live_mode_authorize_net');
        ?>

		<p>
			<strong><?php 
        _e('Payment Gateway Mode', 'premise');
        ?>
</strong>:
			<select name="<?php 
        echo $this->get_field_name('gateway_live_mode_authorize_net');
        ?>
">
				<option value="0" <?php 
        selected('0' == $gateway_mode);
        ?>
><?php 
        _e('Test', 'premise');
        ?>
</option>
				<option value="1" <?php 
        selected('1', $gateway_mode);
        ?>
><?php 
        _e('Live', 'premise');
        ?>
</option>
			</select>
		</p>
		<?php 
        submit_button(__('Test Gateway', 'premise'), 'button secondary', $this->get_field_name('test-cc'));
        ?>

		<p>
			<?php 
        _e('API Login ID', 'premise');
        ?>
:<br /><input type="text" name="<?php 
        echo $this->get_field_name('authorize_net_id');
        ?>
" id="<?php 
        $this->get_field_id('authorize_net_id');
        ?>
" value="<?php 
        echo $this->get_field_value('authorize_net_id');
        ?>
" style="min-width:50%" />
			<br />
			<?php 
        _e('Transaction Key', 'premise');
        ?>
:<br /><input type="text" name="<?php 
        echo $this->get_field_name('authorize_net_key');
        ?>
" id="<?php 
        $this->get_field_id('authorize_net_key');
        ?>
" value="<?php 
        echo $this->get_field_value('authorize_net_key');
        ?>
" style="min-width:50%" />
		</p>

		<?php 
        if ($this->get_field_value('authorize_net_recurring')) {
            $cron = sprintf('php -f %s \'key=%s&url=%s&path=%s\'', PREMISE_LIB_DIR . 'cron/recurring-cron-script.php', memberaccess_get_cron_key(), site_url('/'), ABSPATH);
            ?>
		<p>
			<?php 
            _e('Recurring payments for Authorize.net require Server cron. Use the following command for cron:', 'premise');
            ?>
			<br />
			<textarea disabled="disabled" rows="4" cols="80"><?php 
            echo esc_html($cron);
            ?>
</textarea>
		</p>
		<?php 
        }
        ?>

	<?php 
    }
示例#3
0
    function payment_settings_metabox()
    {
        ?>

		<p>
			<strong><?php 
        _e('Payment Gateway Mode', 'premise');
        ?>
</strong>:
			<select name="<?php 
        echo $this->get_field_name('gateway_live_mode');
        ?>
">
				<option value="0" <?php 
        selected('0' == $this->get_field_value('gateway_live_mode'));
        ?>
><?php 
        _e('Test', 'premise');
        ?>
</option>
				<option value="1" <?php 
        selected('1', $this->get_field_value('gateway_live_mode'));
        ?>
><?php 
        _e('Live', 'premise');
        ?>
</option>
			</select>
		</p>

		<p>
			<input type="checkbox" name="<?php 
        echo $this->get_field_name('authorize_net_recurring');
        ?>
" id="<?php 
        echo $this->get_field_id('authorize_net_recurring');
        ?>
" value="1" <?php 
        checked('1', $this->get_field_value('authorize_net_recurring'));
        ?>
 />
			<label for="<?php 
        echo $this->get_field_id('authorize_net_recurring');
        ?>
"><?php 
        _e('Enable Recurring Payment Option?', 'premise');
        ?>
</label>
			<br />
			<span class="description"><?php 
        _e('Enable subscriptions on individual products.', 'premise');
        ?>
</span>
		</p>

		<p>
			<strong><?php 
        _e('PayPal for Express Checkout and Website Payments Pro', 'premise');
        ?>
</strong>
			<a href="<?php 
        echo add_query_arg(array('test-paypal' => 'true'), menu_page_url('premise-member', false));
        ?>
" class="button secondary"><?php 
        _e('Test', 'premise');
        ?>
</a>
		</p>

		<p>
			<?php 
        _e('Username', 'premise');
        ?>
:
			<br />
			<input type="text" name="<?php 
        echo $this->get_field_name('paypal_express_username');
        ?>
" id="<?php 
        $this->get_field_id('paypal_express_username');
        ?>
" value="<?php 
        echo $this->get_field_value('paypal_express_username');
        ?>
" style="min-width:50%" />
			<br />
			<?php 
        _e('Password', 'premise');
        ?>
:
			<br />
			<input type="password" name="<?php 
        echo $this->get_field_name('paypal_express_password');
        ?>
" id="<?php 
        $this->get_field_id('paypal_express_password');
        ?>
" value="<?php 
        echo $this->get_field_value('paypal_express_password');
        ?>
" style="min-width:50%" />
			<br />
			<?php 
        _e('Signature', 'premise');
        ?>
:
			<br />
			<input type="password" name="<?php 
        echo $this->get_field_name('paypal_express_signature');
        ?>
" id="<?php 
        $this->get_field_id('paypal_express_signature');
        ?>
" value="<?php 
        echo $this->get_field_value('paypal_express_signature');
        ?>
" style="min-width:50%" />
		</p>

		<?php 
        if ($this->get_field_value('authorize_net_recurring')) {
            $ipn = add_query_arg(array('premiseipn' => 'paypal'), site_url('/'));
            ?>
		<p>
			<?php 
            _e('Recurring payments for Paypal require setting up Paypal IPN. Use the following URL for Paypal IPN:', 'premise');
            ?>
			<br />
			<textarea disabled="disabled" rows="2" cols="100"><?php 
            echo esc_html($ipn);
            ?>
</textarea>
		</p>
		<?php 
        }
        ?>

		<p>
			<strong><?php 
        _e('Authorize.net', 'premise');
        ?>
</strong>
			<a href="<?php 
        echo add_query_arg(array('test-cc' => 'true'), menu_page_url('premise-member', false));
        ?>
" class="button secondary"><?php 
        _e('Test', 'premise');
        ?>
</a>
		</p>

		<p>
			<?php 
        _e('API Login ID', 'premise');
        ?>
:<br /><input type="text" name="<?php 
        echo $this->get_field_name('authorize_net_id');
        ?>
" id="<?php 
        $this->get_field_id('authorize_net_id');
        ?>
" value="<?php 
        echo $this->get_field_value('authorize_net_id');
        ?>
" style="min-width:50%" />
			<br />
			<?php 
        _e('Transaction Key', 'premise');
        ?>
:<br /><input type="text" name="<?php 
        echo $this->get_field_name('authorize_net_key');
        ?>
" id="<?php 
        $this->get_field_id('authorize_net_key');
        ?>
" value="<?php 
        echo $this->get_field_value('authorize_net_key');
        ?>
" style="min-width:50%" />
		</p>

		<?php 
        if ($this->get_field_value('authorize_net_recurring')) {
            $cron = sprintf('php -f %s \'key=%s&url=%s&path=%s\'', PREMISE_LIB_DIR . 'cron/recurring-cron-script.php', memberaccess_get_cron_key(), site_url('/'), ABSPATH);
            ?>
		<p>
			<?php 
            _e('Recurring payments for Authorize.net require Server cron. Use the following command for cron:', 'premise');
            ?>
			<br />
			<textarea disabled="disabled" rows="4" cols="100"><?php 
            echo esc_html($cron);
            ?>
</textarea>
		</p>
		<?php 
        }
        ?>

	<?php 
    }