/** * @return PaymentTokenRepositoryInterface */ private function getInstance() { if (!$this->vaultPayment->isActive()) { return $this->nullRepository; } $methodCode = $this->config->getValue(VaultProvidersMap::VALUE_CODE); return isset($this->repositories[$methodCode]) ? $this->objectManager->get($this->repositories[$methodCode]) : $this->nullRepository; }
/** * Builds ENV request * * @param array $buildSubject * @return array */ public function build(array $buildSubject) { if (!isset($buildSubject['payment']) || !$buildSubject['payment'] instanceof PaymentDataObjectInterface) { throw new \InvalidArgumentException('Payment data object should be provided'); } /** @var PaymentDataObjectInterface $payment */ $payment = $buildSubject['payment']; $order = $payment->getOrder(); $address = $order->getShippingAddress(); return ['TXN_TYPE' => 'A', 'INVOICE' => $order->getOrderIncrementId(), 'AMOUNT' => $order->getGrandTotalAmount(), 'CURRENCY' => $order->getCurrencyCode(), 'EMAIL' => $address->getEmail(), 'MERCHANT_KEY' => $this->config->getValue('merchant_gateway_key', $order->getStoreId())]; }
/** * @param array $validationSubject * @return bool * @throws NotFoundException * @throws \Exception */ public function validate(array $validationSubject) { $isValid = true; $storeId = $validationSubject['storeId']; if ((int) $this->config->getValue('allowspecific', $storeId) === 1) { $availableCountries = explode(',', $this->config->getValue('specificcountry', $storeId)); if (!in_array($validationSubject['country'], $availableCountries)) { $isValid = false; } } return $this->resultFactory->create(['isValid' => $isValid]); }
/** * Builds ENV request * * @param array $buildSubject * @return array */ public function build(array $buildSubject) { if (!isset($buildSubject['payment']) || !$buildSubject['payment'] instanceof PaymentDataObjectInterface) { throw new \InvalidArgumentException('Payment data object should be provided'); } /** @var PaymentDataObjectInterface $paymentDO */ $paymentDO = $buildSubject['payment']; $order = $paymentDO->getOrder(); $payment = $paymentDO->getPayment(); if (!$payment instanceof OrderPaymentInterface) { throw new \LogicException('Order payment should be provided.'); } return ['TXN_TYPE' => 'S', 'TXN_ID' => $payment->getLastTransId(), 'MERCHANT_KEY' => $this->config->getValue('merchant_gateway_key', $order->getStoreId())]; }
/** * Prepare PayPal-specific payment information * * @param \Magento\Framework\DataObject|array|null $transport * @return \Magento\Framework\DataObject */ protected function _prepareSpecificInformation($transport = null) { $transport = parent::_prepareSpecificInformation($transport); $payment = $this->getInfo(); $fieldsToStore = explode(',', (string) $this->config->getValue('paymentInfoKeys')); if ($this->getIsSecureMode()) { $fieldsToStore = array_diff($fieldsToStore, explode(',', (string) $this->config->getValue('privateInfoKeys'))); } foreach ($fieldsToStore as $field) { if ($payment->getAdditionalInformation($field) !== null) { $this->setDataToTransfer($transport, $field, $payment->getAdditionalInformation($field)); } } return $transport; }
/** * @return PaymentTokenRepositoryInterface */ private function getInstance() { $methodCode = $this->config->getValue(VaultProvidersMap::VALUE_CODE); return isset($this->repositories[$methodCode]) ? $this->objectManager->get($this->repositories[$methodCode]) : $this->defaultRepository; }
/** * @inheritdoc */ public function handle(array $subject, $storeId = null) { $vaultPaymentCode = $this->config->getValue(VaultProvidersMap::VALUE_CODE, $storeId); return (int) ((int) $this->config->getValue('active', $storeId) === 1 && $vaultPaymentCode && $vaultPaymentCode !== VaultProvidersMap::EMPTY_VALUE); }
/** * Retrieve method configured value * * @param array $subject * @param int|null $storeId * * @return mixed */ public function handle(array $subject, $storeId = null) { return $this->configInterface->getValue(SubjectReader::readField($subject), $storeId); }
/** * Retrieve method configured value * * @param string $field * @param int|null $storeId * * @return mixed */ public function handle($field, $storeId = null) { return $this->configInterface->getValue($field, $storeId); }
/** * @param null $storeId * @return string|null */ public function getProviderCode($storeId = null) { return $this->config->getValue(VaultProvidersMap::VALUE_CODE, $this->getStore() ?: $storeId); }
/** * Whether debug is enabled in configuration * * @return bool */ private function isDebugOn() { return $this->config and (bool) $this->config->getValue('debug'); }
/** * @inheritdoc */ public function isActive($storeId = null) { return $this->getVaultProvider()->isActive($storeId) && $this->config->getValue(self::$activeKey, $this->getStore() ?: $storeId); }