Changeset 3102357
- Timestamp:
- 06/13/2024 01:57:56 PM (22 months ago)
- Location:
- yoco-payment-gateway
- Files:
-
- 14 edited
- 1 copied
-
tags/3.6.0 (copied) (copied from yoco-payment-gateway/trunk)
-
tags/3.6.0/README.md (modified) (1 diff)
-
tags/3.6.0/readme.txt (modified) (2 diffs)
-
tags/3.6.0/src/Gateway/Processors/OptionsProcessor.php (modified) (2 diffs)
-
tags/3.6.0/src/Integrations/Yoco/Webhooks/REST/Routes/Webhook.php (modified) (1 diff)
-
tags/3.6.0/src/Telemetry/Models/TelemetryObject.php (modified) (2 diffs)
-
tags/3.6.0/src/Telemetry/Telemetry.php (modified) (1 diff)
-
tags/3.6.0/yoco_wc_payment_gateway.php (modified) (1 diff)
-
trunk/README.md (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Gateway/Processors/OptionsProcessor.php (modified) (2 diffs)
-
trunk/src/Integrations/Yoco/Webhooks/REST/Routes/Webhook.php (modified) (1 diff)
-
trunk/src/Telemetry/Models/TelemetryObject.php (modified) (2 diffs)
-
trunk/src/Telemetry/Telemetry.php (modified) (1 diff)
-
trunk/yoco_wc_payment_gateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yoco-payment-gateway/tags/3.6.0/README.md
r2953749 r3102357 42 42 - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) 43 43 - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) 44 45 ### Note 46 To update version, update it in the: 47 - [package.json](package.json) 48 - [readme.txt](readme.txt) 49 - [yoco_wc_payment_gateway.php](yoco_wc_payment_gateway.php) 44 50 45 51 *** -
yoco-payment-gateway/tags/3.6.0/readme.txt
r3067451 r3102357 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.4.0 7 Stable tag: 3. 5.07 Stable tag: 3.6.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 137 137 == Changelog == 138 138 139 = 3.6.0 = 140 * Conditionally reset installation idempotency key. 141 * Extend the installation telemetry data. 142 139 143 = 3.5.0 = 140 144 * Add payment status polling as fallback method. -
yoco-payment-gateway/tags/3.6.0/src/Gateway/Processors/OptionsProcessor.php
r3067423 r3102357 34 34 35 35 $response = $installationRequest->send(); 36 37 // If we get 500 error, reset Idempotence Key and retry the request. 38 if ( 500 === (int) $response['code'] ) { 39 add_filter( 'yoco_payment_gateway/installation/request/headers', array( $this, 'resetIdempotenceKey' ) ); 40 41 $response = $installationRequest->send(); 42 } 36 43 37 44 if ( ! in_array( $response['code'], array( 200, 201, 202 ) ) ) { … … 100 107 } 101 108 } 109 110 public function resetIdempotenceKey( $headers ) { 111 if ( ! isset( $headers['Idempotency-Key'] ) || ! is_scalar( $headers['Idempotency-Key'] ) ) { 112 return $headers; 113 } 114 115 $headers['Idempotency-Key'] = hash( 'SHA256', $headers['Idempotency-Key'] . time() ); 116 117 return $headers; 118 } 102 119 } -
yoco-payment-gateway/tags/3.6.0/src/Integrations/Yoco/Webhooks/REST/Routes/Webhook.php
r2972271 r3102357 28 28 29 29 public function callback( WP_REST_Request $request ): WP_REST_Response { 30 return ( new WebhookController( $request ) )->handleRequest(); 30 return wp_salt() === json_decode( $request->get_body() ) 31 ? new WP_REST_Response( 'OK', 200 ) 32 : ( new WebhookController( $request ) )->handleRequest(); 31 33 } 32 34 33 35 public function permit( WP_REST_Request $request ): bool { 34 return yoco( Guard::class )->verifySignature( $request );36 return wp_salt() === json_decode( $request->get_body() ) ? true : yoco( Guard::class )->verifySignature( $request ); 35 37 } 36 38 } -
yoco-payment-gateway/tags/3.6.0/src/Telemetry/Models/TelemetryObject.php
r3067423 r3102357 13 13 14 14 private ?string $host = null; 15 16 private ?array $webhook = null; 15 17 16 18 private ?string $url = null; … … 48 50 49 51 return $this->host; 52 } 53 54 public function getWebhook(): array { 55 if ( null === $this->webhook ) { 56 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only comparing the value. 57 $cache = isset( $_GET['section'] ) && 'class_yoco_wc_payment_gateway' === $_GET['section'] ? false : get_transient( 'yoco_available_webhooks' ); 58 $webhook = array(); 59 60 if ( is_array( $cache ) ) { 61 $this->webhook = $cache; 62 63 return $this->webhook; 64 } 65 66 $args = array( 67 'headers' => array( 68 'Content-Type' => 'application/json', 69 ), 70 'body' => wp_json_encode( wp_salt() ), 71 'timeout' => 10, 72 ); 73 74 $endpoints = array( 75 '/index.php?rest_route=/yoco/webhook', 76 '/yoco/webhook', 77 '/wp-json/yoco/webhook', 78 ); 79 80 foreach ( $endpoints as $endpoint ) { 81 $result = wp_remote_post( $this->getHostUrl() . $endpoint, $args ); 82 $webhook[] = array( 83 'endpoint' => $endpoint, 84 'status' => 200 === wp_remote_retrieve_response_code( $result ), 85 ); 86 } 87 88 $this->webhook = $webhook; 89 90 set_transient( 'yoco_available_webhooks', $this->webhook ); 91 } 92 93 return $this->webhook; 50 94 } 51 95 -
yoco-payment-gateway/tags/3.6.0/src/Telemetry/Telemetry.php
r3005796 r3102357 18 18 array( 19 19 'domain' => $object->getHostUrl(), 20 'webhook' => $object->getWebhook(), 20 21 'installationName' => $object->getSiteName(), 21 22 'phpVersion' => $object->getPhpVersion(), -
yoco-payment-gateway/tags/3.6.0/yoco_wc_payment_gateway.php
r3067423 r3102357 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3. 5.08 * Version: 3.6.0 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.5 -
yoco-payment-gateway/trunk/README.md
r2953749 r3102357 42 42 - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) 43 43 - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) 44 45 ### Note 46 To update version, update it in the: 47 - [package.json](package.json) 48 - [readme.txt](readme.txt) 49 - [yoco_wc_payment_gateway.php](yoco_wc_payment_gateway.php) 44 50 45 51 *** -
yoco-payment-gateway/trunk/readme.txt
r3067451 r3102357 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.4.0 7 Stable tag: 3. 5.07 Stable tag: 3.6.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 137 137 == Changelog == 138 138 139 = 3.6.0 = 140 * Conditionally reset installation idempotency key. 141 * Extend the installation telemetry data. 142 139 143 = 3.5.0 = 140 144 * Add payment status polling as fallback method. -
yoco-payment-gateway/trunk/src/Gateway/Processors/OptionsProcessor.php
r3067423 r3102357 34 34 35 35 $response = $installationRequest->send(); 36 37 // If we get 500 error, reset Idempotence Key and retry the request. 38 if ( 500 === (int) $response['code'] ) { 39 add_filter( 'yoco_payment_gateway/installation/request/headers', array( $this, 'resetIdempotenceKey' ) ); 40 41 $response = $installationRequest->send(); 42 } 36 43 37 44 if ( ! in_array( $response['code'], array( 200, 201, 202 ) ) ) { … … 100 107 } 101 108 } 109 110 public function resetIdempotenceKey( $headers ) { 111 if ( ! isset( $headers['Idempotency-Key'] ) || ! is_scalar( $headers['Idempotency-Key'] ) ) { 112 return $headers; 113 } 114 115 $headers['Idempotency-Key'] = hash( 'SHA256', $headers['Idempotency-Key'] . time() ); 116 117 return $headers; 118 } 102 119 } -
yoco-payment-gateway/trunk/src/Integrations/Yoco/Webhooks/REST/Routes/Webhook.php
r2972271 r3102357 28 28 29 29 public function callback( WP_REST_Request $request ): WP_REST_Response { 30 return ( new WebhookController( $request ) )->handleRequest(); 30 return wp_salt() === json_decode( $request->get_body() ) 31 ? new WP_REST_Response( 'OK', 200 ) 32 : ( new WebhookController( $request ) )->handleRequest(); 31 33 } 32 34 33 35 public function permit( WP_REST_Request $request ): bool { 34 return yoco( Guard::class )->verifySignature( $request );36 return wp_salt() === json_decode( $request->get_body() ) ? true : yoco( Guard::class )->verifySignature( $request ); 35 37 } 36 38 } -
yoco-payment-gateway/trunk/src/Telemetry/Models/TelemetryObject.php
r3067423 r3102357 13 13 14 14 private ?string $host = null; 15 16 private ?array $webhook = null; 15 17 16 18 private ?string $url = null; … … 48 50 49 51 return $this->host; 52 } 53 54 public function getWebhook(): array { 55 if ( null === $this->webhook ) { 56 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only comparing the value. 57 $cache = isset( $_GET['section'] ) && 'class_yoco_wc_payment_gateway' === $_GET['section'] ? false : get_transient( 'yoco_available_webhooks' ); 58 $webhook = array(); 59 60 if ( is_array( $cache ) ) { 61 $this->webhook = $cache; 62 63 return $this->webhook; 64 } 65 66 $args = array( 67 'headers' => array( 68 'Content-Type' => 'application/json', 69 ), 70 'body' => wp_json_encode( wp_salt() ), 71 'timeout' => 10, 72 ); 73 74 $endpoints = array( 75 '/index.php?rest_route=/yoco/webhook', 76 '/yoco/webhook', 77 '/wp-json/yoco/webhook', 78 ); 79 80 foreach ( $endpoints as $endpoint ) { 81 $result = wp_remote_post( $this->getHostUrl() . $endpoint, $args ); 82 $webhook[] = array( 83 'endpoint' => $endpoint, 84 'status' => 200 === wp_remote_retrieve_response_code( $result ), 85 ); 86 } 87 88 $this->webhook = $webhook; 89 90 set_transient( 'yoco_available_webhooks', $this->webhook ); 91 } 92 93 return $this->webhook; 50 94 } 51 95 -
yoco-payment-gateway/trunk/src/Telemetry/Telemetry.php
r3005796 r3102357 18 18 array( 19 19 'domain' => $object->getHostUrl(), 20 'webhook' => $object->getWebhook(), 20 21 'installationName' => $object->getSiteName(), 21 22 'phpVersion' => $object->getPhpVersion(), -
yoco-payment-gateway/trunk/yoco_wc_payment_gateway.php
r3067423 r3102357 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3. 5.08 * Version: 3.6.0 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.5
Note: See TracChangeset
for help on using the changeset viewer.