Ejemplo n.º 1
0
 public function before_confirm()
 {
     global $temp_orders_id, $customer_id, $currency, $languages_code, $currencies, $cart_PayPal_IPN_ID;
     if (!isset($_GET['tx'])) {
         //only process if we don't come back from paypal
         $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id);
         /*REGISTER PAYPAL IPN CART ID*/
         $cart_PayPal_IPN_ID = $temp_orders_id . '||' . date("Y-m-d H:i:s");
         tep_session_register('cart_PayPal_IPN_ID');
         /*GET CURRENCY*/
         $my_currency = $currency;
         if (!in_array($my_currency, array('AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'USD'))) {
             $my_currency = 'USD';
         }
         $parameters = array();
         foreach ($temp_data[$temp_orders_id]['orders_total'] as $key => $data) {
             if ($data['class'] == 'order_total') {
                 $total = $data['value'];
             }
         }
         /*AGGREGATED*/
         $parameters['cmd'] = '_ext-enter';
         $parameters['redirect_cmd'] = '_xclick';
         $parameters['item_name'] = STORE_NAME;
         $parameters['amount'] = number_format($total, $currencies->get_decimal_places($my_currency));
         $parameters['shipping'] = number_format(0 * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
         $parameters['business'] = $this->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['ipn_id'];
         $parameters['address_override'] = '1';
         $parameters['no_shipping'] = '2';
         $parameters['night_phone_b'] = $temp_data[$temp_orders_id]['orders']['customers_telephone'];
         $parameters['first_name'] = $temp_data[$temp_orders_id]['orders']['customers_name'];
         $parameters['address1'] = $temp_data[$temp_orders_id]['orders']['billing_street_address'];
         $parameters['city'] = $temp_data[$temp_orders_id]['orders']['billing_city'];
         $parameters['zip'] = $temp_data[$temp_orders_id]['orders']['billing_postcode'];
         $parameters['country'] = tep_get_countries_with_iso_codes($temp_data[$temp_orders_id]['orders']['billing_country']);
         $parameters['country'] = $parameters['country']['countries_iso_code_2'];
         $parameters['email'] = $temp_data[$temp_orders_id]['orders']['customers_email_address'];
         $parameters['charset'] = "utf-8";
         $parameters['currency_code'] = $my_currency;
         $parameters['invoice'] = $temp_orders_id;
         $parameters['custom'] = $customer_id . '[-]' . substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-') + 1);
         $parameters['no_note'] = '1';
         $parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', 'language=' . $languages_code, 'SSL', false, false);
         $parameters['cbt'] = Translate('Vervolledig orderbevestiging');
         $parameters['return'] = tep_href_link(FILENAME_CHECKOUT);
         $parameters['cancel_return'] = tep_href_link(FILENAME_CHECKOUT, 'tx=canceled', 'SSL');
         $parameters['bn'] = $this->identifier;
         $parameters['lc'] = $parameters['country'];
         reset($parameters);
         while (list($key, $value) = each($parameters)) {
             $process_button_string .= tep_draw_hidden_field($key, $value);
         }
         $html = '</div><div class="span12">';
         $html .= '<div class="step active"><div class="step_title">' . Translate('Betaling met Paypal') . '</div></div>';
         $html .= '<form name="redirectForm" action="' . $this->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['url'] . '" method="POST">';
         $html .= $process_button_string;
         $html .= '</form>';
         $html .= '<div style="text-align:center;"><img src="' . DIR_WS_IMAGES . 'ajax-loader.gif"><br>' . Translate('Bestelgegevens worden doorgestuurd naar de beveiligde betaal server, even geduld...') . '</div>';
         $html .= '</div><div>';
         $html .= '<script>document.forms["redirectForm"].submit();</script>';
         echo $html;
         die;
     }
 }
Ejemplo n.º 2
0
 public function before_confirm()
 {
     global $temp_orders_id, $customer_id, $currency, $languages_code;
     if (!isset($_GET['TransactionID'])) {
         $post_payment = explode('__', $this->temp_data[$temp_orders_id]['orders']['payment_method_extra']);
         $paymentmethod = $post_payment[0];
         $issuer = $post_payment[1];
         $payment = new $paymentmethod();
         $country = tep_get_countries_with_iso_codes($this->temp_data[$temp_orders_id]['orders']['billing_country']);
         try {
             // Merchant Settings
             $payment->setMerchantID($this->instances[$this->temp_data[$temp_orders_id]['orders']['payment_method']]['merchant_id'])->setSecretCode($this->instances[$this->temp_data[$temp_orders_id]['orders']['payment_method']]['secret_code']);
             // Transaction Settings
             $payment->setAmount($this->order_total * 100)->setCountry($country['countries_iso_code_2'])->setLanguage(strtoupper($languages_code))->setCurrency($currency)->setIssuer($issuer)->setReference($temp_orders_id)->setDescription(STORE_NAME);
             // You should always set the order ID, however, this is ommitted here for testing purposes
             $url = $payment->setOrderID($temp_orders_id . ' ' . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9))->getURL();
             header("Location: " . $url);
             exit;
         } catch (Exception $e) {
             $this->errors[$this->type] = Translate($e->getMessage());
         }
     }
 }