Remove code duplication

This commit is contained in:
Alex P 2023-06-12 15:24:28 +03:00
parent 9db147679d
commit fde0aae9a0
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -9,12 +9,14 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Session\Cancellation;
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
/**
* Class CancelController
*/
class CancelController {
use ContextTrait;
public const NONCE = 'ppcp-cancel';
@ -61,20 +63,10 @@ class CancelController {
$this->session_handler->destroy_session_data();
}
$order = $this->session_handler->order();
if ( ! $order ) {
if ( ! $this->is_paypal_continuation() ) {
return;
}
$source = $order->payment_source();
if ( $source && $source->card() ) {
return; // Ignore for DCC.
}
if ( 'card' === $this->session_handler->funding_source() ) {
return; // Ignore for card buttons.
}
$url = add_query_arg( array( $param_name => wp_create_nonce( self::NONCE ) ), wc_get_checkout_url() );
add_action(
'woocommerce_review_order_after_submit',