updated plgntls :
- renamed PLGNTLS_class -> Plgntls - changed method 'add_to_front()' to static method - moved fetch script as inline script, so the plgntls file is single - improved the way inline script and styles are added
This commit is contained in:
@@ -17,14 +17,14 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function payment_page_checks_CIPF() {
|
||||
PLGNTLS_class::debug_infos(2);
|
||||
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
|
||||
// check the slug
|
||||
if (!is_page($slug_paypal_page)) {
|
||||
return;
|
||||
}
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// get the user id
|
||||
$user_id = get_current_user_id();
|
||||
@@ -42,9 +42,9 @@ add_action('wp', 'payment_page_checks_CIPF');
|
||||
*
|
||||
*/
|
||||
function payment_page_redirects_CIPF() {
|
||||
PLGNTLS_class::debug_infos(2);
|
||||
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
|
||||
// don't redirect if it is the divi builder mode
|
||||
if (et_fb_is_enabled()) {
|
||||
@@ -54,7 +54,7 @@ function payment_page_redirects_CIPF() {
|
||||
if (!is_page($slug_paypal_page)) {
|
||||
return;
|
||||
}
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
/*
|
||||
* if prof, don't redirect
|
||||
@@ -77,14 +77,14 @@ add_action('template_redirect', 'payment_page_redirects_CIPF');
|
||||
*
|
||||
*/
|
||||
function payment_page_scripts_CIPF() {
|
||||
PLGNTLS_class::debug_infos(2);
|
||||
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
|
||||
Plgntls::debug_infos(2);
|
||||
$slug_paypal_page = Plgntls::SLUG_PAYPAL_PAGE;
|
||||
|
||||
// check the slug
|
||||
if (!is_page($slug_paypal_page)) {
|
||||
return;
|
||||
}
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// get the user id
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
@@ -9,15 +9,15 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
include_once(PLGNTLS_class::root_path() . '/php/utils/http_errors.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_utils.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/user_can_pay.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/update_user_payment.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/shortcode.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders_capture.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/routes.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/payment_page.php');
|
||||
include_once(Plgntls::root_path() . '/php/utils/http_errors.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/route_api_utils.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/user_can_pay.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/update_user_payment.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/shortcode.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/route_api_orders.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/route_api_orders_capture.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/routes.php');
|
||||
include_once(Plgntls::root_path() . '/php/paypal/payment_page.php');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function handle_orders_request_CIPF($request_data) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// declaring outside the try..catch scope
|
||||
$order_response = array();
|
||||
@@ -90,9 +90,9 @@ function handle_orders_request_CIPF($request_data) {
|
||||
*
|
||||
*/
|
||||
function create_order_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
|
||||
$acf_card_price_total = PLGNTLS_class::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
|
||||
|
||||
$access_token = generate_access_token_CIPF();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
function handle_orders_capture_request_CIPF($request) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
$order_id = $request['orderID'];
|
||||
// declaring outside the try..catch scope
|
||||
$response_json = array();
|
||||
@@ -75,7 +75,7 @@ function handle_orders_capture_request_CIPF($request) {
|
||||
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||
*/
|
||||
function capture_order_CIPF($order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
|
||||
$access_token = generate_access_token_CIPF();
|
||||
$url = $paypal_api_base_url . '/v2/checkout/orders/' . $order_id . '/capture';
|
||||
|
||||
@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function handle_json_response_CIPF($response, $ch) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
if ($response === false)
|
||||
throw new HttpException('cURL error: ' . curl_error($ch), 502);
|
||||
|
||||
@@ -33,7 +33,7 @@ function handle_json_response_CIPF($response, $ch) {
|
||||
);
|
||||
}
|
||||
function handle_response_CIPF($response) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
try
|
||||
{
|
||||
// Decode JSON response
|
||||
@@ -60,7 +60,7 @@ function handle_response_CIPF($response) {
|
||||
* @see https://developer.paypal.com/api/rest/authentication/
|
||||
*/
|
||||
function generate_access_token_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
$paypal_client_id = get_paypal_client_id_CIPF();
|
||||
$paypal_client_secret = get_paypal_client_secret_CIPF();
|
||||
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
|
||||
|
||||
@@ -12,11 +12,11 @@ if (!defined('ABSPATH')) {
|
||||
// handling routes and endpoints
|
||||
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
|
||||
function routes_endpoints_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
if (is_admin()) {
|
||||
return;
|
||||
}
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
$base_rest_route = Plgntls::URL_BASE_REST_ROUTE;
|
||||
register_rest_route($base_rest_route, '/orders', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'handle_orders_request_CIPF',
|
||||
|
||||
@@ -16,16 +16,15 @@ if (!defined('ABSPATH')) {
|
||||
* call to paypal_shortcode_content()
|
||||
*/
|
||||
function paypal_shortcode_content_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_paypal_redirection_success = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
Plgntls::debug_infos();
|
||||
$slug_paypal_redirection_success = Plgntls::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = Plgntls::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
$paypal_client_id = get_paypal_client_id_CIPF();
|
||||
$paypal_message_success = get_payment_message_success_CIPF();
|
||||
$paypal_message_failure = get_payment_message_failure_CIPF();
|
||||
|
||||
// if (!can_pay_now_CIPF())
|
||||
// return no_payment_CIPF();
|
||||
$cipfcard_paypal = new PLGNTLS_class();
|
||||
|
||||
$pp_client_id = $paypal_client_id;
|
||||
$pp_sdk_currency = "EUR";
|
||||
@@ -35,7 +34,7 @@ function paypal_shortcode_content_CIPF() {
|
||||
$paypal_redirection_success = home_url() . '/' . $slug_paypal_redirection_success;
|
||||
$paypal_redirection_failure = home_url() . '/' . $slug_paypal_redirection_failure;
|
||||
|
||||
$added_to_front = $cipfcard_paypal->add_to_front(
|
||||
$added_to_front = Plgntls::add_to_front(
|
||||
array(
|
||||
$pp_sdk_url,
|
||||
array("js/paypal/paypal.js", 'type'=>'module'),
|
||||
@@ -55,7 +54,7 @@ add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
|
||||
|
||||
|
||||
function no_payment_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function update_user_pre_order_CIPF($message) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
Plgntls::debug_infos();
|
||||
$acf_payment_status = Plgntls::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
@@ -71,7 +71,7 @@ function update_user_pre_order_CIPF($message) {
|
||||
*
|
||||
*/
|
||||
function update_user_post_capture_CIPF($message) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
@@ -127,8 +127,8 @@ function update_user_post_capture_CIPF($message) {
|
||||
*
|
||||
*/
|
||||
function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
@@ -149,8 +149,8 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
*
|
||||
*/
|
||||
function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
@@ -185,9 +185,9 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
*
|
||||
*/
|
||||
function find_user_with_order_id_CIPF($current_user_id, $order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
Plgntls::debug_infos();
|
||||
$meta_order_id = Plgntls::META_ORDER_ID;
|
||||
$role_prof = Plgntls::ROLE_PROF;
|
||||
|
||||
$user_metas = get_user_meta($current_user_id, $meta_order_id, false);
|
||||
if (in_array($order_id, $user_metas)) {
|
||||
|
||||
@@ -42,13 +42,13 @@ function get_acf_value_CIPF($acf_field, $acf_id) {
|
||||
*
|
||||
*/
|
||||
function check_can_pay_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_card_price_total = PLGNTLS_class::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
|
||||
$card_renew_period = PLGNTLS_class::CARD_RENEW_PERIOD;
|
||||
Plgntls::debug_infos();
|
||||
$acf_card_payment_method = Plgntls::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = Plgntls::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = Plgntls::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_card_price_total = Plgntls::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_expiration = Plgntls::ACF_CARD_EXPIRATION;
|
||||
$card_renew_period = Plgntls::CARD_RENEW_PERIOD;
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
Reference in New Issue
Block a user