updates acf fields const values in class to avoid errors
This commit is contained in:
@@ -51,6 +51,8 @@ function handle_orders_request_CIPF($request_data) {
|
||||
//function create_order_CIPF($cart)
|
||||
function create_order_CIPF()
|
||||
{
|
||||
$paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL;
|
||||
|
||||
// use the cart information passed from the front-end to calculate the purchase unit details
|
||||
|
||||
$access_token = generate_access_token_CIPF();
|
||||
@@ -59,7 +61,7 @@ function create_order_CIPF()
|
||||
$acf_id = 'user_' . $user_id;
|
||||
$price = get_field('somme_a_regler', $acf_id);
|
||||
|
||||
$url = PAYPAL_API_BASE_URL . '/v2/checkout/orders';
|
||||
$url = $paypal_api_base_url . '/v2/checkout/orders';
|
||||
$payload = array(
|
||||
'intent' => "CAPTURE",
|
||||
'note' => 'ERRPYO005',
|
||||
|
||||
@@ -17,7 +17,7 @@ function handle_orders_capture_request_CIPF($request) {
|
||||
// Implement captureOrder function logic here
|
||||
// Make sure you implement captureOrder function similar to the Node.js code
|
||||
|
||||
$response_data = capture_order_CIPF($order_id);
|
||||
$response_data = capture_order_cipf($order_id);
|
||||
$http_status_code = $response_data['http_status_code'];
|
||||
$json_response = $response_data['json_response'];
|
||||
|
||||
@@ -35,9 +35,10 @@ function handle_orders_capture_request_CIPF($request) {
|
||||
* Capture payment for the created order to complete the transaction.
|
||||
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||
*/
|
||||
function capture_order_CIPF($orderID) {
|
||||
function capture_order_CIPF($order_id) {
|
||||
$paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL;
|
||||
$access_token = generate_access_token_CIPF();
|
||||
$url = PAYPAL_API_BASE_URL . '/v2/checkout/orders/' . $orderID . '/capture';
|
||||
$url = $paypal_api_base_url . '/v2/checkout/orders/' . $order_id . '/capture';
|
||||
|
||||
$headers = array(
|
||||
"Content-Type: application/json",
|
||||
|
||||
@@ -38,6 +38,8 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function update_user_payment_CIPF($message, $step) {
|
||||
$meta_payement_status = PLGNTLS_class::META_PAYEMENT_STATUS;
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
$status = $message->status;
|
||||
@@ -55,15 +57,15 @@ function update_user_payment_CIPF($message, $step) {
|
||||
* - '' -> no message to output | on author page (after set to empty on author page)
|
||||
*
|
||||
*/
|
||||
delete_user_meta($user_id, 'cipf_payement_status');
|
||||
add_user_meta($user_id, 'cipf_payement_status', 'started');
|
||||
delete_user_meta($user_id, $meta_payement_status);
|
||||
add_user_meta($user_id, $meta_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_CIPF($user_id, $order_id);
|
||||
// change payement status to success
|
||||
update_user_meta($user_id_to_update, 'cipf_payement_status', 'success');
|
||||
update_user_meta($user_id_to_update, $meta_payement_status, 'success');
|
||||
// proceed to validate payment for user
|
||||
validate_payment_for_user_CIPF($user_id_to_update, $order_id);
|
||||
}
|
||||
@@ -92,18 +94,13 @@ function update_user_payment_CIPF($message, $step) {
|
||||
function validate_payment_for_user_CIPF($user_id, $order_id) {
|
||||
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE;
|
||||
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
|
||||
$acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW;
|
||||
$card_duration = PLGNTLS_class::CARD_VALIDITY_TIME;
|
||||
$prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||
|
||||
$acf_date_format = 'Y-m-d H:i:s';
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
/*
|
||||
* update card validity to true
|
||||
*
|
||||
*/
|
||||
update_field($acf_card_state, 'Renouvellement', $acf_id);
|
||||
|
||||
$date_now = date_create('today');
|
||||
/*
|
||||
* update purchase date to now
|
||||
@@ -151,10 +148,12 @@ function validate_payment_for_user_CIPF($user_id, $order_id) {
|
||||
* change user profil :
|
||||
* - to active
|
||||
* - card state is renewal
|
||||
* - cannot renew
|
||||
*
|
||||
*/
|
||||
update_field($prof_is_activ, 'Actif', $acf_id);
|
||||
update_field($acf_card_state, 'Renouvellement', $acf_id);
|
||||
update_field($prof_is_activ['_name'], $prof_is_activ['activ'], $acf_id);
|
||||
update_field($acf_card_state['_name'], $acf_card_state['renew'], $acf_id);
|
||||
update_field($acf_prof_can_renew['_name'], $acf_prof_can_renew['cannot'] , $acf_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
* default true
|
||||
*/
|
||||
function can_pay_now_CIPF() {
|
||||
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE;
|
||||
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
|
||||
@@ -23,7 +22,7 @@ function can_pay_now_CIPF() {
|
||||
/*
|
||||
* check if payment is virement or immediat
|
||||
*
|
||||
$payement = get_field($acf_card_payment_method, $acf_id);
|
||||
$payement = get_field($acf_card_payment_method['_name'], $acf_id);
|
||||
if (strtolower($payement) === 'virement') {
|
||||
return false;
|
||||
}
|
||||
@@ -35,8 +34,8 @@ function can_pay_now_CIPF() {
|
||||
* in case it was changed from admin pannel
|
||||
*
|
||||
*/
|
||||
$tarif = (int)get_field($acf_card_price_choice, $acf_id);
|
||||
$livraison = (int)get_field($acf_card_price_delivery, $acf_id);
|
||||
$tarif = (int)get_field($acf_card_price_choice['_name'], $acf_id);
|
||||
$livraison = (int)get_field($acf_card_price_delivery['_name'], $acf_id);
|
||||
$price = $tarif + $livraison;
|
||||
update_field($acf_card_price_total, $price, $acf_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user