35 private $errorsMap = [];
50 private $tokenRepository;
55 private $paymentTokenManagement;
74 $this->jsonFactory = $jsonFactory;
75 $this->fkValidator = $fkValidator;
77 $this->paymentTokenManagement = $paymentTokenManagement;
80 self::WRONG_TOKEN =>
__(
'No token found.'),
81 self::WRONG_REQUEST =>
__(
'Wrong request.'),
82 self::ACTION_EXCEPTION =>
__(
'Deletion failure. Please try again.')
96 return $this->createErrorResponse(self::WRONG_REQUEST);
99 if (!$this->fkValidator->validate(
$request)) {
100 return $this->createErrorResponse(self::WRONG_REQUEST);
105 return $this->createErrorResponse(self::WRONG_TOKEN);
110 }
catch (\Exception $e) {
111 return $this->createErrorResponse(self::ACTION_EXCEPTION);
114 return $this->createSuccessMessage();
121 private function createErrorResponse($errorCode)
123 $this->messageManager->addErrorMessage(
124 $this->errorsMap[$errorCode]
127 return $this->
_redirect(
'vault/cards/listaction');
133 private function createSuccessMessage()
135 $this->messageManager->addSuccessMessage(
136 __(
'Stored Payment Method was successfully removed')
138 return $this->
_redirect(
'vault/cards/listaction');
145 private function getPaymentToken(Http
$request)
149 if ($publicHash ===
null) {
153 return $this->paymentTokenManagement->getByPublicHash(
155 $this->customerSession->getCustomerId()
_redirect($path, $arguments=[])
__construct(Context $context, Session $customerSession, JsonFactory $jsonFactory, Validator $fkValidator, PaymentTokenRepositoryInterface $tokenRepository, PaymentTokenManagement $paymentTokenManagement)