← All changes
|
inc/rest-api/v1/frontend/class-lp-rest-gateway-webhook-controller.php
+5
-4
4.4.0
→
4.4.9
View file →
| @@ -52,15 +52,15 @@ | ||
| 52 | 52 | * @param WP_REST_Request $request |
| 53 | 53 | * |
| 54 | 54 | * @return Response |
| 55 | 55 | * @since 4.3.7 |
| 56 | - * @version 1.0.0 | |
| 56 | + * @version 1.0.1 | |
| 57 | 57 | */ |
| 58 | 58 | public function listen_subscription_webhook( WP_REST_Request $request ): Response { |
| 59 | - $response = new Response(); | |
| 59 | + $response = new Response(); | |
| 60 | + $gateway_id = sanitize_key( (string) $request->get_param( 'gateway' ) ); | |
| 60 | 61 | |
| 61 | 62 | try { |
| 62 | - $gateway_id = sanitize_key( (string) $request->get_param( 'gateway' ) ); | |
| 63 | 63 | if ( empty( $gateway_id ) ) { |
| 64 | 64 | throw new Exception( __( 'Gateway is required.', 'learnpress' ), 400 ); |
| 65 | 65 | } |
| 66 | 66 | |
| @@ -72,9 +72,9 @@ | ||
| 72 | 72 | if ( ! $gateway->is_enabled() ) { |
| 73 | 73 | throw new Exception( __( 'Gateway is not enable.', 'learnpress' ), 404 ); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - LP_Debug::log_to_comment( 'Webhook payload: ' . json_encode( $request->get_body(), JSON_UNESCAPED_UNICODE ) ); | |
| 76 | + //LP_Debug::log_to_comment( 'Webhook payload: ' . json_encode( $request->get_body(), JSON_UNESCAPED_UNICODE ) ); | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @var LP_Gateway_Paypal|LP_Gateway_Stripe $gateway |
| 80 | 80 | */ |
| @@ -79,8 +79,9 @@ | ||
| 79 | 79 | * @var LP_Gateway_Paypal|LP_Gateway_Stripe $gateway |
| 80 | 80 | */ |
| 81 | 81 | $gateway->capture_subscription_webhook( $request ); |
| 82 | 82 | } catch ( Throwable $e ) { |
| 83 | + LP_Debug::log_to_comment( 'Webhook error: ' . $gateway_id . ' - ' . $e->getMessage() ); | |
| 83 | 84 | LP_Debug::error_log( $e ); |
| 84 | 85 | $response->message = $e->getMessage(); |
| 85 | 86 | } |
| 86 | 87 | |