/** * Makes some adjustments in the document prior to rendering * * @param Enlight_Event_EventArgs $args * @return void */ public static function onBeforeRenderDocument(Enlight_Hook_HookArgs $args) { $document = $args->getSubject(); if ($document->_order->payment['name'] != 'billsafe_invoice') { return; } $view = $document->_view; $client = Shopware()->BillsafeClient(); $documentData = $view->getTemplateVars('Document'); $orderData = $view->getTemplateVars('Order'); $transactionId = $orderData['_order']['transactionID']; $invoiceNumber = $documentData['id']; if (empty($document->_config['_preview'])) { $client->setInvoiceNumber(array( 'transactionId' => $transactionId, 'invoiceNumber' => $invoiceNumber )); } $paymentInstruction = $client->getPaymentInstruction(array( 'transactionId' => $transactionId )); $document->_template->addTemplateDir(dirname(__FILE__) . '/Views/'); $document->_template->assign('instruction', (array)$paymentInstruction->instruction); //$comment = $document->_template->fetch('frontend/payment_billsafe/instruction.tpl'); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer'] = $containerData['Billsafe_Footer']; $containerData['Content_Info'] = $containerData['Billsafe_Content_Info']; $containerData['Content_Info']['value'] = $document->_template->fetch('string:' . $containerData['Content_Info']['value']); $containerData['Content_Info']['style'] = '}' . $containerData['Content_Info']['style'] . ' #info {'; $view->assign('Containers', $containerData); }
public function onBeforeRenderDocument(Enlight_Hook_HookArgs $args) { /* @var Shopware_Components_Document $document */ $document = $args->getSubject(); if ($document->_order->payment['name'] != 'paypal') { return; } /* @var Smarty_Data $view */ $view = $document->_view; $documentData = $view->getTemplateVars('Document'); $orderData = $view->getTemplateVars('Order'); $containers = $view->getTemplateVars('Containers'); if (!isset($containers['Paypal_Content_Info'])) { return; } /** @var InvoiceContentProvider $invoiceContentProvider */ $invoiceContentProvider = $this->get('invoice_content_provider'); $rawFooter = $invoiceContentProvider->getPayPalInvoiceContentInfo($containers, $orderData); $containers['Paypal_Content_Info']['value'] = $rawFooter['value']; $transactionId = $orderData['_order']['transactionID']; $orderNumber = $orderData['_order']['ordernumber']; /** @var PaymentInstructionProvider $paymentInstructionProvider */ $paymentInstructionProvider = $this->get('payment_instruction_provider'); $paymentInstruction = $paymentInstructionProvider->getInstructionsByOrdernumberAndTransactionId($orderNumber, $transactionId); $document->_template->addTemplateDir(dirname(__FILE__) . '/Views/'); $document->_template->assign('instruction', (array) $paymentInstruction); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer'] = $containerData['Paypal_Footer']; $containerData['Content_Info'] = $containerData['Paypal_Content_Info']; $containerData['Content_Info']['value'] = $document->_template->fetch('string:' . $containerData['Content_Info']['value']); $containerData['Content_Info']['style'] = '}' . $containerData['Content_Info']['style'] . ' #info {'; $view->assign('Containers', $containerData); }
/** * Registers the endpoint for the notifications * * @param Enlight_Hook_HookArgs $arguments * @return null */ public function beforeSavePluginConfig($arguments) { $request = $arguments->getSubject()->Request(); $parameter = $request->getParams(); if ($parameter['name'] !== $this->getName() || $parameter['controller'] !== 'config') { return; } foreach ($parameter['elements'] as $element) { if (in_array($element['name'], array('privateKey')) && empty($element['values'][0]['value'])) { return; } if ($element['name'] === 'privateKey') { $privateKey = $element['values'][0]['value']; } } $webHookService = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_WebhookService(); $webHookService->registerWebhookEndpoint($privateKey); }
/** * If the user confirm the order, this function sends the buyer protection request * * @param Enlight_Hook_HookArgs $args * @return void */ public function onSaveOrder(Enlight_Hook_HookArgs $args) { set_time_limit(1000); $orderSubject = $args->getSubject(); $article = $this->isTsArticleInOrder($orderSubject); if(!empty($article)) { $config = $this->getTrustedShopBasicConfig(); $tsDataModel = new TrustedShopsDataModel(); $returnValue = $tsDataModel->sendBuyerProtectionRequest($orderSubject,$article["ordernumber"]); if(is_int($returnValue) && $returnValue > 0) { /* * Inserts the order to the trusted shops order table * The Status will be updated in the cronjob onRunTSCheckOrderState * Status Description: * Status 0 Pending * Status 1 Success * Status 3 Error */ $sql= "INSERT INTO `s_plugin_swag_trusted_shops_excellence_orders` (`ordernumber`, `ts_applicationId`, `status`) VALUES (?,?,0)"; Shopware()->Db()->query($sql, array($orderSubject->sOrderNumber, $returnValue)); $comment = $config["stateWaiting"]["description"]; $status = $config["stateWaiting"]["id"]; } else { //failed $comment = $config["stateError"]["description"]; $status = $config["stateError"]["id"]; } $sql = "UPDATE s_order SET internalcomment = ?, status = ? WHERE ordernumber = ?"; Shopware()->Db()->query($sql, array($comment, $status, $orderSubject->sOrderNumber)); } }
/** * Event listener method to add extra information to the invoice(pdf) * * @param Enlight_Event_EventArgs $args */ public static function onBeforeRenderDocument(Enlight_Hook_HookArgs $args) { $document = $args->getSubject(); $paymentName = $document->_order->payment['name']; if ($paymentName != 'RatePAYInvoice' && $paymentName != 'RatePAYRate' && $paymentName != 'RatePAYDebit'){ return; } $view = $document->_view; $config = Shopware()->Plugins()->Frontend()->PigmbhRatePAYPayment()->Config(); $containerData = array(); $sql = "SELECT `descriptor` FROM `pi_ratepay_orders` WHERE `order_number` = ?"; $descriptor = Shopware()->Db()->fetchOne($sql, array($document->_order->order['ordernumber'])); $bankAdditional = $config->bank_additional; $configAdditional = ""; $bankAdditionalRate = $config->bank_additional_rate; $configRateAdditional = ""; //Ratepay Invoice if ($paymentName == 'RatePAYInvoice') { if($bankAdditional != ""){ $configAdditional = "\n\n".$bankAdditional; } $ratepay = array( 'shopname' => Shopware()->Config()->Shopname, 'host' => Shopware()->Config()->Host, 'merchant_address' => htmlentities($config->merchant_address), 'merchant_phone' => htmlentities($config->merchant_phone), 'merchant_fax' => htmlentities($config->merchant_fax), 'merchant_email' => htmlentities($config->merchant_email), 'merchant_name' => htmlentities($config->merchant_name), 'merchant_court' => htmlentities($config->merchant_court), 'merchant_hr' => htmlentities($config->merchant_hr), 'merchant_ustid' => htmlentities($config->merchant_ustid), 'bank_firm' => htmlentities($config->bank_firm), 'bank_credit' => htmlentities($config->bank_credit), 'bank_blz' => htmlentities($config->bank_blz), 'bank_kto' => htmlentities($config->bank_kto), 'bank_swift' => htmlentities($config->bank_swift), 'bank_iban' => htmlentities($config->bank_iban), 'descriptor' => htmlentities($descriptor), 'bank_additional' => preg_replace('/[\t\r\n]+/', '<br/>', htmlentities($configAdditional)), 'due_date' => htmlentities($config->due_date_invoice) ); $document->_template->assign('ratepay', (array)$ratepay); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer'] = $containerData['pi_ratepay_rechnung_Footer']; $containerData['Header_Box_Right'] = $containerData['pi_ratepay_rechnung_Header_Right']; $containerData['Content_Info'] = $containerData['pi_ratepay_rechnung_Content_Info']; } //Ratepay Rate else if($paymentName == 'RatePAYRate') { if($bankAdditionalRate != ""){ $configRateAdditional = "\n\n".$bankAdditionalRate; } $ratepay = array( 'shopname' => Shopware()->Config()->Shopname, 'host' => Shopware()->Config()->Host, 'merchant_address' => htmlentities($config->merchant_address_rate), 'merchant_phone' => htmlentities($config->merchant_phone_rate), 'merchant_fax' => htmlentities($config->merchant_fax_rate), 'merchant_email' => htmlentities($config->merchant_email_rate), 'merchant_name' => htmlentities($config->merchant_name_rate), 'merchant_court' => htmlentities($config->merchant_court_rate), 'merchant_hr' => htmlentities($config->merchant_hr_rate), 'merchant_ustid' => htmlentities($config->merchant_ustid_rate), 'bank_firm' => htmlentities($config->bank_firm_rate), 'bank_credit' => htmlentities($config->bank_credit_rate), 'bank_blz' => htmlentities($config->bank_blz_rate), 'bank_kto' => htmlentities($config->bank_kto_rate), 'bank_swift' => htmlentities($config->bank_swift_rate), 'bank_iban' => htmlentities($config->bank_iban_rate), 'descriptor' => htmlentities($descriptor), 'bank_additional' => preg_replace('/[\t\r\n]+/', '<br/>', htmlentities($configRateAdditional)), 'forderungsinhaber' => htmlentities($config->forderungsinhaber_rate) ); $document->_template->assign('ratepay', (array)$ratepay); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer']['value'] = $containerData['pi_ratepay_rate_Footer']['value']; $containerData['Header_Box_Right']['value'] = $containerData['pi_ratepay_rate_Header_Right']['value']; $containerData['Content_Info'] = $containerData['pi_ratepay_rate_Content_Info']; } //Ratepay Debit else{ $ratepay = array( 'shopname' => Shopware()->Config()->Shopname, 'host' => Shopware()->Config()->Host, 'merchant_address' => htmlentities($config->merchant_address_debit), 'merchant_phone' => htmlentities($config->merchant_phone_debit), 'merchant_fax' => htmlentities($config->merchant_fax_debit), 'merchant_email' => htmlentities($config->merchant_email_debit), 'merchant_name' => htmlentities($config->merchant_name_debit), 'merchant_court' => htmlentities($config->merchant_court_debit), 'merchant_hr' => htmlentities($config->merchant_hr_debit), 'merchant_ustid' => htmlentities($config->merchant_ustid_debit), 'descriptor' => htmlentities($descriptor), 'due_date' => htmlentities($config->due_date_debit) ); $document->_template->assign('ratepay', (array)$ratepay); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer']['value'] = $containerData['pi_ratepay_debit_Footer']['value']; $containerData['Header_Box_Right']['value'] = $containerData['pi_ratepay_debit_Header_Right']['value']; $containerData['Content_Info'] = $containerData['pi_ratepay_debit_Content_Info']; } $containerData['Footer']['value'] = $document->_template->fetch('string:' . $containerData['Footer']['value']); $containerData['Header_Box_Right']['value'] = $document->_template->fetch('string:' . $containerData['Header_Box_Right']['value']); $containerData['Content_Info']['value'] = $document->_template->fetch('string:' . $containerData['Content_Info']['value']); $containerData['Content_Info']['style'] = $containerData['Content_Info']['style']; $view->assign('Containers', $containerData); }
public static function onsValidateStep3(Enlight_Hook_HookArgs $args) { self::registerNamespace(); $caller = $args->getSubject(); $ret = $args->getReturn(); if (is_array($ret) && $ret['paymentData']['id'] == self::getPaymentId()) { if (!array_key_exists('payonesubpay', $caller->sSYSTEM->_POST)) { $ret['checkPayment']['sErrorMessages'] = 'Bitte wählen Sie eine Option'; $ret['checkPayment']['sErrorFlag'] = array ('postbanksubpay'); $args->setReturn($ret); } else { self::setUserSettings($caller, $caller->sSYSTEM->_POST['payonesubpay']); } } }
/** * Stops Orderdeletation, when any article has been send * * @param Enlight_Hook_HookArgs $arguments */ public function beforeDeleteOrder(Enlight_Hook_HookArgs $arguments) { $request = $arguments->getSubject()->Request(); $parameter = $request->getParams(); if (!in_array($parameter['payment'][0]['name'], array("rpayratepayinvoice", "rpayratepayrate", "rpayratepaydebit"))) { return false; } $sql = "SELECT COUNT(*) FROM `s_order_details` AS `detail` " . "INNER JOIN `rpay_ratepay_order_positions` AS `position` " . "ON `position`.`s_order_details_id` = `detail`.`id` " . "WHERE `detail`.`orderID`=? AND " . "(`position`.`delivered` > 0 OR `position`.`cancelled` > 0 OR `position`.`returned` > 0)"; $count = Shopware()->Db()->fetchOne($sql, array($parameter['id'])); if ($count > 0) { Shopware()->Pluginlogger()->warning('RatePAY-Bestellung können nicht gelöscht werden, wenn sie bereits bearbeitet worden sind.'); $arguments->stop(); } else { $config = Shopware()->Plugins()->Frontend()->RpayRatePay()->Config(); $request = new Shopware_Plugins_Frontend_RpayRatePay_Component_Service_RequestService($config->get('RatePaySandbox')); $modelFactory = new Shopware_Plugins_Frontend_RpayRatePay_Component_Mapper_ModelFactory(); $modelFactory->setTransactionId($parameter['transactionId']); $paymentChange = $modelFactory->getModel(new Shopware_Plugins_Frontend_RpayRatePay_Component_Model_PaymentChange()); $head = $paymentChange->getHead(); $head->setOperationSubstring('full-cancellation'); $paymentChange->setHead($head); $basket = new Shopware_Plugins_Frontend_RpayRatePay_Component_Model_SubModel_ShoppingBasket(); $basket->setAmount(0); $basket->setCurrency($parameter['currency']); $paymentChange->setShoppingBasket($basket); $response = $request->xmlRequest($paymentChange->toArray()); $result = Shopware_Plugins_Frontend_RpayRatePay_Component_Service_Util::validateResponse('PAYMENT_CHANGE', $response); if (!$result) { Shopware()->Pluginlogger()->warning('Bestellung könnte nicht gelöscht werden, da die Stornierung bei RatePAY fehlgeschlagen ist.'); $arguments->stop(); } } }
/** * Event listener method * * @param Enlight_Event_EventArgs|Enlight_Hook_HookArgs $args */ public static function onBeforeRenderDocument(Enlight_Hook_HookArgs $args) { $document = $args->getSubject(); if ($document->_order->payment['name'] != 'PaymorrowInvoice' && $document->_order->payment['name'] != 'PaymorrowRate' ) { return; } $view = $document->_view; $orderData = array(); $orderData = $view->getTemplateVars('Order'); $invoiceNumber = $orderData['_order']['ordernumber']; $paymorrowData = Shopware()->Db()->fetchRow(" SELECT * FROM pi_paymorrow_orders WHERE ordernumber = '" . $invoiceNumber . "' "); $paymorrow = array( 'payment' => $orderData['_order']['payment_description'], 'bankName' => htmlentities($paymorrowData['nationalBankName']), 'bankCode' => htmlentities($paymorrowData['nationalBankCode']), 'accountNumber' => htmlentities($paymorrowData['nationalBankAccountNumber']), 'reference' => htmlentities($paymorrowData['paymentReference']), 'reference2' => htmlentities(Shopware()->Config()->Shopname), 'bic' => htmlentities($paymorrowData['bic']), 'iban' => htmlentities($paymorrowData['iban']) ); $document->_template->assign('paymorrow', (array) $paymorrow); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer'] = $containerData['Paymorrow_Footer']; if ($paymorrowData["nationalBankName"] && $paymorrowData["nationalBankCode"] && $paymorrowData["nationalBankAccountNumber"] && $paymorrowData["paymentReference"] ) { $containerData['Content_Info'] = $containerData['Paymorrow_Content_Info']; } else { $containerData['Content_Info'] = $containerData['Paymorrow_no_Bankdata_Content_Info']; } $containerData['Content_Info']['value'] = $document->_template->fetch('string:' . $containerData['Content_Info']['value']); $containerData['Content_Info']['style'] = '}' . $containerData['Content_Info']['style'] . ' #info {'; $view->assign('Containers', $containerData); }
public function onBeforeRenderDocument(Enlight_Hook_HookArgs $args) { $document = $args->getSubject(); if (!$this->Application()->PayoneMain()->getPaymentHelper()->isPayoneBillsafe($document->_order->payment['name'])) { return; } // get PAYONE data from log $moptPayoneMain = $this->Application()->PayoneMain(); $payoneData = $moptPayoneMain->getPaymentHelper()->getClearingDataFromOrderId($document->_order->order->id); if (empty($payoneData)) { return; } $payoneData['amount'] = $document->_order->order->invoice_amount; $view = $document->_view; //@TODO check if additional treatment for responsive theme is needed here $document->_template->addTemplateDir(dirname(__FILE__) . '/Views/'); $document->_template->assign('instruction', (array) $payoneData); $containerData = $view->getTemplateVars('Containers'); $containerData['Footer'] = $containerData['PAYONE_Footer']; $containerData['Content_Info'] = $containerData['PAYONE_Content_Info']; $containerData['Content_Info']['value'] = $document->_template->fetch('string:' . $containerData['Content_Info']['value']); $containerData['Content_Info']['style'] = '}' . $containerData['Content_Info']['style'] . ' #info {'; $view->assign('Containers', $containerData); }