better handle transfert validation
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: cipf_plugin
|
|||||||
Plugin URI:
|
Plugin URI:
|
||||||
Description:
|
Description:
|
||||||
Author: hugogogo
|
Author: hugogogo
|
||||||
Version: 0.3.11
|
Version: 0.3.11.1
|
||||||
Author URI:
|
Author URI:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
|
|||||||
* change status to :
|
* change status to :
|
||||||
* if paypal & new prof : 'to pay'
|
* if paypal & new prof : 'to pay'
|
||||||
* if paypal & expired card : 'to_pay'
|
* if paypal & expired card : 'to_pay'
|
||||||
* if transfert $ expired card : 'waiting_invalid'
|
* if transfert $ expired card : 'waiting_invalid', reset transfert validation
|
||||||
* if transfert $ valid card : 'waiting_valid'
|
* if transfert $ valid card : 'waiting_valid' , reset transfert validation
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (is_payment_method_paypal_CIPF($user_id)) {
|
if (is_payment_method_paypal_CIPF($user_id)) {
|
||||||
@@ -58,6 +58,7 @@ function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
|
|||||||
else if (is_account_valid_CIPF($user_id)) {
|
else if (is_account_valid_CIPF($user_id)) {
|
||||||
set_account_waiting_valid_CIPF($user_id);
|
set_account_waiting_valid_CIPF($user_id);
|
||||||
}
|
}
|
||||||
|
reset_acf_transfert_CIPF($user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3);
|
add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3);
|
||||||
|
|||||||
@@ -30,11 +30,26 @@ function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* when transfert is validate, change card to valid
|
* check if transfert was waiting, if no stop here
|
||||||
|
* when transfert is validate,
|
||||||
|
* - change card to valid
|
||||||
|
* - and reset the field
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
$is_transfert = false;
|
||||||
|
if (is_account_waiting_valid_CIPF($user_id)) {
|
||||||
|
$is_transfert = true;
|
||||||
|
}
|
||||||
|
else if (is_account_waiting_invalid_CIPF($user_id)) {
|
||||||
|
$is_transfert = true;
|
||||||
|
}
|
||||||
|
if ($is_transfert === false) {
|
||||||
|
reset_acf_transfert_CIPF($user_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (is_transfert_success_CIPF($user_id)) {
|
if (is_transfert_success_CIPF($user_id)) {
|
||||||
set_account_valid_CIPF($user_id);
|
set_account_valid_CIPF($user_id);
|
||||||
|
reset_acf_transfert_CIPF($user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('df_after_process', 'prof_after_form_transfert_validation_CIPF', 10, 3);
|
add_action('df_after_process', 'prof_after_form_transfert_validation_CIPF', 10, 3);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if (!defined('ABSPATH')) {
|
|||||||
*
|
*
|
||||||
* [/] cgv
|
* [/] cgv
|
||||||
*
|
*
|
||||||
* [/] etat_virement -> ko 0/2 : [1: at form validation - ko], [2: check on profil page - ko]
|
* [/] etat_virement -> ko 2/3 : [1: at form validation - ok], [2: check on profil page - ko], [3: when transfert is started, reset - ok]]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -374,21 +374,31 @@ function is_transfert_success_CIPF($user_id = null) {
|
|||||||
$acf_id = 'user_'.$user_id;
|
$acf_id = 'user_'.$user_id;
|
||||||
$transfert_state = get_field($acf_transfert_state['_name'], $acf_id);
|
$transfert_state = get_field($acf_transfert_state['_name'], $acf_id);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* before first use : returns null
|
* before first use : returns null
|
||||||
* if checked : returns value
|
* if checked : returns value
|
||||||
* if unchecked : returns empty
|
* if unchecked : returns empty
|
||||||
*/
|
*/
|
||||||
if (empty($transfert_state)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (is_null($transfert_state)) {
|
if (is_null($transfert_state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (reset($transfert_state) === $acf_transfert_state['success']) {
|
else if (empty($transfert_state)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
function reset_acf_transfert_CIPF($user_id = null) {
|
||||||
|
PLGNTLS_class::debug_infos();
|
||||||
|
$acf_transfert_state = PLGNTLS_class::ACF_TRANSFERT_STATE;
|
||||||
|
|
||||||
|
if (is_null($user_id)) {
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
}
|
||||||
|
$acf_id = 'user_'.$user_id;
|
||||||
|
update_field($acf_transfert_state['_name'], array(""), $acf_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user