public static function get_existing_user_information($blog_id, $domain, $get_all = true)
    {
        global $psts, $wpdb;
        $args = array();
        $prev_billing = $next_billing = $content = '';
        if (!$blog_id) {
            return;
        }
        $img_base = $psts->plugin_url . 'images/';
        $cancel_label = __('Cancel Your Subscription', 'psts');
        //Check if blog is still under trial
        $trialing = ProSites_Helper_Registration::is_trial($blog_id);
        if ($trialing) {
            $args['trial'] = '<div id="psts-general-error" class="psts-warning">' . __('You are still within your trial period. Once your trial finishes your account will be automatically charged.', PSTS_TEXT_DOMAIN) . '</div>';
        }
        //Check if payment is not yet confirmed
        if (!empty($blog_id) && 1 == get_blog_option($blog_id, 'psts_waiting_step')) {
            //Fetch, if payment status is pending and reason is stored
            $psts_payment_details = get_user_meta(get_current_user_id(), 'psts_payment_details', true);
            if (!empty($psts_payment_details['pending_reason'])) {
                $args['pending'] = '<div id="psts-general-error" class="psts-warning message">' . $psts_payment_details['pending_reason'] . __('<br/>If you have enabled payment review for PayPal, make sure you accept the payment to avail the premium services.', PSTS_TEXT_DOMAIN) . '</div>';
            } else {
                $args['pending'] = '<div id="psts-general-error" class="psts-warning">' . __('There are pending changes to your account. This message will disappear once these pending changes are completed.', PSTS_TEXT_DOMAIN) . '</div>';
            }
        }
        //Check if its a recurring subscription or not
        $is_recurring = $psts->is_blog_recurring($blog_id);
        $args['recurring'] = $is_recurring;
        //if Payment was successful display a complete message
        if (self::$complete_message) {
            $content = '<div id="psts-complete-msg">' . self::$complete_message . '</div>';
            $args['complete_message'] = $content;
            $args['thanks_message'] = '<p>' . $psts->get_setting('pypl_thankyou') . '</p>';
            $args['visit_site_message'] = '<p><a href="' . get_admin_url($blog_id, '', 'http') . '">' . __('Visit your newly upgraded site »', 'psts') . '</a></p>';
        }
        // Cancellation message
        if (self::$cancel_message) {
            $args['cancel'] = true;
            $args['cancellation_message'] = self::$cancel_message;
            self::$cancel_message = false;
        }
        //check if pro/express user
        if ($profile_id = self::get_profile_id($blog_id)) {
            $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
            $level = $psts->get_level_setting($psts->get_level($blog_id), 'name');
            $content = '<div id="psts_existing_info">';
            //show sub details
            $resArray = PaypalApiHelper::GetRecurringPaymentsProfileDetails($profile_id);
            if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && $resArray['STATUS'] == 'Active') {
                if (isset($resArray['LASTPAYMENTDATE'])) {
                    $prev_billing = strtotime($resArray['LASTPAYMENTDATE']);
                } else {
                    if ($last_payment = $psts->last_transaction($blog_id)) {
                        $prev_billing = $last_payment['timestamp'];
                    } else {
                        //					$prev_billing = __( "None yet with this subscription <small>(only initial separate single payment has been made, or you've recently modified your subscription)</small>", 'psts' );
                    }
                }
                if (isset($resArray['NEXTBILLINGDATE'])) {
                    $next_billing = strtotime($resArray['NEXTBILLINGDATE']);
                } else {
                    //					$next_billing = __( "None", 'psts' );
                }
                $content .= '<h3>' . stripslashes($resArray['DESC']) . '</h3><ul>';
                if (is_pro_site($blog_id)) {
                    $args['level'] = $level;
                }
                if (isset($resArray['ACCT'])) {
                    //credit card
                    $month = substr($resArray['EXPDATE'], 0, 2);
                    $year = substr($resArray['EXPDATE'], 2, 4);
                    $args['card_type'] = $resArray['CREDITCARDTYPE'];
                    $args['card_reminder'] = $resArray['ACCT'];
                    $args['card_digit_location'] = 'end';
                    $args['card_expire_month'] = $month;
                    $args['card_expire_year'] = $year;
                } else {
                    //paypal
                    $content .= '<li>' . __('Payment Method: <strong>Your PayPal Account</strong>', 'psts') . '</li>';
                }
                $args['last_payment_date'] = $prev_billing;
                $args['next_payment_date'] = $next_billing;
                // Cancellation link
                if ($is_recurring) {
                    if (is_pro_site($blog_id)) {
                        $args['cancel_info'] = '<p class="prosites-cancel-description">' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                        // CSS class of <a> is important to handle confirmations
                        $args['cancel_link'] = '<p class="prosites-cancel-link"><a class="cancel-prosites-plan button" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . esc_attr($cancel_label) . '">' . esc_html($cancel_label) . '</a></p>';
                    }
                }
            } else {
                if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && $resArray['STATUS'] == 'Cancelled') {
                    if ($is_recurring) {
                        $args['cancel'] = true;
                        $args['cancellation_message'] = '<div class="psts-cancel-notification">
													<p class="label"><strong>' . __('Your subscription has been canceled', 'psts') . '</strong></p>
													<p>' . sprintf(__('This site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                    }
                } else {
                    if ($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') {
                        $content .= '<h3>' . sprintf(__('Your subscription is: %s', 'psts'), $resArray['STATUS']) . '</h3>';
                        $content .= '<p>' . __('Please update your payment information below to resolve this.', 'psts') . '</p>';
                        if (is_pro_site($blog_id)) {
                            $args['cancel_info'] = '<p>' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                        }
                        $args['cancel_link'] = '<p><a id="pypl_cancel" href="' . wp_nonce_url($psts->checkout_url($blog_id) . '&action=cancel', 'psts-cancel') . '" title="' . $cancel_label . '"><img src="' . $img_base . 'cancel_subscribe_gen.gif" /></a></p>';
                    } else {
                        $content .= '<div class="psts-error">' . __("There was a problem accessing your subscription information: ", 'psts') . self::parse_error_string($resArray) . '</div>';
                    }
                }
            }
            //print receipt send form
            $args['receipt_form'] = $psts->receipt_form($blog_id);
        } else {
            if (is_pro_site($blog_id)) {
                $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
                $level = $psts->get_level_setting($psts->get_level($blog_id), 'name');
                $old_gateway = $wpdb->get_var("SELECT gateway FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '{$blog_id}'");
                $content .= '<div id="psts_existing_info">';
                $content .= '<h3>' . __('Your Subscription Information', 'psts') . '</h3><ul>';
                $args['level'] = $level;
                if ($old_gateway == 'PayPal') {
                    $content .= '<li>' . __('Payment Method: <strong>Your PayPal Account</strong>', 'psts') . '</li>';
                } else {
                    if ($old_gateway == 'Amazon') {
                        $content .= '<li>' . __('Payment Method: <strong>Your Amazon Account</strong>', 'psts') . '</li>';
                    } else {
                        if ($psts->get_expire($blog_id) >= 9999999999.0) {
                            $content .= '<li>' . __('Expire Date: <strong>Never</strong>', 'psts') . '</li>';
                        } else {
                            $content .= '<li>' . sprintf(__('Expire Date: <strong>%s</strong>', 'psts'), $end_date) . '</li>';
                        }
                    }
                }
                $content .= '</ul><br />';
                if ($old_gateway == 'PayPal' || $old_gateway == 'Amazon') {
                    $args['cancel_info'] = '<p>' . sprintf(__('If your subscription is still active your next scheduled payment should be %1$s.', 'psts'), $end_date) . '</p>';
                    $args['cancel_info'] .= '<p>' . sprintf(__('If you choose to cancel your subscription this site should continue to have %1$s features until %2$s.', 'psts'), $level, $end_date) . '</p>';
                    //show instructions for old gateways
                    if ($old_gateway == 'PayPal') {
                        $args['cancel_link'] = '<p><a id="pypl_cancel" target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=' . urlencode(get_site_option("supporter_paypal_email")) . '" title="' . $cancel_label . '"><img src="' . $psts->plugin_url . 'images/cancel_subscribe_gen.gif" /></a><br /><small>' . __('You can also cancel following <a href="https://www.paypal.com/helpcenter/main.jsp;jsessionid=SCPbTbhRxL6QvdDMvshNZ4wT2DH25d01xJHj6cBvNJPGFVkcl6vV!795521328?t=solutionTab&ft=homeTab&ps=&solutionId=27715&locale=en_US&_dyncharset=UTF-8&countrycode=US&cmd=_help-ext">these steps</a>.', 'psts') . '</small></p>';
                    } else {
                        if ($old_gateway == 'Amazon') {
                            $args['cancel_link'] = '<p>' . __('To cancel your subscription, simply go to <a id="pypl_cancel" target="_blank" href="https://payments.amazon.com/">https://payments.amazon.com/</a>, click Your Account at the top of the page, log in to your Amazon Payments account (if asked), and then click the Your Subscriptions link. This page displays your subscriptions, showing the most recent, active subscription at the top. To view the details of a specific subscription, click Details. Then cancel your subscription by clicking the Cancel Subscription button on the Subscription Details page.', 'psts') . '</p>';
                        }
                    }
                }
                //print receipt send form
                $args['receipt_form'] = $psts->receipt_form($blog_id);
            }
        }
        // Show all is true
        $args['all_fields'] = true;
        return $args;
    }
예제 #2
0
        /**
         * PayPal Pro/Express
         *
         * @return string
         */
        public static function render_tab_paypal()
        {
            global $psts;
            ProSites_Helper_Settings::settings_header(ProSites_Helper_Tabs_Gateways::get_active_tab());
            $class_name = 'ProSites_Gateway_PayPalExpressPro';
            $active_gateways = (array) $psts->get_setting('gateways_enabled');
            $checked = in_array($class_name, $active_gateways) ? 'on' : 'off';
            ?>
			<table class="form-table">
				<tr>
					<th scope="row"><?php 
            _e('Enable Gateway', 'psts');
            ?>
</th>
					<td>
						<input type="hidden" name="gateway" value="<?php 
            echo esc_attr($class_name);
            ?>
" />
						<input type="checkbox" name="gateway_active" value="1" <?php 
            checked($checked, 'on');
            ?>
 />
					</td>
				</tr>
			</table>
			<?php 
            $gateway = new ProSites_Gateway_PayPalExpressPro();
            echo $gateway->settings();
        }