Пример #1
0
 public function checkoutReview()
 {
     $type = $_SESSION['CHECKOUT_DATA']['payment'][$this->id]['cc_type'];
     $num = $_SESSION['CHECKOUT_DATA']['payment'][$this->id]['cc_num'];
     $strCard = implode(' ', str_split(substr($num, 0, 2) . str_repeat('*', strlen($num) - 6) . substr($num, -4), 4));
     list($endTag) = IsotopeFrontend::getElementAndScriptTags();
     return sprintf('%s<br' . $endTag . '%s: %s', $this->label, $GLOBALS['ISO_LANG']['CCT'][$type], $strCard);
 }
Пример #2
0
 /**
  * Inject Ajax scripts
  */
 protected function injectAjax()
 {
     list(, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags();
     $GLOBALS['TL_MOOTOOLS'][get_class($this) . '_ajax'] = "\n{$startScript}\nwindow.addEvent('ajaxready', function() {\n  Mediabox ? Mediabox.scanPage() : Lightbox.scanPage();\n});\n{$endScript}\n";
 }
Пример #3
0
    /**
     * Return the PayPal form.
     *
     * @access public
     * @return string
     */
    public function checkoutForm()
    {
        $objOrder = new IsotopeOrder();
        if (!$objOrder->findBy('cart_id', $this->Isotope->Cart->id)) {
            $this->redirect($this->addToUrl('step=failed', true));
        }
        list($endTag, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags();
        $strBuffer = '
<h2>' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0] . '</h2>
<p class="message">' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1] . '</p>
<form id="payment_form" action="https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart"' . $endTag . '
<input type="hidden" name="upload" value="1"' . $endTag . '
<input type="hidden" name="charset" value="UTF-8"' . $endTag . '
<input type="hidden" name="business" value="' . $this->paypal_account . '"' . $endTag . '
<input type="hidden" name="lc" value="' . strtoupper($GLOBALS['TL_LANGUAGE']) . '"' . $endTag;
        foreach ($this->Isotope->Cart->getProducts() as $objProduct) {
            $strOptions = '';
            $arrOptions = $objProduct->getOptions();
            if (is_array($arrOptions) && count($arrOptions)) {
                $options = array();
                foreach ($arrOptions as $option) {
                    $options[] = $option['label'] . ': ' . $option['value'];
                }
                $strOptions = ' (' . implode(', ', $options) . ')';
            }
            $strBuffer .= '
<input type="hidden" name="item_number_' . ++$i . '" value="' . $objProduct->sku . '"' . $endTag . '
<input type="hidden" name="item_name_' . $i . '" value="' . $objProduct->name . $strOptions . '"' . $endTag . '
<input type="hidden" name="amount_' . $i . '" value="' . $objProduct->price . '"/>
<input type="hidden" name="quantity_' . $i . '" value="' . $objProduct->quantity_requested . '"' . $endTag;
        }
        $fltDiscount = 0;
        foreach ($this->Isotope->Cart->getSurcharges() as $arrSurcharge) {
            if ($arrSurcharge['add'] === false) {
                continue;
            }
            // PayPal does only support one single discount item
            if ($arrSurcharge['total_price'] < 0) {
                $fltDiscount -= $arrSurcharge['total_price'];
                continue;
            }
            $strBuffer .= '
<input type="hidden" name="item_name_' . ++$i . '" value="' . $arrSurcharge['label'] . '"' . $endTag . '
<input type="hidden" name="amount_' . $i . '" value="' . $arrSurcharge['total_price'] . '"' . $endTag;
        }
        if ($fltDiscount > 0) {
            $strBuffer .= '
<input type="hidden" name="discount_amount_cart" value="' . $fltDiscount . '"' . $endTag;
        }
        $strBuffer .= '
<input type="hidden" name="no_shipping" value="1"' . $endTag . '
<input type="hidden" name="no_note" value="1"' . $endTag . '
<input type="hidden" name="currency_code" value="' . $this->Isotope->Config->currency . '"' . $endTag . '
<input type="hidden" name="button_subtype" value="services"' . $endTag . '
<input type="hidden" name="return" value="' . $this->Environment->base . IsotopeFrontend::addQueryStringToUrl('uid=' . $objOrder->uniqid, $this->addToUrl('step=complete')) . '"' . $endTag . '
<input type="hidden" name="cancel_return" value="' . $this->Environment->base . $this->addToUrl('step=failed') . '"' . $endTag . '
<input type="hidden" name="rm" value="1"' . $endTag . '
<input type="hidden" name="invoice" value="' . $objOrder->id . '"' . $endTag . '

<input type="hidden" name="address_override" value="' . ($this->debug ? '0' : '1') . '"' . $endTag . '
<input type="hidden" name="first_name" value="' . $this->Isotope->Cart->billingAddress['firstname'] . '"' . $endTag . '
<input type="hidden" name="last_name" value="' . $this->Isotope->Cart->billingAddress['lastname'] . '"' . $endTag . '
<input type="hidden" name="address1" value="' . $this->Isotope->Cart->billingAddress['street_1'] . '"' . $endTag . '
<input type="hidden" name="address2" value="' . $this->Isotope->Cart->billingAddress['street_2'] . '"' . $endTag . '
<input type="hidden" name="zip" value="' . $this->Isotope->Cart->billingAddress['postal'] . '"' . $endTag . '
<input type="hidden" name="city" value="' . $this->Isotope->Cart->billingAddress['city'] . '"' . $endTag . '
<input type="hidden" name="country" value="' . strtoupper($this->Isotope->Cart->billingAddress['country']) . '"' . $endTag . '
<input type="hidden" name="email" value="' . $this->Isotope->Cart->billingAddress['email'] . '"' . $endTag . '
<input type="hidden" name="night_phone_b" value="' . $this->Isotope->Cart->billingAddress['phone'] . '"' . $endTag . '

<input type="hidden" name="notify_url" value="' . $this->Environment->base . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id . '"' . $endTag . '
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted"' . $endTag . '
<input type="' . (strlen($this->button) ? 'image" src="' . $this->button . '" border="0"' : 'submit" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]) . '"') . ' alt="PayPal - The safer, easier way to pay online!"' . $endTag . '
</form>

' . $startScript . '
window.addEvent( \'domready\' , function() {
  $(\'payment_form\').submit();
});
' . $endScript;
        return $strBuffer;
    }
Пример #4
0
 /**
  * Generate a product template
  * @param string
  * @param object
  * @return string
  */
 public function generate($strTemplate, &$objModule)
 {
     global $objPage;
     $this->formSubmit = ($objModule instanceof ContentElement ? 'cte' : 'fmd') . $objModule->id . '_product_' . ($this->pid ? $this->pid : $this->id);
     $this->validateVariant();
     $objTemplate = new IsotopeTemplate($strTemplate);
     $arrProductOptions = array();
     $arrAjaxOptions = array();
     $arrAttributes = $this->getAttributes();
     foreach ($arrAttributes as $attribute => $varValue) {
         if ($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['customer_defined'] || $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['variant_option']) {
             $objTemplate->hasOptions = true;
             $arrProductOptions[$attribute] = array_merge($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute], array('name' => $attribute, 'html' => $this->generateProductOptionWidget($attribute)));
             if ($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['variant_option']) {
                 $arrAjaxOptions[] = $attribute;
             }
         } else {
             $objTemplate->{$attribute} = $this->generateAttribute($attribute, $varValue);
         }
     }
     $arrButtons = array();
     // Buttons
     if (isset($GLOBALS['ISO_HOOKS']['buttons']) && is_array($GLOBALS['ISO_HOOKS']['buttons'])) {
         foreach ($GLOBALS['ISO_HOOKS']['buttons'] as $callback) {
             $this->import($callback[0]);
             $arrButtons = $this->{$callback}[0]->{$callback}[1]($arrButtons);
         }
         $arrButtons = array_intersect_key($arrButtons, array_flip(deserialize($objModule->iso_buttons, true)));
     }
     if ($this->Input->post('FORM_SUBMIT') == $this->formSubmit && !$this->doNotSubmit) {
         foreach ($arrButtons as $button => $data) {
             if (strlen($this->Input->post($button))) {
                 if (is_array($data['callback']) && count($data['callback']) == 2) {
                     $this->import($data['callback'][0]);
                     $this->{$data['callback'][0]}->{$data['callback'][1]}($this, $objModule);
                 }
                 break;
             }
         }
     }
     $objTemplate->buttons = $arrButtons;
     $objTemplate->quantityLabel = $GLOBALS['TL_LANG']['MSC']['quantity'];
     $objTemplate->useQuantity = $objModule->iso_use_quantity;
     $objTemplate->quantity_requested = $this->quantity_requested;
     $objTemplate->raw = array_merge($this->arrData, $this->arrCache);
     $objTemplate->raw_options = $this->arrOptions;
     $objTemplate->href_reader = $this->href_reader;
     $objTemplate->label_detail = $GLOBALS['TL_LANG']['MSC']['detailLabel'];
     $objTemplate->options = IsotopeFrontend::generateRowClass($arrProductOptions, 'product_option');
     $objTemplate->hasOptions = count($arrProductOptions) > 0 ? true : false;
     $objTemplate->enctype = $this->hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
     $objTemplate->formId = $this->formSubmit;
     $objTemplate->action = ampersand($this->Environment->request, true);
     $objTemplate->formSubmit = $this->formSubmit;
     list(, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags();
     $GLOBALS['TL_MOOTOOLS'][] = $startScript . "\nnew {$this->ajaxClass}('{$objModule->id}', '" . ($this->pid ? $this->pid : $this->id) . "', '{$this->formSubmit}', ['ctrl_" . implode("_" . $this->formSubmit . "', 'ctrl_", $arrAjaxOptions) . "_" . $this->formSubmit . "'], {language: '{$GLOBALS['TL_LANGUAGE']}', action: '" . ($objModule instanceof Module ? 'fmd' : 'cte') . "', page: {$objPage->id}, loadMessage:'" . specialchars($GLOBALS['ISO_LANG']['MSC']['loadingProductData']) . "'});\n" . $endScript;
     // HOOK for altering product data before output
     if (isset($GLOBALS['ISO_HOOKS']['generateProduct']) && is_array($GLOBALS['ISO_HOOKS']['generateProduct'])) {
         foreach ($GLOBALS['ISO_HOOKS']['generateProduct'] as $callback) {
             $this->import($callback[0]);
             $objTemplate = $this->{$callback}[0]->{$callback}[1]($objTemplate, $this);
         }
     }
     return $objTemplate->parse();
 }
Пример #5
0
 /**
  * Use generatePage Hook to inject messages if they have not been included in a module
  */
 public function injectMessages()
 {
     $strMessages = IsotopeFrontend::getIsotopeMessages();
     if ($strMessages != '') {
         list(, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags();
         $GLOBALS['TL_MOOTOOLS'][] = "\n{$startScript}\nwindow.addEvent('domready', function()\n{\n\tIsotope.displayBox('" . $strMessages . "', true);\n});\n{$endScript}";
     }
 }
Пример #6
0
    public function checkoutForm()
    {
        $this->import('Isotope');
        $fields = '';
        // Get the current order, review page will create the data
        $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->execute($this->Isotope->Cart->id);
        $doNotSubmit = false;
        $strBuffer = '';
        $arrPayment = $this->Input->post('payment');
        $arrCCTypes = deserialize($this->allowed_cc_types);
        //standard keys
        foreach ($arrCCTypes as $type) {
            // numeric keys specific to Cybersource
            // @todo merchant bank makes a difference!
            $arrAllowedCCTypes[] = $this->arrCardTypes[$type];
        }
        $intStartYear = (int) date('Y', time());
        //4-digit year
        for ($i = 0; $i <= 7; $i++) {
            $arrYears[] = (string) $intStartYear + $i;
        }
        //card_accountNumber,card_cardType,card_expirationMonth,card_expirationYear,card_cvNumber
        $arrFields = array('card_accountNumber' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_num'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'digit', 'tableless' => true)), 'card_cardType' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_type'], 'inputType' => 'select', 'options' => $arrAllowedCCTypes, 'eval' => array('mandatory' => true, 'rgxp' => 'digit', 'tableless' => true), 'reference' => &$GLOBALS['ISO_LANG']['CCT']), 'card_expirationMonth' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_exp_month'], 'inputType' => 'select', 'options' => array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'), 'eval' => array('mandatory' => true, 'tableless' => true, 'includeBlankOption' => true)), 'card_expirationYear' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_exp_year'], 'inputType' => 'select', 'options' => $arrYears, 'eval' => array('mandatory' => true, 'tableless' => true, 'includeBlankOption' => true)), 'card_cvNumber' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_ccv'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'tableless' => true)));
        foreach ($arrFields as $field => $arrData) {
            $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
            // Continue if the class is not defined
            if (!$this->classFileExists($strClass)) {
                continue;
            }
            $objWidget = new $strClass($this->prepareForWidget($arrData, 'payment[' . $field . ']'));
            // Validate input
            if ($this->Input->post('FORM_SUBMIT') == 'iso_mod_checkout_payment' && $arrPayment['module'] == $this->id) {
                $objWidget->validate();
                if ($objWidget->hasErrors()) {
                    $doNotSubmit = true;
                }
            } elseif ($objWidget->mandatory && !strlen($arrPayment[$field])) {
                $doNotSubmit = true;
            }
            $strBuffer .= $objWidget->parse();
        }
        global $objPage;
        $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->execute($this->Isotope->Cart->id);
        $intTotal = round($this->Isotope->Cart->grandTotal, 2);
        $arrSubdivision = explode('-', $this->Isotope->Cart->billingAddress['subdivision']);
        if (!$doNotSubmit && $this->Input->post('FORM_SUBMIT') == 'payment_form') {
            try {
                $objSoapClient = new CybersourceClient('https://ics2ws' . ($this->debug ? 'test' : '') . '.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.26.wsdl', array(), $this->cybersource_merchant_id, $this->cybersource_trans_key);
                $objRequest = new stdClass();
                $objRequest->merchantID = $this->cybersource_merchant_id;
                // Before using this example, replace the generic value with your own.
                $objRequest->merchantReferenceCode = $objOrder->id;
                // To help us troubleshoot any problems that you may encounter,
                // please include the following information about your PHP application.
                $objRequest->clientLibrary = "PHP";
                $objRequest->clientLibraryVersion = phpversion();
                $objRequest->clientEnvironment = php_uname();
                // This section builds the transaction information
                // service with complete billing, payment card, and purchase (two items) information.
                $objCCAuthService = new stdClass();
                $objCCAuthService->run = "true";
                $objRequest->ccAuthService = $objCCAuthService;
                $objBillTo = new stdClass();
                $objBillTo->firstName = $this->Isotope->Cart->billingAddress['firstname'];
                $objBillTo->lastName = $this->Isotope->Cart->billingAddress['lastname'];
                $objBillTo->street1 = $this->Isotope->Cart->billingAddress['street_1'];
                $objBillTo->city = $this->Isotope->Cart->billingAddress['city'];
                $objBillTo->state = $arrSubdivision[1];
                $objBillTo->postalCode = $this->Isotope->Cart->billingAddress['postal'];
                $objBillTo->country = $this->Isotope->Cart->billingAddress['country'];
                $objBillTo->email = $this->Isotope->Cart->billingAddress['email'];
                $objBillTo->ipAddress = $this->Environment->ip;
                $objRequest->billTo = $objBillTo;
                $objCard = new stdClass();
                $objCard->accountNumber = $arrPayment['card_accountNumber'];
                $objCard->expirationMonth = $arrPayment['card_expirationMonth'];
                $objCard->expirationYear = $arrPayment['card_expirationYear'];
                //if($this->requireCardType)
                $objCard->cardType = $arrPayment['card_cardType'];
                if ($this->requireCCV) {
                    $objCard->cvNumber = $arrPayment['card_cvNumber'];
                }
                $objRequest->card = $objCard;
                $objPurchaseTotals = new stdClass();
                $objPurchaseTotals->currency = $this->Isotope->Config->currency;
                $objPurchaseTotals->grandTotalAmount = round($this->Isotope->Cart->grandTotal, 2);
                $objRequest->purchaseTotals = $objPurchaseTotals;
                /*$arrProducts = $this->Isotope->Cart->getProducts();
                
                				foreach($arrProducts as $i=>$objProduct)
                				{
                					$objItem = new stdClass();
                
                					$objItem->unitPrice = $objProduct->price;
                					$objItem->quantity = $objProduct->quantity;
                					$objItem->id = $objProduct->id;
                
                					$arrItems[] = $objItem;
                				}
                
                				$objRequest->item = $arrItems;*/
                //, $strLocation, $strAction, $strVersion, $strMerchantId, $strTransactionKey
                $objReply = $objSoapClient->runTransaction($objRequest);
                $arrPaymentData['transaction_response'] = $objReply->decision;
                $arrPaymentData['transaction_response_code'] = $objReply->reasonCode;
                $arrPaymentData['request_id'] = $objReply->requestID;
                $arrPaymentData['request_token'] = $objReply->requestToken;
                $arrSet['payment_data'] = serialize($arrPaymentData);
                switch ($objReply->decision) {
                    case 'ACCEPT':
                        $arrPaymentData['cc_last_four'] = substr($strCCNum, strlen($strCCNum) - 4, 4);
                        break;
                    default:
                        $blnFail = true;
                        break;
                }
                $this->Database->prepare("UPDATE tl_iso_orders %s WHERE id={$objOrder->id}")->set($arrSet)->executeUncached();
                if ($blnFail) {
                    $this->log('Invalid payment data received.', 'PaymentCybersource checkoutForm()', TL_ERROR);
                    $this->redirect(IsotopeFrontend::addQueryStringToUrl('error=' . $objReply->reasonCode));
                }
                $this->redirect($this->addToUrl('step=complete', true));
            } catch (SoapFault $exception) {
                var_dump(get_class($exception));
                var_dump($exception);
            }
        }
        list($endTag) = IsotopeFrontend::getElementAndScriptTags();
        return '
<h2>' . $this->label . '</h2>' . ($this->Input->get('error') == '' ? '' : '<p class="error message">' . $GLOBALS['TL_LANG']['CYB'][$this->Input->get('error')] . '</p>') . '<form id="payment_form" action="' . $this->Environment->request . '" method="post">
<input type="hidden" name="FORM_SUBMIT" value="payment_form"' . $endTag . '
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"' . $endTag . $strBuffer . '
<input type="submit" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['confirmOrder']) . '"' . $endTag . '
</form>';
    }