Commit 8d705218 authored by Maikel Koek's avatar Maikel Koek

B: Only delete Vault token remotely when payment method is Adyen

Fixes #297
parent 114a3aca
...@@ -27,7 +27,6 @@ use Magento\Vault\Api\Data\PaymentTokenInterface; ...@@ -27,7 +27,6 @@ use Magento\Vault\Api\Data\PaymentTokenInterface;
class PaymentVaultDeleteToken class PaymentVaultDeleteToken
{ {
/** /**
* @var \Adyen\Payment\Model\Api\PaymentRequest * @var \Adyen\Payment\Model\Api\PaymentRequest
*/ */
...@@ -52,6 +51,10 @@ class PaymentVaultDeleteToken ...@@ -52,6 +51,10 @@ class PaymentVaultDeleteToken
public function beforeDelete(\Magento\Vault\Api\PaymentTokenRepositoryInterface $subject, PaymentTokenInterface $paymentToken) public function beforeDelete(\Magento\Vault\Api\PaymentTokenRepositoryInterface $subject, PaymentTokenInterface $paymentToken)
{ {
if (strpos($paymentToken->getPaymentMethodCode(), 'adyen_') !== 0) {
return $paymentToken;
}
try { try {
$this->_paymentRequest->disableRecurringContract( $this->_paymentRequest->disableRecurringContract(
$paymentToken->getGatewayToken(), $paymentToken->getGatewayToken(),
...@@ -61,7 +64,5 @@ class PaymentVaultDeleteToken ...@@ -61,7 +64,5 @@ class PaymentVaultDeleteToken
} catch(\Exception $e) { } catch(\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract')); throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
} }
} }
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment