/** * Return the payment form * * @param IsotopeProductCollection|Order $objOrder * @param \Module|\Isotope\Module\Checkout $objModule * * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $objTemplate = new \Isotope\Template('iso_payment_quickpay'); $objTemplate->setData($this->arrData); $params = array('version' => 'v10', 'merchant_id' => $this->quickpay_merchantId, 'agreement_id' => $this->quickpay_agreementId, 'order_id' => str_pad($objOrder->id, 4, '0', STR_PAD_LEFT), 'language' => substr($GLOBALS['TL_LANGUAGE'], 0, 2), 'amount' => Currency::getAmountInMinorUnits($objOrder->getTotal(), $objOrder->currency), 'currency' => $objOrder->currency, 'continueurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'cancelurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'callbackurl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'autocapture' => $this->trans_type == 'capture' ? '1' : '0'); if ('' !== $this->quickpay_paymentMethods) { $params['payment_methods'] = $this->quickpay_paymentMethods; } $apiKey = $this->quickpay_apiKey; $objTemplate->params = $params; $objTemplate->calculateHash = function ($params) use($apiKey) { ksort($params); return hash_hmac("sha256", implode(" ", $params), $apiKey); }; return $objTemplate->parse(); }
/** * Return the PayPal form. * * @param IsotopeProductCollection|Order $objOrder The order being places * @param \Module|Checkout $objModule The checkout module instance * * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $arrData = array(); $fltDiscount = 0; $i = 0; foreach ($objOrder->getItems() as $objItem) { // Set the active product for insert tags replacement if ($objItem->hasProduct()) { Product::setActive($objItem->getProduct()); } $strConfig = ''; $arrConfig = $objItem->getConfiguration(); if (!empty($arrConfig)) { array_walk($arrConfig, function (&$option) { $option = $option['label'] . ': ' . (string) $option; }); $strConfig = ' (' . implode(', ', $arrConfig) . ')'; } $arrData['item_number_' . ++$i] = $objItem->getSku(); $arrData['item_name_' . $i] = \StringUtil::restoreBasicEntities($objItem->getName() . $strConfig); $arrData['amount_' . $i] = $objItem->getPrice(); $arrData['quantity_' . $i] = $objItem->quantity; } foreach ($objOrder->getSurcharges() as $objSurcharge) { if (!$objSurcharge->addToTotal) { continue; } // PayPal does only support one single discount item if ($objSurcharge->total_price < 0) { $fltDiscount -= $objSurcharge->total_price; continue; } $arrData['item_name_' . ++$i] = $objSurcharge->label; $arrData['amount_' . $i] = $objSurcharge->total_price; } $objTemplate = new \Isotope\Template('iso_payment_paypal'); $objTemplate->setData($this->arrData); $objTemplate->id = $this->id; $objTemplate->action = 'https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr'; $objTemplate->invoice = $objOrder->id; $objTemplate->data = array_map('specialchars', $arrData); $objTemplate->discount = $fltDiscount; $objTemplate->address = $objOrder->getBillingAddress(); $objTemplate->currency = $objOrder->currency; $objTemplate->return = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder); $objTemplate->cancel_return = \Environment::get('base') . $objModule->generateUrlForStep('failed'); $objTemplate->notify_url = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id; $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]); $objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]); $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); $objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]); return $objTemplate->parse(); }
/** * Generate and return document template * @return string */ protected function generateTemplate(IsotopeProductCollection $objCollection, array $arrTokens) { $objTemplate = new \Isotope\Template($this->documentTpl); $objTemplate->setData($this->arrData); $objTemplate->title = \String::parseSimpleTokens($this->documentTitle, $arrTokens); $objTemplate->collection = $objCollection; // Render the collection $objCollectionTemplate = new \Isotope\Template($this->collectionTpl); $objCollection->addToTemplate($objCollectionTemplate, array('gallery' => $this->gallery, 'sorting' => $objCollection->getItemsSortingCallable($this->orderCollectionBy))); $objTemplate->products = $objCollectionTemplate->parse(); // Generate template and fix PDF issues, see Contao's ModuleArticle $strBuffer = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false)); $strBuffer = html_entity_decode($strBuffer, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']); $strBuffer = \Controller::convertRelativeUrls($strBuffer, '', true); // Remove form elements and JavaScript links $arrSearch = array('@<form.*</form>@Us', '@<a [^>]*href="[^"]*javascript:[^>]+>.*</a>@Us'); $strBuffer = preg_replace($arrSearch, '', $strBuffer); // URL decode image paths (see contao/core#6411) // Make image paths absolute $strBuffer = preg_replace_callback('@(src=")([^"]+)(")@', function ($args) { if (preg_match('@^(http://|https://)@', $args[2])) { return $args[2]; } return $args[1] . TL_ROOT . '/' . rawurldecode($args[2]) . $args[3]; }, $strBuffer); // Handle line breaks in preformatted text $strBuffer = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strBuffer); // Default PDF export using TCPDF $arrSearch = array('@<span style="text-decoration: ?underline;?">(.*)</span>@Us', '@(<img[^>]+>)@', '@(<div[^>]+block[^>]+>)@', '@[\\n\\r\\t]+@', '@<br( /)?><div class="mod_article@', '@href="([^"]+)(pdf=[0-9]*(&|&)?)([^"]*)"@'); $arrReplace = array('<u>$1</u>', '<br>$1', '<br>$1', ' ', '<div class="mod_article', 'href="$1$4"'); $strBuffer = preg_replace($arrSearch, $arrReplace, $strBuffer); return $strBuffer; }
/** * HTML form for checkout * @param object * @param object * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $strPrice = number_format(round($objOrder->getTotal(), 2), 2, '.', ''); $objTemplate = new \Isotope\Template('iso_payment_transferujpl'); $objTemplate->setData($this->arrData); $objTemplate->id = $this->id; $objTemplate->order_id = $objOrder->id; $objTemplate->amount = $strPrice; $objTemplate->products = specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['transferujpl_order'], $objOrder->uniqid)); $objTemplate->hash = md5($this->transferujpl_id . $strPrice . $objOrder->id . $this->transferujpl_code); $objTemplate->postsaleUrl = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id; $objTemplate->successUrl = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder); $objTemplate->errorUrl = \Environment::get('base') . $objModule->generateUrlForStep('failed'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->address = $objOrder->getBillingAddress(); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_transferujpl'][2]); return $objTemplate->parse(); }
/** * Return the checkout form. * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { global $objPage; $objAddress = $objOrder->getBillingAddress(); $arrData['instId'] = $this->worldpay_instId; $arrData['cartId'] = $objOrder->id; $arrData['amount'] = number_format($objOrder->getTotal(), 2); $arrData['currency'] = $objOrder->currency; $arrData['description'] = Translation::get($this->worldpay_description); $arrData['name'] = substr($objAddress->firstname . ' ' . $objAddress->lastname, 0, 40); if ($objAddress->company != '') { $arrData['address1'] = substr($objAddress->company, 0, 84); $arrData['address2'] = substr($objAddress->street_1, 0, 84); $arrData['address3'] = substr($objAddress->street_2, 0, 84); } else { $arrData['address1'] = substr($objAddress->street_1, 0, 84); $arrData['address2'] = substr($objAddress->street_2, 0, 84); $arrData['address3'] = substr($objAddress->street_3, 0, 84); } $arrData['town'] = substr($objAddress->city, 0, 30); $arrData['region'] = substr($objAddress->subdivision, 0, 30); $arrData['postcode'] = substr($objAddress->postal, 0, 12); $arrData['country'] = strtoupper($objAddress->country); $arrData['tel'] = substr($objAddress->phone, 0, 30); $arrData['email'] = substr($objAddress->email, 0, 80); // Generate MD5 secret hash $arrData['signature'] = md5($this->worldpay_md5secret . ':' . implode(':', array_intersect_key($arrData, array_flip(trimsplit(':', $this->worldpay_signatureFields))))); $objTemplate = new \Isotope\Template('iso_payment_worldpay'); $objTemplate->setData($arrData); $objTemplate->id = $this->id; $objTemplate->pageId = $objPage->id; $objTemplate->debug = $this->debug; $objTemplate->action = $this->debug ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase'; $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]); $objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]); $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); $objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]); return $objTemplate->parse(); }
/** * Return the payment form * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $arrParams = $this->preparePSPParams($objOrder, $objModule); // SHA-1 must be generated on alphabetically sorted keys. // Use the natural order algorithm so ITEM10 gets listed after ITEM2 // We can only use ksort($arrParams, SORT_NATURAL) as of PHP 5.4 uksort($arrParams, 'strnatcasecmp'); $strSHASign = ''; foreach ($arrParams as $k => $v) { if ($v == '') { continue; } $strSHASign .= $k . '=' . htmlspecialchars_decode($v) . $this->psp_hash_in; } $arrParams['SHASIGN'] = strtoupper(hash($this->psp_hash_method, $strSHASign)); $objTemplate = new \Isotope\Template($this->strTemplate); $objTemplate->setData($this->arrData); $objTemplate->params = $arrParams; $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->slabel = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]; return $objTemplate->parse(); }