Override supports for PayPal to see if credentials exist

This commit is contained in:
Mike Jolley 2018-03-13 11:35:20 +00:00
parent 64f85346c0
commit 291de9c1fb
1 changed files with 25 additions and 0 deletions

View File

@ -87,6 +87,31 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
}
}
/**
* Check if a gateway supports a given feature.
*
* Gateways should override this to declare support (or lack of support) for a feature.
* For backward compatibility, gateways support 'products' by default, but nothing else.
*
* @param string $feature string The name of a feature to test support for.
* @return bool True if the gateway supports the feature, false otherwise.
*/
public function supports( $feature ) {
if ( 'refunds' === $feature ) {
// Ensure the gateway has API credentials.
$has_api_creds = false;
if ( $this->testmode ) {
$has_api_creds = $this->get_option( 'sandbox_api_username' ) && $this->get_option( 'sandbox_api_password' ) && $this->get_option( 'sandbox_api_signature' );
} else {
$has_api_creds = $this->get_option( 'api_username' ) && $this->get_option( 'api_password' ) && $this->get_option( 'api_signature' );
}
return $has_api_creds;
}
return parent::supports( $feature );
}
/**
* Logging method.
*