本文整理汇总了PHP中rcp_get_subscription_details函数的典型用法代码示例。如果您正苦于以下问题:PHP rcp_get_subscription_details函数的具体用法?PHP rcp_get_subscription_details怎么用?PHP rcp_get_subscription_details使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rcp_get_subscription_details函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_signup
public function process_signup()
{
global $rcp_options;
$user_id = get_current_user_id();
$user_data = get_userdata($user_id);
if (empty($_POST['stripeToken'])) {
wp_die('Missing Stripe token, please try again or contact support if the issue persists.');
}
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$plan_id = $_POST['subscription_id'];
$subscription = rcp_get_subscription_details($plan_id);
$price = $subscription->price;
$base_price = $price;
$discount = isset($_POST['rcp_discount']) ? sanitize_text_field($_POST['rcp_discount']) : '';
$discount_valid = false;
$expiration = rcp_get_subscription_length($plan_id);
$currency = strtolower($rcp_options['currency']);
$redirect = rcp_get_current_url();
$subscription_data = array('price' => $price, 'discount' => $base_price - $price, 'discount_code' => $discount, 'fee' => !empty($subscription->fee) ? number_format($subscription->fee, 2) : 0, 'length' => $expiration->duration, 'length_unit' => strtolower($expiration->duration_unit), 'subscription_id' => $subscription->id, 'subscription_name' => $subscription->name, 'key' => '', 'user_id' => $user_data->id, 'user_name' => $user_data->user_login, 'user_email' => $user_data->user_email, 'currency' => $rcp_options['currency'], 'auto_renew' => true, 'return_url' => $redirect, 'new_user' => false, 'post_data' => $_POST);
// Update the user's plan
update_user_meta($user_id, 'rcp_subscription_level', $plan_id);
// send all of the subscription data off for processing by the gateway
rcp_send_to_gateway('stripe', apply_filters('rcp_subscription_data', $subscription_data));
}
示例2: setup_user_type
function setup_user_type($e, $i)
{
$type = isset($_POST['reg_type']) ? $_POST['reg_type'] : 'buyer';
add_user_meta($e, 'reg_type', $type);
$id = rcp_get_subscription_details($type);
add_user_meta($e, 'eddc_user_rate', $id->commission);
return $e;
}
示例3: rcp_stripe_checkout_shortcode
function rcp_stripe_checkout_shortcode($atts)
{
global $rcp_options;
if (isset($rcp_options['sandbox'])) {
$key = $rcp_options['stripe_test_publishable'];
} else {
$key = $rcp_options['stripe_live_publishable'];
}
$atts = shortcode_atts(array('plan_id' => 0, 'price' => 0), $atts);
$user_id = get_current_user_id();
$user = get_userdata($user_id);
$is_active = rcp_is_active($user_id);
$subscription = rcp_get_subscription_details($atts['plan_id']);
$price = $subscription->price * 100;
?>
<form action="" method="post">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php
echo $key;
?>
"
data-name="CG Cookie"
data-image="https://s3.amazonaws.com/cgcookie/cgc_logo_128.png"
data-description="Join Citizen ($<?php
echo $price / 100;
?>
per month)"
data-label="Join <?php
echo $subscription->name;
?>
"
data-amount="<?php
echo $price;
?>
"
data-locale="auto"
data-email="<?php
echo $user->user_email;
?>
"
data-allow-remember-me="true"
>
</script>
<input type="hidden" name="subscription_id" value="<?php
echo $subscription->id;
?>
" />
<input type="hidden" name="price" value="<?php
echo $price;
?>
" />
<input type="hidden" name="source" value="stripe-checkout" />
</form>
<?php
}
示例4: set_subscription
/**
* Set the subscription for this registration
*
* @since 2.5
* @param $subscription_id
*
* @return bool
*/
public function set_subscription($subscription_id)
{
if (!($subscription = rcp_get_subscription_details($subscription_id))) {
return false;
}
$this->subscription = $subscription_id;
if ($subscription->fee) {
$description = $subscription->fee > 0 ? __('Signup Fee', 'rcp') : __('Signup Credit', 'rcp');
$this->add_fee($subscription->fee, $description);
}
return true;
}
示例5: rcp_get_subscription_details
<?php
global $rcp_options, $rcp_level, $post;
?>
<?php
$level = rcp_get_subscription_details($rcp_level);
?>
<?php
if (!is_user_logged_in()) {
?>
<h3 class="rcp_header">
<?php
echo apply_filters('rcp_registration_header_logged_in', __('Register New Account', 'rcp'));
?>
</h3>
<?php
} else {
?>
<h3 class="rcp_header">
<?php
echo apply_filters('rcp_registration_header_logged_out', __('Upgrade Your Subscription', 'rcp'));
?>
</h3>
<?php
}
// show any error messages after form submission
rcp_show_error_messages('register');
?>
示例6: rcp_get_subscription_details
<?php
$level = rcp_get_subscription_details(absint(urldecode($_GET['edit_subscription'])));
$level->role = empty($level->role) ? 'subscriber' : $level->role;
?>
<h2>
<?php
_e('Edit Subscription Level:', 'rcp');
echo ' ' . stripslashes($level->name);
?>
<a href="<?php
echo admin_url('/admin.php?page=rcp-member-levels');
?>
" class="add-new-h2">
<?php
_e('Cancel', 'rcp');
?>
</a>
</h2>
<form id="rcp-edit-subscription" action="" method="post">
<table class="form-table">
<tbody>
<tr class="form-field">
<th scope="row" valign="top">
<label for="rcp-name"><?php
_e('Name', 'rcp');
?>
</label>
</th>
<td>
<input name="name" id="rcp-name" type="text" value="<?php
示例7: rcp_get_auto_renew_behavior
/**
* Get the auto renew behavior
*
* 1 == All subscriptions auto renew
* 2 == No subscriptions auto renew
* 3 == Customer chooses whether to auto renew
*
* @access public
* @since 2.0
* @return int
*/
function rcp_get_auto_renew_behavior() {
global $rcp_options, $rcp_level;
// Check for old disable auto renew option
if( isset( $rcp_options['disable_auto_renew'] ) ) {
$rcp_options['auto_renew'] = '2';
unset( $rcp_options['disable_auto_renew'] );
update_option( 'rcp_settings', $rcp_options );
}
$behavior = isset( $rcp_options['auto_renew'] ) ? $rcp_options['auto_renew'] : '3';
if( $rcp_level ) {
$level = rcp_get_subscription_details( $rcp_level );
if( $level->price == '0' ) {
$behavior = '2';
}
}
return apply_filters( 'rcp_auto_renew_behavior', $behavior );
}
示例8: renew
/**
* Renews a member's membership by updating status and expiration date
*
* Does NOT handle payment processing for the renewal. This should be called after receiving a renewal payment
*
* @access public
* @since 2.1
*/
public function renew($recurring = false, $status = 'active', $expiration = '')
{
$subscription_id = $this->get_pending_subscription_id();
if (empty($subscription_id)) {
$subscription_id = $this->get_subscription_id();
}
if (!$subscription_id) {
return false;
}
if (!$expiration) {
$subscription = rcp_get_subscription_details($subscription_id);
$expiration = apply_filters('rcp_member_renewal_expiration', $this->calculate_expiration(), $subscription, $this->ID);
}
do_action('rcp_member_pre_renew', $this->ID, $expiration, $this);
$this->set_expiration_date($expiration);
if (!empty($status)) {
$this->set_status($status);
}
$this->set_recurring($recurring);
$this->set_renewed_date();
delete_user_meta($this->ID, '_rcp_expired_email_sent');
do_action('rcp_member_post_renew', $this->ID, $expiration, $this);
}
示例9: process_webhooks
/**
* Process PayPal IPN
*
* @since 2.1
*/
public function process_webhooks()
{
if (!isset($_GET['listener']) || strtoupper($_GET['listener']) != 'IPN') {
return;
}
global $rcp_options;
nocache_headers();
if (!class_exists('IpnListener')) {
// instantiate the IpnListener class
include RCP_PLUGIN_DIR . 'includes/gateways/paypal/paypal-ipnlistener.php';
}
$listener = new IpnListener();
$verified = false;
if ($this->test_mode) {
$listener->use_sandbox = true;
}
/*
if( isset( $rcp_options['ssl'] ) ) {
$listener->use_ssl = true;
} else {
$listener->use_ssl = false;
}
*/
//To post using the fsockopen() function rather than cURL, use:
if (isset($rcp_options['disable_curl'])) {
$listener->use_curl = false;
}
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
status_header(402);
//die( 'IPN exception: ' . $e->getMessage() );
}
/*
The processIpn() method returned true if the IPN was "VERIFIED" and false if it
was "INVALID".
*/
if ($verified || isset($_POST['verification_override']) || ($this->test_mode || isset($rcp_options['disable_ipn_verify']))) {
status_header(200);
$user_id = 0;
$posted = apply_filters('rcp_ipn_post', $_POST);
// allow $_POST to be modified
if (!empty($posted['custom']) && is_numeric($posted['custom'])) {
$user_id = absint($posted['custom']);
} else {
if (!empty($posted['subscr_id'])) {
$user_id = rcp_get_member_id_from_profile_id($posted['subscr_id']);
} else {
if (!empty($posted['payer_email'])) {
$user = get_user_by('email', $posted['payer_email']);
$user_id = $user ? $user->ID : false;
}
}
}
$member = new RCP_Member($user_id);
if (!$member || !$member->get_subscription_id()) {
die('no member found');
}
if (!rcp_get_subscription_details($member->get_subscription_id())) {
die('no subscription level found');
}
$subscription_name = $posted['item_name'];
$subscription_key = $posted['item_number'];
$amount = number_format((double) $posted['mc_gross'], 2);
$amount2 = number_format((double) $posted['mc_amount3'], 2);
$payment_status = $posted['payment_status'];
$currency_code = $posted['mc_currency'];
$subscription_price = number_format((double) rcp_get_subscription_price($member->get_subscription_id()), 2);
// setup the payment info in an array for storage
$payment_data = array('date' => date('Y-m-d g:i:s', strtotime($posted['payment_date'], current_time('timestamp'))), 'subscription' => $posted['item_name'], 'payment_type' => $posted['txn_type'], 'subscription_key' => $subscription_key, 'amount' => $amount, 'user_id' => $user_id, 'transaction_id' => $posted['txn_id']);
do_action('rcp_valid_ipn', $payment_data, $user_id, $posted);
if ($posted['txn_type'] == 'web_accept' || $posted['txn_type'] == 'subscr_payment') {
// only check for an existing payment if this is a payment IPD request
if (rcp_check_for_existing_payment($posted['txn_type'], $posted['payment_date'], $subscription_key)) {
$log_data = array('post_title' => __('Duplicate Payment', 'rcp'), 'post_content' => __('A duplicate payment was detected. The new payment was still recorded, so you may want to check into both payments.', 'rcp'), 'post_parent' => 0, 'log_type' => 'gateway_error');
$log_meta = array('user_subscription' => $posted['item_name'], 'user_id' => $user_id);
$log_entry = WP_Logging::insert_log($log_data, $log_meta);
die('duplicate IPN detected');
}
if (strtolower($currency_code) != strtolower($rcp_options['currency'])) {
// the currency code is invalid
$log_data = array('post_title' => __('Invalid Currency Code', 'rcp'), 'post_content' => sprintf(__('The currency code in an IPN request did not match the site currency code. Payment data: %s', 'rcp'), json_encode($payment_data)), 'post_parent' => 0, 'log_type' => 'gateway_error');
$log_meta = array('user_subscription' => $posted['item_name'], 'user_id' => $user_id);
$log_entry = WP_Logging::insert_log($log_data, $log_meta);
die('invalid currency code');
}
}
if (isset($rcp_options['email_ipn_reports'])) {
wp_mail(get_bloginfo('admin_email'), __('IPN report', 'rcp'), $listener->getTextReport());
}
/* now process the kind of subscription/payment */
$rcp_payments = new RCP_Payments();
// Subscriptions
switch ($posted['txn_type']) {
//.........这里部分代码省略.........
示例10: rcp_register_form_stripe_checkout
/**
* Displays stripe checkout form
*
* @since 2.5
* @access public
*
* @param $atts
* @return mixed|void
*/
function rcp_register_form_stripe_checkout($atts)
{
global $rcp_options;
if (empty($atts['id'])) {
return '';
}
// button is an alias for data-label
if (isset($atts['button'])) {
$atts['data-label'] = $atts['button'];
}
$key = rcp_is_sandbox() ? $rcp_options['stripe_test_publishable'] : $rcp_options['stripe_live_publishable'];
$member = new RCP_Member(wp_get_current_user()->ID);
$subscription = rcp_get_subscription_details($atts['id']);
$amount = $subscription->price + $subscription->fee;
if ($member->ID > 0) {
$amount -= $member->get_prorate_credit_amount();
}
if ($amount < 0) {
$amount = 0;
}
$data = wp_parse_args($atts, array('id' => 0, 'data-key' => $key, 'data-name' => get_option('blogname'), 'data-description' => $subscription->description, 'data-label' => sprintf(__('Join %s', 'rcp'), $subscription->name), 'data-panel-label' => __('Register - {{amount}}', 'rcp'), 'data-amount' => $amount * rcp_stripe_get_currency_multiplier(), 'data-locale' => 'auto', 'data-allow-remember-me' => true, 'data-currency' => rcp_get_currency(), 'data-alipay' => isset($rcp_options['stripe_alipay']) && '1' === $rcp_options['stripe_alipay'] && 'USD' === rcp_get_currency() ? 'true' : 'false'));
if (empty($data['data-email']) && !empty($member->user_email)) {
$data['data-email'] = $member->user_email;
}
if (empty($data['data-image']) && ($image = get_site_icon_url())) {
$data['data-image'] = $image;
}
$data = apply_filters('rcp_stripe_checkout_data', $data);
if ('USD' !== rcp_get_currency()) {
unset($data['data-alipay']);
}
ob_start();
if ($member->ID > 0 && $member->get_subscription_id() == $subscription->id && $member->is_active()) {
?>
<div class="rcp-stripe-checkout-notice"><?php
_e('You are already subscribed.', 'rcp');
?>
</div>
<?php
} else {
?>
<form action="" method="post">
<?php
do_action('register_form_stripe_fields', $data);
?>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button" <?php
foreach ($data as $label => $value) {
printf(' %s="%s" ', esc_attr($label), esc_attr($value));
}
?>
></script>
<input type="hidden" name="rcp_level" value="<?php
echo $subscription->id;
?>
" />
<input type="hidden" name="rcp_register_nonce" value="<?php
echo wp_create_nonce('rcp-register-nonce');
?>
"/>
<input type="hidden" name="rcp_gateway" value="stripe_checkout"/>
<input type="hidden" name="rcp_stripe_checkout" value="1"/>
</form>
<?php
}
return apply_filters('register_form_stripe', ob_get_clean(), $atts);
}
示例11: get_checkout_details
public function get_checkout_details($token = '')
{
$args = array('USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, 'VERSION' => '121', 'METHOD' => 'GetExpressCheckoutDetails', 'TOKEN' => $token);
$request = wp_remote_get(add_query_arg($args, $this->api_endpoint), array('timeout' => 45, 'sslverify' => false));
if (is_wp_error($request)) {
return $request;
} elseif (200 == $request['response']['code'] && 'OK' == $request['response']['message']) {
parse_str($request['body'], $data);
$data['subscription'] = (array) rcp_get_subscription_details(rcp_get_subscription_id($_GET['user_id']));
return $data;
}
return false;
}
示例12: rcp_registration_recurring_total
/**
* Get formatted recurring total for this registration
*
* @since 2.5
* @param bool $echo
*
* @return mixed|string|void
*/
function rcp_registration_recurring_total($echo = true)
{
$total = rcp_get_registration_recurring_total();
// the registration has not been setup yet
if (false === $total) {
return false;
}
if (0 < $total) {
$total = number_format($total, rcp_currency_decimal_filter());
$total = rcp_currency_filter($total);
$subscription = rcp_get_subscription_details(rcp_get_registration()->get_subscription());
if ($subscription->duration == 1) {
$total .= '/' . rcp_filter_duration_unit($subscription->duration_unit, 1);
} else {
$total .= sprintf(__(' every %s %s', 'rcp'), $subscription->duration, rcp_filter_duration_unit($subscription->duration_unit, $subscription->duration));
}
} else {
$total = __('free', 'rcp');
}
$total = apply_filters('rcp_registration_recurring_total', $total);
if ($echo) {
echo $total;
}
return $total;
}
示例13: renew
/**
* Renews a member's membership by updating status and expiration date
*
* Does NOT handle payment processing for the renewal. This should be called after receiving a renewal payment
*
* @access public
* @since 2.1
*/
public function renew($recurring = false, $status = 'active')
{
if (!$this->get_subscription_id()) {
return false;
}
// Get the member's current expiration date
$expires = $this->get_expiration_time();
// Determine what date to use as the start for the new expiration calculation
if ($expires > current_time('timestamp') && rcp_is_active($this->ID)) {
$base_date = $expires;
} else {
$base_date = current_time('timestamp');
}
$subscription = rcp_get_subscription_details($this->get_subscription_id());
if ($subscription->duration > 0) {
$last_day = cal_days_in_month(CAL_GREGORIAN, date('n', $base_date), date('Y', $base_date));
$expiration = date('Y-m-d H:i:s', strtotime('+' . $subscription->duration . ' ' . $subscription->duration_unit . ' 23:59:59'));
if (date('j', $base_date) == $last_day && 'day' != $subscription->duration_unit) {
$expiration = date('Y-m-d H:i:s', strtotime($expiration . ' +2 days'));
}
} else {
$expiration = 'none';
}
$expiration = apply_filters('rcp_member_renewal_expiration', $expiration, $subscription, $this->ID);
do_action('rcp_member_pre_renew', $this->ID, $expiration, $this);
$this->set_status($status);
$this->set_expiration_date($expiration);
$this->set_recurring($recurring);
delete_user_meta($this->ID, '_rcp_expired_email_sent');
do_action('rcp_member_post_renew', $this->ID, $expiration, $this);
}
示例14: rcp_check_ipn
function rcp_check_ipn()
{
global $rcp_options;
if (!class_exists('IpnListener')) {
// instantiate the IpnListener class
include RCP_PLUGIN_DIR . 'includes/gateways/paypal/ipnlistener.php';
}
$listener = new IpnListener();
if (isset($rcp_options['sandbox'])) {
$listener->use_sandbox = true;
}
if (isset($rcp_options['ssl'])) {
$listener->use_ssl = true;
} else {
$listener->use_ssl = false;
}
//To post using the fsockopen() function rather than cURL, use:
if (isset($rcp_options['disable_curl'])) {
$listener->use_curl = false;
}
try {
$listener->requirePostMethod();
$verified = $listener->processIpn();
} catch (Exception $e) {
//exit(0);
}
/*
The processIpn() method returned true if the IPN was "VERIFIED" and false if it
was "INVALID".
*/
if ($verified || isset($_POST['verification_override']) || (isset($rcp_options['sandbox']) || isset($rcp_options['disable_ipn_verify']))) {
$posted = apply_filters('rcp_ipn_post', $_POST);
// allow $_POST to be modified
$user_id = $posted['custom'];
$subscription_name = $posted['item_name'];
$subscription_key = $posted['item_number'];
$amount = number_format((double) $posted['mc_gross'], 2);
$amount2 = number_format((double) $posted['mc_amount3'], 2);
$payment_status = $posted['payment_status'];
$currency_code = $posted['mc_currency'];
$subscription_id = rcp_get_subscription_id($user_id);
$subscription_price = number_format((double) rcp_get_subscription_price(rcp_get_subscription_id($user_id)), 2);
$user_data = get_userdata($user_id);
if (!$user_data || !$subscription_id) {
return;
}
if (!rcp_get_subscription_details($subscription_id)) {
return;
}
// setup the payment info in an array for storage
$payment_data = array('date' => date('Y-m-d g:i:s', strtotime($posted['payment_date'])), 'subscription' => $posted['item_name'], 'payment_type' => $posted['txn_type'], 'subscription_key' => $subscription_key, 'amount' => $amount, 'user_id' => $user_id, 'transaction_id' => $posted['txn_id']);
do_action('rcp_valid_ipn', $payment_data, $user_id, $posted);
if ($posted['txn_type'] == 'web_accept' || $posted['txn_type'] == 'subscr_payment') {
// only check for an existing payment if this is a payment IPD request
if (rcp_check_for_existing_payment($posted['txn_type'], $posted['payment_date'], $subscription_key)) {
$log_data = array('post_title' => __('Duplicate Payment', 'rcp'), 'post_content' => __('A duplicate payment was detected. The new payment was still recorded, so you may want to check into both payments.', 'rcp'), 'post_parent' => 0, 'log_type' => 'gateway_error');
$log_meta = array('user_subscription' => $posted['item_name'], 'user_id' => $user_id);
$log_entry = WP_Logging::insert_log($log_data, $log_meta);
return;
// this IPN request has already been processed
}
/* do some quick checks to make sure all necessary data validates */
if ($amount < $subscription_price && $amount2 < $subscription_price) {
/*
// the subscription price doesn't match, so lets check to see if it matches with a discount code
if( ! rcp_check_paypal_return_price_after_discount( $subscription_price, $amount, $amount2, $user_id ) ) {
$log_data = array(
'post_title' => __( 'Price Mismatch', 'rcp' ),
'post_content' => sprintf( __( 'The price in an IPN request did not match the subscription price. Payment data: %s', 'rcp' ), json_encode( $payment_data ) ),
'post_parent' => 0,
'log_type' => 'gateway_error'
);
$log_meta = array(
'user_subscription' => $posted['item_name'],
'user_id' => $user_id
);
$log_entry = WP_Logging::insert_log( $log_data, $log_meta );
//return;
}
*/
}
if (strtolower($currency_code) != strtolower($rcp_options['currency'])) {
// the currency code is invalid
$log_data = array('post_title' => __('Invalid Currency Code', 'rcp'), 'post_content' => sprintf(__('The currency code in an IPN request did not match the site currency code. Payment data: %s', 'rcp'), json_encode($payment_data)), 'post_parent' => 0, 'log_type' => 'gateway_error');
$log_meta = array('user_subscription' => $posted['item_name'], 'user_id' => $user_id);
$log_entry = WP_Logging::insert_log($log_data, $log_meta);
return;
}
}
if (isset($rcp_options['email_ipn_reports'])) {
wp_mail(get_bloginfo('admin_email'), __('IPN report', 'rcp'), $listener->getTextReport());
}
if (rcp_get_subscription_key($user_id) != $subscription_key) {
// the subscription key is invalid
$log_data = array('post_title' => __('Subscription Key Mismatch', 'rcp'), 'post_content' => sprintf(__('The subscription key in an IPN request did not match the subscription key recorded for the user. Payment data: %s', 'rcp'), json_encode($payment_data)), 'post_parent' => 0, 'log_type' => 'gateway_error');
$log_meta = array('user_subscription' => $posted['item_name'], 'user_id' => $user_id);
$log_entry = WP_Logging::insert_log($log_data, $log_meta);
return;
}
/* now process the kind of subscription/payment */
//.........这里部分代码省略.........
示例15: _e
<tr class="rcp-total">
<th><?php
_e('Total Today', 'rcp');
?>
</th>
<th><?php
rcp_registration_total();
?>
</th>
</tr>
<?php
if (rcp_registration_is_recurring()) {
?>
<?php
$subscription = rcp_get_subscription_details(rcp_get_registration()->get_subscription());
if ($subscription->duration == 1) {
$label = sprintf(__('Total Recurring Per %s', 'rcp'), rcp_filter_duration_unit($subscription->duration_unit, 1));
} else {
$label = sprintf(__('Total Recurring Every %s %s', 'rcp'), $subscription->duration, rcp_filter_duration_unit($subscription->duration_unit, $subscription->duration));
}
?>
<tr class="rcp-recurring-total">
<th><?php
echo $label;
?>
</th>
<th><?php
rcp_registration_recurring_total();
?>
</th>