function popover_payment_form()
    {
        global $M_options;
        $gateway = $_POST['gateway'];
        if ($gateway == 'authorizenetarb') {
            $subscription_id = $_POST['subscription'];
            $coupon_code = $_POST['coupon_code'];
            $user_id = $_POST['user'];
            $factory = Membership_Plugin::factory();
            if (empty($user_id)) {
                $user = wp_get_current_user();
                $spmemuserid = $user->ID;
                if (!empty($user->ID) && is_numeric($user->ID)) {
                    $member = $factory->get_member($user->ID);
                } else {
                    $member = current_member();
                }
            } else {
                $member = $factory->get_member($user_id);
            }
            $subscription = (int) $_REQUEST['subscription'];
            $gateway = M_get_class_for_gateway($gateway);
            if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) {
                $sub = $factory->get_subscription($subscription);
                // Get the coupon
                $coupon = membership_get_current_coupon();
                // Build the pricing array
                $pricing = $sub->get_pricingarray();
                if (!empty($pricing) && !empty($coupon)) {
                    $pricing = $coupon->apply_coupon_pricing($pricing);
                }
                // Check if the pricing is now a free subscription and if so then handle the signup directly
                // We are on a free signup - check the subscription then set it up
                if (isset($pricing[0]) && $pricing[0]['amount'] < 1 && count($pricing) == 1 || count($pricing) == 2 && $pricing[0]['amount'] < 1 && $pricing[1]['amount'] < 1) {
                    // We have a free level
                    $member->create_subscription($subscription_id, $this->gateway);
                    if (!empty($M_options['registrationcompleted_message'])) {
                        echo $this->get_completed_message($sub);
                    } else {
                        wp_safe_redirect(!strpos(home_url(), 'https:') ? str_replace('https:', 'http:', M_get_registrationcompleted_permalink()) : M_get_registrationcompleted_permalink());
                    }
                } else {
                    ?>
					<div class='header' style='width: 750px'>
						<h1><?php 
                    echo __('Enter Your Credit Card Information', 'membership');
                    ?>
</h1>
					</div>
					<?php 
                    $this->display_payment_form($sub, $pricing, $member->ID);
                }
            }
        }
        // Need this to stop processing
        die;
    }
예제 #2
0
<?php

if (!$user_id) {
    $user = wp_get_current_user();
    $spmemuserid = $user->ID;
    if (!empty($user->ID) && is_numeric($user->ID)) {
        $member = new M_Membership($user->ID);
    } else {
        $member = current_member();
    }
} else {
    $member = new M_Membership($user_id);
}
$subscription = (int) $_REQUEST['subscription'];
if (isset($_REQUEST['gateway']) && isset($_REQUEST['extra_form'])) {
    $gateway = M_get_class_for_gateway($_REQUEST['gateway']);
    if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) {
        $sub = new M_Subscription($subscription);
        $pricing = $sub->get_pricingarray();
        $coupon_code = membership_get_current_coupon();
        if (!empty($pricing) && !empty($coupon_code)) {
            $pricing = $sub->apply_coupon_pricing($coupon_code, $pricing);
        }
        ?>
		<div class='header' style='width: 750px'>
			<h1><?php 
        echo __('Enter Your Credit Card Information', 'membership') . " " . $sub->sub_name();
        ?>
</h1>
		</div>
		<div class='fullwidth'>
예제 #3
0
                        // Join the new subscription
                        $member->create_subscription($sub_id, $gateway);
                        // Remove the old subscription
                        $member->drop_subscription($fromsub_id);
                        // Timestamp the update
                        update_user_meta($user, '_membership_last_upgraded', time());
                    }
                    break;
            }
        }
        $rels = $member->get_relationships();
        foreach ((array) $rels as $rel) {
            $sub = new M_Subscription($rel->sub_id);
            $nextlevel = $sub->get_next_level($rel->level_id, $rel->order_instance);
            if (!empty($rel->usinggateway) && $rel->usinggateway != 'admin') {
                $gateway = M_get_class_for_gateway($rel->usinggateway);
                if (!empty($gateway) && $gateway->issingle) {
                    $gatewayissingle = 'yes';
                } else {
                    $gatewayissingle = 'no';
                }
            } else {
                $gatewayissingle = 'admin';
            }
            ?>
					<div class="renew-form">
						<div class="formleft">
							<p>
							<?php 
            echo __('<strong>You are currently on the subscription</strong> : ', 'membership') . $sub->sub_name();
            ?>