also capturing pending paypal status

This commit is contained in:
Hugo LAMY
2026-02-11 12:33:52 +01:00
parent 17afb658af
commit cae655af7e
3 changed files with 19 additions and 12 deletions

View File

@@ -18,10 +18,6 @@ function handle_orders_capture_request_CIPF($request) {
/*
* ask paypal about the finished order
* update the client situation
* and return the response of paypal
*
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* - COMPLETED
* - DECLINED
@@ -32,11 +28,11 @@ function handle_orders_capture_request_CIPF($request) {
*
*/
try {
$response_json = capture_order_cipf($order_id);
$response_json = capture_order_CIPF($order_id);
$http_status_code = $response_json['http_status_code'];
$json_response = $response_json['json_response'];
update_user_post_capture_CIPF($json_response, 'end');
update_user_post_capture_CIPF($json_response);
return new WP_REST_Response($json_response, $http_status_code);
}

View File

@@ -98,8 +98,17 @@ function update_user_post_capture_CIPF($message) {
if ($user_id_to_update === false) {
throw new HttpException('cannot find user with this order_id', 502);
}
if ($status === 'COMPLETED') {
// proceed to validate payment for user
/*
* PayPal capture status: https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* - COMPLETED: Payment captured successfully
* - PENDING: Payment authorized, awaiting capture (valid for some payment methods)
* - DECLINED: Payment was declined
* - PARTIALLY_REFUNDED: Order partially refunded
* - REFUNDED: Order fully refunded
* - FAILED: Order failed
*/
if ($status === 'COMPLETED' || $status === 'PENDING') {
// proceed to validate payment for user (both COMPLETED and PENDING are successful)
success_payment_for_user_CIPF($user_id_to_update, $order_id);
}
else {