/** * Prepare the PayPal IPN fields * * Details here: * https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/ * * @since 1.0.0 * @return array */ private function prepare_fields() { $subscription = $this->data['ms_relationship']; $membership = $subscription->get_membership(); if (0 === $membership->price) { return; } $gateway = $this->data['gateway']; $invoice = $subscription->get_current_invoice(); $fields = array('business' => array('id' => 'business', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->paypal_email), 'cmd' => array('id' => 'cmd', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => '_xclick'), 'bn' => array('id' => 'bn', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'incsub_SP'), 'item_number' => array('id' => 'item_number', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $subscription->membership_id), 'item_name' => array('id' => 'item_name', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->name), 'amount' => array('id' => 'amount', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Helper_Billing::format_price($invoice->total)), 'currency_code' => array('id' => 'currency_code', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->currency), 'return' => array('id' => 'return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => esc_url_raw(add_query_arg(array('ms_relationship_id' => $subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE, false)))), 'cancel_return' => array('id' => 'cancel_return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER)), 'notify_url' => array('id' => 'notify_url', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->get_return_url()), 'lc' => array('id' => 'lc', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->paypal_site), 'invoice' => array('id' => 'invoice', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id)); // Don't send to paypal if free if (0 === $invoice->total) { $fields = array('gateway' => array('id' => 'gateway', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->id), 'ms_relationship_id' => array('id' => 'ms_relationship_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $subscription->id), 'step' => array('id' => 'step', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Controller_Frontend::STEP_PROCESS_PURCHASE), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($gateway->id . '_' . $subscription->id))); $this->data['action_url'] = null; } else { if ($gateway->is_live_mode()) { $this->data['action_url'] = 'https://www.paypal.com/cgi-bin/webscr'; } else { $this->data['action_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } } $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE, 'value' => 'https://www.paypalobjects.com/en_US/i/btn/x-click-but06.gif', 'alt' => __('PayPal - The safer, easier way to pay online', MS_TEXT_DOMAIN)); // custom pay button defined in gateway settings $custom_label = $gateway->pay_button_url; if (!empty($custom_label)) { if (false !== strpos($custom_label, '://')) { $fields['submit']['value'] = $custom_label; } else { $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => $custom_label); } } return apply_filters('ms_gateway_paypalsingle_view_prepare_fields', $fields); }
/** * Prepare html fields. * * @since 1.0.0 * * @return array */ function prepare_fields() { $invoice = $this->data['invoice']; $currency = MS_Plugin::instance()->settings->currency; $user_name = ''; $transaction_link = ''; $user_id = 0; $user_list = array(); if ($invoice->id) { $member = $invoice->get_member(); $user_id = $member->id; $user_name = $member->name; $transaction_link = sprintf('<a href="%s" target="_blank">%s</a>', MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'invoice' => $invoice->id)), __('Show Transactions', 'membership2')); } else { $user_list = MS_Model_Member::get_usernames(null, MS_Model_Member::SEARCH_ALL_USERS); } $fields = array('link_transactions' => array('id' => 'link_transactions', 'title' => $transaction_link, 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'wrapper_class' => 'ms-transactions-link'), 'txt_user' => array('id' => 'txt_user', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => sprintf('<a href="%s">%s</a>', MS_Controller_Plugin::get_admin_url('add-member', array('user_id' => $user_id)), $user_name)), 'txt_membership' => array('id' => 'txt_membership', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_created' => array('id' => 'txt_created', 'title' => __('Invoice created on', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'status' => array('id' => 'status', 'title' => __('Invoice status', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'field_options' => MS_Model_Invoice::get_status_types(true), 'value' => $invoice->status), 'user_id' => array('id' => 'user_id', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->user_id, 'field_options' => $user_list), 'membership_id' => array('id' => 'membership_id', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->membership_id, 'field_options' => $this->data['memberships']), 'amount' => array('id' => 'amount', 'title' => sprintf(__('Amount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->amount), 'config' => array('step' => 'any', 'min' => 0)), 'discount' => array('id' => 'discount', 'title' => sprintf(__('Discount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->discount), 'config' => array('step' => 'any', 'min' => 0)), 'due_date' => array('id' => 'due_date', 'title' => __('Due date', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $invoice->due_date), 'description' => array('id' => 'description', 'title' => __('Description', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'class' => 'widefat', 'value' => $invoice->description), 'notes' => array('id' => 'notes', 'title' => __('Notes', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA, 'class' => 'widefat', 'value' => $invoice->get_notes_desc()), 'invoice_id' => array('id' => 'invoice_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($this->data['action'])), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['action']), 'separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'execute' => array('id' => 'execute', 'title' => __('Execute status change actions on Save (add/remove membership)', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'value' => true), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'title' => __('Cancel', 'membership2'), 'value' => __('Cancel', 'membership2'), 'url' => esc_url_raw(remove_query_arg(array('action', 'invoice_id'))), 'class' => 'wpmui-field-button button'), 'submit' => array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Changes', 'membership2'))); if ($invoice->id > 0) { $fields['user_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN; $fields['membership_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN; $fields['txt_membership']['value'] = $this->data['memberships'][$invoice->membership_id]; $fields['txt_created']['value'] = MS_Helper_Period::format_date($invoice->invoice_date); } else { unset($fields['txt_user']); unset($fields['txt_membership']); unset($fields['txt_created']); unset($fields['txt_separator']); } return apply_filters('ms_view_billing_edit_prepare_fields', $fields, $this); }
public function column_discount($item) { $html = ''; if (MS_Addon_Coupon_Model::TYPE_VALUE == $item->discount_type) { $html = sprintf('%s %s', MS_Plugin::instance()->settings->currency, MS_Helper_Billing::format_price($item->discount)); } elseif (MS_Addon_Coupon_Model::TYPE_PERCENT == $item->discount_type) { $html = $item->discount . ' %'; } else { $html = apply_filters('ms_addon_coupon_helper_listtable_column_discount', $item->discount); } return $html; }
/** * Prepare html fields. * * @since 1.0.1.0 * * @return array */ function prepare_fields() { $member = $this->data['member']; $userlist = $this->data['users']; $log = $this->data['log']; $data_action = MS_Controller_Billing::AJAX_ACTION_TRANSACTION_LINK_DATA; $update_action = MS_Controller_Billing::AJAX_ACTION_TRANSACTION_UPDATE; $fields = array(); $member_id = 0; if ($member && $member->id) { $member_id = $member->id; } $fields['info'] = array('id' => array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'title' => __('Transaction ID', MS_TEXT_DOMAIN), 'value' => $log->id), 'gateway' => array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'title' => __('Payment Gateway', MS_TEXT_DOMAIN), 'value' => MS_Model_Gateway::get_name($log->gateway_id, true)), 'amount' => array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'title' => __('Transaction Amount', MS_TEXT_DOMAIN), 'value' => MS_Helper_Billing::format_price($log->amount)), 'details' => array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'title' => __('Transaction Details', MS_TEXT_DOMAIN), 'value' => $log->description), 'sep' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR, 'value' => 'vertical')); $fields['member'] = array('user_id' => array('id' => 'user_id', 'title' => __('1. Payment by user', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $member_id, 'field_options' => $userlist)); $fields['subscription'] = array('subscription_id' => array('id' => 'subscription_id', 'title' => __('2. Payment for subscription', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => 0, 'field_options' => array())); $fields['invoice'] = array('invoice_id' => array('id' => 'invoice_id', 'title' => __('3. Link payment with invoice', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => 0, 'field_options' => array(), 'after' => __('The selected Invoice will be marked as "paid"', MS_TEXT_DOMAIN))); $fields['buttons'] = array('nonce_link_data' => array('id' => 'nonce_link_data', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($data_action)), 'nonce_update' => array('id' => 'nonce_update', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($update_action)), 'log_id' => array('id' => 'log_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $log->id), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'value' => __('Cancel', MS_TEXT_DOMAIN), 'class' => 'wpmui-field-button button close'), 'submit' => array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Transaction', MS_TEXT_DOMAIN))); return apply_filters('ms_view_billing_link_prepare_fields', $fields, $this); }
public function to_html() { ob_start(); ?> <div class="ms-account-wrapper"> <?php if (MS_Model_Member::is_logged_in()) { ?> <h2> <?php _e('Invoice', MS_TEXT_DOMAIN); ?> </h2> <table> <thead> <tr> <th class="ms-col-invoice-no"><?php _e('Invoice #', MS_TEXT_DOMAIN); ?> </th> <th class="ms-col-invoice-status"><?php _e('Status', MS_TEXT_DOMAIN); ?> </th> <th class="ms-col-invoice-total"><?php printf('%s (%s)', __('Total', MS_TEXT_DOMAIN), MS_Plugin::instance()->settings->currency); ?> </th> <th class="ms-col-invoice-title"><?php _e('Membership', MS_TEXT_DOMAIN); ?> </th> <th class="ms-col-invoice-due"><?php _e('Due date', MS_TEXT_DOMAIN); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->data['invoices'] as $invoice) { $inv_membership = MS_Factory::load('MS_Model_Membership', $invoice->membership_id); $inv_classes = array('ms-invoice-' . $invoice->id, 'ms-subscription-' . $invoice->ms_relationship_id, 'ms-invoice-' . $invoice->status, 'ms-gateway-' . $invoice->gateway_id, 'ms-membership-' . $invoice->membership_id, 'ms-type-' . $inv_membership->type, 'ms-payment-' . $inv_membership->payment_type); ?> <tr class="<?php echo esc_attr(implode(' ', $inv_classes)); ?> "> <td class="ms-col-invoice-no"><?php printf('<a href="%s">%s</a>', get_permalink($invoice->id), $invoice->get_invoice_number()); ?> </td> <td class="ms-col-invoice-status"><?php echo esc_html($invoice->status_text()); ?> </td> <td class="ms-col-invoice-total"><?php echo esc_html(MS_Helper_Billing::format_price($invoice->total)); ?> </td> <td class="ms-col-invoice-title"><?php echo esc_html($inv_membership->name); ?> </td> <td class="ms-col-invoice-due"><?php echo esc_html(MS_Helper_Period::format_date($invoice->due_date, __('F j', MS_TEXT_DOMAIN))); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <?php $redirect = esc_url_raw(add_query_arg(array())); $title = __('Your account', MS_TEXT_DOMAIN); echo do_shortcode("[ms-membership-login redirect='{$redirect}' title='{$title}']"); ?> <?php } ?> </div> <?php $html = ob_get_clean(); $html = apply_filters('ms_compact_code', $html); return $html; }
public function column_total($item, $column_name) { if ($item->total) { $currency = $item->currency; $value = MS_Helper_Billing::format_price($item->total); $html = sprintf('<b>%1$s</b> <small>%2$s</small>', $value, $currency); } else { $html = __('Free', 'membership2'); } return $html; }
/** * Output column content * * @since 1.0.0 * @param object $item The item that is displayed. * @return string The HTML code to output. */ public function column_amount($item, $column_name) { $html = MS_Helper_Billing::format_price($item->amount); return $html; }
/** * Returns the HTML code for the Purchase-Membership form. * * @since 1.0.0 * @return string */ public function to_html() { $membership = $this->data['membership']; $invoice = $this->data['invoice']; $subscription = $this->data['ms_relationship']; $class = 'ms-alert-success'; $msg = __('Please check the details of the membership below and click ' . 'on the relevant button to complete the signup.', 'membership2'); if (!empty($this->data['error'])) { $class = 'ms-alert-error'; $msg = $this->data['error']; } /** * Log the users IP and current timestamp inside the invoice. * * @since 1.0.2.0 */ $invoice->checkout_ip = lib3()->net->current_ip()->ip; $invoice->checkout_date = date('Y-m-d H:i:s'); $invoice->save(); $cancel_warning = false; if (!MS_Model_Member::is_admin_user()) { if (!MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) { // Member can only sign up to one membership. $valid_status = array(MS_Model_Relationship::STATUS_TRIAL, MS_Model_Relationship::STATUS_ACTIVE, MS_Model_Relationship::STATUS_PENDING); foreach ($this->data['member']->subscriptions as $tmp_subscription) { if ($tmp_subscription->is_system()) { continue; } if (in_array($tmp_subscription->status, $valid_status)) { $cancel_warning = __('Your other Memberships will be cancelled when you complete this payment.', 'membership2'); break; } } } elseif ($subscription->move_from_id) { $move_from_ids = explode(',', $subscription->move_from_id); $names = array(); foreach ($move_from_ids as $id) { $ms = MS_Factory::load('MS_Model_Membership', $id); if ($ms->is_system()) { continue; } $names[] = $ms->name; } if (1 == count($names)) { $cancel_warning = sprintf(__('When you complete this payment your Membership "%s" will be cancelled.', 'membership2'), $names[0]); } elseif (1 < count($names)) { $cancel_warning = sprintf(__('When you complete this payment the following Memberships will be cancelled: %s.', 'membership2'), implode(', ', $names)); } } } // Check if the user goes through a trial period before first payment. $is_trial = $invoice->uses_trial; $skip_form = !MS_Model_Member::is_admin_user() && !$cancel_warning && $membership->is_free(); /** * Filter the flag to allow Add-ons like "Invitation codes" to override * the state and force the form to display. * * @var bool */ $skip_form = apply_filters('ms_view_frontend_payment_skip_form', $skip_form, $invoice, $this); if ($skip_form) { // No confirmation required. Simply register for this membership! $args = array(); $args['ms_relationship_id'] = $subscription->id; $args['gateway'] = MS_Gateway_Free::ID; $args['step'] = MS_Controller_Frontend::STEP_PROCESS_PURCHASE; $args['_wpnonce'] = wp_create_nonce($args['gateway'] . '_' . $args['ms_relationship_id']); $url = esc_url_raw(add_query_arg($args)); /* * Very likely the html output has already began. * So we redirect by using javascript. */ ?> <script>window.location.href = '<?php echo $url; ?> ';</script> <?php exit; } $show_tax = MS_Model_Addon::is_enabled(MS_Addon_Taxamo::ID); /** * Trigger an action before the payment form is displayed. This hook * can be used by Add-ons or plugins to initialize payment settings or * add custom code. */ do_action('ms_view_frontend_payment_form_start', $invoice, $this); $classes = array('ms-membership-form-wrapper', 'ms-subscription-' . $subscription->id, 'ms-invoice-' . $invoice->id); ob_start(); ?> <div class="<?php echo esc_attr(implode(' ', $classes)); ?> "> <legend><?php _e('Join Membership', 'membership2'); ?> </legend> <p class="ms-alert-box <?php echo esc_attr($class); ?> "> <?php echo $msg; ?> </p> <table class="ms-purchase-table"> <tr> <td class="ms-title-column"> <?php _e('Name', 'membership2'); ?> </td> <td class="ms-details-column"> <?php echo esc_html($membership->name); ?> </td> </tr> <?php if ($membership->description) { ?> <tr> <td class="ms-title-column"> <?php _e('Description', 'membership2'); ?> </td> <td class="ms-desc-column"> <span class="ms-membership-description"><?php echo $membership->get_description(); ?> </span> </td> </tr> <?php } ?> <?php if (!$membership->is_free()) { ?> <?php if ($invoice->discount || $invoice->pro_rate || $invoice->tax_rate) { ?> <tr> <td class="ms-title-column"> <?php _e('Price', 'membership2'); ?> </td> <td class="ms-details-column"> <?php if ($membership->price > 0) { printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($membership->price)); } else { _e('Free', 'membership2'); } ?> </td> </tr> <?php } ?> <?php if ($invoice->discount) { ?> <tr> <td class="ms-title-column"> <?php _e('Coupon Discount', 'membership2'); ?> </td> <td class="ms-price-column"> <?php printf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->discount)); ?> </td> </tr> <?php } ?> <?php if ($invoice->pro_rate) { ?> <tr> <td class="ms-title-column"> <?php _e('Pro-Rate Discount', 'membership2'); ?> </td> <td class="ms-price-column"> <?php printf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->pro_rate)); ?> </td> </tr> <?php } ?> <?php if ($show_tax) { ?> <tr> <td class="ms-title-column"> <?php printf(__('Taxes %s', 'membership2'), '<a href="#" class="ms-tax-editor"><small>(' . $invoice->tax_name . ')</small></a>'); ?> </td> <td class="ms-price-column"> <?php printf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->tax)); ?> </td> </tr> <?php } ?> <tr> <td class="ms-title-column"> <?php _e('Total', 'membership2'); ?> </td> <td class="ms-price-column ms-total"> <?php if ($invoice->total > 0) { printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($invoice->total)); } else { _e('Free', 'membership2'); } ?> </td> </tr> <?php if ($is_trial) { ?> <tr> <td class="ms-title-column"> <?php _e('Payment due', 'membership2'); ?> </td> <td class="ms-desc-column"><?php echo MS_Helper_Period::format_date($invoice->due_date); ?> </td> </tr> <tr> <td class="ms-title-column"> <?php _e('Trial price', 'membership2'); ?> </td> <td class="ms-desc-column"> <?php if ($invoice->trial_price > 0) { printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($invoice->trial_price)); } else { _e('Free', 'membership2'); } ?> </td> </tr> <?php } ?> <?php do_action('ms_view_frontend_payment_after_total_row', $subscription, $invoice, $this); ?> <tr> <td class="ms-desc-column" colspan="2"> <span class="ms-membership-description"><?php echo $subscription->get_payment_description($invoice); ?> </span> </td> </tr> <?php } ?> <?php if ($cancel_warning) { ?> <tr> <td class="ms-desc-warning" colspan="2"> <span class="ms-cancel-other-memberships"><?php echo $cancel_warning; ?> </span> </td> </tr> <?php } if (MS_Model_Member::is_admin_user()) { ?> <tr> <td class="ms-desc-adminnote" colspan="2"> <em><?php _e('As admin user you already have access to this membership', 'membership2'); ?> </em> </td> </tr> <?php } else { do_action('ms_view_frontend_payment_purchase_button', $subscription, $invoice, $this); } ?> </table> </div> <?php do_action('ms_view_frontend_payment_after', $this->data, $this); do_action('ms_show_prices'); if ($show_tax) { do_action('ms_tax_editor', $invoice); } ?> <div style="clear:both;"></div> <?php $html = ob_get_clean(); $html = apply_filters('ms_compact_code', $html); $html = apply_filters('ms_view_frontend_payment_form', $html, $this); return $html; }
/** * Output the HTML content of a single membership box. * This includes the membership name, description, price and the action * button (Sign-up, Cancel, etc.) * * @since 1.0.0 * @param MS_Model_Membership $membership * @param string $action * @param string $msg * @param MS_Model_Relationship $subscription */ private function membership_box_html($membership, $action, $msg = null, $subscription = null) { $fields = $this->prepare_fields($membership->id, $action, $this->data['step'], $membership->_move_from); $settings = MS_Factory::load('MS_Model_Settings'); if (0 == $membership->price) { $price = __('Free', MS_TEXT_DOMAIN); } else { $price = sprintf('%s %s', $settings->currency, MS_Helper_Billing::format_price($membership->total_price)); } $price = apply_filters('ms_membership_price', $price, $membership); if (is_user_logged_in()) { $current = MS_Model_Pages::MS_PAGE_MEMBERSHIPS; } else { $current = MS_Model_Pages::MS_PAGE_REGISTER; } $url = MS_Model_Pages::get_page_url($current); $classes = array('ms-membership-details-wrapper', 'ms-signup', 'ms-membership-' . $membership->id, 'ms-type-' . $membership->type, 'ms-payment-' . $membership->payment_type, $membership->trial_period_enabled ? 'ms-with-trial' : 'ms-no-trial', 'ms-status-' . ($subscription ? $subscription->status : 'none'), 'ms-subscription-' . ($subscription ? $subscription->id : 'none')); ?> <form action="<?php echo esc_url($url); ?> " class="ms-membership-form" method="post"> <div id="ms-membership-wrapper-<?php echo esc_attr($membership->id); ?> " class="<?php echo esc_attr(implode(' ', $classes)); ?> "> <div class="ms-top-bar"> <h4><span class="ms-title"><?php echo esc_html($membership->name); ?> </span></h4> </div> <div class="ms-price-details"> <div class="ms-description"><?php echo '' . $membership->description; ?> </div> <div class="ms-price price"><?php echo esc_html($price); ?> </div> <?php if ($msg) { ?> <div class="ms-bottom-msg"><?php echo '' . $msg; ?> </div> <?php } ?> </div> <div class="ms-bottom-bar"> <?php $class = apply_filters('ms_view_shortcode_membershipsignup_form_button_class', 'ms-signup-button ' . esc_attr($action)); $button = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => esc_html($this->data["{$action}_text"]), 'class' => $class); if (MS_Helper_Membership::MEMBERSHIP_ACTION_CANCEL === $action) { /** * PayPal Standard Gateway uses a special Cancel button. * * @see MS_Controller_Gateway */ $button = apply_filters('ms_view_shortcode_membershipsignup_cancel_button', $button, $subscription, $this); } elseif (MS_Helper_Membership::MEMBERSHIP_ACTION_PAY === $action) { // Paid membership: Display a Cancel button $cancel_action = MS_Helper_Membership::MEMBERSHIP_ACTION_CANCEL; $url = $this->get_action_url($membership->id, $cancel_action, ''); $link = array('url' => $url, 'class' => 'ms-cancel-button button', 'value' => esc_html($this->data["{$cancel_action}_text"])); MS_Helper_Html::html_link($link); } wp_nonce_field($fields['action']['value']); foreach ($fields as $field) { MS_Helper_Html::html_element($field); } MS_Helper_Html::html_element($button); ?> </div> </div> </form> <?php do_action('ms_show_prices'); }
public function to_html() { global $post; /** * Provide a customized account page. * * @since 1.0.0 */ $html = apply_filters('ms_shortcode_custom_account', '', $this->data); if (!empty($html)) { return $html; } else { $html = ''; } $member = MS_Model_Member::get_current_member(); $fields = $this->prepare_fields(); // Extract shortcode options. extract($this->data); ob_start(); ?> <div class="ms-account-wrapper"> <?php if (MS_Model_Member::is_logged_in()) { ?> <?php // ================================================= MEMBERSHIPS if ($show_membership) { ?> <div id="account-membership"> <h2> <?php echo $membership_title; if ($show_membership_change) { $signup_url = MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER); printf('<a href="%s" class="ms-edit-profile">%s</a>', $signup_url, $membership_change_label); } ?> </h2> <?php /** * Add custom content right before the memberships list. * * @since 1.0.0 */ do_action('ms_view_account_memberships_top', $member, $this); if (MS_Model_Member::is_admin_user()) { _e('You are an admin user and have access to all memberships', 'membership2'); } else { if (!empty($this->data['subscription'])) { ?> <table> <tr> <th class="ms-col-membership"><?php _e('Membership name', 'membership2'); ?> </th> <th class="ms-col-status"><?php _e('Status', 'membership2'); ?> </th> <th class="ms-col-expire-date"><?php _e('Expire date', 'membership2'); ?> </th> </tr> <?php $empty = true; // These subscriptions have no expire date $no_expire_list = array(MS_Model_Relationship::STATUS_PENDING, MS_Model_Relationship::STATUS_WAITING, MS_Model_Relationship::STATUS_DEACTIVATED); // These subscriptions display the trial-expire date $trial_expire_list = array(MS_Model_Relationship::STATUS_TRIAL, MS_Model_Relationship::STATUS_TRIAL_EXPIRED); foreach ($this->data['subscription'] as $subscription) { $empty = false; $membership = $subscription->get_membership(); $subs_classes = array('ms-subscription-' . $subscription->id, 'ms-status-' . $subscription->status, 'ms-type-' . $membership->type, 'ms-payment-' . $membership->payment_type, 'ms-gateway-' . $subscription->gateway_id, 'ms-membership-' . $subscription->membership_id, $subscription->has_trial() ? 'ms-with-trial' : 'ms-no-trial'); ?> <tr class="<?php echo esc_attr(implode(' ', $subs_classes)); ?> "> <td class="ms-col-membership"><?php echo esc_html($membership->name); ?> </td> <td class="ms-col-status"> <?php if (MS_Model_Relationship::STATUS_PENDING == $subscription->status) { // Display a "Purchase" link when status is Pending $code = sprintf('[%s id="%s" label="%s"]', MS_Helper_Shortcode::SCODE_MS_BUY, $membership->id, __('Pending', 'membership2')); echo do_shortcode($code); } else { echo esc_html($subscription->status_text()); } ?> </td> <td class="ms-col-expire-date"><?php if (in_array($subscription->status, $no_expire_list)) { echo ' '; } elseif (in_array($subscription->status, $trial_expire_list)) { echo esc_html(MS_Helper_Period::format_date($subscription->trial_expire_date)); } elseif ($subscription->expire_date) { echo esc_html(MS_Helper_Period::format_date($subscription->expire_date)); } else { _e('Never', 'membership2'); } ?> </td> </tr> <?php } if ($empty) { $cols = 3; if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL)) { $cols += 1; } printf('<tr><td colspan="%1$s">%2$s</td></tr>', $cols, __('(No Membership)', 'membership2')); } ?> </table> <?php } else { _e('No memberships', 'membership2'); } } /** * Add custom content right after the memberships list. * * @since 1.0.0 */ do_action('ms_view_account_memberships_bottom', $member, $this); ?> </div> <?php } // END: if ( $show_membership ) // ============================================================= ?> <?php // ===================================================== PROFILE if ($show_profile) { ?> <div id="account-profile"> <h2> <?php echo $profile_title; if ($show_profile_change) { $edit_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_EDIT_PROFILE))); printf('<a href="%s" class="ms-edit-profile">%s</a>', $edit_url, $profile_change_label); } ?> </h2> <?php /** * Add custom content right before the profile overview. * * @since 1.0.0 */ do_action('ms_view_account_profile_top', $member, $this); ?> <table> <?php foreach ($fields['personal_info'] as $field => $title) { ?> <tr> <th class="ms-label-title"><?php echo esc_html($title); ?> : </th> <td class="ms-label-field"><?php echo esc_html($this->data['member']->{$field}); ?> </td> </tr> <?php } ?> </table> <?php do_action('ms_view_shortcode_account_card_info', $this->data); /** * Add custom content right after the profile overview. * * @since 1.0.0 */ do_action('ms_view_account_profile_bottom', $member, $this); ?> </div> <?php } // END: if ( $show_profile ) // ============================================================= ?> <?php // ==================================================== INVOICES if ($show_invoices) { ?> <div id="account-invoices"> <h2> <?php echo $invoices_title; if ($show_all_invoices) { $detail_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_VIEW_INVOICES))); printf('<a href="%s" class="ms-all-invoices">%s</a>', $detail_url, $invoices_details_label); } ?> </h2> <?php /** * Add custom content right before the invoice overview list. * * @since 1.0.0 */ do_action('ms_view_account_invoices_top', $member, $this); ?> <table> <thead> <tr> <th class="ms-col-invoice-no"><?php _e('Invoice #', 'membership2'); ?> </th> <th class="ms-col-invoice-status"><?php _e('Status', 'membership2'); ?> </th> <th class="ms-col-invoice-total"><?php printf('%s (%s)', __('Total', 'membership2'), MS_Plugin::instance()->settings->currency); ?> </th> <th class="ms-col-invoice-title"><?php _e('Membership', 'membership2'); ?> </th> <th class="ms-col-invoice-due"><?php _e('Due date', 'membership2'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->data['invoices'] as $invoice) { $inv_membership = MS_Factory::load('MS_Model_Membership', $invoice->membership_id); $inv_classes = array('ms-invoice-' . $invoice->id, 'ms-subscription-' . $invoice->ms_relationship_id, 'ms-invoice-' . $invoice->status, 'ms-gateway-' . $invoice->gateway_id, 'ms-membership-' . $invoice->membership_id, 'ms-type-' . $inv_membership->type, 'ms-payment-' . $inv_membership->payment_type); ?> <tr class="<?php echo esc_attr(implode(' ', $inv_classes)); ?> "> <td class="ms-col-invoice-no"><?php printf('<a href="%s">%s</a>', get_permalink($invoice->id), $invoice->get_invoice_number()); ?> </td> <td class="ms-col-invoice-status"><?php echo esc_html($invoice->status_text()); ?> </td> <td class="ms-col-invoice-total"><?php echo esc_html(MS_Helper_Billing::format_price($invoice->total)); ?> </td> <td class="ms-col-invoice-title"><?php echo esc_html($inv_membership->name); ?> </td> <td class="ms-col-invoice-due"><?php echo esc_html(MS_Helper_Period::format_date($invoice->due_date, __('F j', 'membership2'))); ?> </td> </tr> <?php } ?> </tbody> </table> <?php /** * Add custom content right after the invoices overview list. * * @since 1.0.0 */ do_action('ms_view_account_invoices_bottom', $member, $this); ?> </div> <?php } // END: if ( $show_invoices ) // ============================================================= ?> <?php // ==================================================== ACTIVITY if ($show_activity) { ?> <div id="account-activity"> <h2> <?php echo $activity_title; if ($show_all_activities) { $detail_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_VIEW_ACTIVITIES))); printf('<a href="%s" class="ms-all-activities">%s</a>', $detail_url, $activity_details_label); } ?> </h2> <?php /** * Add custom content right before the activities overview list. * * @since 1.0.0 */ do_action('ms_view_account_activity_top', $member, $this); ?> <table> <thead> <tr> <th class="ms-col-activity-date"><?php _e('Date', 'membership2'); ?> </th> <th class="ms-col-activity-title"><?php _e('Activity', 'membership2'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->data['events'] as $event) { $ev_classes = array('ms-activity-topic-' . $event->topic, 'ms-activity-type-' . $event->type, 'ms-membership-' . $event->membership_id); ?> <tr class="<?php echo esc_attr(implode(' ', $ev_classes)); ?> "> <td class="ms-col-activity-date"><?php echo esc_html(MS_Helper_Period::format_date($event->post_modified)); ?> </td> <td class="ms-col-activity-title"><?php echo esc_html($event->description); ?> </td> </tr> <?php } ?> </tbody> </table> <?php /** * Add custom content right after the activities overview list. * * @since 1.0.0 */ do_action('ms_view_account_activity_bottom', $member, $this); ?> </div> <?php } // END: if ( $show_activity ) // ============================================================= ?> <?php } else { $has_login_form = MS_Helper_Shortcode::has_shortcode(MS_Helper_Shortcode::SCODE_LOGIN, $post->post_content); if (!$has_login_form) { $redirect = esc_url_raw(add_query_arg(array())); $title = __('Your account', 'membership2'); $scode = sprintf('[%1$s redirect="%2$s" title="%3$s"]', MS_Helper_Shortcode::SCODE_LOGIN, esc_url($redirect), esc_attr($title)); echo do_shortcode($scode); } } ?> </div> <?php $html = ob_get_clean(); $html = apply_filters('ms_compact_code', $html); return apply_filters('ms_shortcode_account', $html, $this->data); }
/** * Returns the contens of the dialog * * @since 1.0.0 * * @return object */ public function get_contents($data) { $member = $data['model']; $currency = MS_Plugin::instance()->settings->currency; $show_trial = MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL); $all_subscriptions = MS_Model_Relationship::get_subscriptions(array('user_id' => $member->id, 'status' => 'all', 'meta_key' => 'expire_date', 'orderby' => 'meta_value', 'order' => 'DESC')); // Prepare the form fields. $inp_dialog = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'dialog', 'value' => 'View_Member_Dialog'); $inp_id = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'member_id', 'value' => $member->id); $inp_nonce = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => '_wpnonce', 'value' => wp_create_nonce(self::ACTION_SAVE)); $inp_action = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'dialog_action', 'value' => self::ACTION_SAVE); $inp_save = array('type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save', 'membership2'), 'class' => 'ms-submit-form', 'data' => array('form' => 'ms-edit-member')); $inp_cancel = array('type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'value' => __('Close', 'membership2'), 'class' => 'close'); ob_start(); ?> <div> <form class="ms-form wpmui-ajax-update ms-edit-member" data-wpmui-ajax="<?php echo esc_attr('save'); ?> "> <div class="ms-form wpmui-form wpmui-grid-8"> <table class="widefat"> <thead> <tr> <th class="column-membership"> <?php _e('Membership', 'membership2'); ?> </th> <th class="column-status"> <?php _e('Status', 'membership2'); ?> </th> <th class="column-start"> <?php _e('Subscribed on', 'membership2'); ?> </th> <th class="column-expire"> <?php _e('Expires on', 'membership2'); ?> </th> <?php if ($show_trial) { ?> <th class="column-trialexpire"> <?php _e('Trial until', 'membership2'); ?> </th> <?php } ?> <th class="column-payments"> <?php _e('Payments', 'membership2'); ?> </th> </tr> </thead> <tbody> <?php foreach ($all_subscriptions as $subscription) { $membership = $subscription->get_membership(); $payments = $subscription->get_payments(); $num_payments = count($payments); $amount_payments = 0; foreach ($payments as $payment) { $amount_payments += $payment['amount']; } $subscription_info = array('subscription_id' => $subscription->id); $update_info = array('subscription_id' => $subscription->id, 'statuscheck' => 'yes'); ?> <tr> <td class="column-membership"> <?php $membership->name_tag(); ?> </td> <td class="column-status"> <?php printf('<a href="#" data-ms-dialog="View_Member_Subscription" data-ms-data="%2$s">%1$s</a> <a href="#" data-ms-dialog="View_Member_Subscription" data-ms-data="%3$s" title="%5$s">%4$s</a>', $subscription->status, esc_attr(json_encode($subscription_info)), esc_attr(json_encode($update_info)), '<i class="dashicons dashicons-update"></i>', __('Check and update subscription status', 'membership2')); ?> </td> <td class="column-start"> <?php echo $subscription->start_date; ?> </td> <td class="column-expire"> <?php echo $subscription->expire_date; ?> </td> <?php if ($show_trial) { ?> <td class="column-trialexpire"> <?php if ($subscription->start_date == $subscription->trial_expire_date) { echo '-'; } else { echo $subscription->trial_expire_date; } ?> </td> <?php } ?> <td class="column-payments"> <?php $total = sprintf('<b>%1$s</b> (%3$s %2$s)', $num_payments, MS_Helper_Billing::format_price($amount_payments), $currency); printf('<a href="#" data-ms-dialog="View_Member_Payment" data-ms-data="%1$s">%2$s</a>', esc_attr(json_encode($subscription_info)), $total); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php MS_Helper_Html::html_element($inp_id); MS_Helper_Html::html_element($inp_dialog); MS_Helper_Html::html_element($inp_nonce); MS_Helper_Html::html_element($inp_action); ?> </form> <div class="buttons"> <?php MS_Helper_Html::html_element($inp_cancel); // MS_Helper_Html::html_element( $inp_save ); ?> </div> </div> <?php $html = ob_get_clean(); return apply_filters('ms_view_member_dialog_to_html', $html); }
/** * Ajax action handler used by the transaction logs list to change a * transaction log entry. * * Returns a list of requested items * * @since 1.0.1.0 */ public function ajax_link_data_transaction() { $resp = array(); $fields = array('get', 'for'); if (self::validate_required($fields) && $this->verify_nonce()) { $type = $_POST['get']; $id = intval($_POST['for']); $settings = MS_Plugin::instance()->settings; if ('subscriptions' == $type) { $member = MS_Factory::load('MS_Model_Member', $id); $resp[0] = __('Select a subscription', 'membership2'); $active = array(); $inactive = array(); foreach ($member->subscriptions as $subscription) { if ($subscription->is_system()) { continue; } $membership = $subscription->get_membership(); if ($membership->is_free()) { $price = __('Free', 'membership2'); } else { $price = sprintf('%s %s', $settings->currency, MS_Helper_Billing::format_price($membership->price)); } $line = sprintf(__('Membership: %s, Base price: %s', 'membership2'), $membership->name, $price); if ($subscription->is_expired()) { $inactive[$subscription->id] = $line; } else { $active[$subscription->id] = $line; } } if (!count($active) && !count($inactive)) { $resp[0] = __('No subscriptions found', 'membership2'); } else { if (count($active)) { $resp[__('Active Subscriptions', 'membership2')] = $active; } if (count($inactive)) { $resp[__('Expired Subscriptions', 'membership2')] = $inactive; } } } elseif ('invoices' == $type) { $subscription = MS_Factory::load('MS_Model_Relationship', $id); $invoices = $subscription->get_invoices(); $resp[0] = __('Select an invoice', 'membership2'); $unpaid = array(); $paid = array(); foreach ($invoices as $invoice) { $line = sprintf(__('Invoice: %s from %s (%s)', 'membership2'), $invoice->get_invoice_number(), $invoice->due_date, $invoice->currency . ' ' . MS_Helper_Billing::format_price($invoice->total)); if ($invoice->is_paid()) { $paid[$invoice->id] = $line; } else { $unpaid[$invoice->id] = $line; } } if (!count($unpaid) && !count($paid)) { $resp[0] = __('No invoices found', 'membership2'); } else { if (count($unpaid)) { $resp[__('Unpaid Invoices', 'membership2')] = $unpaid; } if (count($paid)) { $resp[__('Paid Invoices', 'membership2')] = $paid; } } } } echo json_encode($resp); exit; }
/** * Get textual payment information description. * * @since 1.0.0 * @api * * @param MS_Model_Invoice $invoice Optional. Specific invoice that defines * the price. Default is the price defined in the membership. * @param bool $short Optional. Default is false. If set to true then a * hort sumary is returned * @return string The description. */ public function get_payment_description($invoice = null, $short = false) { $currency = MS_Plugin::instance()->settings->currency; $membership = $this->get_membership(); $desc = ''; if (null !== $invoice) { $total_price = $invoice->total; // Includes Tax $trial_price = $invoice->trial_price; // Includes Tax } else { $total_price = $membership->total_price; // Excludes Tax $trial_price = $membership->trial_price; // Excludes Tax } $total_price = MS_Helper_Billing::format_price($total_price); $trial_price = MS_Helper_Billing::format_price($trial_price); $payment_type = $this->payment_type; if (!$payment_type) { $payment_type = $membership->payment_type; } switch ($payment_type) { case MS_Model_Membership::PAYMENT_TYPE_PERMANENT: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (for ever)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay nothing for permanent access.', MS_TEXT_DOMAIN); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (for ever)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> for permanent access.', MS_TEXT_DOMAIN); } } $desc = sprintf($lbl, $currency, $total_price); break; case MS_Model_Membership::PAYMENT_TYPE_FINITE: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (until %4$s)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay nothing for access until %3$s.', MS_TEXT_DOMAIN); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (until %4$s)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> for access until %3$s.', MS_TEXT_DOMAIN); } } $desc .= sprintf($lbl, $currency, $total_price, MS_Helper_Period::format_date($this->calc_expire_date($this->expire_date)), $this->calc_expire_date($this->expire_date)); break; case MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (%5$s - %6$s)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay nothing for access from %3$s until %4$s.', MS_TEXT_DOMAIN); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (%5$s - %6$s)', MS_TEXT_DOMAIN); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> to access from %3$s until %4$s.', MS_TEXT_DOMAIN); } } $desc .= sprintf($lbl, $currency, $total_price, MS_Helper_Period::format_date($membership->period_date_start), MS_Helper_Period::format_date($membership->period_date_end), $membership->period_date_start, $membership->period_date_end); break; // RECURRING is PRO ONLY } if ($this->is_trial_eligible() && 0 != $total_price) { if (0 == absint($trial_price)) { if ($short) { // RECURRING is PRO ONLY $lbl = __('on %4$s', MS_TEXT_DOMAIN); } else { $trial_price = __('nothing', MS_TEXT_DOMAIN); $lbl = __('The trial period of %1$s is for free.', MS_TEXT_DOMAIN); } } else { $trial_price = MS_Helper_Billing::format_price($trial_price); $lbl = __('For the trial period of %1$s you only pay <span class="price">%2$s %3$s</span>.', MS_TEXT_DOMAIN); } $desc .= sprintf(' <br />' . $lbl, MS_Helper_Period::get_period_desc($membership->trial_period, true), $currency, $trial_price, MS_Helper_Period::format_date($invoice->due_date, __('M j', MS_TEXT_DOMAIN))); } return apply_filters('ms_model_relationship_get_payment_description', $desc, $membership, $payment_type); }
/** * Get textual payment information description. * * @since 1.0.0 * @api * * @param MS_Model_Invoice $invoice Optional. Specific invoice that defines * the price. Default is the price defined in the membership. * @param bool $short Optional. Default is false. If set to true then a * hort sumary is returned * @return string The description. */ public function get_payment_description($invoice = null, $short = false) { $currency = MS_Plugin::instance()->settings->currency; $membership = $this->get_membership(); $desc = ''; if (null !== $invoice) { $total_price = $invoice->total; // Includes Tax $trial_price = $invoice->trial_price; // Includes Tax } else { $total_price = $membership->total_price; // Excludes Tax $trial_price = $membership->trial_price; // Excludes Tax } $total_price = MS_Helper_Billing::format_price($total_price); $trial_price = MS_Helper_Billing::format_price($trial_price); $payment_type = $this->payment_type; if (!$payment_type) { $payment_type = $membership->payment_type; } switch ($payment_type) { case MS_Model_Membership::PAYMENT_TYPE_PERMANENT: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (for ever)', 'membership2'); } else { $lbl = __('You will pay nothing for permanent access.', 'membership2'); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (for ever)', 'membership2'); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> for permanent access.', 'membership2'); } } $desc = sprintf($lbl, $currency, $total_price); break; case MS_Model_Membership::PAYMENT_TYPE_FINITE: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (until %4$s)', 'membership2'); } else { $lbl = __('You will pay nothing for access until %3$s.', 'membership2'); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (until %4$s)', 'membership2'); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> for access until %3$s.', 'membership2'); } } $desc .= sprintf($lbl, $currency, $total_price, MS_Helper_Period::format_date($this->calc_expire_date($this->expire_date)), $this->calc_expire_date($this->expire_date)); break; case MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE: if (0 == $total_price) { if ($short) { $lbl = __('Nothing (%5$s - %6$s)', 'membership2'); } else { $lbl = __('You will pay nothing for access from %3$s until %4$s.', 'membership2'); } } else { if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (%5$s - %6$s)', 'membership2'); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> to access from %3$s until %4$s.', 'membership2'); } } $desc .= sprintf($lbl, $currency, $total_price, MS_Helper_Period::format_date($membership->period_date_start), MS_Helper_Period::format_date($membership->period_date_end), $membership->period_date_start, $membership->period_date_end); break; case MS_Model_Membership::PAYMENT_TYPE_RECURRING: if (1 == $membership->pay_cycle_repetitions) { // Exactly 1 payment. Actually same as the "finite" type. if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (once)', 'membership2'); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> once.', 'membership2'); } } else { if ($membership->pay_cycle_repetitions > 1) { // Fixed number of payments (more than 1) if ($short) { $lbl = __('%4$s times <span class="price">%1$s %2$s</span> (each %3$s)', 'membership2'); } else { $lbl = __('You will make %4$s payments of <span class="price">%1$s %2$s</span>, one each %3$s.', 'membership2'); } } else { // Indefinite number of payments if ($short) { $lbl = __('<span class="price">%1$s %2$s</span> (each %3$s)', 'membership2'); } else { $lbl = __('You will pay <span class="price">%1$s %2$s</span> each %3$s.', 'membership2'); } } } $desc .= sprintf($lbl, $currency, $total_price, MS_Helper_Period::get_period_desc($membership->pay_cycle_period), $membership->pay_cycle_repetitions); break; } if ($this->is_trial_eligible() && 0 != $total_price) { if (0 == absint($trial_price)) { if ($short) { if (MS_Model_Membership::PAYMENT_TYPE_RECURRING == $payment_type) { $lbl = __('after %4$s', 'membership2'); } else { $lbl = __('on %4$s', 'membership2'); } } else { $trial_price = __('nothing', 'membership2'); $lbl = __('The trial period of %1$s is for free.', 'membership2'); } } else { $trial_price = MS_Helper_Billing::format_price($trial_price); $lbl = __('For the trial period of %1$s you only pay <span class="price">%2$s %3$s</span>.', 'membership2'); } $desc .= sprintf(' <br />' . $lbl, MS_Helper_Period::get_period_desc($membership->trial_period, true), $currency, $trial_price, MS_Helper_Period::format_date($invoice->due_date, __('M j', 'membership2'))); } return apply_filters('ms_model_relationship_get_payment_description', $desc, $membership, $payment_type, $this, $invoice, $short); }
/** * Prepare the PayPal IPN fields * * Details here: * https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/ * * @since 1.0.0 * @return array */ private function prepare_fields() { $subscription = $this->data['ms_relationship']; $membership = $subscription->get_membership(); if (0 === $membership->price) { return; } $gateway = $this->data['gateway']; $invoice = $subscription->get_current_invoice(); $regular_invoice = null; $settings = MS_Factory::load('MS_Model_Settings'); $nonce = wp_create_nonce($gateway->id . '_' . $subscription->id); $cancel_url = MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER); $return_url = esc_url_raw(add_query_arg(array('ms_relationship_id' => $subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE, false))); $fields = array('_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $nonce), 'charset' => array('id' => 'charset', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'utf-8'), 'business' => array('id' => 'business', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->merchant_id), 'cmd' => array('id' => 'cmd', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => '_xclick-subscriptions'), 'bn' => array('id' => 'bn', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'incsub_SP'), 'item_name' => array('id' => 'item_name', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->name), 'item_number' => array('id' => 'item_number', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->id), 'currency_code' => array('id' => 'currency_code', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Plugin::instance()->settings->currency), 'return' => array('id' => 'return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $return_url), 'cancel_return' => array('id' => 'cancel_return', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $cancel_url), 'notify_url' => array('id' => 'notify_url', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->get_return_url()), 'country' => array('id' => 'country', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $gateway->paypal_site), 'no_note' => array('id' => 'no_note', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 1), 'no_shipping' => array('id' => 'no_shipping', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 1), 'invoice' => array('id' => 'invoice', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id)); $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE, 'value' => 'https://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif', 'alt' => __('PayPal - The safer, easier way to pay online', 'membership2')); // custom pay button defined in gateway settings $custom_label = $gateway->pay_button_url; if (!empty($custom_label)) { if (false !== strpos($custom_label, '://')) { $fields['submit']['value'] = $custom_label; } else { $fields['submit'] = array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => $custom_label); } } // Trial period if ($subscription->is_trial_eligible()) { $fields['a1'] = array('id' => 'a1', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->trial_price); $trial_type = MS_Helper_Period::get_period_value($membership->trial_period, 'period_type'); $trial_type = strtoupper($trial_type[0]); $trial_value = MS_Helper_Period::get_period_value($membership->trial_period, 'period_unit'); $trial_value = MS_Helper_Period::validate_range($trial_value, $trial_type); $fields['p1'] = array('id' => 'p1', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $trial_value); $fields['t1'] = array('id' => 't1', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $trial_type); } // Membership price $membership_price = $invoice->total; $membership_price = MS_Helper_Billing::format_price($membership_price); $fields['a3'] = array('id' => 'a3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership_price); $fields['amount'] = array('id' => 'amount', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership_price); $recurring = 0; switch ($membership->payment_type) { // == RECURRING PAYMENTS case MS_Model_Membership::PAYMENT_TYPE_RECURRING: $period_type = MS_Helper_Period::get_period_value($membership->pay_cycle_period, 'period_type'); $period_type = strtoupper($period_type[0]); $period_value = MS_Helper_Period::get_period_value($membership->pay_cycle_period, 'period_unit'); $period_value = MS_Helper_Period::validate_range($period_value, $period_type); $fields['p3'] = array('id' => 'p3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_value); $fields['t3'] = array('id' => 't3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_type); // This makes the payments recurring! $recurring = 1; break; // == FINITE END DATE // == FINITE END DATE case MS_Model_Membership::PAYMENT_TYPE_FINITE: $period_type = MS_Helper_Period::get_period_value($membership->period, 'period_type'); $period_type = strtoupper($period_type[0]); $period_value = MS_Helper_Period::get_period_value($membership->period, 'period_unit'); $period_value = MS_Helper_Period::validate_range($period_value, $period_type); $fields['p3'] = array('id' => 'p3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_value); $fields['t3'] = array('id' => 't3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_type); break; // == DATE RANGE // == DATE RANGE case MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE: $period_value = MS_Helper_Period::subtract_dates($membership->period_date_end, $membership->period_date_start); $period_value = MS_Helper_Period::validate_range($period_value, 'D'); $fields['p3'] = array('id' => 'p3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_value); $fields['t3'] = array('id' => 't3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'D'); break; // == PERMANENT // == PERMANENT case MS_Model_Membership::PAYMENT_TYPE_PERMANENT: /* * Permanent membership: Set the subscription range to 5 years! * PayPal requires us to provide the subscription range and the * maximum possible value is 5 years. */ $period_value = MS_Helper_Period::validate_range(5, 'Y'); $fields['p3'] = array('id' => 'p3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $period_value); $fields['t3'] = array('id' => 't3', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => 'Y'); break; } if (1 == $recurring) { if (1 == $membership->pay_cycle_repetitions) { $recurring = 0; } elseif ($membership->pay_cycle_repetitions > 1) { /** * Recurring times. * The number of times that a recurring payment is made. */ $fields['srt'] = array('id' => 'srt', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $membership->pay_cycle_repetitions); } } /** * Recurring field. * 0 - one time payment * 1 - recurring payments */ $fields['src'] = array('id' => 'src', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $recurring); /** * Modify current subscription field. * value != 0 does not allow trial period. * 0 - allows subscribers only to sign up for new subscriptions * 1 - allows subscribers to sign up for new subscriptions and modify their current subscriptions * 2 - allows subscribers to modify only their current subscriptions */ $modify = !empty($move_from_id); $fields['modify'] = array('id' => 'modify', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $modify ? 2 : 0); if ($gateway->is_live_mode()) { $this->data['action_url'] = 'https://www.paypal.com/cgi-bin/webscr'; } else { $this->data['action_url'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } return apply_filters('ms_gateway_paypalstandard_view_prepare_fields', $fields); }
/** * Return the column value for the custom billing columns. * * @since 1.0.0 * @param MS_Model $item List item that is parsed. * @param string $column_name Column that is parsed. * @return string HTML code to display in the cell. */ public function billing_column_value($default, $item, $column_name) { if (property_exists($item, $column_name)) { $value = $item->{$column_name}; } else { $value = ''; } $currency = $item->currency; $html = ''; if (empty($value)) { if ('discount' == $column_name && empty($value)) { $html = '-'; } } else { $value = MS_Helper_Billing::format_price($value); $html = sprintf('%1$s <small>%2$s</small>', $value, $currency); } return $html; }
/** * Processes online payments. * * Send to Authorize.net to process the payment immediatly. * * @since 1.0.0 * @param MS_Model_Invoice $invoice The invoice to pay. * @param MS_Model_Member The member paying the invoice. * @return bool True on success, otherwise throws an exception. */ protected function online_purchase(&$invoice, $member, $log_action) { $success = false; $notes = ''; $amount = 0; $subscription = $invoice->get_subscription(); do_action('ms_gateway_authorize_online_purchase_before', $invoice, $member, $this); $need_code = lib3()->is_true($this->secure_cc); $have_code = !empty($_POST['card_code']); if (0 == $invoice->total) { $notes = __('Total is zero. Payment approved. Not sent to gateway.', 'membership2'); $invoice->pay_it(MS_Gateway_Free::ID, ''); $invoice->add_notes($notes); $invoice->save(); $invoice->changed(); } elseif (!$need_code || $have_code) { $amount = MS_Helper_Billing::format_price($invoice->total); $cim_transaction = $this->get_cim_transaction($member); $cim_transaction->amount = $amount; $cim_transaction->order->invoiceNumber = $invoice->id; $invoice->timestamp = time(); $invoice->save(); $_POST['API Out: Secure Payment'] = lib3()->is_true($this->secure_cc); $_POST['API Out: CustomerProfileID'] = $cim_transaction->customerProfileId; $_POST['API Out: PaymentProfileID'] = $cim_transaction->customerPaymentProfileId; $_POST['API Out: InvoiceNumber'] = $cim_transaction->order->invoiceNumber; $response = $this->get_cim()->createCustomerProfileTransaction('AuthCapture', $cim_transaction); if (!empty($response->xml) && !empty($response->xml->messages) && !empty($response->xml->messages->message)) { $msg = $response->xml->messages->message; $_POST['API Response: Short'] = $msg->code . ': ' . $msg->text; } else { $_POST['API Response: Short'] = '-'; } if (isset($response->response)) { if (is_string($response->response)) { $_POST['API Response: XML'] = $response->response; } else { $_POST['API Response: XML'] = json_encode($response->response); } } else { $_POST['API Response: XML'] = json_encode($response->response); } if ($response->isOk()) { $transaction_response = $response->getTransactionResponse(); if ($transaction_response->approved) { $external_id = $response->getTransactionResponse()->transaction_id; $invoice->pay_it($this->id, $external_id); $success = true; $notes = __('Payment successful', 'membership2'); } else { $notes = sprintf(__('Payment Failed: code %s, subcode %s, reason code %, reason %s', 'membership2'), $transaction_response->response_code, $transaction_response->response_subcode, $transaction_response->response_reason_code, $transaction_response->response_reason); } } else { $notes = __('Payment Failed: ', 'membership2') . $response->getMessageText(); } } elseif ($need_code && !$have_code) { $notes = __('Secure payment failed: No Card Code found', 'membership2'); } // Mask the credit card number before logging it to database. $card_num = ''; $card_code = ''; if (isset($_POST['card_num'])) { // Card Num 6789765435678765 // Becomes ************8765 $card_num = str_replace(' ', '', $_POST['card_num']); $_POST['card_num'] = str_pad(substr($card_num, -4), strlen($card_num), '*', STR_PAD_LEFT); } if (isset($_POST['card_code'])) { $card_code = $_POST['card_code']; $_POST['card_code'] = str_repeat('*', strlen($card_code)); } do_action('ms_gateway_transaction_log', self::ID, $log_action, $success, $subscription->id, $invoice->id, $amount, $notes, $external_id); // Restore the POST data in case it's used elsewhere. $_POST['card_num'] = $card_num; $_POST['card_code'] = $card_code; unset($_POST['API Out: CustomerProfileID']); unset($_POST['API Out: PaymentProfileID']); unset($_POST['API Out: InvoiceNumber']); unset($_POST['API Out: Secure Payment']); unset($_POST['API Response: Short']); unset($_POST['API Response: XML']); return $success; }
/** * Processes online payments. * * Send to Authorize.net to process the payment immediatly. * * @since 1.0.0 * @param MS_Model_Invoice $invoice The invoice to pay. * @param MS_Model_Member The member paying the invoice. * @return bool True on success, otherwise throws an exception. */ protected function online_purchase(&$invoice, $member, $log_action) { $success = false; $notes = ''; $amount = 0; $subscription = $invoice->get_subscription(); do_action('ms_gateway_authorize_online_purchase_before', $invoice, $member, $this); if (0 == $invoice->total) { $notes = __('Total is zero. Payment approved. Not sent to gateway.', MS_TEXT_DOMAIN); $invoice->pay_it(MS_Gateway_Free::ID, ''); $invoice->add_notes($notes); $invoice->save(); $invoice->changed(); } else { $amount = MS_Helper_Billing::format_price($invoice->total); $cim_transaction = $this->get_cim_transaction($member); $cim_transaction->amount = $amount; $cim_transaction->order->invoiceNumber = $invoice->id; $invoice->timestamp = time(); $invoice->save(); $response = $this->get_cim()->createCustomerProfileTransaction('AuthCapture', $cim_transaction); if ($response->isOk()) { $transaction_response = $response->getTransactionResponse(); if ($transaction_response->approved) { $external_id = $response->getTransactionResponse()->transaction_id; $invoice->pay_it($this->id, $external_id); $success = true; $notes = __('Payment successful', MS_TEXT_DOMAIN); } else { $notes = sprintf(__('Payment Failed: code %s, subcode %s, reason code %, reason %s', MS_TEXT_DOMAIN), $transaction_response->response_code, $transaction_response->response_subcode, $transaction_response->response_reason_code, $transaction_response->response_reason); } } else { $notes = __('Payment Failed: ', MS_TEXT_DOMAIN) . $response->getMessageText(); } } do_action('ms_gateway_transaction_log', self::ID, $log_action, $success, $subscription->id, $invoice->id, $amount, $notes); return $success; }
public function to_html() { /** * Provide a customized invoice. * * @since 1.0.0 */ $html = apply_filters('ms_shortcode_custom_invoice', '', $this->data); if (!empty($html)) { return $html; } else { $html = ''; } $invoice = $this->data['invoice']; $member = $this->data['member']; $subscription = $this->data['ms_relationship']; $membership = $this->data['membership']; $gateway = $this->data['gateway']; $is_free = false; $invoice_number = $invoice->get_invoice_number(); $inv_title = sprintf('<a href="%s">%s</a>', get_permalink($invoice->id), esc_html(__('Invoice ', MS_TEXT_DOMAIN) . $invoice_number)); if ($invoice->amount > 0) { $inv_amount = sprintf('%1$s %2$s', $invoice->currency, MS_Helper_Billing::format_price($invoice->amount)); } else { $inv_amount = __('Free', MS_TEXT_DOMAIN); $is_free = true; } if ($invoice->tax) { $inv_taxes = sprintf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->tax)); } else { $inv_taxes = ''; } if ($invoice->discount) { $inv_discount = sprintf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->discount)); } else { $inv_discount = ''; } if ($invoice->pro_rate) { $inv_pro_rate = sprintf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->pro_rate)); } else { $inv_pro_rate = ''; } $inv_total = sprintf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->total)); $inv_title = apply_filters('ms_invoice_title', $inv_title, $invoice); $inv_from = apply_filters('ms_invoice_sender', MS_Plugin::instance()->settings->invoice_sender_name, $invoice); $inv_to = apply_filters('ms_invoice_recipient', $member->username, $invoice, $member); $inv_status = apply_filters('ms_invoice_status', $invoice->status_text(), $invoice); $inv_item_name = apply_filters('ms_invoice_item_name', $membership->name, $invoice, $membership); $inv_amount = apply_filters('ms_invoice_amount', $inv_amount, $invoice); $inv_taxes = apply_filters('ms_invoice_taxes', $inv_taxes, $invoice); $inv_discount = apply_filters('ms_invoice_discount', $inv_discount, $invoice); $inv_pro_rate = apply_filters('ms_invoice_pro_rate', $inv_pro_rate, $invoice); $inv_total = apply_filters('ms_invoice_total', $inv_total, $invoice); $inv_details = apply_filters('ms_invoice_description', $invoice->description, $invoice, null); $inv_date = apply_filters('ms_invoice_date', MS_Helper_Period::format_date($invoice->invoice_date), $invoice, null); $inv_due_date = apply_filters('ms_invoice_due_date', MS_Helper_Period::format_date($invoice->due_date), $invoice, null); if ($invoice->uses_trial) { $trial_date = apply_filters('ms_invoice_trial_date', MS_Helper_Period::get_period_desc($membership->trial_period, true), $trial_invoice, $invoice); $trial_date .= sprintf(' <small>(%s %s)</small>', __('ends on', MS_TEXT_DOMAIN), MS_Helper_Period::format_date($invoice->trial_ends)); } else { $trial_date = ''; } ob_start(); ?> <div class="entry-content ms-invoice" id="invoice"> <?php /** * We hardcode the CSS styles into this file, because the shortcode * is also used in Emails, which usually do not load remote CSS * files by default... */ ?> <style> #invoice table, th, td { margin: 0; font-size: 14px; } #invoice table { padding: 0; width: 520px; border: 1px solid #DDD; background-color: #FFF; box-shadow: 0 1px 8px #F0F0F0; } #invoice th, td { border: 0; padding: 8px; } #invoice th { font-weight: bold; text-align: left; text-transform: none; font-size: 13px; } #invoice tr.alt { background-color: #F9F9F9; } #invoice tr.sep th, #invoice tr.sep td { border-top: 1px solid #DDD; padding-top: 16px; } #invoice tr.space th, #invoice tr.space td { padding-bottom: 16px; } #invoice tr.ms-inv-sep th, #invoice tr.ms-inv-sep td { line-height: 1px; height: 1px; padding: 0; border-bottom: 1px solid #DDD; background-color: #F9F9F9; } #invoice .ms-inv-total .ms-inv-price { font-weight: bold; font-size: 18px; text-align: right; } #invoice h2 { text-align: right; padding: 10px 10px 0 0; } #invoice h2 a { color: #000; } <?php do_action('ms_invoice_css'); ?> </style> <div class="ms-invoice-details ms-status-<?php echo esc_attr($invoice->status); ?> "> <table class="ms-purchase-table"> <tr class="ms-inv-title"> <td colspan="2"><h2><?php echo $inv_title; ?> </h2></td> </tr> <?php if (!empty($inv_from)) { ?> <tr class="ms-inv-from"> <th><?php _e('Sender', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-text"><?php echo $inv_from; ?> </td> </tr> <?php } ?> <tr class="ms-inv-to"> <th><?php _e('Invoice to', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-text"><?php echo $inv_to; ?> </td> </tr> <tr class="ms-inv-invoice-date"> <th><?php _e('Invoice date', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-date"><?php echo $inv_date; ?> </td> </tr> <?php if (!empty($trial_date)) { ?> <tr class="ms-inv-trial-end-date"> <th><?php _e('Trial period', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-date"><?php echo $trial_date; ?> </td> </tr> <?php } ?> <tr class="ms-inv-status space"> <th><?php _e('Status', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-text"><?php echo $inv_status; ?> </td> </tr> <tr class="ms-inv-item-name alt sep"> <th><?php _e('Name', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-text"><?php echo $inv_item_name; ?> </td> </tr> <?php if (!empty($inv_details)) { ?> <tr class="ms-inv-description alt"> <th><?php _e('Description', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-text"><?php echo $inv_details; ?> </td> </tr> <?php } ?> <tr class="ms-inv-amount alt space"> <th><?php _e('Amount', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-price"><?php echo $inv_amount; ?> </td> </tr> <?php $sep = 'sep'; ?> <?php if (!empty($inv_discount)) { ?> <tr class="ms-inv-discount <?php echo esc_attr($sep); $sep = ''; ?> "> <th><?php _e('Coupon discount', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-price"><?php echo $inv_discount; ?> </td> </tr> <?php } ?> <?php if (!empty($inv_pro_rate)) { ?> <tr class="ms-inv-pro-rate <?php echo esc_attr($sep); $sep = ''; ?> "> <th><?php _e('Pro rate discount', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-price"><?php echo $inv_pro_rate; ?> </td> </tr> <?php } ?> <?php if (!empty($inv_taxes)) { ?> <tr class="ms-inv-tax <?php echo esc_attr($sep); $sep = ''; ?> "> <th><?php printf(__('Taxes %s', MS_TEXT_DOMAIN), '<small>(' . $invoice->tax_name . ')</small>'); ?> </th> <td class="ms-inv-price"><?php echo $inv_taxes; ?> </td> </tr> <?php } ?> <?php if (!$is_free) { ?> <tr class="ms-inv-due-date <?php echo esc_attr($sep); $sep = ''; ?> "> <th><?php _e('Payment due', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-date"><?php echo $inv_due_date; ?> </td> </tr> <?php } ?> <tr class="ms-inv-total <?php echo esc_attr($sep); $sep = ''; ?> "> <th><?php _e('Total', MS_TEXT_DOMAIN); ?> </th> <td class="ms-inv-price"><?php echo $inv_total; ?> </td> </tr> <?php $show_button = lib2()->is_true($this->data['pay_button']); if ($invoice->is_paid()) { // Invoice is already paid. We don't need a payment // button... $show_button = false; } if ($show_button) { ?> <tr class="ms-inv-sep sep"><td colspan="2"></td></tr> <?php do_action('ms_view_shortcode_invoice_purchase_button', $subscription, $invoice); } ?> </table> </div> </div> <?php $html = ob_get_clean(); $html = apply_filters('ms_compact_code', $html); return apply_filters('ms_shortcode_invoice', $html, $this->data); }
public function column_price($item, $column_name) { $html = ''; if (!$item->is_system()) { if (!$item->is_free()) { $html = sprintf('<span class="ms-currency">%1$s</span> <span class="ms-price">%2$s</span> (<span class="ms-payment">%3$s</span>)', MS_Plugin::instance()->settings->currency_symbol, MS_Helper_Billing::format_price($item->price), $item->get_payment_type_desc()); $html = '<span class="ms-bold">' . $html . '</span>'; } else { $html = sprintf('<span class="ms-bold">%1$s</span> (<span class="ms-payment">%2$s</span>)', __('Free', 'membership2'), $item->get_payment_type_desc()); } $followup = MS_Factory::load('MS_Model_Membership', $item->on_end_membership_id); if ($followup->is_valid()) { $html .= '<div class="ms-followup">' . sprintf(__('Follow with: %1$s', 'membership2'), '<span class="ms-color" style="background:' . $followup->get_color() . '"> </span>' . $followup->name) . '</div>'; } } return $html; }