added options in paypal credential and payment

This commit is contained in:
asus
2024-04-09 18:16:38 +02:00
parent 731b69d97d
commit ec9bddaefd
6 changed files with 124 additions and 61 deletions

View File

@@ -54,12 +54,30 @@ function get_paypal_options_CIPF() {
function get_paypal_client_id_CIPF() {
Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_id'];
$is_sandbox = $paypal_credentials['is_sandbox'];
$client_id = '';
if ($is_sandbox) {
$client_id = $paypal_credentials['sandbox_client_id'];
}
else {
$client_id = $paypal_credentials['live_client_id'];
}
return $client_id;
}
function get_paypal_client_secret_CIPF() {
Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_secret'];
$is_sandbox = $paypal_credentials['is_sandbox'];
$client_secret = '';
if ($is_sandbox) {
$client_secret = $paypal_credentials['sandbox_client_secret'];
}
else {
$client_secret = $paypal_credentials['live_client_secret'];
}
return $client_secret;
}
function get_paypal_api_base_url_CIPF() {
Plgntls::debug_infos();
@@ -75,7 +93,31 @@ function get_paypal_api_base_url_CIPF() {
}
return $paypal_base_url;
}
function is_paypal_force_1_cent_CIPF() {
Plgntls::debug_infos();
$paypal_options = get_paypal_options_CIPF();
error_log("paypal_options: " . json_encode($paypal_options));
return $paypal_options['force_1_cent'];
}
function get_paypal_price_CIPF($user_id = null) {
Plgntls::debug_infos();
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
if (is_paypal_force_1_cent_CIPF($user_id)) {
$price = "0.01";
}
else {
$price = get_card_price_CIPF($user_id);
}
return $price;
}