Skip to content

Instantly share code, notes, and snippets.

@htdat
Created December 31, 2022 10:03
Show Gist options
  • Save htdat/6a52eec1be77b8442ac05401908a3627 to your computer and use it in GitHub Desktop.
Save htdat/6a52eec1be77b8442ac05401908a3627 to your computer and use it in GitHub Desktop.
<?php
// Prevent maybe_process_upe_redirect. For testing UPE flow.
// Stop at this point https://github.com/Automattic/woocommerce-payments/blob/41efc3b23fe952fefdb646eb6980cf8faa90489f/includes/payment-methods/class-upe-payment-gateway.php#L591
add_action(
'check_admin_referer',
function( $action ) {
if ( 'wcpay_process_redirect_order_nonce' === $action ) {
exit('Prevent maybe_process_upe_redirect');
}
}
);
// For testing non-UPE flow - 3DS card
// Stop code execution at this point https://github.com/Automattic/woocommerce-payments/blob/41efc3b23fe952fefdb646eb6980cf8faa90489f/includes/class-wc-payment-gateway-wcpay.php#L2492-L2492
add_action(
'check_ajax_referer',
function( $action ) {
if ( 'wcpay_update_order_status_nonce' === $action ) {
exit('Prevent update_order_status');
}
}
);
// Prevent processing the webhook endpoint
add_filter( 'rest_pre_dispatch',
function ( $response, $wp_rest_server, $request ) {
if( '/wc/v3/payments/webhook' === $request->get_route() ) {
$response = new WP_Error(
503,
'Prevent the webhook endpoint for testing WCPay'
);
}
return $response;
},
10,
3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment