コード例 #1
0
        function modify_form($blog_id)
        {
            global $psts, $wpdb;
            if (!ProSites_Helper_Gateway::is_last_gateway_used($blog_id, self::get_slug())) {
                return false;
            }
            $active_member = false;
            $canceled_member = false;
            //get subscription info
            $profile_id = $this->get_profile_id($blog_id);
            if ($profile_id) {
                $resArray = $this->tcheckout_get_profile_detail($profile_id);
                $active_recurring = $this->get_recurring_lineitems($resArray);
                $lineitem = $active_recurring[0];
                if ($resArray['response_code'] == 'OK' && $lineitem['status'] == 'active') {
                    $active_member = true;
                    $next_payment_timestamp = strtotime($lineitem['date_next']);
                } else {
                    if ($resArray['response_code'] == 'OK' && empty($lineitem)) {
                        $canceled_member = true;
                    }
                }
            }
            $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
            if ($active_member) {
                ?>
				<h4><?php 
                _e('Cancelations:', 'psts');
                ?>
</h4>
				<label><input type="radio" name="twocheckout_mod_action"
				              value="cancel"/> <?php 
                _e('Cancel Subscription Only', 'psts');
                ?>
					<small>(<?php 
                printf(__('Their access will expire on %s', 'psts'), $end_date);
                ?>
)</small>
				</label><br/>
				<?php 
                if ($last_payment = $psts->last_transaction($blog_id)) {
                    $days_left = ($next_payment_timestamp - time()) / 60 / 60 / 24;
                    $period = $wpdb->get_var("SELECT term FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '{$blog_id}'");
                    $refund = intval($period) ? round($days_left / (intval($period) * 30.4166) * $last_payment['amount'], 2) : 0;
                    if ($refund > $last_payment['amount']) {
                        $refund = $last_payment['amount'];
                    }
                    ?>
					<label><input type="radio" name="twocheckout_mod_action"
					              value="cancel_refund"/> <?php 
                    printf(__('Cancel Subscription and Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                    ?>
						<small>(<?php 
                    printf(__('Their access will expire on %s', 'psts'), $end_date);
                    ?>
)</small>
					</label><br/>
					<?php 
                    if ($refund) {
                        ?>
						<label><input type="radio" name="twocheckout_mod_action"
						              value="cancel_refund_pro"/> <?php 
                        printf(__('Cancel Subscription and Refund Prorated (%s) Last Payment', 'psts'), $psts->format_currency(false, $refund));
                        ?>
							<small>(<?php 
                        printf(__('Their access will expire on %s', 'psts'), $end_date);
                        ?>
)
							</small>
						</label><br/>
					<?php 
                    }
                    ?>

					<h4><?php 
                    _e('Refunds:', 'psts');
                    ?>
</h4>
					<label><input type="radio" name="twocheckout_mod_action"
					              value="refund"/> <?php 
                    printf(__('Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                    ?>
						<small>(<?php 
                    _e('Their subscription and access will continue', 'psts');
                    ?>
)</small>
					</label><br/>
					<label><input type="radio" name="twocheckout_mod_action"
					              value="partial_refund"/> <?php 
                    printf(__('Refund a Partial %s Amount of Last Payment', 'psts'), $psts->format_currency() . '<input type="text" name="refund_amount" size="4" value="' . $last_payment['amount'] . '" />');
                    ?>
						<small>(<?php 
                    _e('Their subscription and access will continue', 'psts');
                    ?>
)</small>
					</label><br/>

				<?php 
                }
            } else {
                if ($canceled_member && ($last_payment = $psts->last_transaction($blog_id))) {
                    ?>
					<h4><?php 
                    _e('Refunds:', 'psts');
                    ?>
</h4>
					<label><input type="radio" name="twocheckout_mod_action"
					              value="refund"/> <?php 
                    printf(__('Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                    ?>
						<small>(<?php 
                    _e('Their subscription and access will continue', 'psts');
                    ?>
)</small>
					</label><br/>
					<label><input type="radio" name="twocheckout_mod_action"
					              value="partial_refund"/> <?php 
                    printf(__('Refund a Partial %s Amount of Last Payment', 'psts'), $psts->format_currency() . '<input type="text" name="refund_amount" size="4" value="' . $last_payment['amount'] . '" />');
                    ?>
						<small>(<?php 
                    _e('Their subscription and access will continue', 'psts');
                    ?>
)</small>
					</label><br/>
				<?php 
                } else {
                    ?>
				<?php 
                }
            }
        }
コード例 #2
0
    /**
     * Renders the Modify Pro Site Status content for this gateway
     *
     * @param $blog_id
     *
     * @return bool
     */
    public static function modify_form($blog_id)
    {
        global $psts, $wpdb;
        if (!ProSites_Helper_Gateway::is_last_gateway_used($blog_id, self::get_slug())) {
            return false;
        }
        $active_member = false;
        $canceled_member = false;
        $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
        $customer_id = self::get_customer_data($blog_id)->customer_id;
        try {
            $existing_invoice_object = Stripe_Invoice::all(array("customer" => $customer_id, "count" => 1));
            $last_payment = isset($existing_invoice_object->data[0]->total) ? $existing_invoice_object->data[0]->total / 100 : '';
            $cancel_status = get_blog_option($blog_id, 'psts_stripe_canceled');
            if ($last_payment != '') {
                if ($cancel_status == 0 && $cancel_status != '') {
                    ?>
					<h4><?php 
                    _e('Cancelations:', 'psts');
                    ?>
</h4>
					<label><input type="radio" name="stripe_mod_action" value="cancel"/> <?php 
                    _e('Cancel Subscription Only', 'psts');
                    ?>
						<small>(<?php 
                    printf(__('Their access will expire on %s', 'psts'), $end_date);
                    ?>
)</small>
					</label><br/>

					<label><input type="radio" name="stripe_mod_action" value="cancel_refund"/> <?php 
                    printf(__('Cancel Subscription and Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment));
                    ?>
						<small>(<?php 
                    printf(__('Their access will expire on %s', 'psts'), $end_date);
                    ?>
)</small>
					</label><br/>
				<?php 
                }
                ?>

				<h4><?php 
                _e('Refunds:', 'psts');
                ?>
</h4>
				<label><input type="radio" name="stripe_mod_action" value="refund"/> <?php 
                printf(__('Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment));
                ?>
					<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
				</label><br/>
				<label><input type="radio" name="stripe_mod_action" value="partial_refund"/> <?php 
                printf(__('Refund a Partial %s Amount of Last Payment', 'psts'), $psts->format_currency() . '<input type="text" name="refund_amount" size="4" value="' . $last_payment . '" />');
                ?>
					<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
				</label><br/>
			<?php 
            }
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
コード例 #3
0
    function modify_form($blog_id)
    {
        global $psts, $wpdb;
        if (!ProSites_Helper_Gateway::is_last_gateway_used($blog_id, self::get_slug())) {
            return false;
        }
        $active_member = false;
        $canceled_member = false;
        //get subscription info
        $profile_id = $this->get_profile_id($blog_id);
        if ($profile_id) {
            $resArray = PaypalApiHelper::GetRecurringPaymentsProfileDetails($profile_id);
            if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && ($resArray['STATUS'] == 'Active' || $resArray['STATUS'] == 'Suspended')) {
                $active_member = true;
                $next_payment_timestamp = strtotime($resArray['NEXTBILLINGDATE']);
            } else {
                if (($resArray['ACK'] == 'Success' || $resArray['ACK'] == 'SuccessWithWarning') && $resArray['STATUS'] == 'Cancelled') {
                    $canceled_member = true;
                }
            }
        }
        $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
        if ($active_member) {
            ?>
			<h4><?php 
            _e('Cancelations:', 'psts');
            ?>
</h4>
			<label><input type="radio" name="pypl_mod_action" value="cancel"/> <?php 
            _e('Cancel Subscription Only', 'psts');
            ?>
				<small>(<?php 
            printf(__('Their access will expire on %s', 'psts'), $end_date);
            ?>
)</small>
			</label><br/>
			<?php 
            if ($last_payment = $psts->last_transaction($blog_id)) {
                $days_left = ($next_payment_timestamp - time()) / 60 / 60 / 24;
                $period = $wpdb->get_var("SELECT term FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '{$blog_id}'");
                $refund = intval($period) ? round($days_left / (intval($period) * 30.4166) * $last_payment['amount'], 2) : 0;
                if ($refund > $last_payment['amount']) {
                    $refund = $last_payment['amount'];
                }
                ?>
				<label><input type="radio" name="pypl_mod_action" value="cancel_refund"/> <?php 
                printf(__('Cancel Subscription and Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                ?>
					<small>(<?php 
                printf(__('Their access will expire on %s', 'psts'), $end_date);
                ?>
)</small>
				</label><br/>
				<?php 
                if ($refund) {
                    ?>
					<label><input type="radio" name="pypl_mod_action" value="cancel_refund_pro"/> <?php 
                    printf(__('Cancel Subscription and Refund Prorated (%s) Last Payment', 'psts'), $psts->format_currency(false, $refund));
                    ?>
						<small>(<?php 
                    printf(__('Their access will expire on %s', 'psts'), $end_date);
                    ?>
)</small>
					</label><br/>
				<?php 
                }
                ?>

				<h4><?php 
                _e('Refunds:', 'psts');
                ?>
</h4>
				<label><input type="radio" name="pypl_mod_action" value="refund"/> <?php 
                printf(__('Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                ?>
					<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
				</label><br/>
				<label><input type="radio" name="pypl_mod_action" value="partial_refund"/> <?php 
                printf(__('Refund a Partial %s Amount of Last Payment', 'psts'), $psts->format_currency() . '<input type="text" name="refund_amount" size="4" value="' . $last_payment['amount'] . '" />');
                ?>
					<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
				</label><br/>

			<?php 
            }
        } else {
            if ($canceled_member && ($last_payment = $psts->last_transaction($blog_id))) {
                ?>
			<h4><?php 
                _e('Refunds:', 'psts');
                ?>
</h4>
			<label><input type="radio" name="pypl_mod_action" value="refund"/> <?php 
                printf(__('Refund Full (%s) Last Payment', 'psts'), $psts->format_currency(false, $last_payment['amount']));
                ?>
				<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
			</label><br/>
			<label><input type="radio" name="pypl_mod_action" value="partial_refund"/> <?php 
                printf(__('Refund a Partial %s Amount of Last Payment', 'psts'), $psts->format_currency() . '<input type="text" name="refund_amount" size="4" value="' . $last_payment['amount'] . '" />');
                ?>
				<small>(<?php 
                _e('Their subscription and access will continue', 'psts');
                ?>
)</small>
			</label><br/>
		<?php 
            } else {
                ?>
			<p>
				<small style="color:red;"><?php 
                _e('Note: This <strong>will not</strong> cancel their PayPal subscription or refund any payments made. You will have to do it from your PayPal account for this site.', 'psts');
                ?>
</small>
			</p>
		<?php 
            }
        }
    }
コード例 #4
0
 function subscriber_info($blog_id)
 {
     global $psts;
     if (!ProSites_Helper_Gateway::is_last_gateway_used($blog_id, self::get_slug())) {
         return false;
     }
     $email = get_blog_option($blog_id, 'admin_email');
     $user = get_user_by('email', $email);
     $name = !empty($user->data) && !empty($user->data->display_name) ? $user->data->display_name : $user->data->user_nicename;
     if (!empty($name)) {
         echo '<p> <strong>' . $name . '</strong>';
         echo "<p>Email: <strong>" . $email . "</strong></p>";
     } else {
         echo __("Subscriber details not available.", 'psts');
     }
 }