本文整理汇总了PHP中MemberOrder::getGatewaySubscriptionStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberOrder::getGatewaySubscriptionStatus方法的具体用法?PHP MemberOrder::getGatewaySubscriptionStatus怎么用?PHP MemberOrder::getGatewaySubscriptionStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberOrder
的用法示例。
在下文中一共展示了MemberOrder::getGatewaySubscriptionStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MemberOrder
/**
* Filter pmpro_next_payment to get date via API if possible
*
* @since 1.8.5
*/
static function pmpro_next_payment($timestamp, $user_id, $order_status)
{
//find the last order for this user
if (!empty($user_id)) {
//get last order
$order = new MemberOrder();
$order->getLastMemberOrder($user_id, $order_status);
//check if this is a paypal express order with a subscription transaction id
if (!empty($order->id) && !empty($order->subscription_transaction_id) && $order->gateway == "paypalexpress") {
//get the subscription status
$status = $order->getGatewaySubscriptionStatus();
d($status);
if (!empty($status) && !empty($status['NEXTBILLINGDATE'])) {
//found the next billing date at PayPal, going to use that
$timestamp = strtotime(urldecode($status['NEXTBILLINGDATE']), current_time('timestamp'));
} elseif (!empty($status) && !empty($status['PROFILESTARTDATE']) && $order_status == "cancelled") {
//startdate is in the future and we cancelled so going to use that as the next payment date
$startdate_timestamp = strtotime(urldecode($status['PROFILESTARTDATE']), current_time('timestamp'));
if ($startdate_timestamp > current_time('timestamp')) {
$timestamp = $startdate_timestamp;
}
}
}
}
return $timestamp;
}
示例2: pmproppsc_admin_page
function pmproppsc_admin_page()
{
?>
<div class="wrap">
<h2>PMPro Subscription Check</h2>
<?php
if (!empty($_REQUEST['pmpro_subscription_check']) && current_user_can("manage_options")) {
global $wpdb;
//get members
if (!empty($_REQUEST['limit'])) {
$limit = intval($_REQUEST['limit']);
} else {
$limit = 20;
}
if (!empty($_REQUEST['start'])) {
$start = intval($_REQUEST['start']);
} else {
$start = 0;
}
//when using auto refresh get the last user id
if (!empty($_REQUEST['autorefresh']) && empty($_REQUEST['restart'])) {
$last_user_id = get_option("pmpro_subscription_check_last_user_id", 0);
} else {
$last_user_id = 0;
}
//get gateway
$gateway = $_REQUEST['gateway'];
if (!in_array($gateway, array_keys(pmpro_gateways()))) {
wp_die('Invalid gateway selection.');
}
//when using auto refresh get the last user id
if (!empty($_REQUEST['autorefresh']) && empty($_REQUEST['restart'])) {
$last_user_id = get_option("pmpro_stripe_subscription_check_last_user_id", 0);
} else {
$last_user_id = 0;
}
$sqlQuery = "SELECT DISTINCT(user_id) FROM {$wpdb->pmpro_membership_orders} WHERE gateway = '" . esc_sql($gateway) . "' ";
if (!empty($last_user_id)) {
$sqlQuery .= "AND user_id > '" . $last_user_id . "' ";
}
$sqlQuery .= "ORDER BY user_id LIMIT {$start}, {$limit}";
$user_ids = $wpdb->get_col($sqlQuery);
$totalrows = $wpdb->get_var("SELECT COUNT(DISTINCT(user_id)) FROM {$wpdb->pmpro_membership_orders} WHERE gateway = '" . esc_sql($gateway) . "'");
if (empty($_REQUEST['autorefresh'])) {
echo "Checking users for orders " . $start . " to " . min(intval($start + $limit), $totalrows) . ". ";
if ($totalrows > intval($start + $limit)) {
$url = "?page=pmproppsc&pmpro_subscription_check=1&start=" . ($start + $limit) . "&limit=" . $limit . "&gateway=" . $gateway;
echo '<a href="' . $url . '">Next ' . $limit . ' Results</a>';
} else {
echo "All done.";
}
echo "<hr />";
}
$allmembers = "";
$requiresaction = "";
foreach ($user_ids as $user_id) {
$user = get_userdata($user_id);
if (empty($user)) {
$s = "User #" . $user_id . " has been deleted. ";
} else {
$s = "User #" . $user->ID . "(" . $user->user_email . ", " . $user->first_name . " " . $user->lat_name . ") ";
}
$level = pmpro_getMembershipLevelForUser($user_id);
if (!empty($level) && empty($user)) {
$s .= " Had level #" . $level->id . ". ";
$level_id = $level->id;
} elseif (!empty($level)) {
$s .= " Has level #" . $level->id . ". ";
$level_id = $level->id;
} else {
$s .= " Does not have a level. ";
$level_id = "";
}
$order = new MemberOrder();
$order->getLastMemberOrder($user_id, "");
if (!empty($order->id)) {
$s .= " Last order was #" . $order->id . ", status " . $order->status . ". ";
//check status of order at gateway
$details = $order->getGatewaySubscriptionStatus($order);
if (empty($details)) {
$s .= " Couldn't get status from gateway. ";
echo "<span style='color: gray;'>" . $s . "</span>";
$allmembers .= "<span style='color: gray;'>" . $s . "</span>";
} else {
if (!is_array($details)) {
$details = array('STATUS' => $details);
}
$s .= "Gateway Status is " . $details['STATUS'] . ". ";
//if gateway status is active, but local user has no level, cancel the gateway subscription
if (strtolower($details['STATUS']) == 'active' && $level_id != $order->membership_id) {
$s .= " But this user has level #" . $user_level_id . " and order is for #" . $order->membership_id . ". Will try to cancel at the gateway. ";
if (!empty($_REQUEST['mode'])) {
if ($order->cancel()) {
$s .= " Order cancelled.";
echo "<span style='color: green;'><strong>" . $s . "</strong></span>";
} else {
$s .= " Error cancelling order.";
echo "<span style='color: red;'><strong>" . $s . "</strong></span>";
}
} else {
//.........这里部分代码省略.........
开发者ID:strangerstudios,项目名称:pmpro-paypal-subscription-check,代码行数:101,代码来源:pmpro-subscription-check.php