찾다
백엔드 개발PHP 튜토리얼PHP는 주문 누락을 방지하기 위해 zen-cart 주문 및 결제 프로세스를 수정합니다.

zen-cart를 사용해 본 사람이라면 누구나 zen-cart의 주문 단계가 다음과 같다는 것을 알고 있을 것입니다([] 안의 표현은 필요하지 않습니다).

1. 장바구니

2. [배송방법]

3. 결제방법

4. 주문확인(확인)

5. [제3자 홈페이지 결제]

6. 주문 처리(결제 프로세스) - 장바구니에 있는 정보가 여기에 주문에 기록되므로 이 단계가 더 중요합니다.

7. 주문 성공(결제 성공)

일반적인 상황에서는 이 과정에 아무런 문제가 없습니다. 다만, 5단계부터 6단계까지의 과정에서 사용자는 결제가 성공했다고 생각하고 바로 웹페이지를 닫거나, 네트워크상의 문제로 인해 checkout_process 페이지로 정상적으로 점프하지 못하는 경우가 발생할 수 있습니다. 이는 주문이 정상적으로 생성될 수 없기 때문에 매우 심각한 문제입니다.

위의 분석을 바탕으로 프로세스를 약간 변경하여 결제 전에 주문이 생성되었으므로 결제 도중에 제3자 결제 웹사이트에서 다시 이동할 수 없더라도 사용자가 성공적으로 결제했지만 백그라운드에서 주문이 없는 상황이 있을 수 있습니다. 수정된 도면은 기본적으로 다음과 같습니다.

1. checkour_confirmation 페이지에서 주문 확인 후 직접 처리하여 checkour_success 페이지로 들어가시면 결제 페이지로 진입하실 수 있습니다. 아래 그림과 같습니다.

php 修改zen-cart下单和付款流程以防止漏单

2. 고객이 해당 시점에 결제에 실패한 경우 자신의 백엔드에 들어가 과거 주문에 대한 결제도 가능합니다. 아래 그림과 같이

php 修改zen-cart下单和付款流程以防止漏单

위의 기능을 단계별로 구현하는 방법을 살펴보겠습니다.

1. 먼저 기존 결제 모듈을 혁신해야 합니다. 결제를 위한 페이지 URL을 나타내기 위해 결제 방법 클래스에 paynow_action_url 필드를 추가해야 합니다. 또한 결제 양식의 숨겨진 필드 코드 매개변수를 가져오려면 paynow_button($order_id) 함수를 추가해야 합니다.
paynow_action_url 필드를 추가하려면 결제 클래스 생성자 끝에 다음 코드를 추가하세요.

if ( (zen_not_null($module)) && (in_array($module.'.php', $this->modules)) && (isset($GLOBALS[$module]->paynow_action_url)) ) { 
$this->paynow_action_url = $GLOBALS[$module]->paynow_action_url; 
}

paynow_button($order_id) 함수를 추가하려면 마지막 뒤에 추가하세요. 결제 클래스 기능 다음 코드를 추가하세요.

function paynow_button($order_id){ 
if (is_array($this->modules)) { 
if (is_object($GLOBALS[$this->selected_module])) { 
return $GLOBALS[$this->selected_module]->paynow_button($order_id); 
} 
} 
}

2. 페이팔 결제 방식을 예로 들어 구현 방법을 설명합니다. 페이팔의 원래 코드를 파괴하지 않기 위해 paypal.php 파일의 복사본을 만들고 이름을 paypalsimple.php로 지정한 후 내부 코드를 적절하게 수정하겠습니다. 코드는 아래와 같습니다. 여기서는 form_action_url의 지정이 제거되고 paynow_action_url이 부여된 것을 볼 수 있습니다. 왜냐하면 사용자가 "Confirm Order"를 클릭한 후 checkout_process에 직접 진입하기를 바라기 때문에 form_action_url을 지정하지 않으면 주문 확인 양식은 checkout_process 페이지로 직접 제출되며, paynow_action_url은 이전 form_action_url의 값입니다. paynow_button 함수의 구현도 매우 간단합니다. 여기서는 원래 process_button() 함수의 내용을 잘라내지만 전역 $order 변수를 사용하지 않고 $order = new order($order_id)를 사용하여 다시 만듭니다. 지금 결제 버튼을 과거 순서대로 표시하기 위해 생성된 객체입니다.
paypalsimple.php

<?php 
/** 
* @package paypalsimple payment module 
* @copyright Copyright 2003-2006 Zen Cart Development Team 
* @copyright Portions Copyright 2003 osCommerce 
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 
* @version $Id: paypalsimple.php 4960 2009-12-29 11:46:46Z gary $ 
*/ 
// ensure dependencies are loaded 
include_once((IS_ADMIN_FLAG === true ? DIR_FS_CATALOG_MODULES : DIR_WS_MODULES) . &#39;payment/paypal/paypal_functions.php&#39;); 
class paypalsimple { 
var $code, $title, $description, $enabled; 
// class constructor 
function paypalsimple() { 
global $order; 
$this->code = &#39;paypalsimple&#39;; 
$this->title = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_TITLE; 
if(IS_ADMIN_FLAG === true){ 
$this->title = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_ADMIN_TITLE; 
} 
$this->description = MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_DESCRIPTION; 
$this->sort_order = MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER; 
$this->enabled = ((MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS == &#39;True&#39;) ? true : false); 
if ((int)MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID > 0) { 
$this->order_status = MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID; 
} 
$this->paynow_action_url = &#39;https://&#39; . MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER; 
if (is_object($order)) $this->update_status(); 
} 
// class methods 
function update_status() { 
global $order, $db; 
if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE > 0) ) { 
$check_flag = false; 
$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = &#39;" . MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE . "&#39; and zone_country_id = &#39;" . $order->billing[&#39;country&#39;][&#39;id&#39;] . "&#39; order by zone_id"); 
while (!$check->EOF) { 
if ($check->fields[&#39;zone_id&#39;] < 1) { 
$check_flag = true; 
break; 
} elseif ($check->fields[&#39;zone_id&#39;] == $order->billing[&#39;zone_id&#39;]) { 
$check_flag = true; 
break; 
} 
$check->MoveNext(); 
} 
if ($check_flag == false) { 
$this->enabled = false; 
} 
} 
} 
function javascript_validation() { 
return false; 
} 
function selection() { 
$text = MODULE_PAYMENT_SIMPLE_PAYPAL_TEXT_CATALOG_LOGO.&#39;  &#39;.MODULE_PAYMENT_PAYPAL_SIMPLE_TEXT_TITLE . &#39;<br/><br/>    <span class="smallText">&#39; . MODULE_PAYMENT_PAYPAL_SIMPLE_ACCEPTANCE_MARK_TEXT . &#39;</span><br/><br/>&#39;; 
return array(&#39;id&#39; => $this->code, 
&#39;module&#39; => $text 
); 
} 
function pre_confirmation_check() { 
return false; 
} 
function confirmation() { 
return false; 
} 
function process_button() { 
return false; 
} 
function before_process() { 
return false; 
} 
function after_process() { 
return false; 
} 
function get_error() { 
return false; 
} 
function check() { 
global $db; 
if (!isset($this->_check)) { 
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;"); 
$this->_check = $check_query->RecordCount(); 
} 
return $this->_check; 
} 
function install() { 
global $db; 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values (&#39;Enable PayPal-Simple Module&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;, &#39;True&#39;, &#39;Do you want to accept PayPal-Simple payments?&#39;, &#39;6&#39;, &#39;0&#39;, &#39;zen_cfg_select_option(array(\&#39;True\&#39;, \&#39;False\&#39;), &#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values (&#39;Sort order of display.&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER&#39;, &#39;0&#39;, &#39;Sort order of display. Lowest is displayed first.&#39;, &#39;6&#39;, &#39;8&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values (&#39;Payment Zone&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE&#39;, &#39;0&#39;, &#39;If a zone is selected, only enable this payment method for that zone.&#39;, &#39;6&#39;, &#39;2&#39;, &#39;zen_get_zone_class_title&#39;, &#39;zen_cfg_pull_down_zone_classes(&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values (&#39;Set Order Status&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID&#39;, &#39;0&#39;, &#39;Set the status of orders made with this payment module to this value&#39;, &#39;6&#39;, &#39;0&#39;, &#39;zen_cfg_pull_down_order_statuses(&#39;, &#39;zen_get_order_status_name&#39;, now())"); 
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values (&#39;Mode for PayPal web services<br /><br />Default:<br /><code>www.paypal.com/cgi-bin/webscr</code><br />or<br /><code>www.paypal.com/us/cgi-bin/webscr</code><br />or for the UK,<br /><code>www.paypal.com/uk/cgi-bin/webscr</code>&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER&#39;, &#39;www.paypal.com/cgi-bin/webscr&#39;, &#39;Choose the URL for PayPal live processing&#39;, &#39;6&#39;, &#39;73&#39;, &#39;&#39;, now())"); 
} 
function remove() { 
global $db; 
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in (&#39;" . implode("&#39;, &#39;", $this->keys()) . "&#39;)"); 
} 
function keys() { 
return array(&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_STATUS&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_SORT_ORDER&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ZONE&#39;,&#39;MODULE_PAYMENT_PAYPAL_SIMPLE_ORDER_STATUS_ID&#39;, &#39;MODULE_PAYMENT_PAYPAL_SIMPLE_HANDLER&#39;); 
} 
function paynow_button($order_id){ 
global $db, $order, $currencies, $currency; 
require_once(DIR_WS_CLASSES . &#39;order.php&#39;); 
$order = new order($order_id); 
$options = array(); 
$optionsCore = array(); 
$optionsPhone = array(); 
$optionsShip = array(); 
$optionsLineItems = array(); 
$optionsAggregate = array(); 
$optionsTrans = array(); 
$buttonArray = array(); 
$this->totalsum = $order->info[&#39;total&#39;]; 
// save the session stuff permanently in case paypal loses the session 
$_SESSION[&#39;ppipn_key_to_remove&#39;] = session_id(); 
$db->Execute("delete from " . TABLE_PAYPAL_SESSION . " where session_id = &#39;" . zen_db_input($_SESSION[&#39;ppipn_key_to_remove&#39;]) . "&#39;"); 
$sql = "insert into " . TABLE_PAYPAL_SESSION . " (session_id, saved_session, expiry) values ( 
&#39;" . zen_db_input($_SESSION[&#39;ppipn_key_to_remove&#39;]) . "&#39;, 
&#39;" . base64_encode(serialize($_SESSION)) . "&#39;, 
&#39;" . (time() + (1*60*60*24*2)) . "&#39;)"; 
$db->Execute($sql); 
$my_currency = select_pp_currency(); 
$this->transaction_currency = $my_currency; 
$this->transaction_amount = ($this->totalsum * $currencies->get_value($my_currency)); 
$telephone = preg_replace(&#39;/\D/&#39;, &#39;&#39;, $order->customer[&#39;telephone&#39;]); 
if ($telephone != &#39;&#39;) { 
$optionsPhone[&#39;H_PhoneNumber&#39;] = $telephone; 
if (in_array($order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], array(&#39;US&#39;,&#39;CA&#39;))) { 
$optionsPhone[&#39;night_phone_a&#39;] = substr($telephone,0,3); 
$optionsPhone[&#39;night_phone_b&#39;] = substr($telephone,3,3); 
$optionsPhone[&#39;night_phone_c&#39;] = substr($telephone,6,4); 
$optionsPhone[&#39;day_phone_a&#39;] = substr($telephone,0,3); 
$optionsPhone[&#39;day_phone_b&#39;] = substr($telephone,3,3); 
$optionsPhone[&#39;day_phone_c&#39;] = substr($telephone,6,4); 
} else { 
$optionsPhone[&#39;night_phone_b&#39;] = $telephone; 
$optionsPhone[&#39;day_phone_b&#39;] = $telephone; 
} 
} 
$optionsCore = array( 
&#39;charset&#39; => CHARSET, 
&#39;lc&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;page_style&#39; => MODULE_PAYMENT_PAYPAL_PAGE_STYLE, 
&#39;custom&#39; => zen_session_name() . &#39;=&#39; . zen_session_id(), 
&#39;business&#39; => MODULE_PAYMENT_PAYPAL_BUSINESS_ID, 
&#39;return&#39; => zen_href_link(FILENAME_PAY_SUCCESS, &#39;referer=paypal&#39;, &#39;SSL&#39;), 
&#39;cancel_return&#39; => zen_href_link(FILENAME_PAY_FAILED, &#39;&#39;, &#39;SSL&#39;), 
&#39;shopping_url&#39; => zen_href_link(FILENAME_SHOPPING_CART, &#39;&#39;, &#39;SSL&#39;), 
&#39;notify_url&#39; => zen_href_link(&#39;ipn_main_handler.php&#39;, &#39;&#39;, &#39;SSL&#39;,false,false,true), 
&#39;redirect_cmd&#39; => &#39;_xclick&#39;, 
&#39;rm&#39; => 2, 
&#39;bn&#39; => &#39;zencart&#39;, 
&#39;mrb&#39; => &#39;R-6C7952342H795591R&#39;, 
&#39;pal&#39; => &#39;9E82WJBKKGPLQ&#39;, 
); 
$optionsCust = array( 
&#39;first_name&#39; => replace_accents($order->customer[&#39;firstname&#39;]), 
&#39;last_name&#39; => replace_accents($order->customer[&#39;lastname&#39;]), 
&#39;address1&#39; => replace_accents($order->customer[&#39;street_address&#39;]), 
&#39;city&#39; => replace_accents($order->customer[&#39;city&#39;]), 
&#39;state&#39; => zen_get_zone_code($order->customer[&#39;country&#39;][&#39;id&#39;], $order->customer[&#39;zone_id&#39;], $order->customer[&#39;zone_id&#39;]), 
&#39;zip&#39; => $order->customer[&#39;postcode&#39;], 
&#39;country&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;email&#39; => $order->customer[&#39;email_address&#39;], 
); 
if ($order->customer[&#39;suburb&#39;] != &#39;&#39;) $optionsCust[&#39;address2&#39;] = $order->customer[&#39;suburb&#39;]; 
if (MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED == 2) $optionsCust = array( 
&#39;address_name&#39; => replace_accents($order->customer[&#39;firstname&#39;] . &#39; &#39; . $order->customer[&#39;lastname&#39;]), 
&#39;address_street&#39; => replace_accents($order->customer[&#39;street_address&#39;]), 
&#39;address_city&#39; => replace_accents($order->customer[&#39;city&#39;]), 
&#39;address_state&#39; => zen_get_zone_code($order->customer[&#39;country&#39;][&#39;id&#39;], $order->customer[&#39;zone_id&#39;], $order->customer[&#39;zone_id&#39;]), 
&#39;address_zip&#39; => $order->customer[&#39;postcode&#39;], 
&#39;address_country&#39; => $order->customer[&#39;country&#39;][&#39;title&#39;], 
&#39;address_country_code&#39; => $order->customer[&#39;country&#39;][&#39;iso_code_2&#39;], 
&#39;payer_email&#39; => $order->customer[&#39;email_address&#39;], 
); 
$optionsShip = array( 
//&#39;address_override&#39; => MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE, 
&#39;no_shipping&#39; => MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED, 
); 
if (MODULE_PAYMENT_PAYPAL_DETAILED_CART == &#39;Yes&#39;) $optionsLineItems = ipn_getLineItemDetails(); 
if (sizeof($optionsLineItems) > 0) { 
$optionsLineItems[&#39;cmd&#39;] = &#39;_cart&#39;; 
// $optionsLineItems[&#39;num_cart_items&#39;] = sizeof($order->products); 
if (isset($optionsLineItems[&#39;shipping&#39;])) { 
$optionsLineItems[&#39;shipping_1&#39;] = $optionsLineItems[&#39;shipping&#39;]; 
unset($optionsLineItems[&#39;shipping&#39;]); 
} 
if (isset($optionsLineItems[&#39;handling&#39;])) { 
$optionsLineItems[&#39;handling_1&#39;] = $optionsLineItems[&#39;handling&#39;]; 
unset($optionsLineItems[&#39;handling&#39;]); 
} 
unset($optionsLineItems[&#39;subtotal&#39;]); 
// if line-item details couldn&#39;t be kept due to calculation mismatches or discounts etc, default to aggregate mode 
if (!isset($optionsLineItems[&#39;item_name_1&#39;])) $optionsLineItems = array(); 
//if ($optionsLineItems[&#39;amount&#39;] != $this->transaction_amount) $optionsLineItems = array(); 
ipn_debug_email(&#39;Line Item Details (if blank, this means there was a data mismatch, and thus bypassed): &#39; . "\n" . print_r($optionsLineItems, true)); 
} 
$products_name_display = ""; 
/* 
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 
if(i > 0) { 
$products_name_display.= &#39;, &#39;; 
} 
$products_name_display.= $order->products[$i][&#39;name&#39;]. &#39;(&#39;. $order->products[$i][&#39;qty&#39;] .&#39;,&#39;.$order->products[$i][&#39;dhisys_web_order_number&#39;].&#39;)&#39;; 
}*/ 
$optionsAggregate = array( 
&#39;cmd&#39; => &#39;_ext-enter&#39;, 
&#39;item_name&#39; => $products_name_display, 
&#39;item_number&#39; => $order_id, 
&#39;num_cart_items&#39; => sizeof($order->products), 
&#39;amount&#39; => number_format($this->transaction_amount, $currencies->get_decimal_places($my_currency)), 
&#39;shipping&#39; => &#39;0.00&#39;, 
); 
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == &#39;true&#39;) $optionsAggregate[&#39;tax&#39;] = &#39;0.00&#39;; 
if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == &#39;true&#39;) $optionsAggregate[&#39;tax_cart&#39;] = &#39;0.00&#39;; 
$optionsTrans = array( 
&#39;upload&#39; => (int)(sizeof($order->products) > 0), 
&#39;currency_code&#39; => $my_currency, 
// &#39;paypal_order_id&#39; => $paypal_order_id, 
//&#39;no_note&#39; => &#39;1&#39;, 
//&#39;invoice&#39; => &#39;&#39;, 
); 
// if line-item info is invalid, use aggregate: 
if (sizeof($optionsLineItems) > 0) $optionsAggregate = $optionsLineItems; 
// prepare submission 
$options = array_merge($optionsCore, $optionsCust, $optionsPhone, $optionsShip, $optionsTrans, $optionsAggregate); 
ipn_debug_email(&#39;Keys for submission: &#39; . print_r($options, true)); 
if(sizeof($order->products) > 0){ 
$options[&#39;cmd&#39;] = &#39;_cart&#39;; 
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 
$options[&#39;item_name_&#39;. (string)($i+1)] = $order->products[$i][&#39;name&#39;]; 
$options[&#39;item_number_&#39;. (string)($i+1)] = $order->products[$i][&#39;dhisys_web_order_number&#39;]; 
$options[&#39;amount_&#39;. (string)($i+1)] = number_format((float)$order->products[$i][&#39;final_price&#39;],2); 
$options[&#39;quantity_&#39;. (string)($i+1)] = $order->products[$i][&#39;qty&#39;]; 
} 
} 
// build the button fields 
foreach ($options as $name => $value) { 
// remove quotation marks 
$value = str_replace(&#39;"&#39;, &#39;&#39;, $value); 
// check for invalid chars 
if (preg_match(&#39;/[^a-zA-Z_0-9]/&#39;, $name)) { 
ipn_debug_email(&#39;datacheck - ABORTING - preg_match found invalid submission key: &#39; . $name . &#39; (&#39; . $value . &#39;)&#39;); 
break; 
} 
// do we need special handling for & and = symbols? 
//if (strpos($value, &#39;&&#39;) !== false || strpos($value, &#39;=&#39;) !== false) $value = urlencode($value); 
$buttonArray[] = zen_draw_hidden_field($name, $value); 
} 
$_SESSION[&#39;paypal_transaction_info&#39;] = array($this->transaction_amount, $this->transaction_currency); 
$process_button_string = implode("\n", $buttonArray) . "\n"; 
return $process_button_string; 
} 
} 
?>

3. checkout_success 페이지에 지금 결제 버튼을 표시합니다. "includes/modules/pages/checkout_success/header.php" 파일을 열고 파일 끝에 다음 코드를 추가합니다(zen-cart에서 알리미/관찰자 모드를 마스터했고 zen- 장바구니 핵심 코드가 그렇다면 NOTIFY_HEADER_END_CHECKOUT_SUCCESS를 수신하는 관찰 클래스를 생성할 수도 있습니다.

require_once(DIR_WS_CLASSES . &#39;order.php&#39;); 
require_once(DIR_WS_CLASSES . &#39;payment.php&#39;); 
$payment_modules = new payment($orders->fields[&#39;payment_module_code&#39;]);

"includes/modules/templates/template_default/templates/tpl_checkout_success_default.php" 파일을 열고 해당 위치에 다음 코드를 추가합니다. 여기서 주문 상태에 대한 판단이 이루어집니다. 이 버튼은 주문 상태가 미결제일 때만 표시됩니다.

<div id="pay_now"> 
<?php 
//&& $orders->fields[&#39;orders_status&#39;] == &#39;1&#39; 
if(isset($payment_modules->paynow_action_url) && $payment_modules->paynow_action_url != &#39;&#39;&& $orders->fields[&#39;orders_status&#39;] == &#39;1&#39;){ 
echo(&#39;<fieldset id="csNotifications">&#39;); 
echo(&#39;<legend>&#39;.TEXT_PAYNOW.&#39;</legend>&#39;); 
echo zen_draw_form(&#39;checkout_paynow&#39;, $payment_modules->paynow_action_url, &#39;post&#39;, &#39;id="checkout_confirmation" onsubmit="submitonce();"&#39;); 
$selection = $payment_modules->selection(); 
echo(&#39;<div class="buttonRow payment_method">&#39;.$selection[0][&#39;module&#39;].&#39;</div>&#39;); 
echo(&#39;<div class="buttonRow forward paynow">&#39;); 
if (is_array($payment_modules->modules)) { 
echo $payment_modules->paynow_button($orders_id); 
} 
echo(zen_image_submit(BUTTON_IMAGE_PAYNOW, BUTTON_IMAGE_PAYNOW_ALT, &#39;name="btn_paynow" id="btn_paynow"&#39;)); 
echo(&#39;</div>&#39;); 
echo(&#39;</form>&#39;); 
echo(&#39;</fieldset>&#39;); 
} 
?> 
</div>

4. 在历史订单中显示pay now按钮。需要显示pay now按钮的页面有三个:account, account_history,account_history_info,这里的实现和checkout_success页面的实现大同小异,只是传给$payment_modules的函数paynow_button的参数不一样而已,这里就不再赘述。 
总结: 
经过上面的修改,我们的流程如下: 
1. 购物车(shopping cart) 
2. [货运方式(delivery method)] 
3. 支付方式(payment method) 
4. 订单确认(confirmation) 
5. 订单处理(checkout process) 
6. 下单成功(checkout success) 
7. [第三方网站支付] 
因为从订单确认到订单处理,都是在我们自己的网站完成的,并且进入支付网站之前,订单已经存在了,这样就不会出现掉单的情况了。 

更多php 修改zen-cart下单和付款流程以防止漏单相关文章请关注PHP中文网!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
세션과 관련된 크로스 사이트 스크립팅 (XSS) 공격으로부터 어떻게 보호 할 수 있습니까?세션과 관련된 크로스 사이트 스크립팅 (XSS) 공격으로부터 어떻게 보호 할 수 있습니까?Apr 23, 2025 am 12:16 AM

세션 관련 XSS 공격으로부터 응용 프로그램을 보호하려면 다음 조치가 필요합니다. 1. 세션 쿠키를 보호하기 위해 Httponly 및 Secure 플래그를 설정하십시오. 2. 모든 사용자 입력에 대한 내보내기 코드. 3. 스크립트 소스를 제한하기 위해 컨텐츠 보안 정책 (CSP)을 구현하십시오. 이러한 정책을 통해 세션 관련 XSS 공격을 효과적으로 보호 할 수 있으며 사용자 데이터가 보장 될 수 있습니다.

PHP 세션 성능을 어떻게 최적화 할 수 있습니까?PHP 세션 성능을 어떻게 최적화 할 수 있습니까?Apr 23, 2025 am 12:13 AM

PHP 세션 성능을 최적화하는 방법 : 1. 지연 세션 시작, 2. 데이터베이스를 사용하여 세션을 저장, 3. 세션 데이터 압축, 4. 세션 수명주기 관리 및 5. 세션 공유 구현. 이러한 전략은 높은 동시성 환경에서 응용의 효율성을 크게 향상시킬 수 있습니다.

SESSION.GC_MAXLIFETIME 구성 설정은 무엇입니까?SESSION.GC_MAXLIFETIME 구성 설정은 무엇입니까?Apr 23, 2025 am 12:10 AM

THESESSION.GC_MAXLIFETIMESETTINGINSTTINGTINGSTINGTERMINESTERMINESTERSTINGSESSIONDATA, SETINSECONDS.1) IT'SCONFIGUDEDINPHP.INIORVIAINI_SET ()

PHP에서 세션 이름을 어떻게 구성합니까?PHP에서 세션 이름을 어떻게 구성합니까?Apr 23, 2025 am 12:08 AM

PHP에서는 Session_Name () 함수를 사용하여 세션 이름을 구성 할 수 있습니다. 특정 단계는 다음과 같습니다. 1. Session_Name () 함수를 사용하여 Session_Name ( "my_session")과 같은 세션 이름을 설정하십시오. 2. 세션 이름을 설정 한 후 세션을 시작하여 세션을 시작하십시오. 세션 이름을 구성하면 여러 응용 프로그램 간의 세션 데이터 충돌을 피하고 보안을 향상시킬 수 있지만 세션 이름의 독창성, 보안, 길이 및 설정 타이밍에주의를 기울일 수 있습니다.

세션 ID를 얼마나 자주 재생해야합니까?세션 ID를 얼마나 자주 재생해야합니까?Apr 23, 2025 am 12:03 AM

세션 ID는 로그인시, 민감한 작업 전에 및 30 분마다 정기적으로 재생되어야합니다. 1. 세션 고정 공격을 방지하기 위해 로그인 할 때 세션 ID를 재생합니다. 2. 안전성을 향상시키기 위해 민감한 작업 전에 재생성. 3. 정기적 인 재생은 장기 활용 위험을 줄이지 만 사용자 경험을 평가해야합니다.

PHP에서 세션 쿠키 매개 변수를 어떻게 설정합니까?PHP에서 세션 쿠키 매개 변수를 어떻게 설정합니까?Apr 22, 2025 pm 05:33 PM

Session_SET_COOKIE_PARAMS () 함수를 통해 PHP에서 세션 쿠키 매개 변수 설정을 달성 할 수 있습니다. 1)이 기능을 사용하여 만료 시간, 경로, 도메인 이름, 보안 플래그 등과 같은 매개 변수를 설정하십시오. 2) call session_start ()를 호출하려면 매개 변수를 발효시킵니다. 3) 사용자 로그인 상태와 같은 요구에 따라 매개 변수를 동적으로 조정합니다. 4) 보안을 향상시키기 위해 안전하고 httponly 플래그 설정에주의를 기울이십시오.

PHP에서 세션을 사용하는 주요 목적은 무엇입니까?PHP에서 세션을 사용하는 주요 목적은 무엇입니까?Apr 22, 2025 pm 05:25 PM

PHP에서 세션을 사용하는 주요 목적은 다른 페이지간에 사용자의 상태를 유지하는 것입니다. 1) 세션은 Session_Start () 함수를 통해 시작되어 고유 한 세션 ID를 생성하고 사용자 쿠키에 저장합니다. 2) 세션 데이터는 서버에 저장되므로 로그인 상태 및 쇼핑 카트 컨텐츠와 같은 다른 요청간에 데이터를 전달할 수 있습니다.

하위 도메인에서 세션을 어떻게 공유 할 수 있습니까?하위 도메인에서 세션을 어떻게 공유 할 수 있습니까?Apr 22, 2025 pm 05:21 PM

하위 도메인 간의 세션을 공유하는 방법? 공통 도메인 이름에 대한 세션 쿠키를 설정하여 구현. 1. 세션 쿠키 도메인을 서버 측에서 .example.com으로 설정하십시오. 2. 메모리, 데이터베이스 또는 분산 캐시와 같은 적절한 세션 저장 방법을 선택하십시오. 3. 쿠키를 통해 세션 ID를 전달하면 서버는 ID를 기반으로 세션 데이터를 검색하고 업데이트합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전

VSCode Windows 64비트 다운로드

VSCode Windows 64비트 다운로드

Microsoft에서 출시한 강력한 무료 IDE 편집기

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는