wpestate_email_to_admin(1); } else { update_post_meta($listing_id, 'pay_status', 'paid'); $admin_submission_status = esc_html(get_option('wp_estate_admin_submission', '')); $paid_submission_status = esc_html(get_option('wp_estate_paid_submission', '')); if ($admin_submission_status == 'no' && $paid_submission_status == 'per listing') { $post = array('ID' => $listing_id, 'post_status' => 'publish'); $post_id = wp_update_post($post); } // end make post publish if ($is_featured == 1) { update_post_meta($listing_id, 'prop_featured', 1); $invoice_id = wpestate_insert_invoice('Publish Listing with Featured', 'One Time', $listing_id, $date, $current_user->ID, 1, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } else { $invoice_id = wpestate_insert_invoice('Listing', 'One Time', $listing_id, $date, $current_user->ID, 0, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } wpestate_email_to_admin(0); } $redirect = wpestate_get_dashboard_link(); wp_redirect($redirect); } catch (Exception $e) { $error = '<div class="alert alert-danger"> <strong>Error!</strong> ' . $e->getMessage() . ' </div>'; print $error; } } else { if (isset($_POST['stripe_recuring']) && $_POST['stripe_recuring'] == 1) { ////////////////////////////////////////////////////////////////////////////////
function wpestate_upgrade_user_membership($user_id, $pack_id, $type, $paypal_tax_id) { $available_listings = get_post_meta($pack_id, 'pack_listings', true); $featured_available_listings = get_post_meta($pack_id, 'pack_featured_listings', true); $pack_unlimited_list = get_post_meta($pack_id, 'mem_list_unl', true); $current_used_listings = get_user_meta($user_id, 'package_listings', true); $curent_used_featured_listings = get_user_meta($user_id, 'package_featured_listings', true); $current_pack = get_user_meta($user_id, 'package_id', true); $user_curent_listings = wpestate_get_user_curent_listings_no_exp($user_id); $user_curent_future_listings = wpestate_get_user_curent_future_listings_no_exp($user_id); if (wpestate_check_downgrade_situation($user_id, $pack_id)) { $new_listings = $available_listings; $new_featured_listings = $featured_available_listings; } else { $new_listings = $available_listings - $user_curent_listings; $new_featured_listings = $featured_available_listings - $user_curent_future_listings; } // in case of downgrade if ($new_listings < 0) { $new_listings = 0; } if ($new_featured_listings < 0) { $new_featured_listings = 0; } if ($pack_unlimited_list == 1) { $new_listings = -1; } update_user_meta($user_id, 'package_listings', $new_listings); update_user_meta($user_id, 'package_featured_listings', $new_featured_listings); $time = time(); $date = date('Y-m-d H:i:s', $time); update_user_meta($user_id, 'package_activation', $date); update_user_meta($user_id, 'package_id', $pack_id); $headers = 'From: No Reply <noreply@' . $_SERVER['HTTP_HOST'] . '>' . "\r\n"; $message = esc_html__('Hi there,', 'wpestate') . "\r\n\r\n"; $message .= sprintf(esc_html__("Your new membership on %s is activated! You should go check it out.", 'wpestate'), get_option('blogname')) . "\r\n\r\n"; $user = get_user_by('id', $user_id); $user_email = $user->user_email; wp_mail($user_email, sprintf(esc_html__('[%s] Membership Activated', 'wpestate'), get_option('blogname')), $message, $headers); $billing_for = 'Package'; $invoice_id = wpestate_insert_invoice($billing_for, $type, $pack_id, $date, $user_id, 0, 0, $paypal_tax_id); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); }
} else { update_post_meta($listing_id, 'pay_status', 'paid'); // if admin does not need to approve - make post status as publish $admin_submission_status = esc_html(get_option('wp_estate_admin_submission', '')); $paid_submission_status = esc_html(get_option('wp_estate_paid_submission', '')); if ($admin_submission_status == 'no' && $paid_submission_status == 'per listing') { $post = array('ID' => $listing_id, 'post_status' => 'publish'); $post_id = wp_update_post($post); } // end make post publish if ($is_featured == 1) { update_post_meta($listing_id, 'prop_featured', 1); $invoice_id = wpestate_insert_invoice('Publish Listing with Featured', esc_html__('One Time', 'wpestate'), $listing_id, $date, $current_user->ID, 1, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } else { $invoice_id = wpestate_insert_invoice('Listing', esc_html__('One Time', 'wpestate'), $listing_id, $date, $current_user->ID, 0, 0, ''); update_post_meta($invoice_id, 'invoice_status', 'confirmed'); } wpestate_email_to_admin(0); } } } $redirect = wpestate_get_dashboard_link(); wp_redirect($redirect); } $token = ''; ////////////////////////////////////////////////////////////////////////////////////// /// Process messages from Paypal IPN ////////////////////////////////////////////////////////////////////////////////////// define('DEBUG', 0); $raw_post_data = file_get_contents('php://input');