WikiFormatting: checkout_payment.php.txt

File checkout_payment.php.txt, 18.2 KB (added by ashokmca31, 3 years ago)
Line 
1<?php
2/*
3  $Id: checkout_payment.php 1739 2007-12-20 00:52:16Z hpdl $
4
5  osCommerce, Open Source E-Commerce Solutions
6  http://www.oscommerce.com
7
8  Copyright (c) 2007 osCommerce
9
10  Released under the GNU General Public License
11*/
12
13  require('includes/application_top.php');
14
15// if the customer is not logged on, redirect them to the login page
16  if (!tep_session_is_registered('customer_id')) {
17    $navigation->set_snapshot();
18    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
19  }
20
21// if there is nothing in the customers cart, redirect them to the shopping cart page
22  if ($cart->count_contents() < 1) {
23    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
24  }
25
26// if no shipping method has been selected, redirect the customer to the shipping method selection page
27  if (!tep_session_is_registered('shipping')) {
28    tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
29  }
30
31// avoid hack attempts during the checkout procedure by checking the internal cartID
32  if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
33    if ($cart->cartID != $cartID) {
34      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
35    }
36  }
37
38// Stock Check
39  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
40    $products = $cart->get_products();
41    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
42      if (tep_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
43        tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
44        break;
45      }
46    }
47  }
48
49// if no billing destination address was selected, use the customers own address as default
50  if (!tep_session_is_registered('billto')) {
51    tep_session_register('billto');
52    $billto = $customer_default_address_id;
53  } else {
54// verify the selected billing address
55    if ( (is_array($billto) && empty($billto)) || is_numeric($billto) ) {
56      $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$billto . "'");
57      $check_address = tep_db_fetch_array($check_address_query);
58
59      if ($check_address['total'] != '1') {
60        $billto = $customer_default_address_id;
61        if (tep_session_is_registered('payment')) tep_session_unregister('payment');
62      }
63    }
64  }
65
66  require(DIR_WS_CLASSES . 'order.php');
67  $order = new order;
68
69  if (!tep_session_is_registered('comments')) tep_session_register('comments');
70  if (isset($HTTP_POST_VARS['comments']) && tep_not_null($HTTP_POST_VARS['comments'])) {
71    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
72  }
73
74  $total_weight = $cart->show_weight();
75  $total_count = $cart->count_contents();
76
77// load all enabled payment modules
78  require(DIR_WS_CLASSES . 'payment.php');
79  $payment_modules = new payment;
80
81  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT);
82
83  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
84  $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
85?>
86<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
87<html <?php echo HTML_PARAMS; ?>>
88<head>
89<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
90<title><?php echo TITLE; ?></title>
91<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
92<link rel="stylesheet" type="text/css" href="stylesheet.css">
93<script language="javascript"><!--
94var selected;
95
96function selectRowEffect(object, buttonSelect) {
97  if (!selected) {
98    if (document.getElementById) {
99      selected = document.getElementById('defaultSelected');
100    } else {
101      selected = document.all['defaultSelected'];
102    }
103  }
104
105  if (selected) selected.className = 'moduleRow';
106  object.className = 'moduleRowSelected';
107  selected = object;
108
109// one button is not an array
110  if (document.checkout_payment.payment[0]) {
111    document.checkout_payment.payment[buttonSelect].checked=true;
112  } else {
113    document.checkout_payment.payment.checked=true;
114  }
115}
116
117function rowOverEffect(object) {
118  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
119}
120
121function rowOutEffect(object) {
122  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
123}
124//--></script>
125<?php echo $payment_modules->javascript_validation(); ?>
126</head>
127<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
128<!-- header //-->
129<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
130<!-- header_eof //-->
131
132<!-- body //-->
133<table border="0" width="100%" cellspacing="3" cellpadding="3">
134  <tr>
135    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
136<!-- left_navigation //-->
137<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
138<!-- left_navigation_eof //-->
139    </table></td>
140<!-- body_text //-->
141    <td width="100%" valign="top"><?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
142      <tr>
143        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
144          <tr>
145            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
146            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_payment.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
147          </tr>
148        </table></td>
149      </tr>
150      <tr>
151        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
152      </tr>
153<?php
154//---PayPal WPP Modification START ---//
155  tep_paypal_wpp_checkout_payment_error_display();
156//---PayPal WPP Modification END ---//
157?>
158<?php
159  if (isset($HTTP_GET_VARS['payment_error']) && is_object(${$HTTP_GET_VARS['payment_error']}) && ($error = ${$HTTP_GET_VARS['payment_error']}->get_error())) {
160?>
161      <tr>
162        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
163          <tr>
164            <td class="main"><b><?php echo tep_output_string_protected($error['title']); ?></b></td>
165          </tr>
166        </table></td>
167      </tr>
168      <tr>
169        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBoxNotice">
170          <tr class="infoBoxNoticeContents">
171            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
172              <tr>
173                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
174                <td class="main" width="100%" valign="top"><?php echo tep_output_string_protected($error['error']); ?></td>
175                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
176              </tr>
177            </table></td>
178          </tr>
179        </table></td>
180      </tr>
181      <tr>
182        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
183      </tr>
184<?php
185  }
186?>
187<?php //---PayPal WPP Modification START ---//-- ?>
188<?php if (!$ec_enabled || isset($_GET['ec_cancel']) || (!tep_session_is_registered('paypal_ec_payer_id') && !tep_session_is_registered('paypal_ec_payer_info'))) { ?>
189<?php //---PayPal WPP Modification END ---//-- ?>
190      <tr>
191        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
192          <tr>
193            <td class="main"><b><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></b></td>
194          </tr>
195        </table></td>
196      </tr>
197      <tr>
198        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
199          <tr class="infoBoxContents">
200            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
201              <tr>
202                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
203                <td class="main" width="50%" valign="top"><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?><br><br><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_address.gif', IMAGE_BUTTON_CHANGE_ADDRESS) . '</a>'; ?></td>
204                <td align="right" width="50%" valign="top"><table border="0" cellspacing="0" cellpadding="2">
205                  <tr>
206                    <td class="main" align="center" valign="top"><b><?php echo TITLE_BILLING_ADDRESS; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?></td>
207                    <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
208                    <td class="main" valign="top"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?></td>
209                    <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
210                  </tr>
211                </table></td>
212              </tr>
213            </table></td>
214          </tr>
215        </table></td>
216      </tr>
217      <tr>
218        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
219      </tr>
220      <tr>
221        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
222          <tr>
223            <td class="main"><b><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></b></td>
224          </tr>
225        </table></td>
226      </tr>
227      <tr>
228        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
229          <tr class="infoBoxContents">
230            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
231<?php
232  $selection = $payment_modules->selection();
233
234  if (sizeof($selection) > 1) {
235?>
236              <tr>
237                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
238                <td class="main" width="50%" valign="top"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></td>
239                <td class="main" width="50%" valign="top" align="right"><b><?php echo TITLE_PLEASE_SELECT; ?></b><br><?php echo tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td>
240                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
241              </tr>
242<?php
243  } else {
244?>
245              <tr>
246                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
247                <td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></td>
248                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
249              </tr>
250<?php
251  }
252
253  $radio_buttons = 0;
254  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
255?>
256              <tr>
257                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
258                <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
259<?php
260    if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
261      echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
262    } else {
263      echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
264    }
265?>
266                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
267                    <td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
268                    <td class="main" align="right">
269<?php
270    if (sizeof($selection) > 1) {
271      echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment));
272    } else {
273      echo tep_draw_hidden_field('payment', $selection[$i]['id']);
274    }
275?>
276                    </td>
277                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
278                  </tr>
279<?php
280    if (isset($selection[$i]['error'])) {
281?>
282                  <tr>
283                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
284                    <td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>
285                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
286                  </tr>
287<?php
288    } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
289?>
290                  <tr>
291                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
292                    <td colspan="4"><table border="0" cellspacing="0" cellpadding="2">
293<?php
294      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
295?>
296                      <tr>
297                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
298                        <td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>
299                        <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
300                        <td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>
301                        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
302                      </tr>
303<?php
304      }
305?>
306                    </table></td>
307                    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
308                  </tr>
309<?php
310    }
311?>
312                </table></td>
313                <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
314              </tr>
315<?php
316    $radio_buttons++;
317  }
318?>
319            </table></td>
320          </tr>
321        </table></td>
322      </tr>
323<?php
324//---PayPal WPP Modification START ---//
325  } else {
326    tep_paypal_wpp_switch_checkout_method(FILENAME_CHECKOUT_PAYMENT);
327  }
328//---PayPal WPP Modification END ---//
329?>
330      <tr>
331        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
332      </tr>
333      <tr>
334        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
335          <tr>
336            <td class="main"><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
337          </tr>
338        </table></td>
339      </tr>
340      <tr>
341        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
342          <tr class="infoBoxContents">
343            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
344              <tr>
345                <td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>
346              </tr>
347            </table></td>
348          </tr>
349        </table></td>
350      </tr>
351      <tr>
352        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
353      </tr>
354      <tr>
355        <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
356          <tr class="infoBoxContents">
357            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
358              <tr>
359                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
360                <td class="main"><b><?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE . '</b><br>' . TEXT_CONTINUE_CHECKOUT_PROCEDURE; ?></td>
361                <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
362                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
363              </tr>
364            </table></td>
365          </tr>
366        </table></td>
367      </tr>
368      <tr>
369        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
370      </tr>
371      <tr>
372        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
373          <tr>
374            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
375              <tr>
376                <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
377                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
378              </tr>
379            </table></td>
380            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
381              <tr>
382                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
383                <td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
384                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
385              </tr>
386            </table></td>
387            <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
388            <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
389              <tr>
390                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
391                <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
392              </tr>
393            </table></td>
394          </tr>
395          <tr>
396            <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
397            <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
398            <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
399            <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
400          </tr>
401        </table></td>
402      </tr>
403    </table></form></td>
404<!-- body_text_eof //-->
405    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
406<!-- right_navigation //-->
407<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
408<!-- right_navigation_eof //-->
409    </table></td>
410  </tr>
411</table>
412<!-- body_eof //-->
413
414<!-- footer //-->
415<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
416<!-- footer_eof //-->
417<br>
418</body>
419</html>
420<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>