added change card prof 5€
This commit is contained in:
@@ -10,6 +10,27 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* action to be done at the init state of the page
|
||||
*
|
||||
*/
|
||||
function prof_payment_page_init_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
|
||||
if (!is_prof_CIPF()) {
|
||||
return;
|
||||
}
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
|
||||
global $wp;
|
||||
$wp->add_query_var('prof_card_change');
|
||||
}
|
||||
add_action('init','prof_payment_page_init_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -29,7 +50,18 @@ function payment_page_checks_CIPF() {
|
||||
// get the user id
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
// do checks here
|
||||
/*
|
||||
* check for query card change
|
||||
* and modify acf field accordingly
|
||||
*
|
||||
*/
|
||||
$is_card_change = get_query_var('prof_card_change', false);
|
||||
if ($is_card_change == true) {
|
||||
set_acf_prof_change_card_CIPF();
|
||||
}
|
||||
else {
|
||||
reset_acf_prof_change_card_CIPF();
|
||||
}
|
||||
}
|
||||
add_action('wp', 'payment_page_checks_CIPF');
|
||||
|
||||
@@ -37,6 +69,8 @@ add_action('wp', 'payment_page_checks_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* only profs can access this page
|
||||
*
|
||||
|
||||
@@ -24,8 +24,6 @@ function paypal_shortcode_content_CIPF() {
|
||||
$paypal_message_failure = get_payment_message_failure_CIPF();
|
||||
$paypal_message_problem = get_payment_message_problem_CIPF();
|
||||
|
||||
// if (!can_pay_now_CIPF())
|
||||
// return no_payment_CIPF();
|
||||
|
||||
$pp_client_id = $paypal_client_id;
|
||||
$pp_sdk_currency = "EUR";
|
||||
@@ -55,10 +53,6 @@ function paypal_shortcode_content_CIPF() {
|
||||
add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
|
||||
|
||||
|
||||
function no_payment_CIPF() {
|
||||
Plgntls::debug_infos();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -128,11 +128,26 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
|
||||
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||
set_payment_failure_CIPF($user_id);
|
||||
set_account_to_pay_CIPF($user_id);
|
||||
send_emails_CIPF('payment_echec', $user_id);
|
||||
|
||||
/*
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
reset_acf_prof_change_card_CIPF($user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* else
|
||||
*
|
||||
*/
|
||||
set_account_to_pay_CIPF($user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* things to do when a payment is a success
|
||||
*
|
||||
@@ -141,9 +156,24 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
|
||||
Plgntls::debug_infos();
|
||||
|
||||
schedule_delete_orderid_CIPF($order_id, $user_id);
|
||||
|
||||
/*
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
reset_acf_prof_change_card_CIPF($user_id);
|
||||
send_emails_CIPF('change_card_success', $user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* else
|
||||
*
|
||||
*/
|
||||
update_card_date_expiration_CIPF($user_id);
|
||||
|
||||
if (is_card_new_CIPF()) {
|
||||
if (is_card_new_CIPF($user_id)) {
|
||||
set_card_number_CIPF($user_id);
|
||||
set_card_renew_CIPF($user_id);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ function check_can_pay_CIPF() {
|
||||
|
||||
|
||||
|
||||
schedule_prof_account_deletion_CIPF($user_id);
|
||||
//schedule_prof_account_deletion_CIPF($user_id);
|
||||
|
||||
/*
|
||||
* check if payment is virement or immediat
|
||||
@@ -98,6 +98,16 @@ schedule_prof_account_deletion_CIPF($user_id);
|
||||
return new WP_Error('cannot_purchase', "price is 0, nothing to purchase");
|
||||
}
|
||||
|
||||
/*
|
||||
* if is new account and is only to change card
|
||||
*
|
||||
*/
|
||||
if (is_card_new_CIPF()) {
|
||||
if (is_acf_prof_change_card_CIPF()) {
|
||||
return new WP_Error('cannot_purchase', "account is new, you cannot change your card");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* date validity is empty
|
||||
|
||||
Reference in New Issue
Block a user