Пример #1
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();
 }
Пример #2
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();
 }
Пример #3
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();
 }
Пример #4
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();
 }
Пример #5
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;
 }
Пример #6
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;
 }
Пример #7
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');
 }
Пример #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
 /**
  * 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();
 }