17 use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
44 private static $activeKey =
'active';
49 private static $titleKey =
'title';
54 private $configFactory;
64 private $vaultProvider;
69 private $objectManager;
79 private $valueHandlerPool;
84 private $eventManager;
89 private $commandManagerPool;
94 private $tokenManagement;
99 private $paymentExtensionFactory;
131 OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
137 $this->valueHandlerPool = $valueHandlerPool;
138 $this->vaultProvider = $vaultProvider;
139 $this->eventManager = $eventManager;
140 $this->commandManagerPool = $commandManagerPool;
141 $this->tokenManagement = $tokenManagement;
149 private function getVaultProvider()
151 return $this->vaultProvider;
161 private function getConfiguredValue($field, $storeId =
null)
163 $handler = $this->valueHandlerPool->get($field);
164 $subject = [
'field' => $field];
193 return $this->getConfiguredValue(self::$titleKey);
202 $this->storeId = (int)$storeId;
211 return $this->storeId;
229 return $this->getVaultProvider()->canAuthorize()
230 && $this->getVaultProvider()->getConfigData(static::CAN_AUTHORIZE);
239 return $this->getVaultProvider()->canCapture()
240 && $this->getVaultProvider()->getConfigData(static::CAN_CAPTURE);
258 return $this->getVaultProvider()->canCaptureOnce();
294 $isInternalAllowed = $this->getConfiguredValue(
'can_use_internal');
296 if ($isInternalAllowed ===
null) {
297 return $this->getVaultProvider()->canUseInternal();
299 return (
bool) $isInternalAllowed;
308 return $this->getVaultProvider()->canUseCheckout();
317 return $this->getVaultProvider()->canEdit();
335 throw new \DomainException(
"Not implemented");
344 return $this->getVaultProvider()->isGateway();
353 return $this->getVaultProvider()->isOffline();
362 return $this->getVaultProvider()->isInitializeNeeded();
371 return $this->getVaultProvider()->canUseForCountry($country);
380 return $this->getVaultProvider()->canUseForCurrency($currencyCode);
389 return $this->getVaultProvider()->getInfoBlockType();
398 return $this->getVaultProvider()->getInfoInstance();
407 $this->getVaultProvider()->setInfoInstance(
$info);
416 return $this->getVaultProvider()->validate();
425 throw new \DomainException(
"Not implemented");
435 throw new \DomainException(
'Not implemented');
439 $this->attachTokenExtensionAttribute(
$payment);
441 $commandExecutor = $this->commandManagerPool->get(
442 $this->getVaultProvider()->
getCode()
445 $commandExecutor->executeByCode(
464 if (!
$payment instanceof OrderPaymentInterface) {
465 throw new \DomainException(
'Not implemented');
469 if (
$payment->getAuthorizationTransaction()) {
470 throw new \DomainException(
'Capture can not be performed through vault');
473 $this->attachTokenExtensionAttribute(
$payment);
475 $commandExecutor = $this->commandManagerPool->get(
476 $this->getVaultProvider()->
getCode()
479 $commandExecutor->executeByCode(
494 private function attachTokenExtensionAttribute(OrderPaymentInterface $orderPayment)
496 $additionalInformation = $orderPayment->getAdditionalInformation();
498 throw new \LogicException(
'Public hash should be defined');
509 throw new \LogicException(
"No token found");
520 private function getPaymentExtensionAttributes(OrderPaymentInterface
$payment)
537 throw new \DomainException(
"Not implemented");
546 throw new \DomainException(
"Not implemented");
555 throw new \DomainException(
"Not implemented");
564 throw new \DomainException(
"Not implemented");
573 throw new \DomainException(
"Not implemented");
582 throw new \DomainException(
"Not implemented");
591 return $this->getConfiguredValue($field, $storeId);
600 $this->eventManager->dispatch(
601 'payment_method_assign_data_vault',
609 $this->eventManager->dispatch(
618 return $this->getVaultProvider()->assignData(
$data);
627 return $this->getVaultProvider()->isAvailable(
$quote)
628 && $this->config->getValue(self::$activeKey, $this->
getStore() ?: (
$quote ?
$quote->getStoreId() :
null));
637 return $this->getVaultProvider()->isActive($storeId)
638 && $this->config->getValue(self::$activeKey, $this->
getStore() ?: $storeId);
647 throw new \DomainException(
"Not implemented");
656 return $this->getVaultProvider()->getConfigPaymentAction();
665 return $this->getVaultProvider()->getCode();
getConfigData($field, $storeId=null)
fetchTransactionInfo(InfoInterface $payment, $transactionId)
canFetchTransactionInfo()
cancel(\Magento\Payment\Model\InfoInterface $payment)
refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
order(\Magento\Payment\Model\InfoInterface $payment, $amount)
__construct(ConfigInterface $config, ConfigFactoryInterface $configFactory, ObjectManagerInterface $objectManager, MethodInterface $vaultProvider, ManagerInterface $eventManager, ValueHandlerPoolInterface $valueHandlerPool, Command\CommandManagerPoolInterface $commandManagerPool, PaymentTokenManagementInterface $tokenManagement, OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory, $code)
void(\Magento\Payment\Model\InfoInterface $payment)
assignData(\Magento\Framework\DataObject $data)
setInfoInstance(InfoInterface $info)
canRefundPartialPerInvoice()
canUseForCurrency($currencyCode)
denyPayment(InfoInterface $payment)
canUseForCountry($country)
isAvailable(\Magento\Quote\Api\Data\CartInterface $quote=null)
const VAULT_AUTHORIZE_COMMAND
initialize($paymentAction, $stateObject)
acceptPayment(InfoInterface $payment)
foreach( $_productCollection as $_product)() ?>" class $info
authorize(\Magento\Payment\Model\InfoInterface $payment, $amount)
capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
catch(\Exception $e) $handler