public function testAssignData() { $additionalData = ['cc_type' => 'VI', 'cc_owner' => 'Bruce', 'cc_number' => '41111111111111', 'cc_cid' => '42', 'cc_exp_month' => '02', 'cc_exp_year' => '30', 'cc_ss_issue' => '9', 'cc_ss_start_month' => '01', 'cc_ss_start_year' => '30']; $inputData = new DataObject([PaymentInterface::KEY_ADDITIONAL_DATA => $additionalData]); $payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock(); $expectedData = ['cc_type' => 'VI', 'cc_owner' => 'Bruce', 'cc_last_4' => '1111', 'cc_number' => '41111111111111', 'cc_cid' => '42', 'cc_exp_month' => '02', 'cc_exp_year' => '30', 'cc_ss_issue' => '9', 'cc_ss_start_month' => '01', 'cc_ss_start_year' => '30']; $payment->expects(static::once())->method('addData')->with($expectedData); $this->ccModel->setInfoInstance($payment); $this->ccModel->assignData($inputData); }
public function assignData(\Magento\Framework\DataObject $data) { parent::assignData($data); if (!$data instanceof \Magento\Framework\DataObject) { $data = new \Magento\Framework\DataObject($data); } $additionalData = $data->getAdditionalData(); $infoInstance = $this->getInfoInstance(); if (isset($additionalData['cc_type'])) { $infoInstance->setCcType($additionalData['cc_type']); } $infoInstance->setAdditionalInformation('token', $additionalData['token']); return $this; }
/** * Fetch transaction details info * * Update transaction info if there is one placing transaction only * * @param \Magento\Payment\Model\Info $payment * @param string $transactionId * @return array */ public function fetchTransactionInfo(\Magento\Payment\Model\Info $payment, $transactionId) { $cardsStorage = $this->getCardsStorage($payment); if ($cardsStorage->getCardsCount() != 1) { return parent::fetchTransactionInfo($payment, $transactionId); } $cards = $cardsStorage->getCards(); $card = array_shift($cards); $transactionId = $card->getLastTransId(); $transaction = $payment->getTransaction($transactionId); if (!$transaction->getAdditionalInformation($this->_isTransactionFraud)) { return parent::fetchTransactionInfo($payment, $transactionId); } $response = $this->_getTransactionDetails($transactionId); if ($response->getResponseCode() == self::RESPONSE_CODE_APPROVED) { $transaction->setAdditionalInformation($this->_isTransactionFraud, false); $payment->setIsTransactionApproved(true); } elseif ($response->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_DECLINED) { $payment->setIsTransactionDenied(true); } return parent::fetchTransactionInfo($payment, $transactionId); }
/** * Check whether payment method can be used * * @param \Magento\Sales\Model\Quote|null $quote * @return bool */ public function isAvailable($quote = null) { $storeId = $this->_storeManager->getStore($this->getStore())->getId(); /** @var \Magento\Paypal\Model\Config $config */ $config = $this->_configFactory->create()->setStoreId($storeId); if (parent::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) { return true; } return false; }
/** * Attempt to deny a pending payment * * @param \Magento\Payment\Model\Info|PaymentInterface $payment * @return bool */ public function denyPayment(\Magento\Payment\Model\InfoInterface $payment) { parent::denyPayment($payment); return $this->_pro->reviewPayment($payment, \Magento\Paypal\Model\Pro::PAYMENT_REVIEW_DENY); }
/** * Check whether payment method can be used * * @param \Magento\Quote\Api\Data\CartInterface|Quote|null $quote * @return bool * @throws \Magento\Framework\Exception\LocalizedException */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { return parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable($this->getCode()); }
/** * Check whether payment method is applicable to quote * Purposed to allow use in controllers some logic that was implemented in blocks only before * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { if (parent::isAvailable($quote)) { if ($quote != null) { $availableCcTypes = $this->config->getApplicableCardTypes($quote->getBillingAddress()->getCountryId()); if (!$availableCcTypes) { return false; } } } else { return false; } return true; }
/** * Assign data to info model instance * * @param \Magento\Framework\Object|mixed $data * @return $this */ public function assignData($data) { parent::assignData($data); $infoInstance = $this->getInfoInstance(); if ($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) { if (isset($data['encrypted_data'])) { $infoInstance->setAdditionalInformation('encrypted_data', $data['encrypted_data']); } else { throw new \Magento\Framework\Exception\LocalizedException(__('Card encryption failed')); } } return $this; }
/** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Payment\Model\Method\Logger $logger * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \PayStand\PayStandMagento\Helper\Data $dataHelper * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \PayStand\PayStandMagento\Helper\Data $dataHelper, ZendClientFactory $httpClientFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = []) { $this->dataHelper = $dataHelper; $this->httpClientFactory = $httpClientFactory; parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, $logger, $moduleList, $localeDate, $resource, $resourceCollection, $data); }
/** * Refund specified amount for payment * * @param \Magento\Framework\DataObject|InfoInterface $payment * @param float $amount * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @api * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) { parent::refund($payment, $amount); $order = $payment->getOrder(); // if amount is a full refund send a refund/cancelled request so if it is not captured yet it will cancel the order $grandTotal = $order->getGrandTotal(); if ($grandTotal == $amount) { $this->_paymentRequest->cancelOrRefund($payment); } else { $this->_paymentRequest->refund($payment, $amount); } return $this; }
/** * Determine method availability based on quote amount and config data * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { if ($quote && ($quote->getBaseGrandTotal() < $this->_minAmount || $this->_maxAmount && $quote->getBaseGrandTotal() > $this->_maxAmount)) { return false; } if (!$this->getConfigData('api_key')) { return false; } return parent::isAvailable($quote); }
/** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Payment\Model\Method\Logger $logger * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Authorizenet\Helper\Data $dataHelper * @param \Magento\Authorizenet\Model\Request\Factory $requestFactory * @param \Magento\Authorizenet\Model\Response\Factory $responseFactory * @param \Magento\Authorizenet\Model\TransactionService $transactionService * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Authorizenet\Helper\Data $dataHelper, \Magento\Authorizenet\Model\Request\Factory $requestFactory, \Magento\Authorizenet\Model\Response\Factory $responseFactory, TransactionService $transactionService, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = []) { $this->dataHelper = $dataHelper; $this->requestFactory = $requestFactory; $this->responseFactory = $responseFactory; $this->transactionService = $transactionService; parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, $logger, $moduleList, $localeDate, $resource, $resourceCollection, $data); }
/** * Check whether payment method can be used * * @param Quote|null $quote * @return bool */ public function isAvailable($quote = null) { return parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable($this->getCode()); }
/** * Set fallback API URL if not defined in configuration * * @return \Magento\Centinel\Model\Service */ public function getCentinelValidator() { $validator = parent::getCentinelValidator(); if (!$validator->getCustomApiEndpointUrl()) { $validator->setCustomApiEndpointUrl($this->_pro->getConfig()->getConfigValue('centinelDefaultApiUrl')); } return $validator; }
/** * is payment method available? * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { $parent = parent::isAvailable($quote); if (!$this->_accessToken) { $this->_accessToken = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\Data::XML_PATH_ACCESS_TOKEN); } if (!$this->_publicKey) { $this->_publicKey = $this->_scopeConfig->getValue(\MercadoPago\Core\Helper\Data::XML_PATH_PUBLIC_KEY); } $custom = !empty($this->_publicKey) && !empty($this->_accessToken); if (!$parent || !$custom) { return false; } $debugMode = $this->_scopeConfig->getValue('payment/mercadopago/debug_mode'); $secure = $this->_request->isSecure(); if (!$secure && !$debugMode) { return false; } return $this->_helperData->isValidAccessToken($this->_accessToken); }
/** * Determines method's availability based on config data and quote amount * * @param \Magento\Quote\Api\Data\CartInterface|null $quote * @return bool */ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) { return parent::isAvailable($quote) && $this->getConfigHelper()->isMethodAvailable() && $this->getModuleHelper()->isStoreSecure(); }
/** * Log debug data to file * * @param mixed $debugData * @return $this */ protected function _debug($debugData) { if (!$this->config->isDebugEnabled()) { return $this; } if (!is_array($debugData)) { if (is_object($debugData)) { $debugData = var_export($debugData, true); } else { $debugData = [$debugData]; } } parent::_debug((array) $debugData); return $this; }