PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 6.3.1
Pay with Vipps and MobilePay for WooCommerce v6.3.1
6.3.1 6.2.6 6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 All 190 releases
← All changes | recurring/includes/wc-vipps-recurring-rest-api.php +25 -8 6.1.2 → 6.3.1 View file →
@@ -43,9 +43,9 @@
43 43 $order_key = $request->get_param( 'key' );
44 44
45 45 $order = wc_get_order( $order_id );
46 46
47 - if ( ! $order || $order_key !== $order->get_order_key() ) {
47 + if ( ! $order || ! is_string( $order_key ) || ! hash_equals( $order->get_order_key(), $order_key ) ) {
48 48 return new WP_Error(
49 49 'not_found',
50 50 'Order not found.',
51 51 [ 'status' => 404 ]
@@ -57,23 +57,40 @@
57 57 do_action( 'wc_vipps_recurring_before_rest_api_check_order_status', $order_id );
58 58
59 59 // Skip the lock here, otherwise we get a false result
60 60 $gateway->check_charge_status( $order_id, true );
61 + $order = wc_get_order( $order_id );
61 62 $agreement_id = WC_Vipps_Recurring_Helper::get_agreement_id_from_order( $order );
62 63
63 64 if ( ! $agreement_id ) {
64 - return new WP_Error(
65 - 'not_found',
66 - 'Subscription not found.',
67 - [ 'status' => 404 ]
68 - );
65 + return new WP_REST_Response( [
66 + 'status' => 'PENDING',
67 + 'redirect_url' => false
68 + ], 202 );
69 69 }
70 70
71 - $agreement = $gateway->api->get_agreement( $agreement_id );
71 + try {
72 + $agreement = $gateway->api->get_agreement( $agreement_id );
73 + } catch ( WC_Vipps_Recurring_Exception $exception ) {
74 + if ( $exception->response_code !== 404 ) {
75 + throw $exception;
76 + }
72 77
78 + return new WP_REST_Response( [
79 + 'status' => 'PENDING',
80 + 'redirect_url' => false
81 + ], 202 );
82 + }
83 +
73 84 do_action( 'wc_vipps_recurring_after_rest_api_check_order_status', $order_id );
74 85
75 - $return_url = $order->get_checkout_order_received_url();
86 + $return_url = false;
87 + if ( $agreement->status !== 'PENDING' ) {
88 + if ( $agreement->status === 'ACTIVE' && class_exists( WC_Vipps_Recurring_Checkout::class ) ) {
89 + WC_Vipps_Recurring_Checkout::get_instance()->maybe_login_checkout_user( $order->get_id(), $order_key );
90 + }
91 + $return_url = $order->get_checkout_order_received_url();
92 + }
76 93
77 94 return [
78 95 'status' => $agreement->status,
79 96 'redirect_url' => $return_url