Commit 5f1ff32c authored by Rik ter Beek's avatar Rik ter Beek

If token is deleted, delete this on adyen side as well

parent f8e1aca4
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Magento\Vault\Api\Data\PaymentTokenInterface;
class PaymentVaultDeleteToken
{
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected $_paymentRequest;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* PaymentVaultDeleteToken constructor.
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
*/
public function __construct(
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_paymentRequest = $paymentRequest;
$this->_storeManager = $storeManager;
}
public function beforeDelete(\Magento\Vault\Api\PaymentTokenRepositoryInterface $subject, PaymentTokenInterface $paymentToken)
{
try {
$this->_paymentRequest->disableRecurringContract(
$paymentToken->getGatewayToken(),
$paymentToken->getCustomerId(),
$this->_storeManager->getStore()->getStoreId()
);
} catch(\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
}
}
}
\ No newline at end of file
......@@ -916,4 +916,10 @@
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement" />
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\AdyenPaymentMethodManagement" />
<preference for="Adyen\Payment\Api\AdyenRequestMerchantSessionInterface" type="Adyen\Payment\Model\AdyenRequestMerchantSession" />
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type>
</config>
\ 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