/**
  * Instantiate the classes
  *
  * @return void
  */
 function instantiate()
 {
     new WPUF_Upload();
     WPUF_Frontend_Form_Post::init();
     // requires for form preview
     new WPUF_Frontend_Form_Profile();
     new WPUF_Payment();
     WPUF_Subscription::init();
     if (is_admin()) {
         WPUF_Settings::init();
         new WPUF_Admin_Form();
         new WPUF_Admin_Posting();
         new WPUF_Admin_Posting_Profile();
         new WPUF_Updates();
     } else {
         new WPUF_Frontend_Dashboard();
     }
 }
 function update_subscription()
 {
     global $wpdb;
     $table = $wpdb->prefix . 'wpuf_subscription';
     $results = $wpdb->get_results("SELECT name, description, count, duration, cost FROM {$table}");
     if (!$results) {
         return;
     }
     $post_type = WPUF_Subscription::init()->get_all_post_type();
     foreach ($results as $key => $result) {
         $args = array('post_title' => $result->name, 'post_content' => $result->description, 'post_status' => 'publish', 'post_type' => 'wpuf_subscription');
         $post_ID = wp_insert_post($args);
         if ($post_ID) {
             foreach ($post_type as $key => $name) {
                 $post_type[$key] = $result->count;
             }
             $post = array('cost' => $result->cost, 'duration' => $result->duration, 'recurring_pay' => 'no', 'trial_period' => '', 'post_type_name' => $post_type);
             WPUF_Subscription::init()->update_user_subscription_meta($post_ID, $post);
         }
     }
     $sql = "DROP TABLE IF_EXISTS {$table}";
     $wpdb->query($sql);
 }
Example #3
0
    function subscription_dropdown($selected = null)
    {
        $subscriptions = WPUF_Subscription::init()->get_subscriptions();
        if (!$subscriptions) {
            printf('<option>%s</option>', '- Select -');
            return;
        }
        printf('<option>%s</option>', '- Select -');
        foreach ($subscriptions as $key => $subscription) {
            ?>
                <option value="<?php 
            echo esc_attr($subscription->ID);
            ?>
" <?php 
            selected($selected, $subscription->ID);
            ?>
 ><?php 
            echo $subscription->post_title;
            ?>
</option>
            <?php 
        }
    }
                        <td><?php 
        echo stripslashes(htmlspecialchars($row->user_id));
        ?>
</td>
                        <td><?php 
        echo stripslashes(htmlspecialchars($row->status));
        ?>
</td>
                        <td><?php 
        echo stripslashes(htmlspecialchars($row->cost));
        ?>
</td>
                        <td>
                            <?php 
        if ($row->post_id) {
            $post = WPUF_Subscription::post_by_orderid($row->post_id);
            if ($post) {
                printf('<a href="%s">%s</a>', get_permalink($post->ID), $post->post_title);
            }
        } else {
            echo $row->post_id;
        }
        ?>
                        </td>
                        <td><?php 
        echo stripslashes(htmlspecialchars($row->pack_id));
        ?>
</td>
                        <td><?php 
        echo $row->payer_first_name . ' ' . $row->payer_last_name;
        ?>
Example #5
0
 /**
  * Send payment handler to the gateway
  *
  * This function sends the payment handler mechanism to the selected
  * gateway. If 'paypal' is selected, then a particular action is being
  * called. A  listener function can be invoked for that gateway to handle
  * the request and send it to the gateway.
  *
  * Need to use `wpuf_gateway_{$gateway_name}
  */
 function send_to_gateway()
 {
     if (isset($_POST['wpuf_payment_submit']) && $_POST['action'] == 'wpuf_pay' && wp_verify_nonce($_POST['_wpnonce'], 'wpuf_payment_gateway')) {
         $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
         $pack_id = isset($_REQUEST['pack_id']) ? intval($_REQUEST['pack_id']) : 0;
         $gateway = $_POST['wpuf_payment_method'];
         $type = $_POST['type'];
         if (is_user_logged_in()) {
             $userdata = wp_get_current_user();
         } else {
             $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0;
             if ($user_id) {
                 $userdata = get_userdata($user_id);
             } else {
                 $userdata = new stdClass();
                 $userdata->ID = 0;
                 $userdata->user_email = '';
                 $userdata->first_name = '';
                 $userdata->last_name = '';
             }
         }
         switch ($type) {
             case 'post':
                 $post = get_post($post_id);
                 $amount = wpuf_get_option('cost_per_post', 'wpuf_payment');
                 $item_number = get_post_meta($post_id, '_wpuf_order_id', true);
                 $item_name = $post->post_title;
                 break;
             case 'pack':
                 $pack = WPUF_Subscription::init()->get_subscription($pack_id);
                 $custom = $pack->meta_value;
                 $amount = $this->coupon_discount($_POST['coupon_code'], $pack->meta_value['billing_amount'], $pack_id);
                 $item_name = $pack->post_title;
                 $item_number = $pack->ID;
                 break;
         }
         $payment_vars = array('currency' => wpuf_get_option('currency', 'wpuf_payment'), 'price' => $amount, 'item_number' => $item_number, 'item_name' => $item_name, 'type' => $type, 'user_info' => array('id' => $userdata->ID, 'email' => $userdata->user_email, 'first_name' => $userdata->first_name, 'last_name' => $userdata->last_name), 'date' => date('Y-m-d H:i:s'), 'post_data' => $_POST, 'custom' => isset($custom) ? $custom : '');
         do_action('wpuf_gateway_' . $gateway, $payment_vars);
     }
 }
Example #6
0
 function force_pack_permission($perm, $id, $form_settings)
 {
     $force_pack = wpuf_get_option('force_pack', 'wpuf_payment');
     if ($force_pack == 'yes' && WPUF_Subscription::has_user_error($form_settings)) {
         return 'no';
     }
     return $perm;
 }
Example #7
0
 /**
  * Validate a coupon code
  *
  * @param  null|float $billing_amount
  * @param  int $coupon_id
  * @param  int $pack_id
  * @return WP_Error|float
  */
 function coupon_validation($billing_amount = null, $coupon_id, $pack_id)
 {
     $coupon_meta = $this->get_coupon_meta($coupon_id);
     $coupon_amount = intval($coupon_meta['amount']);
     if (empty($coupon_amount)) {
         return $billing_amount;
     }
     $coupon_usage = get_post_meta($coupon_id, '_coupon_used', true);
     $start_date = !empty($coupon_meta['start_date']) ? strtotime(date('Y-m-d', strtotime($coupon_meta['start_date']))) : '';
     $end_date = !empty($coupon_meta['end_date']) ? strtotime(date('Y-m-d', strtotime($coupon_meta['end_date']))) : '';
     $today = time();
     $pack = WPUF_Subscription::init()->get_subscription($pack_id);
     $current_use_email = is_user_logged_in() ? wp_get_current_user()->user_email : '';
     if (!in_array('all', $coupon_meta['package']) && !in_array($pack_id, $coupon_meta['package'])) {
         return new WP_Error('message', __('Coupon is not availiable for this package!', 'wpuf'));
     }
     if (!empty($coupon_meta['usage_limit']) && $coupon_meta['usage_limit'] < $coupon_usage) {
         return new WP_Error('message', __('Coupon usage limit exceeded!', 'wpuf'));
     }
     if (!empty($start_date)) {
         if ($start_date > $today) {
             return new WP_Error('message', __('Sorry, this coupon is not start!', 'wpuf'));
         }
     }
     if (!empty($end_date)) {
         if ($end_date < $today) {
             return new WP_Error('message', __('Sorry, this coupon has been expired!', 'wpuf'));
         }
     }
     if (count($coupon_meta['access']) && !in_array($current_use_email, $coupon_meta['access'])) {
         return new WP_Error('message', __('You are not allowed to use this coupon!', 'wpuf'));
     }
     if (!empty($coupon_amount) && $coupon_meta['type'] == 'amount') {
         $billing_amount = $pack->meta_value['billing_amount'] - $coupon_amount;
     } else {
         if ($coupon_amount && !empty($coupon_amount) && $coupon_meta['type'] == 'percent') {
             $billing_amount = $pack->meta_value['billing_amount'] * $coupon_amount / 100;
             $billing_amount = $pack->meta_value['billing_amount'] - $billing_amount;
         }
     }
     if ($billing_amount > 0) {
         return $billing_amount;
     }
     return 0;
 }
Example #8
0
    /**
     * Adds the postlock form in users profile
     *
     * @param object $profileuser
     */
    function profile_subscription_details($profileuser)
    {
        if (!is_admin() && !current_user_can('edit_users')) {
            return;
        }
        if (wpuf_get_option('charge_posting', 'wpuf_payment') != 'yes') {
            return;
        }
        $userdata = get_userdata($profileuser->ID);
        //wp 3.3 fix
        $packs = WPUF_Subscription::init()->get_subscriptions();
        $user_sub = WPUF_Subscription::get_user_pack($userdata->ID);
        $pack_id = isset($user_sub['pack_id']) ? $user_sub['pack_id'] : '';
        ?>
        <div class="wpuf-user-subscription">
            <h3><?php 
        _e('WPUF Subscription', 'wpuf');
        ?>
</h3>
            <a class="btn button-primary wpuf-assing-pack-btn wpuf-add-pack" href="#"><?php 
        _e('Assign Package', 'wpuf');
        ?>
</a>
            <a class="btn button-primary wpuf-assing-pack-btn wpuf-cancel-pack" style="display:none;" href="#"><?php 
        _e('Show Package', 'wpuf');
        ?>
</a>
            <table class="form-table wpuf-pack-dropdown" disabled="disabled" style="display: none;">
                <tr>
                    <th><label for="wpuf_sub_pack"><?php 
        _e('Pack:', 'wpuf');
        ?>
 </label></th>
                    <td>
                        <select name="pack_id" id="wpuf_sub_pack">
                        <option value="-1"><?php 
        _e('--Select--', 'wpuf');
        ?>
</option>
                        <?php 
        $this->packdropdown_without_recurring($packs, $pack_id);
        //WPUF_Subscription::init()->packdropdown( $packs, $selected = '' );
        ?>
                        </select>
                    </td>
                </tr>

            </table>
            <?php 
        if (!isset($user_sub['pack_id'])) {
            return;
        }
        $pack = WPUF_Subscription::get_subscription($user_sub['pack_id']);
        $details_meta = WPUF_Subscription::init()->get_details_meta_value();
        $billing_amount = intval($pack->meta_value['billing_amount']) > 0 ? $details_meta['symbol'] . $pack->meta_value['billing_amount'] : __('Free', 'wpuf');
        if ($billing_amount && $pack->meta_value['recurring_pay'] == 'yes') {
            $recurring_des = sprintf('For each %s %s', $pack->meta_value['billing_cycle_number'], $pack->meta_value['cycle_period'], $pack->meta_value['trial_duration_type']);
            $recurring_des .= !empty($pack->meta_value['billing_limit']) ? sprintf(', for %s installments', $pack->meta_value['billing_limit']) : '';
            $recurring_des = $recurring_des;
        } else {
            $recurring_des = '';
        }
        ?>

            <div class="wpuf-user-sub-info">
                <h3><?php 
        _e('Subscription Details', 'wpuf');
        ?>
</h3>
                <div class="wpuf-text">
                    <div><strong><?php 
        _e('Subcription Name: ', 'wpuf');
        ?>
</strong><?php 
        echo $pack->post_title;
        ?>
</div>
                    <div>
                        <strong><?php 
        _e('Package billing details: ');
        ?>
</strong>
                        <div class="wpuf-pricing-wrap">
                            <div class="wpuf-sub-amount">
                                <?php 
        echo $billing_amount;
        ?>
                                <?php 
        echo $recurring_des;
        ?>

                            </div>
                        </div>
                    </div>

                    <strong><?php 
        _e('Remaining post: ', 'wpuf');
        ?>
</strong>
                    <table class="form-table">

                        <?php 
        foreach ($user_sub['posts'] as $key => $value) {
            ?>
                             <tr>
                                 <th><label><?php 
            echo $key;
            ?>
</label></th>
                                 <td><input type="text" value="<?php 
            echo $value;
            ?>
" name="<?php 
            echo $key;
            ?>
" ></td>
                             </tr>
                            <?php 
        }
        ?>



                    <?php 
        if ($user_sub['recurring'] != 'yes') {
            if (!empty($user_sub['expire'])) {
                $expire = $user_sub['expire'] == 'unlimited' ? ucfirst('unlimited') : wpuf_date2mysql($user_sub['expire']);
                ?>
                            <tr>
                                <th><label><?php 
                echo _e('Expire date:');
                ?>
</label></th>
                                <td><input type="text" class="wpuf-date-picker" name="expire" value="<?php 
                echo wpuf_get_date($expire);
                ?>
"></td>
                            </tr>
                            <?php 
            }
        }
        ?>
                    </table>
                </div>
            </div>
        </div>
            <?php 
    }
Example #9
0
    /**
     * Adds the postlock form in users profile
     *
     * @param object $profileuser
     */
    function profile_subscription_details($profileuser)
    {
        if (!current_user_can('edit_users')) {
            return;
        }
        if (wpuf_get_option('charge_posting', 'wpuf_payment') != 'yes') {
            return;
        }
        $userdata = get_userdata($profileuser->ID);
        //wp 3.3 fix
        $packs = WPUF_Subscription::init()->get_subscriptions();
        $user_sub = WPUF_Subscription::get_user_pack($userdata->ID);
        $pack_id = isset($user_sub['pack_id']) ? $user_sub['pack_id'] : '';
        ?>
        <div class="wpuf-user-subscription">
            <h3><?php 
        _e('WPUF Subscription', 'wpuf');
        ?>
</h3>
            <?php 
        if (isset($user_sub['pack_id'])) {
            $pack = WPUF_Subscription::get_subscription($user_sub['pack_id']);
            $details_meta = WPUF_Subscription::init()->get_details_meta_value();
            $billing_amount = intval($pack->meta_value['billing_amount']) > 0 ? $details_meta['symbol'] . $pack->meta_value['billing_amount'] : __('Free', 'wpuf');
            if ($billing_amount && $pack->meta_value['recurring_pay'] == 'yes') {
                $recurring_des = sprintf('For each %s %s', $pack->meta_value['billing_cycle_number'], $pack->meta_value['cycle_period'], $pack->meta_value['trial_duration_type']);
                $recurring_des .= !empty($pack->meta_value['billing_limit']) ? sprintf(', for %s installments', $pack->meta_value['billing_limit']) : '';
                $recurring_des = $recurring_des;
            } else {
                $recurring_des = '';
            }
            ?>
                <div class="wpuf-user-sub-info">
                    <h3><?php 
            _e('Subscription Details', 'wpuf');
            ?>
</h3>
                    <?php 
            if (isset($user_sub['recurring']) && $user_sub['recurring'] == 'yes') {
                ?>
                        <div class="updated">
                            <p><?php 
                _e('This user is using recurring subscription pack', 'wpuf');
                ?>
</p>
                        </div>
                    <?php 
            }
            ?>
                    <div class="wpuf-text">
                        <div><strong><?php 
            _e('Subcription Name: ', 'wpuf');
            ?>
</strong><?php 
            echo $pack->post_title;
            ?>
</div>
                        <div>
                            <strong><?php 
            _e('Package billing details: ');
            ?>
</strong>
                            <div class="wpuf-pricing-wrap">
                                <div class="wpuf-sub-amount">
                                    <?php 
            echo $billing_amount;
            ?>
                                    <?php 
            echo $recurring_des;
            ?>

                                </div>
                            </div>
                        </div>

                        <strong><?php 
            _e('Remaining post: ', 'wpuf');
            ?>
</strong>
                        <table class="form-table">

                            <?php 
            foreach ($user_sub['posts'] as $key => $value) {
                ?>
                                 <tr>
                                     <th><label><?php 
                echo $key;
                ?>
</label></th>
                                     <td><input type="text" value="<?php 
                echo $value;
                ?>
" name="<?php 
                echo $key;
                ?>
" ></td>
                                 </tr>
                                <?php 
            }
            ?>
                        <?php 
            if ($user_sub['recurring'] != 'yes') {
                if (!empty($user_sub['expire'])) {
                    $expire = $user_sub['expire'] == 'unlimited' ? ucfirst('unlimited') : wpuf_date2mysql($user_sub['expire']);
                    ?>
                                <tr>
                                    <th><label><?php 
                    echo _e('Expire date:');
                    ?>
</label></th>
                                    <td><input type="text" class="wpuf-date-picker" name="expire" value="<?php 
                    echo wpuf_get_date($expire);
                    ?>
"></td>
                                </tr>
                                <?php 
                }
            }
            ?>
                            <?php 
            $is_post_exp_selected = isset($user_sub['_enable_post_expiration']) ? 'checked' : '';
            $_post_expiration_time = explode(' ', isset($user_sub['_post_expiration_time']) ? $user_sub['_post_expiration_time'] : ' ');
            $time_value = isset($_post_expiration_time[0]) && !empty($_post_expiration_time[0]) ? $_post_expiration_time[0] : '1';
            $time_type = isset($_post_expiration_time[1]) && !empty($_post_expiration_time[1]) ? $_post_expiration_time[1] : 'day';
            ?>
                            <tr>
                                <th><label><?php 
            echo _e('Post Expiration Enabled');
            ?>
</label></th>
                                <td><input type="checkbox" name="is_post_expiration_enabled" value="on" <?php 
            echo $is_post_exp_selected;
            ?>
></td>
                            </tr>
                            <tr>
                                <?php 
            $timeType_array = array('year' => 100, 'month' => 12, 'day' => 30);
            ?>
                                <th><?php 
            _e('Post Expiration Time', 'wpuf');
            ?>
</th>
                                <td>
                                    <select name="post_expiration_settings[expiration_time_value]" id="wpuf-expiration_time_value">
                                        <?php 
            for ($i = 1; $i <= $timeType_array[$time_type]; $i++) {
                ?>
                                            <option value="<?php 
                echo $i;
                ?>
" <?php 
                echo $i == $time_value ? 'selected' : '';
                ?>
><?php 
                echo $i;
                ?>
</option>
                                        <?php 
            }
            ?>
                                    </select>
                                    <select name="post_expiration_settings[expiration_time_type]" id="wpuf-expiration_time_type">
                                        <?php 
            foreach ($timeType_array as $each_time_type => $each_time_type_val) {
                ?>
                                            <option value="<?php 
                echo $each_time_type;
                ?>
" <?php 
                echo $each_time_type == $time_type ? 'selected' : '';
                ?>
><?php 
                echo ucfirst($each_time_type);
                ?>
</option>
                                        <?php 
            }
            ?>
                                    </select>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            <?php 
        }
        ?>
            <?php 
        if (!isset($user_sub['recurring']) || $user_sub['recurring'] != 'yes') {
            ?>
            <a class="btn button-primary wpuf-assing-pack-btn wpuf-add-pack" href="#"><?php 
            _e('Assign Package', 'wpuf');
            ?>
</a>
            <a class="btn button-primary wpuf-assing-pack-btn wpuf-cancel-pack" style="display:none;" href="#"><?php 
            _e('Show Package', 'wpuf');
            ?>
</a>
            <table class="form-table wpuf-pack-dropdown" disabled="disabled" style="display: none;">
                <tr>
                    <th><label for="wpuf_sub_pack"><?php 
            _e('Pack:', 'wpuf');
            ?>
 </label></th>
                    <td>
                        <select name="pack_id" id="wpuf_sub_pack">
                            <option value="-1"><?php 
            _e('--Select--', 'wpuf');
            ?>
</option>
                            <?php 
            $this->packdropdown_without_recurring($packs, $pack_id);
            //WPUF_Subscription::init()->packdropdown( $packs, $selected = '' );
            ?>
                        </select>
                    </td>
                </tr>
            </table>
            <?php 
        }
        ?>
            <?php 
        if (!empty($user_sub)) {
            ?>
                <a class="btn button-primary wpuf-delete-pack-btn" href="javascript:" data-userid = "<?php 
            echo $userdata->ID;
            ?>
"><?php 
            _e('Delete Package', 'wpuf');
            ?>
</a>
            <?php 
        }
        ?>
        </div>
        <?php 
    }
Example #10
0
 /**
  * Send payment handler to the gateway
  *
  * This function sends the payment handler mechanism to the selected
  * gateway. If 'paypal' is selected, then a particular action is being
  * called. A  listener function can be invoked for that gateway to handle
  * the request and send it to the gateway.
  *
  * Need to use `wpuf_gateway_{$gateway_name}
  */
 function send_to_gateway()
 {
     if (isset($_POST['wpuf_payment_submit']) && $_POST['action'] == 'wpuf_pay' && wp_verify_nonce($_POST['_wpnonce'], 'wpuf_payment_gateway')) {
         $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
         $pack_id = isset($_REQUEST['pack_id']) ? intval($_REQUEST['pack_id']) : 0;
         $gateway = $_POST['wpuf_payment_method'];
         $type = $_POST['type'];
         $userdata = wp_get_current_user();
         switch ($type) {
             case 'post':
                 $post = get_post($post_id);
                 $amount = wpuf_get_option('cost_per_post');
                 $item_number = get_post_meta($post_id, 'wpuf_order_id', true);
                 $item_name = $post->post_title;
                 break;
             case 'pack':
                 $subscription = new WPUF_Subscription();
                 $pack = $subscription->get_subscription($pack_id);
                 $amount = $pack->cost;
                 $item_name = $pack->name;
                 $item_number = $pack->id;
                 break;
         }
         $payment_vars = array('currency' => wpuf_get_option('currency'), 'price' => $amount, 'item_number' => $item_number, 'item_name' => $item_name, 'type' => $type, 'user_info' => array('id' => $userdata->ID, 'email' => $userdata->user_email, 'first_name' => $userdata->first_name, 'last_name' => $userdata->last_name), 'date' => date('Y-m-d H:i:s'), 'post_data' => $_POST);
         do_action('wpuf_gateway_' . $gateway, $payment_vars);
     }
 }
Example #11
0
 /**
  * Prepare the payment form and send to paypal
  *
  * @since 0.8
  * @param array $data payment info
  */
 function prepare_to_send($data)
 {
     $user_id = $data['user_info']['id'];
     $listener_url = add_query_arg('action', 'wpuf_paypal_success', home_url('/'));
     $redirect_page_id = wpuf_get_option('payment_success', 'wpuf_payment');
     if ($redirect_page_id) {
         $return_url = add_query_arg('action', 'wpuf_paypal_success', get_permalink($redirect_page_id));
     } else {
         $return_url = add_query_arg('action', 'wpuf_paypal_success', get_permalink(wpuf_get_option('subscription_page', 'wpuf_payment')));
     }
     $billing_amount = empty($data['price']) ? 0 : number_format($data['price'], 2);
     if (isset($_POST['coupon_id']) && !empty($_POST['coupon_id'])) {
         $billing_amount = WPUF_Coupons::init()->discount($billing_amount, $_POST['coupon_id'], $data['item_number']);
         $coupon_id = $_POST['coupon_id'];
     } else {
         $coupon_id = '';
     }
     if ($billing_amount == 0) {
         WPUF_Subscription::init()->new_subscription($user_id, $data['item_number'], $profile_id = null, false, 'free');
         wp_redirect($return_url);
         exit;
     }
     if ($data['type'] == 'pack' && $data['custom']['recurring_pay'] == 'yes') {
         $trial_cost = !empty($data['custom']['trial_cost']) ? number_format($data['custom']['trial_cost']) : '0';
         if ($data['custom']['cycle_period'] == "day") {
             $period = "D";
         } elseif ($data['custom']['cycle_period'] == "week") {
             $period = "W";
         } elseif ($data['custom']['cycle_period'] == "month") {
             $period = "M";
         } elseif ($data['custom']['cycle_period'] == "year") {
             $period = "Y";
         }
         if ($data['custom']['trial_duration_type'] == "day") {
             $trial_period = "D";
         } elseif ($data['custom']['trial_duration_type'] == "week") {
             $trial_period = "W";
         } elseif ($data['custom']['trial_duration_type'] == "month") {
             $trial_period = "M";
         } elseif ($data['custom']['trial_duration_type'] == "year") {
             $trial_period = "Y";
         }
         $paypal_args = array('cmd' => '_xclick-subscriptions', 'business' => wpuf_get_option('paypal_email', 'wpuf_payment'), 'a3' => $billing_amount, 'p3' => !empty($data['custom']['billing_cycle_number']) ? $data['custom']['billing_cycle_number'] : '0', 't3' => $period, 'item_name' => $data['custom']['post_title'], 'custom' => json_encode(array('billing_amount' => $billing_amount, 'trial_cost' => $trial_cost, 'type' => $data['type'], 'user_id' => $user_id, 'coupon_id' => $coupon_id)), 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => $data['currency'], 'item_number' => $data['item_number'], 'charset' => 'UTF-8', 'rm' => '2', 'return' => $return_url, 'notify_url' => $listener_url, 'src' => '1', 'sra' => '1', 'srt' => intval($data['custom']['billing_limit']));
         if ($data['custom']['trial_status'] == 'yes') {
             $paypal_args['a1'] = $trial_cost;
             $paypal_args['p1'] = $data['custom']['trial_duration'];
             $paypal_args['t1'] = $trial_period;
         }
     } else {
         $paypal_args = array('cmd' => '_xclick', 'business' => wpuf_get_option('paypal_email', 'wpuf_payment'), 'amount' => $billing_amount, 'item_name' => isset($data['custom']['post_title']) ? $data['custom']['post_title'] : $data['item_name'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => $data['currency'], 'item_number' => $data['item_number'], 'charset' => 'UTF-8', 'rm' => '2', 'custom' => json_encode(array('type' => $data['type'], 'user_id' => $user_id, 'coupon_id' => $coupon_id)), 'return' => $return_url, 'notify_url' => $listener_url);
     }
     $this->set_mode();
     $paypal_url = $this->gateway_url . http_build_query($paypal_args);
     wp_redirect($paypal_url);
     exit;
 }
 function force_pack_permission($perm, $id, $form_settings)
 {
     $force_pack = wpuf_get_option('force_pack', 'wpuf_payment');
     if (is_user_logged_in()) {
         $is_user_postlock = get_user_meta(get_current_user_id(), 'wpuf_postlock', true);
         if ($is_user_postlock == 'yes') {
             return 'no';
         } else {
             if ($force_pack == 'yes' && WPUF_Subscription::has_user_error($form_settings)) {
                 return 'no';
             } else {
                 return 'yes';
             }
         }
     }
     return $perm;
 }
Example #13
0
 /**
  * Instantiate the classes
  *
  * @return void
  */
 function instantiate()
 {
     // var_dump( get_option( 'wpuf_payment' ) );
     new WPUF_Upload();
     new WPUF_Frontend_Form_Profile();
     new WPUF_Payment();
     WPUF_Frontend_Form_Post::init();
     // requires for form preview
     WPUF_Login::init();
     WPUF_Subscription::init();
     WPUF_Coupons::init();
     if (is_admin()) {
         WPUF_Admin_Settings::init();
         new WPUF_Admin_Form();
         new WPUF_Admin_Posting();
         new WPUF_Admin_Posting_Profile();
         new WPUF_Admin_Coupon();
         new WPUF_Updates();
         new WPUF_Admin_Subscription();
         new WPUF_Admin_Installer();
     } else {
         new WPUF_Frontend_Dashboard();
     }
 }
Example #14
0
 /**
  * @param $user_meta
  * @param $user_id
  * @param $pack_id
  * @param $recurring
  * @return mixed
  */
 public static function set_subscription_meta_to_user($user_meta, $user_id, $pack_id, $recurring)
 {
     $subscription = parent::get_subscription($pack_id);
     $user_meta['postnum_rollback_on_delete'] = isset($subscription->meta_value['postnum_rollback_on_delete']) ? $subscription->meta_value['postnum_rollback_on_delete'] : '';
     return $user_meta;
 }
    /**
     * Adds the postlock form in users profile
     *
     * @param object $profileuser
     */
    function profile_subscription_details($profileuser)
    {
        if (is_admin() && current_user_can('edit_users')) {
            if (wpuf_get_option('charge_posting', 'wpuf_payment') == 'yes') {
                $validity = isset($profileuser->wpuf_sub_validity) ? $profileuser->wpuf_sub_validity : date('Y-m-d G:i:s', time());
                $count = isset($profileuser->wpuf_sub_pcount) ? $profileuser->wpuf_sub_pcount : 0;
                if (isset($profileuser->wpuf_sub_pack)) {
                    $pack = WPUF_Subscription::get_subscription($profileuser->wpuf_sub_pack);
                    $pack = $pack->name;
                } else {
                    $pack = 'Free';
                }
                ?>

                <h3><?php 
                _e('WPUF Subscription', 'wpuf');
                ?>
</h3>

                <table class="form-table">
                    <tr>
                        <th><label for="wpuf_sub_pack"><?php 
                _e('Pack:', 'wpuf');
                ?>
 </label></th>
                        <td>
                            <input type="text" disabled="disabled" name="wpuf_sub_pack" id="wpuf_sub_pack" class="regular-text" value="<?php 
                echo $pack;
                ?>
" />
                        </td>
                    </tr>
                    <tr>
                        <th><label for="wpuf_sub_pcount"><?php 
                _e('Post Count:', 'wpuf');
                ?>
 </label></th>
                        <td>
                            <input type="text" name="wpuf_sub_pcount" id="wpuf_sub_pcount" class="regular-text" value="<?php 
                echo $count;
                ?>
" />
                        </td>
                    </tr>
                    <tr>
                        <th><label for="wpuf_sub_validity"><?php 
                _e('Validity:', 'wpuf');
                ?>
 </label></th>
                        <td>
                            <input type="text" name="wpuf_sub_validity" id="wpuf_sub_validity" class="regular-text" value="<?php 
                echo $validity;
                ?>
" />
                        </td>
                    </tr>
                </table>

            <?php 
            }
            ?>

            <?php 
        }
    }