Error! swpm_render_pp_buy_now_button_sc_output() function requires the button ID value to be passed to it.
'; } //Check new_window parameter $window_target = isset($args['new_window']) ? 'target="_blank"' : ''; $settings = SwpmSettings::get_instance(); $button_cpt = get_post($button_id); //Retrieve the CPT for this button $membership_level_id = get_post_meta($button_id, 'membership_level_id', true); //Verify that this membership level exists (to prevent user paying for a level that has been deleted) if(!SwpmUtils::membership_level_id_exists($membership_level_id)){ return 'Error! The membership level specified in this button does not exist. You may have deleted this membership level. Edit the button and use the correct membership level.
'; } $paypal_email = get_post_meta($button_id, 'paypal_email', true); $payment_amount = get_post_meta($button_id, 'payment_amount', true); if (!is_numeric($payment_amount)) { return 'Error! The payment amount value of the button must be a numeric number. Example: 49.50
'; } $payment_amount = round($payment_amount, 2); //round the amount to 2 decimal place. $payment_currency = get_post_meta($button_id, 'payment_currency', true); $sandbox_enabled = $settings->get_value('enable-sandbox-testing'); $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_ipn=1'; $return_url = get_post_meta($button_id, 'return_url', true); if (empty($return_url)) { $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; } $cancel_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; $user_ip = SwpmUtils::get_user_ip_address(); $_SESSION['swpm_payment_button_interaction'] = $user_ip; //Custom field data $custom_field_value = 'subsc_ref=' . $membership_level_id; $custom_field_value .= '&user_ip=' . $user_ip; if (SwpmMemberUtils::is_member_logged_in()) { $custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id(); } $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value); /* === PayPal Buy Now Button Form === */ $output = ''; $output .= ' '; //End .swpm_button_wrapper return $output; } /* * ************************************************ * PayPal subscription button shortcode handler * *********************************************** */ add_filter('swpm_payment_button_shortcode_for_pp_subscription', 'swpm_render_pp_subscription_button_sc_output', 10, 2); function swpm_render_pp_subscription_button_sc_output($button_code, $args) { $button_id = isset($args['id']) ? $args['id'] : ''; if (empty($button_id)) { return 'Error! swpm_render_pp_subscription_button_sc_output() function requires the button ID value to be passed to it.
'; } //Check new_window parameter $window_target = isset($args['new_window']) ? 'target="_blank"' : ''; $settings = SwpmSettings::get_instance(); $button_cpt = get_post($button_id); //Retrieve the CPT for this button $membership_level_id = get_post_meta($button_id, 'membership_level_id', true); //Verify that this membership level exists (to prevent user paying for a level that has been deleted) if(!SwpmUtils::membership_level_id_exists($membership_level_id)){ return 'Error! The membership level specified in this button does not exist. You may have deleted this membership level. Edit the button and use the correct membership level.
'; } $paypal_email = get_post_meta($button_id, 'paypal_email', true); $payment_currency = get_post_meta($button_id, 'payment_currency', true); //Subscription payment details $billing_amount = get_post_meta($button_id, 'billing_amount', true); if (!is_numeric($billing_amount)) { return 'Error! The billing amount value of the button must be a numeric number. Example: 49.50
'; } $billing_amount = round($billing_amount, 2); //round the amount to 2 decimal place. $billing_cycle = get_post_meta($button_id, 'billing_cycle', true); $billing_cycle_term = get_post_meta($button_id, 'billing_cycle_term', true); $billing_cycle_count = get_post_meta($button_id, 'billing_cycle_count', true); $billing_reattempt = get_post_meta($button_id, 'billing_reattempt', true); //Trial billing details $trial_billing_amount = get_post_meta($button_id, 'trial_billing_amount', true); if (!empty($trial_billing_amount)) { if(!is_numeric($trial_billing_amount)){ return 'Error! The trial billing amount value of the button must be a numeric number. Example: 19.50
'; } } $trial_billing_cycle = get_post_meta($button_id, 'trial_billing_cycle', true); $trial_billing_cycle_term = get_post_meta($button_id, 'trial_billing_cycle_term', true); $sandbox_enabled = $settings->get_value('enable-sandbox-testing'); $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_ipn=1'; $return_url = get_post_meta($button_id, 'return_url', true); if (empty($return_url)) { $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; } $cancel_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL; $user_ip = SwpmUtils::get_user_ip_address(); $_SESSION['swpm_payment_button_interaction'] = $user_ip; //Custom field data $custom_field_value = 'subsc_ref=' . $membership_level_id; $custom_field_value .= '&user_ip=' . $user_ip; if (SwpmMemberUtils::is_member_logged_in()) { $custom_field_value .= '&swpm_id=' . SwpmMemberUtils::get_logged_in_members_id(); } $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value); /* === PayPal Subscription Button Form === */ $output = ''; $output .= ' '; //End .swpm_button_wrapper return $output; }