Receiver email set separately for bw compat

This commit is contained in:
Peter Fabian 2022-03-07 19:53:14 +01:00 committed by Jonathan Sadowski
parent b1b68f52cd
commit 95ec1fc56e
2 changed files with 12 additions and 3 deletions

View File

@ -84,7 +84,8 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
if ( $this->identity_token ) { if ( $this->identity_token ) {
include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-pdt-handler.php'; 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 );
} }
} }

View File

@ -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 $identity_token Identity token for PDT support.
* @param string $receiver_email Email to receive PDT notification from. * @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' ) ); add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response_for_order' ) );
$this->receiver_email = $receiver_email;
$this->identity_token = $identity_token; $this->identity_token = $identity_token;
$this->sandbox = $sandbox; $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. * Validate a PDT transaction to ensure its authentic.
* *