Commit 46bc4c90 authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #298 from ho-nl-fork/delete-plugin

B: Only delete Vault token remotely when payment method is Adyen
parents 114a3aca d7b5dd97
...@@ -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