diff --git a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php index a54d891d125..658cec00094 100644 --- a/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php +++ b/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php @@ -84,7 +84,8 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway { if ( $this->identity_token ) { include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-pdt-handler.php'; - new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token, $this->receiver_email ); + $pdt_handler = new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token ); + $pdt_handler->set_receiver_email( $this->receiver_email ); } } diff --git a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php index 51c5deeb378..dd31b02d303 100644 --- a/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php +++ b/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php @@ -39,14 +39,22 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response { * @param string $identity_token Identity token for PDT support. * @param string $receiver_email Email to receive PDT notification from. */ - public function __construct( $sandbox = false, $identity_token = '', $receiver_email = '' ) { + public function __construct( $sandbox = false, $identity_token = '' ) { add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response_for_order' ) ); - $this->receiver_email = $receiver_email; $this->identity_token = $identity_token; $this->sandbox = $sandbox; } + /** + * Set receiver email to enable more strict validation. + * + * @param string $receiver_email PayPal reciever email. + */ + public function set_receiver_email( $receiver_email = '' ) { + $this->receiver_email = $receiver_email; + } + /** * Validate a PDT transaction to ensure its authentic. *