public function execute() { $redirectUrl = $this->getUrl('wirecardcheckoutpage/fundtransfer/transfer'); if (!($data = $this->getRequest()->getPostValue())) { $this->_redirect($redirectUrl); return; } $postObject = new \Magento\Framework\DataObject(); $postObject->setData($data); $this->_session->setWirecardCheckoutPageFundTrandsferFormData($postObject); try { $return = $this->_fundTransferModel->sendrequest($postObject); if ($return->hasFailed()) { $this->messageManager->addErrorMessage($return->getError()->getMessage()); } else { $this->_logger->debug(__METHOD__ . ':' . print_r($postObject->getData(), true)); $this->_session->unsWirecardCheckoutPageFundTrandsferFormData(); $this->messageManager->addNoticeMessage($this->_dataHelper->__('Fund transfer submitted successfully!')); $this->messageManager->addNoticeMessage($this->_dataHelper->__('Credit number' . ':' . $return->getCreditNumber())); } } catch (\Exception $e) { $this->messageManager->addErrorMessage($e->getMessage()); } $this->_redirect($redirectUrl); }
public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->_resultPageFactory->create(); $resultPage->setActiveMenu('Magento_Backend::system_store'); $resultPage->getConfig()->getTitle()->prepend($this->_dataHelper->__('Wirecard Checkout Page Support Request')); return $resultPage; }
/** * @param Context $context * @param Registry $registry * @param \Wirecard\CheckoutPage\Helper\Data $dataHelper * @param array $data */ public function __construct(Context $context, Registry $registry, \Wirecard\CheckoutPage\Helper\Data $dataHelper, array $data = []) { parent::__construct($context, $data); $this->_coreRegistry = $registry; $this->_dataHelper = $dataHelper; $this->_objectId = 'id'; $this->_controller = 'adminhtml_fundtransfer'; $this->_blockGroup = 'Wirecard_CheckoutPage'; $this->buttonList->remove('save'); $this->buttonList->add('sendrequest', ['label' => $this->_dataHelper->__('Submit Transfer'), 'class' => 'save', 'onclick' => 'jQuery("#edit_form").submit();'], -100, 0, 'footer'); }
public function execute() { $redirectUrl = $this->getUrl('adminhtml/system_config/edit/section/wirecard_checkoutpage'); $urls = ['confirm' => $this->_url->getUrl('wirecardcheckoutpage/checkout/confirm', ['_secure' => true, '_nosid' => true]), 'return' => $this->_url->getUrl('wirecardcheckoutpage/checkout/back', ['_secure' => true, '_nosid' => true])]; try { $this->_testModel->config($urls); $this->messageManager->addNoticeMessage($this->_dataHelper->__('Configuration test ok')); } catch (\Exception $e) { $this->messageManager->addErrorMessage($e->getMessage()); } $this->_redirect($redirectUrl); }
public function execute() { $urls = ['confirm' => $this->_url->getUrl('wirecardcheckoutpage/checkout/confirm', ['_secure' => true, '_nosid' => true]), 'return' => $this->_url->getUrl('wirecardcheckoutpage/checkout/back', ['_secure' => true, '_nosid' => true])]; $payment = null; try { if ($this->getCheckoutMethod() == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) { $this->prepareGuestQuote(); } $customerDob = $this->_cart->getQuote()->getPayment()->getAdditionalInformation('customerDob'); if (strlen($customerDob)) { $this->_cart->getQuote()->setCustomerDob($customerDob); } /** @var \Wirecard\CheckoutPage\Model\AbstractPayment $payment */ $payment = $this->_cart->getQuote()->getPayment()->getMethodInstance(); $init = $payment->initPaymentByCart($this->_cart, $urls, new \Magento\Framework\DataObject($payment->getInfoInstance()->getAdditionalInformation())); if ($this->_dataHelper->getConfigData('options/order_creation') == 'before') { $this->_orderManagement->submitOrder($this->_cart->getQuote()); } $this->getResponse()->setRedirect($init->getRedirectUrl()); } catch (\Exception $e) { $this->_logger->debug(__METHOD__ . ':' . $e->getMessage()); $this->messageManager->addErrorMessage($this->_dataHelper->__('An error occurred during the payment process')); if ($payment === null) { $this->_redirect('/'); } else { $this->getResponse()->setRedirect($this->_url->getUrl('wirecardcheckoutpage/checkout/failed', ['_secure' => true, '_query' => ['iframeused' => (int) ($payment->getDisplayMode() != 'redirect')]])); } } }
public function execute() { $redirectUrl = $this->getUrl('wirecardcheckoutpage/support/contact'); if (!($data = $this->getRequest()->getPostValue())) { $this->_redirect($redirectUrl); return; } $postObject = new \Magento\Framework\DataObject(); $postObject->setData($data); try { $this->_supportModel->sendrequest($postObject); $this->messageManager->addNoticeMessage($this->_dataHelper->__('Support request sent successfully!')); } catch (\Exception $e) { $this->messageManager->addErrorMessage($e->getMessage()); } $this->_redirect($redirectUrl); }
/** * @param \Magento\Framework\DataObject $postObject * * @return \WirecardCEE_QPay_Response_Toolkit_TransferFund * @throws \Exception */ public function sendrequest($postObject) { $backendClient = $this->_dataHelper->getBackendClient(); $type = strtoupper($postObject['transferType']); $client = $backendClient->transferfund($type); if (strlen($postObject['orderNumber'])) { $client->setOrderNumber($postObject['orderNumber']); } if (strlen($postObject['orderReference'])) { $client->setOrderReference($postObject['orderReference']); } if (strlen($postObject['creditNumber'])) { $client->setCreditNumber($postObject['creditNumber']); } switch ($type) { case \WirecardCEE_QPay_ToolkitClient::$TRANSFER_FUND_TYPE_EXISTING: /** @var \WirecardCEE_QPay_Request_Backend_TransferFund_Existing $client */ if (strlen($postObject['customerStatement'])) { $client->setCustomerStatement($postObject['customerStatement']); } $ret = $client->send($postObject['amount'], $postObject['currency'], $postObject['orderDescription'], $postObject['sourceOrderNumber']); break; case \WirecardCEE_QPay_ToolkitClient::$TRANSFER_FUND_TYPE_SKIRLLWALLET: /** @var \WirecardCEE_QPay_Request_Backend_TransferFund_SkrillWallet $client */ $ret = $client->send($postObject['amount'], $postObject['currency'], $postObject['orderDescription'], $postObject['customerStatement'], $postObject['consumerEmail']); break; case \WirecardCEE_QPay_ToolkitClient::$TRANSFER_FUND_TYPE_MONETA: /** @var \WirecardCEE_QPay_Request_Backend_TransferFund_Moneta $client */ $ret = $client->send($postObject['amount'], $postObject['currency'], $postObject['orderDescription'], $postObject['customerStatement'], $postObject['consumerWalletId']); break; case \WirecardCEE_QPay_ToolkitClient::$TRANSFER_FUND_TYPE_SEPACT: /** @var \WirecardCEE_QPay_Request_Backend_TransferFund_SepaCT $client */ $ret = $client->send($postObject['amount'], $postObject['currency'], $postObject['orderDescription'], $postObject['bankAccountOwner'], $postObject['bankBic'], $postObject['bankAccountIban']); break; default: throw new \Exception($this->_dataHelper->__('Invalid fund transfer type')); } return $ret; }
/** * @param \Magento\Framework\DataObject $postObject * * @return bool * @throws \Exception */ public function sendrequest($postObject) { if (!filter_var($postObject->getData('to'), FILTER_VALIDATE_EMAIL)) { throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address.')); } if (strlen(trim($postObject->getData('replyto')))) { if (!filter_var($postObject->getData('replyto'), FILTER_VALIDATE_EMAIL)) { throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address (reply to).')); } $this->_transportBuilder->setReplyTo(trim($postObject->getData('replyto'))); } $sender = ['name' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/name'), 'email' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')]; if (!strlen($sender['email'])) { throw new \Exception('Please set your shop e-mail address!'); } $modules = []; foreach ($this->_moduleLoader->load() as $module) { if (!in_array($module['name'], $this->_moduleBlacklist)) { $modules[] = $module['name']; } } natsort($modules); $payments = $this->_paymentConfig->getActiveMethods(); /** @var \Magento\Framework\App\Config\Data $cfg */ $cfg = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_STORE); $foreign = array(); $mine = array(); foreach ($payments as $paymentCode => $paymentModel) { /** @var AbstractPayment $paymentModel */ $method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => []); if (preg_match('/^wirecard_/i', $paymentCode)) { $method['config'] = $cfg->getValue('payment/' . $paymentCode); $mine[$paymentCode] = $method; } else { $foreign[$paymentCode] = $method; } } $versioninfo = new \Magento\Framework\DataObject(); $versioninfo->setData($this->_dataHelper->getVersionInfo()); $transport = $this->_transportBuilder->setTemplateIdentifier('contact_support_email')->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject, 'modules' => $modules, 'foreign' => $foreign, 'mine' => $mine, 'configstr' => $this->_dataHelper->getConfigString(), 'versioninfo' => $versioninfo])->setFrom($sender)->addTo($postObject->getData('to'))->getTransport(); $transport->sendMessage(); return true; }
public function execute() { $this->_logger->debug(__METHOD__ . ':' . print_r($this->_request->getPost()->toArray(), true)); try { $return = \WirecardCEE_QPay_ReturnFactory::getInstance($this->_request->getPost()->toArray(), $this->_dataHelper->getConfigData('basicdata/secret')); if (!$return->validate()) { throw new \Exception('Validation error: invalid response'); } if (!strlen($return->mage_orderId)) { throw new \Exception('Magento OrderId is missing'); } if (!strlen($return->mage_quoteId)) { throw new \Exception('Magento QuoteId is missing'); } $this->_orderManagement->processOrder($return); die(\WirecardCEE_QPay_ReturnFactory::generateConfirmResponseString()); } catch (\Exception $e) { $this->_logger->debug(__METHOD__ . ':' . $e->getMessage()); $this->_logger->debug(__METHOD__ . ':' . $e->getTraceAsString()); die(\WirecardCEE_QPay_ReturnFactory::generateConfirmResponseString($e->getMessage())); } }
/** * Cancel payment * Cancelaltion, is when the order can no longer be modified. While an order payment might be voided a new * invoice can always be generated. Cancellation of an order prevents any future change from being made to it. * * If REFUND is available do a refund, otherwise do a DEPOSITREVERSAL * Dont make APPROVEREVERSAL (decision by PM) * * @param \Magento\Framework\DataObject|InfoInterface|\Magento\Sales\Model\Order\Payment $payment * * @return $this * @throws \Exception * @api * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function cancel(\Magento\Payment\Model\InfoInterface $payment) { if (!$this->_dataHelper->isBackendAvailable()) { return $this; } $orderNumber = $payment->getAdditionalInformation('orderNumber'); if (!strlen($orderNumber)) { /* dont throw an exception here, might be a pending payment */ $this->_logger->debug(__METHOD__ . ':No order number found.'); return $this; } $orderDetails = $this->getOrderDetails($orderNumber); $backendClient = $this->_dataHelper->getBackendClient(); $log = sprintf("%s", $orderNumber); /* if refund op is available order already has been closed */ /* otherwise revert each single payment */ if (in_array('REFUND', $orderDetails->getOrder()->getOperationsAllowed())) { $log .= sprintf(" action:REFUND %s", $orderDetails->getOrder()->getAmount()); $ret = $backendClient->refund($orderNumber, $orderDetails->getOrder()->getAmount(), $orderDetails->getOrder()->getCurrency()); if ($ret->hasFailed()) { throw new \Exception($ret->getError()->getMessage()); } } else { foreach ($orderDetails->getOrder()->getPayments() as $payment) { /** @var \WirecardCEE_QPay_Response_Toolkit_Order_Payment $payment */ if (in_array('DEPOSITREVERSAL', $payment->getOperationsAllowed())) { $log .= " action:DEPOSITREVERSAL APPROVEREVERSAL"; $ret = $backendClient->depositReversal($orderNumber, $payment->getPaymentNumber()); if ($ret->hasFailed()) { throw new \Exception($ret->getError()->getMessage()); } } } } $this->_logger->debug(__METHOD__ . ":{$log}"); return $this; }
public function toOptionArray() { $configs = array(array('value' => 'prod', 'label' => $this->_dataHelper->__('Production')), array('value' => 'demo', 'label' => $this->_dataHelper->__('Demo')), array('value' => 'test_no3d', 'label' => $this->_dataHelper->__('Test without 3-D Secure')), array('value' => 'test_3d', 'label' => $this->_dataHelper->__('Test with 3-D Secure'))); return $configs; }
public function toOptionArray() { $themes = array(array('value' => 'SINGLE', 'label' => $this->_dataHelper->__('Single')), array('value' => 'INITIAL', 'label' => $this->_dataHelper->__('Initial'))); return $themes; }
/** * Confirm the payment of an order * * @param \Magento\Sales\Model\Order $order * @param \WirecardCEE_Stdlib_Return_ReturnAbstract $return * @param bool $fraudDetected * * @return Order * * @throws \Magento\Framework\Exception\LocalizedException */ public function confirmOrder($order, $return, $fraudDetected) { /** @var \Magento\Sales\Model\Order\Payment $payment */ $payment = $order->getPayment(); /** @var \Wirecard\CheckoutPage\Model\AbstractPayment $paymentInstance */ $paymentInstance = $payment->getMethodInstance(); $additionalInformation = array(); foreach ($return->getReturned() as $fieldName => $fieldValue) { $additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue); } $payment->setAdditionalInformation($additionalInformation); if ($fraudDetected) { $order->setStatus(\Magento\Sales\Model\Order::STATUS_FRAUD); $message = $this->_dataHelper->__('fraud attemmpt detected, cart has been modified during checkout!'); $this->_logger->debug(__METHOD__ . ':' . $message); $order->addStatusHistoryComment($message); } $doCapture = false; if (!$this->isOrderProcessed($order)) { if ($return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_PENDING) { /** @var \WirecardCEE_QPay_Return_Pending $return */ $order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT); $message = $this->_dataHelper->__('The payment authorization is pending.'); } else { /** @var \WirecardCEE_QPay_Return_Success $return */ $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING); $order->setStatus(\Magento\Sales\Model\Order::STATE_PROCESSING); $message = $this->_dataHelper->__('The payment has been successfully completed.'); // invoice payment if ($order->canInvoice()) { $invoice = $order->prepareInvoice(); $invoice->register(); /* capture invoice if toolkit is not availble */ if (!$this->_dataHelper->isBackendAvailable()) { $doCapture = true; } else { $hasBackedOps = false; $orderDetails = $paymentInstance->getOrderDetails($payment->getAdditionalInformation('orderNumber')); foreach ($orderDetails->getOrder()->getPayments() as $wdPayment) { /** @var \WirecardCEE_QPay_Response_Toolkit_Order_Payment $wdPayment */ $this->_logger->debug(__METHOD__ . ':payment-state:' . $wdPayment->getState() . ' allowed operations:' . implode(',', $wdPayment->getOperationsAllowed())); if (count($wdPayment->getOperationsAllowed())) { $hasBackedOps = true; break; } } if (count($orderDetails->getOrder()->getOperationsAllowed())) { $this->_logger->debug(__METHOD__ . ':order allowed operations: ' . implode(',', $orderDetails->getOrder()->getOperationsAllowed())); $hasBackedOps = true; } /* no backend ops allowed anymore, assume final state of payment, capture invoice */ if (!$hasBackedOps) { $doCapture = true; } } if ($doCapture && !$fraudDetected) { $invoice->capture(); } $order->addRelatedObject($invoice); } $this->_orderSender->send($order); } $type = $doCapture ? Transaction::TYPE_CAPTURE : Transaction::TYPE_AUTH; $this->saveTransaction($type, $message, $order, $return); } $order->save(); return $order; }
/** * Get instructions text from config * * @param string $code * * @return string */ protected function getInstructions($code) { return nl2br($this->escaper->escapeHtml($this->_dataHelper->__($this->methods[$code]->getInstructions()))); }
public function execute() { $redirectTo = 'checkout/cart'; $defaultErrorMessage = $this->_dataHelper->__('An error occurred during the payment process.'); try { $this->_logger->debug(__METHOD__ . ':' . print_r($this->_request->getPost()->toArray(), true)); $this->_cart->getCustomerSession()->unsUniqueId(); if (!$this->_request->isPost()) { throw new \Exception('Not a post request'); } $return = \WirecardCEE_QPay_ReturnFactory::getInstance($this->_request->getPost()->toArray(), $this->_dataHelper->getConfigData('basicdata/secret')); if (!$return->validate()) { throw new \Exception('Validation error: invalid response'); } if (!strlen($return->mage_orderId)) { throw new \Exception('Magento OrderId is missing'); } if (!strlen($return->mage_quoteId)) { throw new \Exception('Magento QuoteId is missing'); } $orderId = $this->_request->getPost('mage_orderId'); /** @var \Magento\Sales\Model\Order $order */ $order = $this->_objectManager->create('\\Magento\\Sales\\Model\\Order'); $order->loadByIncrementId($orderId); $orderExists = (bool) $order->getId(); if ($return->mage_orderCreation == 'before') { if (!$orderExists) { throw new \Exception('Order not found'); } $payment = $order->getPayment(); if (!strlen($payment->getAdditionalInformation('paymentState'))) { $this->_logger->debug(__METHOD__ . ':order not processed via confirm server2server request, check your packetfilter!'); $order = $this->_orderManagement->processOrder($return); } } if ($return->mage_orderCreation == 'after') { if (!$orderExists && ($return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_SUCCESS || $return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_PENDING)) { $this->_logger->debug(__METHOD__ . ':order not processed via confirm server2server request, check your packetfilter!'); $order = $this->_orderManagement->processOrder($return); } } switch ($return->getPaymentState()) { case \WirecardCEE_QPay_ReturnFactory::STATE_SUCCESS: case \WirecardCEE_QPay_ReturnFactory::STATE_PENDING: if ($return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_PENDING) { $this->messageManager->addNoticeMessage($this->_dataHelper->__('Your order will be processed as soon as we receive the payment confirmation from your bank.')); } /* needed for success page otherwise magento redirects to cart */ $this->_checkoutSession->setLastQuoteId($order->getQuoteId()); $this->_checkoutSession->setLastSuccessQuoteId($order->getQuoteId()); $this->_checkoutSession->setLastOrderId($order->getId()); $this->_checkoutSession->setLastRealOrderId($order->getIncrementId()); $this->_checkoutSession->setLastOrderStatus($order->getStatus()); $redirectTo = 'checkout/onepage/success'; break; case \WirecardCEE_QPay_ReturnFactory::STATE_CANCEL: /** @var \WirecardCEE_QPay_Return_Cancel $return */ $this->messageManager->addNoticeMessage($this->_dataHelper->__('You have canceled the payment process!')); if ($return->mage_orderCreation == 'before') { $quote = $this->_orderManagement->reOrder($return->mage_quoteId); $this->_checkoutSession->replaceQuote($quote)->unsLastRealOrderId(); } break; case \WirecardCEE_QPay_ReturnFactory::STATE_FAILURE: /** @var \WirecardCEE_QPay_Return_Failure $return */ $msg = $return->getErrors()->getConsumerMessage(); if (!strlen($msg)) { $msg = $defaultErrorMessage; } $this->messageManager->addErrorMessage($msg); if ($return->mage_orderCreation == 'before') { $quote = $this->_orderManagement->reOrder($return->mage_quoteId); $this->_checkoutSession->replaceQuote($quote)->unsLastRealOrderId(); } break; default: throw new \Exception('Unhandled Wirecard Checkout Page payment state:' . $return->getPaymentState()); } if ($this->_request->getPost('iframeUsed')) { $redirectUrl = $this->_url->getUrl($redirectTo); $page = $this->_resultPageFactory->create(); $page->getLayout()->getBlock('checkout.back')->addData(['redirectUrl' => $redirectUrl]); return $page; } else { $this->_redirect($redirectTo); } } catch (\Exception $e) { if (!$this->messageManager->getMessages()->getCount()) { $this->messageManager->addErrorMessage($defaultErrorMessage); } $this->_logger->debug(__METHOD__ . ':' . $e->getMessage()); $this->_redirect($redirectTo); } }
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; }
public function toOptionArray() { $themes = array(array('value' => 'before', 'label' => $this->_dataHelper->__('Create order before payment')), array('value' => 'after', 'label' => $this->_dataHelper->__('Create order after payment'))); return $themes; }
public function toOptionArray() { $themes = array(array('value' => 'iframe', 'label' => $this->_dataHelper->__('Iframe')), array('value' => 'popup', 'label' => $this->_dataHelper->__('Popup')), array('value' => 'redirect', 'label' => $this->_dataHelper->__('Redirect'))); return $themes; }
/** * Prepare title for tab * * @return string */ public function getTabTitle() { return $this->_dataHelper->__('Support Request'); }
public function toOptionArray() { $themes = array(array('value' => '', 'label' => __('No')), array('value' => 'desktop', 'label' => $this->_dataHelper->__('Desktop')), array('value' => 'tablet', 'label' => $this->_dataHelper->__('Tablet')), array('value' => 'smartphone', 'label' => $this->_dataHelper->__('Smartphone'))); return $themes; }
/** * Prepare title for tab * * @return string */ public function getTabTitle() { return $this->_dataHelper->__('Fund Transfer'); }