diff --git a/README.md b/README.md index fdb3cb5..238e79a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# fipf 2024 +# cipf 2024 - this project uses submodules recursively, so after cloning you need to do : `git submodule update --init --recursive` diff --git a/plugins/cipf_plugin/php/paypal/route_api_utils.php b/plugins/cipf_plugin/php/paypal/route_api_utils.php index 8bcc2be..83f2699 100644 --- a/plugins/cipf_plugin/php/paypal/route_api_utils.php +++ b/plugins/cipf_plugin/php/paypal/route_api_utils.php @@ -56,15 +56,18 @@ async function handleResponse(response) { */ function generate_access_token_CIPF() { + $paypal_client_id = PLGNTLS_class::PAYPAL_CLIENT_ID; + $paypal_client_secret = PLGNTLS_class::PAYPAL_CLIENT_SECRET; + $paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL; try { - if ( !PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET ) { + if ( !$paypal_client_id || !$paypal_client_secret ) { throw new Exception( "MISSING_API_CREDENTIALS" ); } - $credentials = PAYPAL_CLIENT_ID . ":" . PAYPAL_CLIENT_SECRET; + $credentials = $paypal_client_id . ":" . $paypal_client_secret; $auth = base64_encode($credentials); - $url = PAYPAL_API_BASE_URL . '/v1/oauth2/token'; + $url = $paypal_api_base_url . '/v1/oauth2/token'; $body = http_build_query(array('grant_type' => 'client_credentials')); // Initialize curl $ch = curl_init(); diff --git a/plugins/cipf_plugin/php/paypal/shortcode.php b/plugins/cipf_plugin/php/paypal/shortcode.php index d598fd0..cbb8838 100644 --- a/plugins/cipf_plugin/php/paypal/shortcode.php +++ b/plugins/cipf_plugin/php/paypal/shortcode.php @@ -17,19 +17,23 @@ if (!defined('ABSPATH')) { */ function paypal_shortcode_content_CIPF() { + $slug_paypal_redirection_success = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_SUCCESS; + $slug_paypal_redirection_failure = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_FAILURE; + $paypal_client_id = PLGNTLS_class::PAYPAL_CLIENT_ID; + $paypal_message_success = PLGNTLS_class::PAYPAL_MESSAGE_SUCCESS; + $paypal_message_failure = PLGNTLS_class::PAYPAL_MESSAGE_FAILURE; + // if (!can_pay_now_CIPF()) // return no_payment_CIPF(); $cipfcard_paypal = new PLGNTLS_class(); - $pp_client_id = PAYPAL_CLIENT_ID; + $pp_client_id = $paypal_client_id; $pp_sdk_currency = "EUR"; $pp_sdk_base_url = "https://www.paypal.com"; $pp_sdk_url = "{$pp_sdk_base_url}/sdk/js?client-id={$pp_client_id}¤cy={$pp_sdk_currency}"; - $paypal_redirection_success = PAYPAL_REDIRECTION_SUCCESS; - $paypal_redirection_failure = PAYPAL_REDIRECTION_FAILURE; - $paypal_message_success = PAYPAL_MESSAGE_SUCCESS; - $paypal_message_failure = PAYPAL_MESSAGE_FAILURE; + $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( array( diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 4caefd6..540a50e 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -15,7 +15,9 @@ if (!defined('ABSPATH')) { * if partenaire -> post page || home page */ function redirection_page_CIPF(){ - if (!is_page(PROF_PARTENAIRE_REDIRECTION_PAGE)) + $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION; + + if (!is_page($slug_page_redirection)) return; $base_url = home_url(); diff --git a/plugins/cipf_plugin/php/utils/globals.php b/plugins/cipf_plugin/php/utils/globals.php index 3dd4a04..4bdccc6 100644 --- a/plugins/cipf_plugin/php/utils/globals.php +++ b/plugins/cipf_plugin/php/utils/globals.php @@ -18,12 +18,6 @@ const CONSOLE_OFF = true; const CIPF_CONSOLE_OFF = false; -/* -* redirections users -*/ -const PROF_PARTENAIRE_REDIRECTION_PAGE = 'redirection_cipf'; -define('PROF_PARTENAIRE_REDIRECTION_URL', home_url() . '/' . PROF_PARTENAIRE_REDIRECTION_PAGE); - /* * paypal credentials @@ -38,20 +32,14 @@ define('PROF_PARTENAIRE_REDIRECTION_URL', home_url() . '/' . PROF_PARTENAIRE_RED * const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl"; * const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-"; * -*/ const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl"; const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-"; +*/ /* * paypal api base url -*/ const PAYPAL_API_BASE_URL = "https://api-m.sandbox.paypal.com"; - -/* -* paypal redirections */ -const PAYPAL_REDIRECTION_SUCCESS = PROF_PARTENAIRE_REDIRECTION_URL; -const PAYPAL_REDIRECTION_FAILURE = PROF_PARTENAIRE_REDIRECTION_URL; /* * paypal messages @@ -63,18 +51,18 @@ const PAYPAL_REDIRECTION_FAILURE = PROF_PARTENAIRE_REDIRECTION_URL; const PAYPAL_MESSAGE_SUCCESS = '`Transaction ${transaction.status}: ${transaction.id}

See console for all available details`'; const PAYPAL_MESSAGE_FAILURE = '`Sorry, your transaction could not be processed...

${error}`'; -*/ const PAYPAL_MESSAGE_SUCCESS = '`paiement reussi`'; const PAYPAL_MESSAGE_FAILURE = '`paiement raté`'; +*/ /* * acf fields for card : * - card_is_valid : has valid card * - card_date_purchase : date of purchase * - card_date_validity : date end of validity -*/ const CARD_IS_VALID = 'carte_est_valide'; const CARD_DATE_PURCHASE = 'date_d_achat'; const CARD_DATE_VALIDITY = 'date_fin_validite'; +*/ ?> diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index 9c33b1a..4f4d35c 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -62,17 +62,28 @@ class PLGNTLS_class const ACF_CARD_PRICE_DELIVERY = 'livraison'; const ACF_CARD_PRICE_TOTAL = 'somme_a_regler'; const ACF_CARD_EXPIRATION = 'fin_de_validite'; - CONST ACF_PROF_IS_ACTIV = 'compte-actif'; - CONST ACF_PROF_CAN_RENEW = 'renouvellement_possible'; - CONST ACF_PROF_CGV = 'cgv'; + const ACF_PROF_IS_ACTIV = 'compte-actif'; + const ACF_PROF_CAN_RENEW = 'renouvellement_possible'; + const ACF_PROF_CGV = 'cgv'; const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days') - CONST SLUG_PROF_INACTIV = 'validation-en-cours'; - CONST SLUG_RENEW_CARD = 'commande'; + const SLUG_PROF_INACTIV = 'validation-en-cours'; + const SLUG_RENEW_CARD = 'commande'; + const SLUG_PAGE_REDIRECTION = 'redirection_cipf'; + const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION; + const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION; + + const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php) + + const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl"; + const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-"; + const PAYPAL_API_BASE_URL = "https://api-m.sandbox.paypal.com"; + const PAYPAL_MESSAGE_SUCCESS = '`paiement reussi`'; + const PAYPAL_MESSAGE_FAILURE = '`paiement raté`'; + - CONST USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php) private static $_root_path; private static $_root_url;