Skip to content

Commit

Permalink
Merge trunk v7.8.1 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
botwoo committed Jun 25, 2024
2 parents 8185eb3 + 121ce88 commit d28a69e
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 57 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*** WooPayments Changelog ***

= 7.8.1 - 2024-06-25 =
* Fix - Fix "Dispute not loaded" error that was affecting responding to disputes.

= 7.8.0 - 2024-06-19 =
* Add - Add a feedback survey modal upon deactivation.
* Add - Add new select component to be used for reporting filters, e.g. Payments overview currency select
Expand Down
4 changes: 4 additions & 0 deletions changelog/revert-8901-update-route-param-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix "Dispute not loaded" error that was affecting responding to disputes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<payment_intent_id>(ch|pi|py)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<payment_intent_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_authorization' ],
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/class-wc-rest-payments-charges-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WC_REST_Payments_Charges_Controller extends WC_Payments_REST_Controller {
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<charge_id>ch_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<charge_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_charge' ],
Expand All @@ -37,7 +37,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/order/(?P<order_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/order/(?P<order_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'generate_charge_from_order' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<customer_id>[A-Za-z0-9_\-]+)/payment_methods',
'/' . $this->rest_base . '/(?P<customer_id>\w+)/payment_methods',
[
[
'methods' => WP_REST_Server::READABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<deposit_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<deposit_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_deposit' ],
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/class-wc-rest-payments-disputes-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<dispute_id>(dp|dispute)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<dispute_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_dispute' ],
Expand All @@ -63,7 +63,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<dispute_id>(dp|dispute)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<dispute_id>\w+)',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'update_dispute' ],
Expand All @@ -72,7 +72,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<dispute_id>(dp|dispute)_[A-Za-z0-9]+)/close',
'/' . $this->rest_base . '/(?P<dispute_id>\w+)/close',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'close_dispute' ],
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/class-wc-rest-payments-files-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function register_routes() {

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<file_id>[A-Za-z0-9_\-]+)/details',
'/' . $this->rest_base . '/(?P<file_id>\w+)/details',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_file_detail' ],
Expand All @@ -45,7 +45,7 @@ public function register_routes() {

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<file_id>[A-Za-z0-9_\-]+)/content',
'/' . $this->rest_base . '/(?P<file_id>\w+)/content',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_file_content' ],
Expand All @@ -55,7 +55,7 @@ public function register_routes() {

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<file_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<file_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_file' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WC_REST_Payments_Fraud_Outcomes_Controller extends WC_Payments_REST_Contro
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[A-Za-z0-9_\-]+)/latest',
'/' . $this->rest_base . '/(?P<id>\w+)/latest',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_latest_fraud_outcome' ],
Expand Down
8 changes: 4 additions & 4 deletions includes/admin/class-wc-rest-payments-orders-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct( WC_Payments_API_Client $api_client, WC_Payment_Gate
public function register_routes() {
register_rest_route(
$this->namespace,
$this->rest_base . '/(?P<order_id>[A-Za-z0-9_\-]+)/capture_terminal_payment',
$this->rest_base . '/(?P<order_id>\w+)/capture_terminal_payment',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'capture_terminal_payment' ],
Expand All @@ -82,7 +82,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
$this->rest_base . '/(?P<order_id>[A-Za-z0-9_\-]+)/capture_authorization',
$this->rest_base . '/(?P<order_id>\w+)/capture_authorization',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'capture_authorization' ],
Expand All @@ -96,7 +96,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
$this->rest_base . '/(?P<order_id>[A-Za-z0-9_\-]+)/cancel_authorization',
$this->rest_base . '/(?P<order_id>\w+)/cancel_authorization',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'cancel_authorization' ],
Expand All @@ -110,7 +110,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
$this->rest_base . '/(?P<order_id>[A-Za-z0-9_\-]+)/create_terminal_intent',
$this->rest_base . '/(?P<order_id>\w+)/create_terminal_intent',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'create_terminal_intent' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WC_REST_Payments_Payment_Intents_Controller extends WC_Payments_REST_Contr
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<payment_intent_id>(ch|pi|py)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<payment_intent_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_payment_intent' ],
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/class-wc-rest-payments-reader-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function register_routes() {

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/charges/(?P<transaction_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/charges/(?P<transaction_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_summary' ],
Expand All @@ -132,7 +132,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/receipts/(?P<payment_intent_id>(ch|pi|py)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/receipts/(?P<payment_intent_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'generate_print_receipt' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<location_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<location_id>\w+)',
[
'methods' => WP_REST_Server::DELETABLE,
'callback' => [ $this, 'delete_location' ],
Expand All @@ -47,7 +47,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<location_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<location_id>\w+)',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'update_location' ],
Expand All @@ -66,7 +66,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<location_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<location_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_location' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WC_REST_Payments_Timeline_Controller extends WC_Payments_REST_Controller {
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<intention_id>(ch|pi|py)_[A-Za-z0-9]+)',
'/' . $this->rest_base . '/(?P<intention_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_timeline' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<transaction_id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<transaction_id>\w+)',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_transaction' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<id>\w+)',
[
[
'methods' => WP_REST_Server::READABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function register_routes() {
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[A-Za-z0-9_\-]+)',
'/' . $this->rest_base . '/(?P<id>\w+)',
[
[
'methods' => WP_REST_Server::READABLE,
Expand Down
26 changes: 0 additions & 26 deletions includes/wc-payment-api/class-wc-payments-api-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,8 @@ public function get_disputes( array $filters = [] ) {
*
* @param string $dispute_id id of requested dispute.
* @return array dispute object.
* @throws API_Exception - Exception thrown in case route validation fails.
*/
public function get_dispute( $dispute_id ) {
if ( ! preg_match( '/(dp|dispute)_[A-Za-z0-9]+/', $dispute_id ) ) {
throw new API_Exception(
__( 'Route param validation failed.', 'woocommerce-payments' ),
'wcpay_route_validation_failure',
400
);
}

$dispute = $this->request( [], self::DISPUTES_API . '/' . $dispute_id, self::GET );

if ( is_wp_error( $dispute ) ) {
Expand Down Expand Up @@ -735,17 +726,8 @@ public function create_token( $request ) {
* @return array
*
* @throws Exception - Exception thrown on request failure.
* @throws API_Exception - Exception thrown in case route validation fails.
*/
public function get_timeline( $id ) {
if ( ! preg_match( '/(ch|pi|py)_[A-Za-z0-9]+/', $id ) ) {
throw new API_Exception(
__( 'Route param validation failed.', 'woocommerce-payments' ),
'wcpay_route_validation_failure',
400
);
}

$timeline = $this->request( [], self::TIMELINE_API . '/' . $id, self::GET );

$has_fraud_outcome_event = false;
Expand Down Expand Up @@ -1187,14 +1169,6 @@ public function update_charge( string $charge_id, array $data = [] ) {
* @throws API_Exception
*/
public function get_charge( string $charge_id ) {
if ( ! preg_match( '/(ch|pi|py)_[A-Za-z0-9]+/', $charge_id ) ) {
throw new API_Exception(
__( 'Route param validation failed.', 'woocommerce-payments' ),
'wcpay_route_validation_failure',
400
);
}

return $this->request(
[],
self::CHARGES_API . '/' . $charge_id,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woocommerce-payments",
"version": "7.8.0",
"version": "7.8.1",
"main": "webpack.config.js",
"author": "Automattic",
"license": "GPL-3.0-or-later",
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.3
Stable tag: 7.8.0
Stable tag: 7.8.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -94,6 +94,10 @@ Please note that our support for the checkout block is still experimental and th

== Changelog ==

= 7.8.1 - 2024-06-25 =
* Fix - Fix "Dispute not loaded" error that was affecting responding to disputes.


= 7.8.0 - 2024-06-19 =
* Add - Add a feedback survey modal upon deactivation.
* Add - Add new select component to be used for reporting filters, e.g. Payments overview currency select
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* WC tested up to: 8.9.3
* Requires at least: 6.0
* Requires PHP: 7.3
* Version: 7.8.0
* Version: 7.8.1
* Requires Plugins: woocommerce
*
* @package WooCommerce\Payments
Expand Down

0 comments on commit d28a69e

Please sign in to comment.