/** * Generate payment authorization form and AUTH or CAPTURE * * @access public * @param object * @return mixed */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $objTemplate = new \Isotope\Template($this->strTemplate); $objTemplate->setData($this->arrData); $objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MODEL']['tl_iso_payment.purchaseorder'][0]); 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) { $strCountry = in_array($objOrder->getBillingAddress()->country, array('de', 'ch', 'at')) ? $objOrder->getBillingAddress()->country : 'de'; $strUrl = 'https://www.sofortueberweisung.' . $strCountry . '/payment/start'; $arrParams = array('user_id' => $this->sofortueberweisung_user_id, 'project_id' => $this->sofortueberweisung_project_id, 'sender_holder' => '', 'sender_account_number' => '', 'sender_bank_code' => '', 'sender_country_id' => strtoupper($objOrder->getBillingAddress()->country), 'amount' => number_format($objOrder->getTotal(), 2, '.', ''), 'currency_id' => $objOrder->currency, 'reason_1' => \Environment::get('host'), 'reason_2' => '', 'user_variable_0' => $objOrder->id, 'user_variable_1' => $this->id, 'user_variable_2' => $objOrder->uniqid, 'user_variable_3' => '', 'user_variable_4' => '', 'user_variable_5' => '', 'project_password' => $this->sofortueberweisung_project_password); $arrParams['hash'] = sha1(implode('|', $arrParams)); $arrParams['language_id'] = $GLOBALS['TL_LANGUAGE']; $objTemplate = new \Isotope\Template('iso_payment_sofortueberweisung'); $objTemplate->setData($this->arrData); $objTemplate->action = $strUrl; $objTemplate->params = array_filter(array_diff_key($arrParams, array('project_password' => ''))); 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) { // get current host and $strDescription = \Environment::get('host'); $objContact = \PageModel::findWithDetails($this->wirecard_contact); $arrParams = array('customerId' => $this->wirecard_customer_id, 'language' => $GLOBALS['TL_LANGUAGE'], 'paymentType' => 'SELECT', 'amount' => number_format($objOrder->getTotal(), 2, '.', ''), 'currency' => $objOrder->currency, 'orderDescription' => $strDescription, 'successUrl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'cancelUrl' => \Environment::get('base') . $objModule->generateUrlForStep('process'), 'failureUrl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'serviceUrl' => \Environment::get('base') . \Controller::generateFrontendUrl($objContact->row()), 'confirmUrl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'customerStatement' => $strDescription, 'order_id' => $objOrder->id, 'order_uniqid' => $objOrder->uniqid, 'secret' => $this->wirecard_secret, 'REQUEST_TOKEN' => REQUEST_TOKEN); $arrParams['requestFingerprintOrder'] = implode(',', array_keys($arrParams)) . ',requestFingerprintOrder'; $arrParams['requestFingerprint'] = $this->calcHashArray($arrParams); $objTemplate = new \Isotope\Template('iso_payment_wirecard'); $objTemplate->setData($this->arrData); $objTemplate->action = 'https://checkout.wirecard.com/page/init.php'; $objTemplate->params = array_filter(array_diff_key($arrParams, array('secret' => ''))); return $objTemplate->parse(); }
/** * Return the ePay 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_epay'); $objTemplate->setData($this->arrData); $objTemplate->currency = $objOrder->currency; $objTemplate->amount = Currency::getAmountInMinorUnits($objOrder->getTotal(), $objOrder->currency); $objTemplate->orderid = $objOrder->id; $objTemplate->instantcapture = $this->trans_type == 'capture' ? '1' : '0'; $objTemplate->callbackurl = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id; $objTemplate->accepturl = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder); $objTemplate->cancelurl = \Environment::get('base') . $objModule->generateUrlForStep('failed'); $objTemplate->language = (int) static::$arrLanguages[substr($GLOBALS['TL_LANGUAGE'], 0, 2)]; return $objTemplate->parse(); }
/** * Return the PayPal form. * @param IsotopeProductCollection The order being places * @param Module 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()); } $strOptions = ''; $arrOptions = Isotope::formatOptions($objItem->getOptions()); Product::unsetActive(); if (!empty($arrOptions)) { array_walk($arrOptions, function (&$option) { $option = $option['label'] . ': ' . $option['value']; }); $strOptions = ' (' . implode(', ', $arrOptions) . ')'; } $arrData['item_number_' . ++$i] = $objItem->getSku(); $arrData['item_name_' . $i] = $objItem->getName() . $strOptions; $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 = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); return $objTemplate->parse(); }
/** * Generate a product template * @param array * @return string */ public function generate(array $arrConfig) { $this->strFormId = ($arrConfig['module'] instanceof \ContentElement ? 'cte' : 'fmd') . $arrConfig['module']->id . '_product_' . $this->getProductId(); $objProduct = $this->validateVariant(); // A variant has been loaded, generate the variant if ($objProduct->id != $this->id) { return $objProduct->generate($arrConfig); } $arrGalleries = array(); $objTemplate = new \Isotope\Template($arrConfig['template']); $objTemplate->setData($this->arrData); $objTemplate->product = $this; $objTemplate->config = $arrConfig; $objTemplate->generateAttribute = function ($strAttribute, array $arrOptions = array()) use($objProduct) { $objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strAttribute]; if (!$objAttribute instanceof IsotopeAttribute) { throw new \InvalidArgumentException($strAttribute . ' is not a valid attribute'); } return $objAttribute->generate($objProduct, $arrOptions); }; $objTemplate->generatePrice = function () use($objProduct) { $objPrice = $objProduct->getPrice(); if (null === $objPrice) { return ''; } return $objPrice->generate($objProduct->getRelated('type')->showPriceTiers()); }; $objTemplate->getGallery = function ($strAttribute) use($objProduct, $arrConfig, &$arrGalleries) { if (!isset($arrGalleries[$strAttribute])) { $arrGalleries[$strAttribute] = Gallery::createForProductAttribute($objProduct, $strAttribute, $arrConfig); } return $arrGalleries[$strAttribute]; }; $arrVariantOptions = array(); $arrProductOptions = array(); $arrAjaxOptions = array(); foreach (array_unique(array_merge($this->getAttributes(), $this->getVariantAttributes())) as $attribute) { $arrData = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$attribute]; if ($arrData['attributes']['customer_defined'] || $arrData['attributes']['variant_option']) { $strWidget = $this->generateProductOptionWidget($attribute, $arrVariantOptions); if ($strWidget != '') { $objTemplate->hasOptions = true; $arrProductOptions[$attribute] = array_merge($arrData, array('name' => $attribute, 'html' => $strWidget)); if ($arrData['attributes']['variant_option'] || $arrData['attributes']['ajax_option']) { $arrAjaxOptions[] = $attribute; } } } } $arrButtons = array(); // !HOOK: retrieve buttons if (isset($GLOBALS['ISO_HOOKS']['buttons']) && is_array($GLOBALS['ISO_HOOKS']['buttons'])) { foreach ($GLOBALS['ISO_HOOKS']['buttons'] as $callback) { $objCallback = \System::importStatic($callback[0]); $arrButtons = $objCallback->{$callback}[1]($arrButtons); } $arrButtons = array_intersect_key($arrButtons, array_flip($arrConfig['buttons'])); } if (\Input::post('FORM_SUBMIT') == $this->getFormId() && !$this->doNotSubmit) { foreach ($arrButtons as $button => $data) { if (\Input::post($button) != '') { if (isset($data['callback'])) { $objCallback = \System::importStatic($data['callback'][0]); $objCallback->{$data['callback'][1]}($this, $arrConfig); } break; } } } RowClass::withKey('rowClass')->addCustom('product_option')->addFirstLast()->addEvenOdd()->applyTo($arrProductOptions); $objTemplate->buttons = $arrButtons; $objTemplate->useQuantity = $arrConfig['useQuantity']; $objTemplate->minimum_quantity = $this->getMinimumQuantity(); $objTemplate->raw = $this->arrData; $objTemplate->raw_options = $this->getOptions(); $objTemplate->href = $this->generateUrl($arrConfig['jumpTo']); $objTemplate->label_detail = $GLOBALS['TL_LANG']['MSC']['detailLabel']; $objTemplate->options = $arrProductOptions; $objTemplate->hasOptions = !empty($arrProductOptions); $objTemplate->enctype = $this->hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; $objTemplate->formId = $this->getFormId(); $objTemplate->action = ampersand(\Environment::get('request'), true); $objTemplate->formSubmit = $this->getFormId(); $objTemplate->product_id = $this->getProductId(); $objTemplate->module_id = $arrConfig['module']->id; $GLOBALS['AJAX_PRODUCTS'][] = array('formId' => $this->getFormId(), 'attributes' => $arrAjaxOptions); // !HOOK: alter product data before output if (isset($GLOBALS['ISO_HOOKS']['generateProduct']) && is_array($GLOBALS['ISO_HOOKS']['generateProduct'])) { foreach ($GLOBALS['ISO_HOOKS']['generateProduct'] as $callback) { $objCallback = \System::importStatic($callback[0]); $objCallback->{$callback}[1]($objTemplate, $this); } } return $objTemplate->parse(); }
/** * HTML form for checkout * @param object * @param object * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $time = time(); $strSessionId = $objOrder->id . '_' . uniqid(); $objAddress = $objOrder->getBillingAddress(); $intPrice = round($objOrder->getTotal(), 2) * 100; $strDescription = sprintf($GLOBALS['TL_LANG']['MSC']['payu_order'], $objOrder->uniqid); $objTemplate = new \Isotope\Template('iso_payment_payu'); $objTemplate->setData($this->arrData); $objTemplate->id = $this->id; $objTemplate->order_id = $objOrder->uniqid; $objTemplate->ts = $time; $objTemplate->amount = $intPrice; $objTemplate->session_id = $strSessionId; $objTemplate->desc = specialchars($strDescription); $objTemplate->sig = md5($this->payu_id . ($this->debug ? 't' : '') . $strSessionId . $this->payu_authKey . $intPrice . $strDescription . $objOrder->uniqid . $objAddress->firstname . $objAddress->lastname . $objAddress->street_1 . $objAddress->city . $objAddress->postal . $objAddress->country . $objAddress->email . $objAddress->phone . $GLOBALS['TL_LANGUAGE'] . \Environment::get('ip') . $time . $this->payu_key1); $objTemplate->ip = \Environment::get('ip'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->address = $objAddress; $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_payu'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_payu'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_payu'][2]); return $objTemplate->parse(); }