Пример #1
0
 /**
  * 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';
     return $objTemplate->parse();
 }
Пример #2
0
 /**
  * Process Transaction URL notification
  *
  * @param IsotopeProductCollection|Order $objOrder
  */
 public function processPostsale(IsotopeProductCollection $objOrder)
 {
     if (\Input::post('aid') != $this->payone_aid || \Input::post('portalid') != $this->payone_portalid || \Input::post('mode') == 'test' && !$this->debug || \Input::post('mode') == 'live' && $this->debug) {
         \System::log('PayOne configuration mismatch', __METHOD__, TL_ERROR);
         die('TSOK');
     }
     // Ignore  all except these actions
     if (\Input::post('txaction') != 'appointed' && \Input::post('txaction') != 'capture' && \Input::post('txaction') != 'paid') {
         die('TSOK');
     }
     if (\Input::post('currency') != $objOrder->currency || $objOrder->getTotal() != \Input::post('price')) {
         \System::log('PayOne order data mismatch for Order ID "' . \Input::post('reference') . '"', __METHOD__, TL_ERROR);
         die('TSOK');
     }
     if (!$objOrder->checkout()) {
         \System::log('Postsale checkout for Order ID "' . \Input::post('reference') . '" failed', __METHOD__, TL_ERROR);
         die('TSOK');
     }
     if (\Input::post('txaction') == 'paid' && \Input::post('balance') == 0) {
         $objOrder->date_paid = time();
     }
     $objOrder->updateOrderStatus($this->new_order_status);
     $objOrder->save();
     // PayOne must get TSOK as return value, otherwise the request will be sent again
     die('TSOK');
 }
 protected function generatePaymentWidget()
 {
     $arrFields = array('purchase_order_id' => array('label' => &$GLOBALS['TL_LANG']['MSC']['purchase_order_id'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'tableless' => true)));
     $arrParsed = array();
     $blnSubmit = true;
     $intSelectedPayment = intval(\Input::post('PaymentMethod') ?: $this->objCart->getPaymentMethod());
     foreach ($arrFields as $field => $arrData) {
         $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
         // Continue if the class is not defined
         if (!class_exists($strClass)) {
             continue;
         }
         $objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field));
         if ($arrData['value']) {
             $objWidget->value = $arrData['value'];
         }
         $objWidget->tableless = $this->tableless;
         //Handle form submit
         if (\Input::post('FORM_SUBMIT') == $this->strFormId && $intSelectedPayment == $this->id) {
             $objWidget->validate();
             if ($objWidget->hasErrors()) {
                 $blnSubmit = false;
                 $objModule->doNotSubmit = true;
             }
         }
         // Give the template plenty of ways to output the fields
         $strParsed = $objWidget->parse();
         $strBuffer .= $strParsed;
         $arrParsed[$field] = $strParsed;
         $objTemplate->{'field_' . $field} = $strParsed;
     }
 }
Пример #4
0
 /**
  * Returns true if the product is available
  * ALMOST THE SAME AS THE PARENT, EXCEPT WE DON'T CHECK FOR PRICE
  *
  * @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection
  *
  * @return bool
  */
 public function isAvailableForCollection(IsotopeProductCollection $objCollection)
 {
     if ($objCollection->isLocked()) {
         return true;
     }
     if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) {
         return false;
     }
     // Show to guests only
     if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) {
         return false;
     }
     // Protected product
     if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) {
         if ($objCollection->member == 0) {
             return false;
         }
         $groups = deserialize($this->arrData['groups']);
         $memberGroups = deserialize($objCollection->getRelated('member')->groups);
         if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) {
             return false;
         }
     }
     // Check that the product is in any page of the current site
     if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) {
         return false;
     }
     // Check if "advanced price" is available
     //if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) {
     //    return false;
     //}
     return true;
 }
Пример #5
0
 /**
  * Prepares the collection tokens
  * @param   IsotopeProductCollection
  * @return  array
  */
 protected function prepareCollectionTokens(IsotopeProductCollection $objCollection)
 {
     $arrTokens = array();
     foreach ($objCollection->row() as $k => $v) {
         $arrTokens['collection_' . $k] = $v;
     }
     return $arrTokens;
 }
Пример #6
0
 /**
  * Get shipping and payment surcharges for given collection
  * @param IsotopeProductCollection
  * @return array
  */
 public function findShippingAndPaymentSurcharges(IsotopeProductCollection $objCollection)
 {
     $arrSurcharges = array();
     if (($objSurcharge = $objCollection->getShippingSurcharge()) !== null) {
         $arrSurcharges[] = $objSurcharge;
     }
     if (($objSurcharge = $objCollection->getPaymentSurcharge()) !== null) {
         $arrSurcharges[] = $objSurcharge;
     }
     return $arrSurcharges;
 }
Пример #7
0
 /**
  * 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();
 }
Пример #8
0
 /**
  * Replace insert tag for a product collection.
  *
  * @param IsotopeProductCollection $collection
  * @param array                    $tokens
  *
  * @return string
  */
 private function getValueForCollectionTag(IsotopeProductCollection $collection, array $tokens)
 {
     switch ($tokens[1]) {
         case 'items':
             return $collection->countItems();
         case 'quantity':
             return $collection->sumItemsQuantity();
         case 'items_label':
             $intCount = $collection->countItems();
             if (!$intCount) {
                 return '';
             }
             if ($intCount == 1) {
                 return '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')';
             } else {
                 return sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
             }
             break;
         case 'quantity_label':
             $intCount = $collection->sumItemsQuantity();
             if (!$intCount) {
                 return '';
             }
             if ($intCount == 1) {
                 return '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')';
             } else {
                 return sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
             }
             break;
         case 'subtotal':
             return Isotope::formatPriceWithCurrency($collection->getSubtotal());
         case 'taxfree_subtotal':
             return Isotope::formatPriceWithCurrency($collection->getTaxFreeSubtotal());
         case 'total':
             return Isotope::formatPriceWithCurrency($collection->getTotal());
         case 'taxfree_total':
             return Isotope::formatPriceWithCurrency($collection->getTaxFreeTotal());
         case 'billing_address':
             if (!$collection instanceof IsotopeOrderableCollection || ($address = $collection->getBillingAddress()) === null) {
                 return '';
             }
             return $this->getValueForAddressTag($address, $tokens[2]);
         case 'shipping_address':
             if (!$collection instanceof IsotopeOrderableCollection || !$collection->hasShipping() || ($address = $collection->getShippingAddress()) === null) {
                 return '';
             }
             return $this->getValueForAddressTag($address, $tokens[2]);
         default:
             return $collection->{$tokens[1]};
     }
 }
Пример #9
0
 /**
  * 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();
 }
Пример #10
0
 /**
  * Generate the submit form for datatrans and if javascript is enabled redirect automaticly
  * @param   IsotopeProductCollection    The order being places
  * @param   Module                      The checkout module instance
  * @return  string
  */
 public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
 {
     $objAddress = $objOrder->getBillingAddress();
     $arrParams = array('merchantId' => $this->datatrans_id, 'amount' => round($objOrder->getTotal() * 100), 'currency' => $objOrder->currency, 'refno' => $objOrder->id, 'language' => $objOrder->language, 'reqtype' => $this->trans_type == 'auth' ? 'NOA' : 'CAA', 'uppCustomerDetails' => 'yes', 'uppCustomerTitle' => $objAddress->salutation, 'uppCustomerFirstName' => $objAddress->firstname, 'uppCustomerLastName' => $objAddress->lastname, 'uppCustomerStreet' => $objAddress->street_1, 'uppCustomerStreet2' => $objAddress->street_2, 'uppCustomerCity' => $objAddress->city, 'uppCustomerCountry' => $objAddress->country, 'uppCustomerZipCode' => $objAddress->postal, 'uppCustomerPhone' => $objAddress->phone, 'uppCustomerEmail' => $objAddress->email, 'successUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder)), 'errorUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('failed')), 'cancelUrl' => ampersand(\Environment::get('base') . $objModule->generateUrlForStep('failed')), 'mod' => 'pay', 'id' => $this->id);
     // Security signature (see Security Level 2)
     $arrParams['sign'] = hash_hmac('md5', $arrParams['merchantId'] . $arrParams['amount'] . $arrParams['currency'] . $arrParams['refno'], $this->datatrans_sign);
     $objTemplate = new \Isotope\Template('iso_payment_datatrans');
     $objTemplate->id = $this->id;
     $objTemplate->action = 'https://' . ($this->debug ? 'pilot' : 'payment') . '.datatrans.biz/upp/jsp/upStart.jsp';
     $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 = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]);
     return $objTemplate->parse();
 }
Пример #11
0
 /**
  * Get shipping and payment surcharges for given collection
  *
  * @param IsotopeProductCollection|Order $objCollection
  *
  * @return ProductCollectionSurcharge[]
  */
 public function findShippingAndPaymentSurcharges(IsotopeProductCollection $objCollection)
 {
     // Do not add shipping and payment surcharge to cart,
     // they should only appear in the order review
     if ($objCollection instanceof Cart) {
         return array();
     }
     $arrSurcharges = array();
     if (($objSurcharge = $objCollection->getShippingSurcharge()) !== null) {
         $arrSurcharges[] = $objSurcharge;
     }
     if (($objSurcharge = $objCollection->getPaymentSurcharge()) !== null) {
         $arrSurcharges[] = $objSurcharge;
     }
     return $arrSurcharges;
 }
Пример #12
0
 /**
  * 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();
 }
Пример #13
0
    /**
     * 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('popupId' => $this->expercash_popupId, 'jobId' => microtime(), 'functionId' => $objOrder->member ?: $objOrder->uniqid, 'transactionId' => $objOrder->id, 'amount' => round($objOrder->getTotal(), 2) * 100, 'currency' => $objOrder->currency, 'paymentMethod' => $this->expercash_paymentMethod, 'returnUrl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'errorUrl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'notifyUrl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'profile' => $this->expercash_profile);
        $strKey = '';
        $strUrl = 'https://epi.expercash.net/epi_popup2.php?';
        foreach ($arrData as $k => $v) {
            $strKey .= $v;
            $strUrl .= $k . '=' . urlencode($v) . '&';
        }
        if (is_file(TL_ROOT . '/' . $this->expercash_css)) {
            $strUrl .= 'cssUrl=' . urlencode(\Environment::get('base') . $this->expercash_css) . '&';
        }
        $strUrl .= 'language=' . strtoupper($GLOBALS['TL_LANGUAGE']) . '&popupKey=' . md5($strKey . $this->expercash_popupKey);
        $strBuffer = '
<h2>' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0] . '</h2>
<p class="message">' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1] . '</p>

<iframe src="' . $strUrl . '" width="100%" height="500">
  <p>Ihr Browser kann leider keine eingebetteten Frames anzeigen:
  Sie können die eingebettete Seite über den folgenden Verweis
  aufrufen: <a href="' . $strUrl . '">ExperCash</a></p>
</iframe>';
        return $strBuffer;
    }
Пример #14
0
 /**
  * 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)
 {
     global $objPage;
     $arrUrl = array();
     $strUrl = 'https://' . ($this->debug ? 'test' : '') . 'system.sparkassen-internetkasse.de/vbv/mpi_legacy?';
     $arrParam = array('amount' => number_format($objOrder->getTotal(), 2, ',', ''), 'basketid' => $objOrder->source_collection_id, 'command' => 'sslform', 'currency' => $objOrder->currency, 'locale' => $objOrder->language, 'orderid' => $objOrder->id, 'paymentmethod' => $this->sparkasse_paymentmethod, 'sessionid' => $objPage->id, 'sslmerchant' => $this->sparkasse_sslmerchant, 'transactiontype' => $this->trans_type == 'auth' ? 'preauthorization' : 'authorization', 'version' => '1.5');
     if ($this->sparkasse_merchantref != '') {
         $arrParam['merchantref'] = substr($this->replaceInsertTags($this->sparkasse_merchantref), 0, 30);
     }
     $arrParam['mac'] = $this->calculateHash($arrParam);
     foreach ($arrParam as $k => $v) {
         $arrUrl[] = $k . '=' . $v;
     }
     $strUrl .= implode('&', $arrUrl);
     return "\n<script>\nwindow.location.href = '" . $strUrl . "';\n</script>\n<h3>" . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0] . "</h3>\n<p>" . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1] . "</p>\n<p><a href=\"" . $strUrl . "\">" . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2] . "</a>";
 }
Пример #15
0
 /**
  * Process post-sale requestion from the PSP payment server.
  * @param   IsotopeProductCollection
  */
 public function processPostsale(IsotopeProductCollection $objOrder)
 {
     if ($this->debug) {
         $this->paybyway_private_key = 'private_key';
     }
     $strChecksum = strtoupper(md5($this->paybyway_private_key . '|' . \Input::post('RETURN_CODE') . '|' . \Input::post('ORDER_NUMBER') . (\Input::post('SETTLED') ? '|' . \Input::post('SETTLED') : '') . (\Input::post('INCIDENT_ID') ? '|' . \Input::post('INCIDENT_ID') : '')));
     if (\Input::post('AUTHCODE') != $strChecksum) {
         \System::log('Postsale manipulation for order ID ' . $objOrder->id, __METHOD__, TL_ERROR);
         \Isotope\Module\Checkout::redirectToStep('failed');
     }
     switch (\Input::post('RETURN_CODE')) {
         case 0:
             // Payment completed successfully.
             if ($objOrder->checkout()) {
                 $objOrder->date_paid = time();
                 $objOrder->updateOrderStatus($this->new_order_status);
                 \Isotope\Module\Checkout::redirectToStep('complete', $objOrder);
             }
             break;
         case 4:
             // Transaction status could not be updated after customer returned from the web page of a bank. Please use the merchant UI to resolve the payment status.
             if (($objConfig = $objOrder->getRelated('config_id')) === null) {
                 \System::log('Config for Order ID ' . $objOrder->id . ' not found', __METHOD__, TL_ERROR);
             } elseif ($objOrder->checkout()) {
                 $objOrder->updateOrderStatus($objConfig->orderstatus_error);
                 \Isotope\Module\Checkout::redirectToStep('complete', $objOrder);
             }
             break;
         case 1:
             // Payment failed. Customer did not successfully finish the payment.
         // Payment failed. Customer did not successfully finish the payment.
         case 2:
             // Duplicate order number. You have reused an order number. Make sure that your order numbers are unique, and are not reused in any case.
         // Duplicate order number. You have reused an order number. Make sure that your order numbers are unique, and are not reused in any case.
         case 3:
             // User disabled. Either your Paybyway account has been temporarily disabled for security reasons, or your sub-merchant is disabled.
         // User disabled. Either your Paybyway account has been temporarily disabled for security reasons, or your sub-merchant is disabled.
         case 10:
             // Maintenance break. The transaction is not created and the user has been notified and transferred back to the cancel address.
             // Do nothing here, we redirect to "failed" by default
             break;
     }
     \System::log('Paybyway checkout failed for order ID ' . $objOrder->id, __METHOD__, TL_ERROR);
     \Isotope\Module\Checkout::redirectToStep('failed');
 }
Пример #16
0
 /**
  * Process payment on checkout page.
  * @param   IsotopeProductCollection    The order being places
  * @param   Module                      The checkout module instance
  * @return  mixed
  */
 public function processPayment(IsotopeProductCollection $objOrder, \Module $objModule)
 {
     $objOrder->checkout();
     $objOrder->updateOrderStatus($this->new_order_status);
     return true;
 }
Пример #17
0
 /**
  * Create ProductCollectionDownload for all product downloads in the given collection
  *
  * @param IsotopeProductCollection $objCollection
  *
  * @return static[]
  */
 public static function createForProductsInCollection(IsotopeProductCollection $objCollection)
 {
     $arrDownloads = array();
     $t = Download::getTable();
     $time = $objCollection->locked ?: ($objCollection->tstamp ?: time());
     foreach ($objCollection->getItems() as $objItem) {
         if ($objItem->hasProduct()) {
             $objDownloads = Download::findBy(array("({$t}.pid=? OR {$t}.pid=?)", "{$t}.published='1'"), array($objItem->getProduct()->id, $objItem->getProduct()->pid));
             if (null !== $objDownloads) {
                 /** @var Download $objDownload */
                 foreach ($objDownloads as $objDownload) {
                     $objItemDownload = new static();
                     $objItemDownload->pid = $objItem->id;
                     $objItemDownload->tstamp = $time;
                     $objItemDownload->download_id = $objDownload->id;
                     if ($objDownload->downloads_allowed > 0) {
                         $objItemDownload->downloads_remaining = $objDownload->downloads_allowed * $objItem->quantity;
                     }
                     $expires = $objDownload->getExpirationTimestamp($time);
                     if (null !== $expires) {
                         $objItemDownload->expires = $expires;
                     }
                     $arrDownloads[] = $objItemDownload;
                 }
             }
         }
     }
     return $arrDownloads;
 }
Пример #18
0
 /**
  * Create a new address for a product collection
  *
  * @param IsotopeProductCollection $objCollection
  * @param array|null               $arrFill an array of member fields to inherit
  * @param bool                     $blnDefaultBilling
  * @param bool                     $blnDefaultShipping
  *
  * @return static
  */
 public static function createForProductCollection(IsotopeProductCollection $objCollection, $arrFill = null, $blnDefaultBilling = false, $blnDefaultShipping = false)
 {
     $objAddress = new static();
     $arrData = array('pid' => (int) $objCollection->id, 'ptable' => 'tl_iso_product_collection', 'tstamp' => time(), 'store_id' => (int) $objCollection->store_id, 'isDefaultBilling' => $blnDefaultBilling ? '1' : '', 'isDefaultShipping' => $blnDefaultShipping ? '1' : '');
     if ($objCollection->member > 0 && !empty($arrFill) && is_array($arrFill) && ($objMember = \MemberModel::findByPk($objCollection->member)) !== null) {
         // Generate address data from tl_member, limit to fields enabled in the shop configuration
         $arrMember = array_intersect_key(array_merge($objMember->row(), array('street_1' => $objMember->street, 'subdivision' => strtoupper($objMember->country . '-' . $objMember->state))), array_flip($arrFill));
         $arrData = array_merge($arrMember, $arrData);
     }
     if ($arrData['country'] == '' && ($objConfig = $objCollection->getRelated('config_id')) !== null) {
         if ($blnDefaultBilling) {
             $arrData['country'] = $objConfig->billing_country ?: $objConfig->country;
         } elseif ($blnDefaultShipping) {
             $arrData['country'] = $objConfig->shipping_country ?: $objConfig->country;
         }
     }
     $objAddress->setRow($arrData);
     return $objAddress;
 }
Пример #19
0
 /**
  * Generate POST data to initialize payment
  *
  * @param IsotopeProductCollection $objOrder
  * @param \Module                  $objModule
  *
  * @return array
  */
 protected function generatePaymentPostData(IsotopeProductCollection $objOrder, \Module $objModule)
 {
     $arrData = array();
     $arrData['ACCOUNTID'] = $this->saferpay_accountid;
     $arrData['AMOUNT'] = round($objOrder->getTotal() * 100, 0);
     $arrData['CURRENCY'] = $objOrder->currency;
     $arrData['SUCCESSLINK'] = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder);
     $arrData['FAILLINK'] = \Environment::get('base') . $objModule->generateUrlForStep('failed');
     $arrData['BACKLINK'] = $arrData['FAILLINK'];
     $arrData['NOTIFYURL'] = \Environment::get('base') . '/system/modules/isotope/postsale.php?mod=pay&id=' . $this->id;
     $arrData['DESCRIPTION'] = $this->saferpay_description;
     $arrData['ORDERID'] = $objOrder->id;
     // order id
     // Additional attributes
     if ($this->saferpay_vtconfig) {
         $arrData['VTCONFIG'] = $this->saferpay_vtconfig;
     }
     if ($this->saferpay_paymentmethods != '') {
         $arrData['PAYMENTMETHODS'] = $this->saferpay_paymentmethods;
     }
     return $arrData;
 }
Пример #20
0
 /**
  * Find advanced price for multiple product/variant IDs
  *
  * @param array                                      $arrIds
  * @param IsotopeProductCollection|ProductCollection $objCollection
  *
  * @return \Model\Collection|null
  */
 public static function findAdvancedByProductIdsAndCollection(array $arrIds, IsotopeProductCollection $objCollection)
 {
     $time = \Date::floorToMinute();
     $arrGroups = static::getMemberGroups($objCollection->getRelated('member'));
     $objResult = \Database::getInstance()->query("\n            SELECT *\n            FROM (\n                SELECT\n                    tl_iso_product_price.*,\n                    GROUP_CONCAT(tl_iso_product_pricetier.min) AS tier_keys,\n                    GROUP_CONCAT(tl_iso_product_pricetier.price) AS tier_values\n                FROM tl_iso_product_price\n                LEFT JOIN tl_iso_product_pricetier ON tl_iso_product_pricetier.pid = tl_iso_product_price.id\n                WHERE\n                    config_id IN (" . (int) $objCollection->config_id . ",0) AND\n                    member_group IN(" . implode(',', $arrGroups) . ") AND\n                    (start='' OR start<'{$time}') AND\n                    (stop='' OR stop>'" . ($time + 60) . "') AND\n                    tl_iso_product_price.pid IN (" . implode(',', $arrIds) . ")\n                GROUP BY tl_iso_product_price.id\n                ORDER BY config_id DESC, " . \Database::getInstance()->findInSet('member_group', $arrGroups) . ", start DESC, stop DESC\n            ) AS prices\n            GROUP BY prices.pid\n        ");
     if ($objResult->numRows) {
         return ProductPriceCollection::createFromDbResult($objResult, static::$strTable);
     }
     return null;
 }
Пример #21
0
 /**
  * Initialize a new collection and duplicate everything from the source
  * @param   IsotopeProductCollection
  */
 public static function createFromCollection(IsotopeProductCollection $objSource)
 {
     global $objPage;
     $objCollection = new static();
     $objConfig = $objSource->getRelated('config_id');
     if (null === $objConfig) {
         $objConfig = Isotope::getConfig();
     }
     $objCollection->uniqid = uniqid(Haste::getInstance()->call('replaceInsertTags', array((string) $objConfig->orderPrefix, false)), true);
     $objCollection->source_collection_id = (int) $objSource->id;
     $objCollection->config_id = (int) $objConfig->id;
     $objCollection->store_id = (int) $objSource->store_id;
     $objCollection->member = (int) $objSource->member;
     $objCollection->language = (string) $GLOBALS['TL_LANGUAGE'];
     $objCollection->currency = (string) $objConfig->currency;
     $objCollection->pageId = (int) $objPage->id;
     $objCollection->setShippingMethod($objSource->getShippingMethod());
     $objCollection->setPaymentMethod($objSource->getPaymentMethod());
     $objCollection->setShippingAddress($objSource->getShippingAddress());
     $objCollection->setBillingAddress($objSource->getBillingAddress());
     $arrItemIds = $objCollection->copyItemsFrom($objSource);
     $arrSurchargeIds = $objCollection->copySurchargesFrom($objSource, $arrItemIds);
     $objCollection->updateDatabase();
     // HOOK: order status has been updated
     if (isset($GLOBALS['ISO_HOOKS']['createFromProductCollection']) && is_array($GLOBALS['ISO_HOOKS']['createFromProductCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['createFromProductCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $objCallback->{$callback}[1]($objCollection, $objSource, $arrItemIds, $arrSurchargeIds);
         }
     }
     return $objCollection;
 }
Пример #22
0
 /**
  * Find advanced price for multiple product/variant IDs
  *
  * @param   array
  * @param   IsotopeProductCollection
  *
  * @return  \Model\Collection|null
  */
 public static function findAdvancedByProductIdsAndCollection(array $arrIds, IsotopeProductCollection $objCollection)
 {
     $time = time();
     $arrGroups = static::getMemberGroups($objCollection->getRelated('member'));
     $objResult = \Database::getInstance()->query("\n            SELECT * FROM (\n                SELECT *\n                FROM " . static::$strTable . "\n                WHERE\n                    config_id IN (" . (int) $objCollection->config_id . ",0) AND\n                    member_group IN(" . implode(',', $arrGroups) . ") AND\n                    (start='' OR start<{$time}) AND\n                    (stop='' OR stop>{$time}) AND\n                    pid IN (" . implode(',', $arrIds) . ")\n                ORDER BY config_id DESC, " . \Database::getInstance()->findInSet('member_group', $arrGroups) . ", start DESC, stop DESC\n            ) AS prices\n            GROUP BY pid\n        ");
     if ($objResult->numRows) {
         return \Isotope\Collection\ProductPrice::createFromDbResult($objResult, static::$strTable);
     }
     return null;
 }
Пример #23
0
 public static function createForRuleInCollection(RuleModel $objRule, IsotopeProductCollection $objCollection)
 {
     // Cart subtotal
     if ($objRule->minSubtotal > 0 && $objCollection->getSubtotal() < $objRule->minSubtotal || $objRule->maxSubtotal > 0 && $objCollection->getSubtotal() > $objRule->maxSubtotal) {
         return null;
     }
     $arrCollectionItems = $objCollection->getItems();
     $blnMatch = false;
     $blnPercentage = $objRule->isPercentage();
     $fltDiscount = $blnPercentage ? $objRule->getPercentage() : 0;
     $fltTotal = 0;
     $arrSubtract = array();
     $objSurcharge = new static();
     $objSurcharge->label = $objRule->getLabel();
     $objSurcharge->price = $objRule->getPercentageLabel();
     $objSurcharge->total_price = 0;
     $objSurcharge->tax_class = 0;
     $objSurcharge->before_tax = true;
     $objSurcharge->addToTotal = true;
     // Product or producttype restrictions
     if ($objRule->productRestrictions != '' && $objRule->productRestrictions != 'none') {
         $arrLimit = \Database::getInstance()->execute("SELECT object_id FROM tl_iso_rule_restriction WHERE pid={$objRule->id} AND type='{$objRule->productRestrictions}'")->fetchEach('object_id');
         if ($objRule->productRestrictions == 'pages' && !empty($arrLimit)) {
             $arrLimit = \Database::getInstance()->execute("SELECT pid FROM " . \Isotope\Model\ProductCategory::getTable() . " WHERE page_id IN (" . implode(',', $arrLimit) . ")")->fetchEach('pid');
         }
         if ($objRule->quantityMode == 'cart_products' || $objRule->quantityMode == 'cart_items') {
             $intTotal = 0;
             foreach ($arrCollectionItems as $objItem) {
                 if (!$objItem->hasProduct()) {
                     continue;
                 }
                 $objProduct = $objItem->getProduct();
                 if (($objRule->productRestrictions == 'products' || $objRule->productRestrictions == 'variants' || $objRule->productRestrictions == 'pages') && (in_array($objProduct->id, $arrLimit) || $objProduct->pid > 0 && in_array($objProduct->pid, $arrLimit)) || $objRule->productRestrictions == 'producttypes' && in_array($objProduct->type, $arrLimit)) {
                     $intTotal += $objRule->quantityMode == 'cart_items' ? $objItem->quantity : 1;
                 }
             }
         }
     } else {
         switch ($objRule->quantityMode) {
             case 'cart_products':
                 $intTotal = $objCollection->countItems();
                 break;
             case 'cart_items':
                 $intTotal = $objCollection->sumItemsQuantity();
                 break;
         }
     }
     foreach ($arrCollectionItems as $objItem) {
         if (!$objItem->hasProduct()) {
             continue;
         }
         $objProduct = $objItem->getProduct();
         // Product restrictions
         if (($objRule->productRestrictions == 'products' || $objRule->productRestrictions == 'variants' || $objRule->productRestrictions == 'pages') && (!in_array($objProduct->id, $arrLimit) && ($objProduct->pid == 0 || !in_array($objProduct->pid, $arrLimit))) || $objRule->productRestrictions == 'producttypes' && !in_array($objProduct->type, $arrLimit)) {
             continue;
         } elseif ($objRule->productRestrictions == 'attribute') {
             switch ($objRule->attributeCondition) {
                 case 'eq':
                     if (!($objProduct->{$objRule->attributeName} == $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'neq':
                     if (!($objProduct->{$objRule->attributeName} != $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'lt':
                     if (!($objProduct->{$objRule->attributeName} < $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'gt':
                     if (!($objProduct->{$objRule->attributeName} > $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'elt':
                     if (!($objProduct->{$objRule->attributeName} <= $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'egt':
                     if (!($objProduct->{$objRule->attributeName} >= $objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'starts':
                     if (stripos($objProduct->{$objRule->attributeName}, $objRule->attributeValue) !== 0) {
                         continue 2;
                     }
                     break;
                 case 'ends':
                     if (strripos($objProduct->{$objRule->attributeName}, $objRule->attributeValue) !== strlen($objProduct->{$objRule->attributeName}) - strlen($objRule->attributeValue)) {
                         continue 2;
                     }
                     break;
                 case 'contains':
                     if (stripos($objProduct->{$objRule->attributeName}, $objRule->attributeValue) === false) {
                         continue 2;
                     }
                     break;
                 default:
                     throw new \Exception('Unknown rule condition "' . $objRule->attributeCondition . '"');
             }
         }
         // Because we apply to the quantity of only this product, we override $intTotal in every foreach loop
         // This matches tl_iso_rules.quantityMode="product_quantity"
         if ($objRule->quantityMode != 'cart_products' && $objRule->quantityMode != 'cart_items') {
             $intTotal = $objItem->quantity;
         }
         // Quantity does not match, do not apply to this product
         if ($objRule->minItemQuantity > 0 && $objRule->minItemQuantity > $intTotal || $objRule->maxItemQuantity > 0 && $objRule->maxItemQuantity < $intTotal) {
             continue;
         }
         // Apply To
         switch ($objRule->applyTo) {
             case 'products':
                 $fltPrice = $blnPercentage ? $objItem->getTotalPrice() / 100 * $fltDiscount : $objRule->discount;
                 $fltPrice = $fltPrice > 0 ? floor($fltPrice * 100) / 100 : ceil($fltPrice * 100) / 100;
                 $objSurcharge->total_price += $fltPrice;
                 $objSurcharge->setAmountForCollectionItem($fltPrice, $objItem);
                 break;
             case 'items':
                 $fltPrice = ($blnPercentage ? $objItem->getPrice() / 100 * $fltDiscount : $objRule->discount) * $objItem->quantity;
                 $fltPrice = $fltPrice > 0 ? floor($fltPrice * 100) / 100 : ceil($fltPrice * 100) / 100;
                 $objSurcharge->total_price += $fltPrice;
                 $objSurcharge->setAmountForCollectionItem($fltPrice, $objItem);
                 break;
             case 'subtotal':
                 $blnMatch = true;
                 $objSurcharge->total_price += $objItem->getTotalPrice();
                 if ($objRule->tax_class == -1) {
                     if ($blnPercentage) {
                         $fltPrice = $objItem->getTotalPrice() / 100 * $fltDiscount;
                         $objSurcharge->setAmountForCollectionItem($fltPrice, $objItem);
                     } else {
                         $arrSubtract[] = $objItem;
                         $fltTotal += (double) $objItem->getTaxFreeTotalPrice();
                     }
                 }
                 break;
         }
     }
     if ($objRule->applyTo == 'subtotal' && $blnMatch) {
         // discount total! not related to tax subtraction
         $fltPrice = $blnPercentage ? $objSurcharge->total_price / 100 * $fltDiscount : $objRule->discount;
         $objSurcharge->total_price = $fltPrice > 0 ? floor(round($fltPrice * 100, 4)) / 100 : ceil(round($fltPrice * 100, 4)) / 100;
         $objSurcharge->before_tax = $objRule->tax_class != 0 ? true : false;
         $objSurcharge->tax_class = $objRule->tax_class > 0 ? $objRule->tax_class : 0;
         // If fixed price discount with splitted taxes, calculate total amount of discount per taxed product
         if ($objRule->tax_class == -1 && !$blnPercentage) {
             foreach ($arrSubtract as $objItem) {
                 $fltPrice = $objRule->discount / 100 * (100 / $fltTotal * $objItem->getTaxFreeTotalPrice());
                 $objSurcharge->setAmountForCollectionItem($fltPrice, $objItem);
             }
         }
     }
     return $objSurcharge->total_price == 0 ? null : $objSurcharge;
 }
Пример #24
0
 /**
  * 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]*(&|&amp;)?)([^"]*)"@');
     $arrReplace = array('<u>$1</u>', '<br>$1', '<br>$1', ' ', '<div class="mod_article', 'href="$1$4"');
     $strBuffer = preg_replace($arrSearch, $arrReplace, $strBuffer);
     return $strBuffer;
 }
Пример #25
0
 /**
  * Validate input parameters and hash
  *
  * @param IsotopeProductCollection|Order $objOrder
  *
  * @return bool
  */
 protected function validatePayment(IsotopeProductCollection $objOrder)
 {
     $arrValues = $_GET;
     unset($arrValues['hash']);
     unset($arrValues['auto_item']);
     unset($arrValues['step']);
     $strHash = md5(implode('', $arrValues) . $this->epay_secretkey);
     $intAmount = Currency::getAmountInMinorUnits($objOrder->getTotal(), $objOrder->currency);
     if ($strHash != \Input::get('hash')) {
         \System::log('Invalid hash for ePay payment. See system/logs/isotope_epay.log for more details.', __METHOD__, TL_ERROR);
         log_message(sprintf("Invalid hash for ePay payment:\ngot %s, expected %s\nParameters: %s\n\n", \Input::get('hash'), $strHash, print_r($arrValues, true)), 'isotope_epay.log');
         return false;
     }
     if (Currency::getIsoNumber($objOrder->currency) != \Input::get('currency') || $intAmount != \Input::get('amount')) {
         \System::log('Currency or amount does not match order.  See system/logs/isotope_epay.log for more details.', __METHOD__, TL_ERROR);
         log_message(sprintf("Currency or amount does not match order:\nCurrency: got %s (%s), expected %s\nAmount: got %s, expected %s\n\n", \Input::get('currency'), Currency::getIsoNumber($objOrder->currency), $objOrder->currency, \Input::get('amount'), $intAmount), 'isotope_epay.log');
         return false;
     }
     return true;
 }
Пример #26
0
 /**
  * @param IsotopeProductCollection|Order   $objOrder
  * @param \Module|\Isotope\Module\Checkout $objModule
  *
  * @return array
  */
 protected function getOutboundParameters(IsotopeProductCollection $objOrder, \Module $objModule = null)
 {
     $objAddress = $objOrder->getBillingAddress();
     $successUrl = '';
     $failureUrl = '';
     $transDate = new DateTime();
     $transDate->setTimezone(new \DateTimeZone('UTC'));
     if (null !== $objModule) {
         $successUrl = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder);
         $failureUrl = \Environment::get('base') . $objModule->generateUrlForStep('failed');
     }
     return array('vads_action_mode' => 'INTERACTIVE', 'vads_amount' => Currency::getAmountInMinorUnits($objOrder->getTotal(), $objOrder->currency), 'vads_contrib' => 'Isotope eCommerce ' . Isotope::VERSION, 'vads_ctx_mode' => $this->debug ? 'TEST' : 'PRODUCTION', 'vads_currency' => Currency::getIsoNumber($objOrder->currency), 'vads_cust_address' => $objAddress->street_1, 'vads_cust_city' => $objAddress->city, 'vads_cust_country' => $objAddress->country, 'vads_cust_email' => $objAddress->email, 'vads_cust_id' => $objOrder->member ?: '', 'vads_cust_name' => $objAddress->firstname . ' ' . $objAddress->lastname, 'vads_cust_phone' => $objAddress->phone, 'vads_cust_title' => $objAddress->salutation, 'vads_cust_zip' => $objAddress->postal, 'vads_language' => $objOrder->language, 'vads_order_id' => $objOrder->id, 'vads_page_action' => 'PAYMENT', 'vads_payment_config' => 'SINGLE', 'vads_return_mode' => 'NONE', 'vads_site_id' => $this->vads_site_id, 'vads_trans_date' => $transDate->format('YmdHis'), 'vads_trans_id' => str_pad($objOrder->id, 6, '0', STR_PAD_LEFT), 'vads_url_cancel' => $failureUrl, 'vads_url_check' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'vads_url_error' => $failureUrl, 'vads_url_referral' => $failureUrl, 'vads_url_refused' => $failureUrl, 'vads_url_success' => $successUrl, 'vads_url_return' => $failureUrl, 'vads_version' => 'V2');
 }
 /**
  * Create or add taxes for each collection item
  *
  * @param Tax[]                        $arrTaxes
  * @param IsotopeProductCollection     $objCollection
  * @param ProductCollectionSurcharge[] $arrSurcharges
  * @param Address[]                    $arrAddresses
  */
 private static function addTaxesForItems(array &$arrTaxes, IsotopeProductCollection $objCollection, array $arrSurcharges, array $arrAddresses)
 {
     foreach ($objCollection->getItems() as $objItem) {
         // This should never happen, but we can't calculate it
         if (!$objItem->hasProduct()) {
             continue;
         }
         $objProduct = $objItem->getProduct();
         /** @var \Isotope\Model\TaxClass $objTaxClass */
         $objTaxClass = $objProduct->getPrice() ? $objProduct->getPrice()->getRelated('tax_class') : null;
         // Skip products without tax class
         if (null === $objTaxClass) {
             continue;
         }
         $arrTaxIds = array();
         $fltPrice = $objItem->getTotalPrice();
         /** @var \Isotope\Model\ProductCollectionSurcharge $objSurcharge */
         foreach ($arrSurcharges as $objSurcharge) {
             $fltPrice += $objSurcharge->getAmountForCollectionItem($objItem);
         }
         /** @var \Isotope\Model\TaxRate $objIncludes */
         if (($objIncludes = $objTaxClass->getRelated('includes')) !== null) {
             if ($objIncludes->isApplicable($fltPrice, $arrAddresses)) {
                 $addToTotal = static::getTaxAddState(false);
                 $total = $addToTotal ? $objIncludes->calculateAmountAddedToPrice($fltPrice) : $objIncludes->calculateAmountIncludedInPrice($fltPrice);
                 $arrTaxIds[] = static::addTax($arrTaxes, $objTaxClass->id . '_' . $objIncludes->id, $objTaxClass->getLabel() ?: $objIncludes->getLabel(), $objIncludes->getAmount(), $objIncludes->isPercentage(), $total, $objTaxClass->applyRoundingIncrement, $addToTotal, false);
             }
         }
         if (($objRates = $objTaxClass->getRelated('rates')) !== null) {
             /** @var \Isotope\Model\TaxRate $objTaxRate */
             foreach ($objRates as $objTaxRate) {
                 if ($objTaxRate->isApplicable($fltPrice, $arrAddresses)) {
                     $addToTotal = static::getTaxAddState(true);
                     $total = $addToTotal ? $objTaxRate->calculateAmountAddedToPrice($fltPrice) : $objTaxRate->calculateAmountIncludedInPrice($fltPrice);
                     $arrTaxIds[] = static::addTax($arrTaxes, $objTaxRate->id, $objTaxRate->getLabel(), $objTaxRate->getAmount(), $objTaxRate->isPercentage(), $total, $objTaxClass->applyRoundingIncrement, $addToTotal, false);
                     if ($objTaxRate->stop) {
                         break;
                     }
                 }
             }
         }
         $strTaxId = implode(',', $arrTaxIds);
         if ($objItem->tax_id != $strTaxId) {
             $objCollection->updateItem($objItem, array('tax_id' => $strTaxId));
         }
         foreach ($arrSurcharges as $objSurcharge) {
             if ($objSurcharge->getAmountForCollectionItem($objItem) > 0) {
                 foreach ($arrTaxIds as $taxId) {
                     $objSurcharge->addTaxNumber($taxId);
                 }
             }
         }
     }
 }
Пример #28
0
 /**
  * Initialize a new collection and duplicate everything from the source
  *
  * @param IsotopeProductCollection $objSource
  *
  * @return static
  */
 public static function createFromCollection(IsotopeProductCollection $objSource)
 {
     $objCollection = new static();
     $objConfig = $objSource->getRelated('config_id');
     if (null === $objConfig) {
         $objConfig = Isotope::getConfig();
     }
     $objCollection->source_collection_id = (int) $objSource->id;
     $objCollection->config_id = (int) $objConfig->id;
     $objCollection->store_id = (int) $objSource->store_id;
     $objCollection->member = (int) $objSource->member;
     $objCollection->setShippingMethod($objSource->getShippingMethod());
     $objCollection->setPaymentMethod($objSource->getPaymentMethod());
     $objCollection->setShippingAddress($objSource->getShippingAddress());
     $objCollection->setBillingAddress($objSource->getBillingAddress());
     $arrItemIds = $objCollection->copyItemsFrom($objSource);
     $objCollection->updateDatabase();
     // HOOK: order status has been updated
     if (isset($GLOBALS['ISO_HOOKS']['createFromProductCollection']) && is_array($GLOBALS['ISO_HOOKS']['createFromProductCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['createFromProductCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $objCallback->{$callback}[1]($objCollection, $objSource, $arrItemIds);
         }
     }
     return $objCollection;
 }
Пример #29
0
 /**
  * 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();
 }
 private function getCollectionTotalAsXML(IsotopeProductCollection $objCollection)
 {
     $intRebate = 0;
     $intRebateGross = 0;
     $strShippingName = '';
     $intShippingPrice = 0;
     $intShippingPriceGross = 0;
     foreach ($objCollection->getSurcharges() as $objSurcharge) {
         if ($objSurcharge->total_price < 0) {
             $intRebate += round($objSurcharge->tax_free_total_price * 100);
             $intRebateGross += round($objSurcharge->total_price * 100);
         } elseif ($objSurcharge instanceof Shipping) {
             $strShippingName = $objSurcharge->label;
             $intShippingPrice += round($objSurcharge->tax_free_total_price * 100);
             $intShippingPriceGross += round($objSurcharge->total_price * 100);
         }
     }
     $xml = new \DOMDocument();
     $total = $xml->createElement('total');
     if ($intShippingPrice != 0 || $intShippingPriceGross != 0) {
         $shippingName = $xml->createAttribute('shippingname');
         $shippingName->value = $strShippingName;
         $total->appendChild($shippingName);
         $shippingPrice = $xml->createAttribute('shippingprice');
         $shippingPrice->value = $intShippingPrice;
         $total->appendChild($shippingPrice);
         $shippingPriceGross = $xml->createAttribute('shippingpricegross');
         $shippingPriceGross->value = $intShippingPriceGross;
         $total->appendChild($shippingPriceGross);
     }
     if ($intRebate != 0 || $intRebateGross != 0) {
         $rebate = $xml->createAttribute('rebate');
         $rebate->value = $intRebate;
         $total->appendChild($rebate);
         $rebateGross = $xml->createAttribute('rebategross');
         $rebateGross->value = $intRebateGross;
         $total->appendChild($rebateGross);
     }
     $cartTotalPrice = $xml->createAttribute('carttotalprice');
     $cartTotalPrice->value = round($objCollection->getTaxFreeTotal() * 100);
     $total->appendChild($cartTotalPrice);
     $cartTotalPriceGross = $xml->createAttribute('carttotalpricegross');
     $cartTotalPriceGross->value = round($objCollection->getTotal() * 100);
     $total->appendChild($cartTotalPriceGross);
     $currency = $xml->createAttribute('currency');
     $currency->value = $objCollection->currency;
     $total->appendChild($currency);
     $xml->appendChild($total);
     return $xml->saveXML($xml->documentElement);
 }