wip prof check page now handle the success message on paiement
This commit is contained in:
@@ -21,31 +21,6 @@ include_once(PLGNTLS_class::get_path() . '/php/paypal/routes.php');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
function check_paypal_request()
|
||||
{
|
||||
error_log("----");
|
||||
if (is_page('test_paypal_payment'))
|
||||
error_log("on test_paypal_payment");
|
||||
else if (is_page('test_paypal_ok'))
|
||||
error_log("on test_paypal_ok");
|
||||
else if (is_page('test_paypal_infos'))
|
||||
error_log("on test_paypal_infos");
|
||||
else
|
||||
return;
|
||||
error_log("_GET");
|
||||
error_log(json_encode($_GET));
|
||||
error_log("_POST");
|
||||
error_log(json_encode($_POST));
|
||||
// error_log("_COOKIE");
|
||||
// error_log(json_encode($_COOKIE));
|
||||
}
|
||||
add_action('template_redirect', 'check_paypal_request');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -26,7 +26,6 @@ function handle_orders_capture_request_FIPF($request) {
|
||||
return new WP_REST_Response($json_response, $http_status_code);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
error_log('Failed to capture order: ' . $e->getMessage());
|
||||
return new WP_REST_Response(array('error' => 'Failed to capture order.'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,22 @@ function update_user_payment_FIPF($message, $step) {
|
||||
// add a schedule event to delete this order_id
|
||||
schedule_delete_orderid_FIPF($user_id, $order_id);
|
||||
|
||||
/*
|
||||
* create a meta field to check states of payements on prof author page :
|
||||
* - 'started' -> payement started | at order creation (if seen on author page, it means failure)
|
||||
* - 'success' -> success payement | at order success (on author page, it means success, then empty it)
|
||||
* - '' -> no message to output | on author page (after set to empty on author page)
|
||||
*
|
||||
*/
|
||||
delete_user_meta($user_id, 'fipf_payement_status');
|
||||
add_user_meta($user_id, 'fipf_payement_status', 'started');
|
||||
|
||||
// if transaction is COMPLETED, then delete order_id and update user
|
||||
if ($status === 'COMPLETED') {
|
||||
// find the user containing the order_id and delete this order_id
|
||||
$user_id_to_update = delete_order_id_on_success_FIPF($user_id, $order_id);
|
||||
// change payement status to success
|
||||
update_user_meta($user_id_to_update, 'fipf_payement_status', 'success');
|
||||
// proceed to validate payment for user
|
||||
validate_payment_for_user_FIPF($user_id_to_update, $order_id);
|
||||
}
|
||||
@@ -132,14 +144,14 @@ function validate_payment_for_user_FIPF($user_id, $order_id) {
|
||||
* update date limit validity to add 1 year
|
||||
*
|
||||
*/
|
||||
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));;
|
||||
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));
|
||||
update_field($acf_card_expiration, $date_plus_one_year->format($acf_date_format), $acf_id);
|
||||
|
||||
/*
|
||||
* change user profil to active
|
||||
*
|
||||
*/
|
||||
update_field($prof_is_activ, 'Active', $acf_id)
|
||||
update_field($prof_is_activ, 'Actif', $acf_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +181,6 @@ function schedule_delete_orderid_FIPF($user_id, $order_id)
|
||||
*/
|
||||
function delete_order_id_later_FIPF($user_id, $order_id)
|
||||
{
|
||||
error_log("delete order_id[$order_id] from user_id[$user_id]");
|
||||
delete_user_meta($user_id, 'fipf_order_id', $order_id);
|
||||
}
|
||||
add_action('orderid_deletion_event_FIPF', 'delete_order_id_later_FIPF', 5, 2);
|
||||
|
||||
Reference in New Issue
Block a user