12 use Magento\Payment\Gateway\Command\Result\ArrayResultFactory;
25 private $tokenManagement;
30 private $adapterFactory;
35 private $resultFactory;
40 private $subjectReader;
45 private $responseValidator;
57 ArrayResultFactory $resultFactory,
61 $this->tokenManagement = $tokenManagement;
62 $this->adapterFactory = $adapterFactory;
63 $this->resultFactory = $resultFactory;
64 $this->subjectReader = $subjectReader;
65 $this->responseValidator = $responseValidator;
72 public function execute(array $commandSubject)
74 $publicHash = $this->subjectReader->readPublicHash($commandSubject);
75 $customerId = $this->subjectReader->readCustomerId($commandSubject);
78 throw new \Exception(
'No available payment tokens');
81 $storeId = $this->subjectReader->readStoreId($commandSubject);
84 $result = $this->responseValidator->validate([
'response' => [
'object' =>
$data]]);
87 throw new \Exception(
__(implode(
"\n",
$result->getFailsDescription())));
90 return $this->resultFactory->create([
'array' => [
'paymentMethodNonce' =>
$data->paymentMethodNonce->nonce]]);
__construct(PaymentTokenManagementInterface $tokenManagement, BraintreeAdapterFactory $adapterFactory, ArrayResultFactory $resultFactory, SubjectReader $subjectReader, PaymentNonceResponseValidator $responseValidator)
execute(array $commandSubject)