public function config($urls) { //$returnUrl = $this->getUrl('wirecard_checkoutpage/processing/return', array('_secure' => true, '_nosid' => true)); $returnUrl = $urls['return']; $init = new \WirecardCEE_QPay_FrontendClient($this->_dataHelper->getConfigArray()); $init->setPluginVersion($this->_dataHelper->getPluginVersion()); $init->setOrderReference('Configtest #' . uniqid()); if ($this->_dataHelper->getConfigData('options/sendconfirmemail')) { $init->setConfirmMail($this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')); } $consumerData = new \WirecardCEE_Stdlib_ConsumerData(); $consumerData->setIpAddress($this->_dataHelper->getClientIp()); $consumerData->setUserAgent($this->_dataHelper->getUserAgent()); $init->setAmount(10)->setCurrency('EUR')->setPaymentType(\WirecardCEE_QPay_PaymentType::SELECT)->setOrderDescription('Configtest #' . uniqid())->setSuccessUrl($returnUrl)->setPendingUrl($returnUrl)->setCancelUrl($returnUrl)->setFailureUrl($returnUrl)->setConfirmUrl($urls['confirm'])->setServiceUrl($this->_dataHelper->getConfigData('options/service_url'))->setConsumerData($consumerData); if (strlen($this->_dataHelper->getConfigData('options/bgcolor'))) { $init->setBackgroundColor($this->_dataHelper->getConfigData('options/bgcolor')); } if (strlen($this->_dataHelper->getConfigData('options/displaytext'))) { $init->setDisplayText($this->_dataHelper->getConfigData('options/displaytext')); } if (strlen($this->_dataHelper->getConfigData('options/imageurl'))) { $init->setImageUrl($this->_dataHelper->getConfigData('options/imageurl')); } $initResponse = $init->initiate(); if ($initResponse->getStatus() == \WirecardCEE_QPay_Response_Initiation::STATE_FAILURE) { $msg = $initResponse->getError()->getConsumerMessage(); if (!strlen($msg)) { $msg = $initResponse->getError()->getMessage(); } throw new \Exception($msg); } return true; }
/** * set payment specific request data * * @param \WirecardCEE_QPay_FrontendClient $init * @param \Magento\Checkout\Model\Cart $cart */ protected function setAdditionalRequestData($init, $cart) { if (!$this->_dataHelper->getConfigData('options/paymenttypesortorder')) { return; } $blacklist = ['wirecard_checkoutpage_ccardmoto', 'wirecard_checkoutpage_invoiceb2b']; $map = ['TRUSTLY' => 'INSTANTBANK']; $paymenttypes = array(); /* read all payment methods, regardless whether they are active or not */ foreach ($this->_scopeConfig->getValue('payment', ScopeInterface::SCOPE_STORE, null) as $paymentCode => $data) { if (isset($data['model']) && isset($data['sort_order']) && $data['sort_order'] != 0) { /** @var AbstractPayment $paymentModel */ if ($paymentCode == $this->getCode()) { continue; } if (!preg_match('/^wirecard_checkoutpage/i', $paymentCode)) { continue; } if (in_array($paymentCode, $blacklist)) { continue; } /** @var AbstractMethod|null $methodModel Actually it's wrong interface */ $paymentModel = $this->_paymentMethodFactory->create($data['model']); $paymentModel->setId($paymentCode); $paymentModel->setStore(null); $paymenttype = $paymentModel->getPaymentMethod(); if (isset($map[$paymentModel->getPaymentMethod()])) { $paymenttype = $map[$paymentModel->getPaymentMethod()]; } $paymenttypes[$paymenttype] = $paymentModel->getConfigData('sort_order'); } } if (count($paymenttypes)) { asort($paymenttypes); $init->setPaymenttypeSortOrder(array_keys($paymenttypes)); } }
/** * return plugin information * * @return string */ public function getPluginVersion() { $versionInfo = $this->getVersionInfo(); return \WirecardCEE_QPay_FrontendClient::generatePluginVersion($versionInfo['product'], $versionInfo['productVersion'], $versionInfo['pluginName'], $versionInfo['pluginVersion']); }
public function testDisplayTextAndImageUrl() { $this->object->setDisplayText('display text')->setImageUrl('https://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif'); }
/** * Init payment, server2server * * @param CheckoutCart $cart * @param $urls * @param \Magento\Framework\DataObject $data * * @return \WirecardCEE_QPay_Response_Initiation * @throws \Exception */ public function initPaymentByCart(CheckoutCart $cart, $urls, \Magento\Framework\DataObject $data) { $quote = $cart->getQuote(); $init = new \WirecardCEE_QPay_FrontendClient($this->_dataHelper->getConfigArray()); $init->setPluginVersion($this->_dataHelper->getPluginVersion()); $init->setConfirmUrl($urls['confirm']); $quote->reserveOrderId(); $quote->save(); $orderId = $quote->getReservedOrderId(); $init->setOrderReference(sprintf('%010d', $orderId)); $init->uniqueId = $this->_getUniqueId($cart); $init->setAmount(round($cart->getQuote()->getBaseGrandTotal(), $this->_dataHelper->getPrecision()))->setCurrency($quote->getCurrency()->getBaseCurrencyCode())->setPaymentType($this->_paymentMethod)->setOrderDescription($this->getUserDescription($quote))->setSuccessUrl($urls['return'])->setPendingUrl($urls['return'])->setCancelUrl($urls['return'])->setFailureUrl($urls['return'])->createConsumerMerchantCrmId($quote->getCustomerEmail())->setServiceUrl($this->_dataHelper->getConfigData('options/service_url'))->setConsumerData($this->_getConsumerData($quote))->setMaxRetries($this->_dataHelper->getConfigData('options/maxretries')); $init->mage_orderId = $orderId; $init->mage_quoteId = $quote->getId(); $init->mage_orderCreation = $this->_dataHelper->getConfigData('options/order_creation'); $init->generateCustomerStatement($this->_dataHelper->getConfigData('options/shopname'), sprintf('%010d', $orderId)); if ($this->_dataHelper->getConfigData('options/sendbasketinformation') || $this->forceSendingBasket()) { $basket = new \WirecardCEE_Stdlib_Basket(); $basket->setCurrency($quote->getBaseCurrencyCode()); foreach ($quote->getAllVisibleItems() as $item) { /** @var \Magento\Quote\Model\Quote\Item $item */ $bitem = new \WirecardCEE_Stdlib_Basket_Item(); $bitem->setDescription($item->getProduct()->getName()); $bitem->setArticleNumber($item->getSku()); $bitem->setUnitPrice(number_format($item->getPrice(), $this->_dataHelper->getPrecision(), '.', '')); $bitem->setTax(number_format($item->getTaxAmount(), $this->_dataHelper->getPrecision(), '.', '')); $basket->addItem($bitem, (int) $item->getQty()); } $bitem = new \WirecardCEE_Stdlib_Basket_Item(); $bitem->setArticleNumber('shipping'); $bitem->setUnitPrice(number_format($quote->getShippingAddress()->getShippingAmount(), $this->_dataHelper->getPrecision(), '.', '')); $bitem->setTax(number_format($quote->getShippingAddress()->getShippingTaxAmount(), $this->_dataHelper->getPrecision(), '.', '')); $bitem->setDescription($quote->getShippingAddress()->getShippingDescription()); $basket->addItem($bitem); foreach ($basket->__toArray() as $k => $v) { $init->{$k} = $v; } } if ($this->_dataHelper->getConfigData('options/sendconfirmationemail')) { $init->setConfirmMail($this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')); } if (strlen($this->_dataHelper->getConfigData('options/bgcolor'))) { $init->setBackgroundColor($this->_dataHelper->getConfigData('options/bgcolor')); } if (strlen($this->_dataHelper->getConfigData('options/displaytext'))) { $init->setDisplayText($this->_dataHelper->getConfigData('options/displaytext')); } if (strlen($this->_dataHelper->getConfigData('options/imageurl'))) { $init->setImageUrl($this->_dataHelper->getConfigData('options/imageurl')); } if (strlen($this->_dataHelper->getConfigData('options/layout'))) { $init->setLayout($this->_dataHelper->getConfigData('options/layout')); } if ($this->_dataHelper->getConfigData('options/autodeposit') && $this->_autoDepositAllowed) { $init->setAutoDeposit(true); } if ($this->_dataHelper->getConfigData('options/duplicaterequestcheck')) { $init->setDuplicateRequestCheck($this->_dataHelper->getConfigData('options/duplicaterequestcheck')); } if ($this->_dataHelper->getConfigData('options/mobiledetect')) { $detect = new \WirecardCEE_QPay_MobileDetect(); if ($detect->isTablet()) { $layout = 'TABLET'; } elseif ($detect->isMobile()) { $layout = 'SMARTPHONE'; } else { $layout = 'DESKTOP'; } $init->setLayout($layout); } if (strlen($data->getData('financialInstitution'))) { $init->setFinancialInstitution($data->getData('financialInstitution')); } $init->iframeUsed = $this->getDisplayMode() != 'redirect'; $init->quoteHash = $this->_dataHelper->calculateQuoteChecksum($quote); $this->setAdditionalRequestData($init, $cart); $this->_logger->debug(__METHOD__ . ':' . print_r($init->getRequestData(), true)); try { $initResponse = $init->initiate(); } catch (\Exception $e) { $this->_logger->debug(__METHOD__ . ':' . $e->getMessage()); throw new $e(); } if ($initResponse->getStatus() == \WirecardCEE_QPay_Response_Initiation::STATE_FAILURE) { $error = $initResponse->getError(); $message = $this->_dataHelper->__('An error occurred during the payment process'); if ($error !== false) { if (strlen($error->getConsumerMessage())) { $message = $error->getConsumerMessage(); } $this->_logger->debug(__METHOD__ . ':' . $error->getMessage()); } throw new \Exception($message); } return $initResponse; }
/** * set payment specific request data * * @param \WirecardCEE_QPay_FrontendClient $init * @param \Magento\Checkout\Model\Cart $cart */ protected function setAdditionalRequestData($init, $cart) { $init->setTransactionIdentifier($this->getConfigData('txident')); }