Zencart先生成订单后付款,类似淘宝后台修改订单价格,zencart生成订单_PHP教程
Zencart先生成订单后付款,类似淘宝后台修改订单价格,zencart生成订单
Zencart 使用 Paypal 付款,会出现漏单的情况,即 paypal 已经收到客户的付款,但是网站后台没有客户的订单。导致 paypal 漏单的原因大致会是当客户跳转到Paypal 网站付款完毕之后,直接关闭了窗口,或者网络不稳定,没有正常跳转到网站。
解决 Paypal 漏单问题的方案有好几种:
一. 开启 Detailed Line Items in Cart 选项。
原理:在 zencart 后台 Module --> Payment --> PayPal Website Payments Standard - IPN 开启 Detailed Line Items in Cart 选项。这个选项会把你所有的订单物品信息传给 paypal,当客户付款成功而后台未能成功生成订单时,也可以通过 paypal 帐号交易信息看到客户购买了哪些物品。
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)函数,请在payment类的最后一个函数之后加上如下的代码:
<span>function</span> paynow_button(<span>$order_id</span><span>){ </span><span>if</span> (<span>is_array</span>(<span>$this</span>-><span>modules)) { </span><span>if</span> (<span>is_object</span>(<span>$GLOBALS</span>[<span>$this</span>-><span>selected_module])) { </span><span>return</span> <span>$GLOBALS</span>[<span>$this</span>->selected_module]->paynow_button(<span>$order_id</span><span>); } } }</span>
2. 以paypal支付方式为例子,说明如何具体实现。这里直接修改 paypal.php 文件,注意备份此文件。代码如下所示,可以看到,这里去掉了对 form_action_url 的指定,并给定了 paynow_action_url,因为我们希望用户点击“确认订单”后直接进入checkout_process,所以如果不指定 form_action_url,那么确认订单的表单就会直接提交到 checkout_process 页面了,而 paynow_action_url 就是 以前的 form_action_url 的值。paynow_button 函数的实现也很简单,这里只是将原先的 process_button() 函数的内容剪切过来而已,只不过我们没有使用全局的$order变量,而是使用 $order = new order($order_id),来重新构造的一个对象,这样做是为在历史订单中显示pay now按钮做准备的。paypal.php修改后的文件如下:

NOTE: This must match EXACTLY the primary email address on your PayPal account settings. It IS case-sensitive, so please check your PayPal profile preferences at paypal.com and be sure to enter the EXACT same primary email address here.', '6', '2', now())"); 253 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_PAYPAL_CURRENCY', 'Selected Currency', 'Which currency should the order be sent to PayPal as?
NOTE: if an unsupported currency is sent to PayPal, it will be auto-converted to USD.', '6', '3', 'zen_cfg_select_option(array(\'Selected Currency\', \'Only USD\', \'Only AUD\', \'Only CAD\', \'Only EUR\', \'Only GBP\', \'Only CHF\', \'Only CZK\', \'Only DKK\', \'Only HKD\', \'Only HUF\', \'Only JPY\', \'Only NOK\', \'Only NZD\', \'Only PLN\', \'Only SEK\', \'Only SGD\', \'Only THB\', \'Only MXN\', \'Only ILS\', \'Only PHP\', \'Only TWD\', \'Only BRL\', \'Only MYR\'), ', now())"); 254 $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 ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '4', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); 255 $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 ('Set Pending Notification Status', 'MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID', '" . DEFAULT_ORDERS_STATUS_ID . "', 'Set the status of orders made with this payment module that are not yet completed to this value
(\'Pending\' recommended)', '6', '5', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); 256 $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 ('Set Order Status', 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID', '2', 'Set the status of orders made with this payment module that have completed payment to this value
(\'Processing\' recommended)', '6', '6', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); 257 $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 ('Set Refund Order Status', 'MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID', '1', 'Set the status of orders that have been refunded made with this payment module to this value
(\'Pending\' recommended)', '6', '7', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); 258 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '8', now())"); 259 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Address Override', 'MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE', '1', 'If set to 1, the customer shipping address selected in Zen Cart will override the customer PayPal-stored address book. The customer will see their address from Zen Cart, but will NOT be able to edit it at PayPal.
(An invalid address will be treated by PayPal as not-supplied, or override=0)
0=No Override
1=ZC address overrides PayPal address choices', '6', '18', 'zen_cfg_select_option(array(\'0\',\'1\'), ', now())"); 260 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Address Requirements?', 'MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED', '2', 'The buyers shipping address. If set to 0 your customer will be prompted to include a shipping address. If set to 1 your customer will not be asked for a shipping address. If set to 2 your customer will be required to provide a shipping address.
0=Prompt
1=Not Asked
2=Required
NOTE: If you allow your customers to enter their own shipping address, then MAKE SURE you PERSONALLY manually verify the PayPal confirmation details to verify the proper address when filling orders. When using Website Payments Standard (IPN), Zen Cart does not know if they choose an alternate shipping address at PayPal vs the one entered when placing an order.', '6', '20', 'zen_cfg_select_option(array(\'0\',\'1\',\'2\'), ', now())"); 261 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Detailed Line Items in Cart', 'MODULE_PAYMENT_PAYPAL_DETAILED_CART', 'No', 'Do you want to give line-item details to PayPal? If set to True, line-item details will be shared with PayPal if no discounts apply and if tax and shipping are simple. Otherwise an Aggregate cart summary will be sent.', '6', '22', 'zen_cfg_select_option(array(\'No\',\'Yes\'), ', now())"); 262 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Page Style', 'MODULE_PAYMENT_PAYPAL_PAGE_STYLE', 'Primary', 'Sets the Custom Payment Page Style for payment pages. The value of page_style is the same as the Page Style Name you chose when adding or editing the page style. You can add and edit Custom Payment Page Styles from the Profile subtab of the My Account tab on the PayPal site. If you would like to always reference your Primary style, set this to \"primary.\" If you would like to reference the default PayPal page style, set this to \"paypal\".', '6', '25', now())"); 263 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode for PayPal web services
Default:
www.paypal.com/cgi-bin/webscr
or
www.paypal.com/us/cgi-bin/webscr
or for the UK,
www.paypal.com/uk/cgi-bin/webscr
', 'MODULE_PAYMENT_PAYPAL_HANDLER', 'www.paypal.com/cgi-bin/webscr', 'Choose the URL for PayPal live processing', '6', '73', '', now())");
264 // sandbox: www.sandbox.paypal.com/cgi-bin/webscr
265 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function) values ('PDT Token (Payment Data Transfer)', 'MODULE_PAYMENT_PAYPAL_PDTTOKEN', '', 'Enter your PDT Token value here in order to activate transactions immediately after processing (if they pass validation).', '6', '25', now(), 'zen_cfg_password_display')");
266 // Paypal testing options here
267 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Debug Mode', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG', 'Off', 'Enable debug logging? NOTE: This can REALLY clutter your email inbox!
Logging goes to the /includes/modules/payment/paypal/logs folder
Email goes to the store-owner address.
Email option NOT recommended.
Leave OFF for normal operation.', '6', '71', 'zen_cfg_select_option(array(\'Off\',\'Log File\',\'Log and Email\'), ', now())"); 268 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Debug Email Address', 'MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS','".STORE_OWNER_EMAIL_ADDRESS."', 'The email address to use for PayPal debugging', '6', '72', now())"); 269 270 $this->notify('NOTIFY_PAYMENT_PAYPAL_INSTALLED'); 271 } 272 /** 273 * Remove the module and all its settings 274 * 275 */ 276 function remove() { 277 global $db; 278 $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE\_PAYMENT\_PAYPAL\_%'"); 279 $this->notify('NOTIFY_PAYMENT_PAYPAL_UNINSTALLED'); 280 } 281 /** 282 * Internal list of configuration keys used for configuration of the module 283 * 284 * @return array 285 */ 286 function keys() { 287 $keys_list = array( 288 'MODULE_PAYMENT_PAYPAL_STATUS', 289 'MODULE_PAYMENT_PAYPAL_BUSINESS_ID', 290 'MODULE_PAYMENT_PAYPAL_PDTTOKEN', 291 'MODULE_PAYMENT_PAYPAL_CURRENCY', 292 'MODULE_PAYMENT_PAYPAL_ZONE', 293 'MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID', 294 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID', 295 'MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID', 296 'MODULE_PAYMENT_PAYPAL_SORT_ORDER', 297 'MODULE_PAYMENT_PAYPAL_DETAILED_CART', 298 'MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE' , 299 'MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED' , 300 'MODULE_PAYMENT_PAYPAL_PAGE_STYLE' , 301 'MODULE_PAYMENT_PAYPAL_HANDLER', 302 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG', 303 ); 304 305 // Paypal testing/debug options go here: 306 if (IS_ADMIN_FLAG === true) { 307 if (isset($_GET['debug']) && $_GET['debug']=='on') { 308 $keys_list[]='MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS'; /* this defaults to store-owner-email-address */ 309 } 310 } 311 return $keys_list; 312 } 313 314 function _getPDTresults($orderAmount, $my_currency, $pdtTX) { 315 global $db; 316 $ipnData = ipn_postback('PDT', $pdtTX); 317 $respdata = $ipnData['info']; 318 319 // parse the data 320 $lines = explode("\n", $respdata); 321 $this->pdtData = array(); 322 for ($i=1; $icount($lines);$i++){ 323 if (!strstr($lines[$i], "=")) continue; 324 list($key,$val) = explode("=", $lines[$i]); 325 $this->pdtData[urldecode($key)] = urldecode($val); 326 } 327 328 if ($this->pdtData['txn_id'] == '' || $this->pdtData['payment_status'] == '') { 329 ipn_debug_email('PDT Returned INVALID Data. Must wait for IPN to process instead. ' . "\n" . print_r($this->pdtData, true)); 330 return FALSE; 331 } else { 332 ipn_debug_email('PDT Returned Data ' . print_r($this->pdtData, true)); 333 } 334 335 $_POST['mc_gross'] = $this->pdtData['mc_gross']; 336 $_POST['mc_currency'] = $this->pdtData['mc_currency']; 337 $_POST['business'] = $this->pdtData['business']; 338 $_POST['receiver_email'] = $this->pdtData['receiver_email']; 339 340 $PDTstatus = (ipn_validate_transaction($respdata, $this->pdtData, 'PDT') && valid_payment($orderAmount, $my_currency, 'PDT') && $this->pdtData['payment_status'] == 'Completed'); 341 if ($this->pdtData['payment_status'] != '' && $this->pdtData['payment_status'] != 'Completed') { 342 ipn_debug_email('PDT WARNING :: Order not marked as "Completed". Check for Pending reasons or wait for IPN to complete.' . "\n" . '[payment_status] => ' . $this->pdtData['payment_status'] . "\n" . '[pending_reason] => ' . $this->pdtData['pending_reason']); 343 } 344 345 $sql = "SELECT order_id, paypal_ipn_id, payment_status, txn_type, pending_reason 346 FROM " . TABLE_PAYPAL . " 347 WHERE txn_id = :transactionID OR parent_txn_id = :transactionID 348 ORDER BY order_id DESC "; 349 $sql = $db->bindVars($sql, ':transactionID', $this->pdtData['txn_id'], 'string'); 350 $ipn_id = $db->Execute($sql); 351 if ($ipn_id->RecordCount() != 0) { 352 ipn_debug_email('PDT WARNING :: Transaction already exists. Perhaps IPN already added it. PDT processing ended.'); 353 $pdtTXN_is_unique = false; 354 } else { 355 $pdtTXN_is_unique = true; 356 } 357 358 $PDTstatus = ($pdtTXN_is_unique && $PDTstatus); 359 360 return $PDTstatus; 361 } 362 363 364 function tableCheckup() { 365 global $db, $sniffer; 366 $fieldOkay1 = (method_exists($sniffer, 'field_type')) ? $sniffer->field_type(TABLE_PAYPAL, 'txn_id', 'varchar(20)', true) : -1; 367 $fieldOkay2 = ($sniffer->field_exists(TABLE_PAYPAL, 'module_name')) ? true : -1; 368 $fieldOkay3 = ($sniffer->field_exists(TABLE_PAYPAL, 'order_id')) ? true : -1; 369 370 if ($fieldOkay1 == -1) { 371 $sql = "show fields from " . TABLE_PAYPAL; 372 $result = $db->Execute($sql); 373 while (!$result->EOF) { 374 if ($result->fields['Field'] == 'txn_id') { 375 if ($result->fields['Type'] == 'varchar(20)') { 376 $fieldOkay1 = true; // exists and matches required type, so skip to other checkup 377 } else { 378 $fieldOkay1 = $result->fields['Type']; // doesn't match, so return what it "is" 379 break; 380 } 381 } 382 $result->MoveNext(); 383 } 384 } 385 386 if ($fieldOkay1 !== true) { 387 // temporary fix to table structure for v1.3.7.x -- may remove in later release 388 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payment_type payment_type varchar(40) NOT NULL default ''"); 389 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE txn_type txn_type varchar(40) NOT NULL default ''"); 390 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payment_status payment_status varchar(32) NOT NULL default ''"); 391 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE reason_code reason_code varchar(40) default NULL"); 392 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE pending_reason pending_reason varchar(32) default NULL"); 393 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE invoice invoice varchar(128) default NULL"); 394 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payer_business_name payer_business_name varchar(128) default NULL"); 395 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_name address_name varchar(64) default NULL"); 396 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_street address_street varchar(254) default NULL"); 397 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_city address_city varchar(120) default NULL"); 398 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_state address_state varchar(120) default NULL"); 399 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payer_email payer_email varchar(128) NOT NULL default ''"); 400 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE business business varchar(128) NOT NULL default ''"); 401 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE receiver_email receiver_email varchar(128) NOT NULL default ''"); 402 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE txn_id txn_id varchar(20) NOT NULL default ''"); 403 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE parent_txn_id parent_txn_id varchar(20) default NULL"); 404 } 405 if ($fieldOkay2 !== true) { 406 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " ADD COLUMN module_name varchar(40) NOT NULL default '' after txn_type"); 407 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " ADD COLUMN module_mode varchar(40) NOT NULL default '' after module_name"); 408 } 409 if ($fieldOkay3 !== true) { 410 $db->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE zen_order_id order_id int(11) NOT NULL default '0'"); 411 } 412 } 413 414 function paynow_button($order_id) { 415 global $db, $order, $currencies, $currency; 416 require_once(DIR_WS_CLASSES . 'order.php'); 417 $order = new order($order_id); 418 $options = array(); 419 $optionsCore = array(); 420 $optionsPhone = array(); 421 $optionsShip = array(); 422 $optionsLineItems = array(); 423 $optionsAggregate = array(); 424 $optionsTrans = array(); 425 $buttonArray = array(); 426 427 $this->totalsum = $order->info['total']; 428 429 // save the session stuff permanently in case paypal loses the session 430 $_SESSION['ppipn_key_to_remove'] = session_id(); 431 $db->Execute("delete from " . TABLE_PAYPAL_SESSION . " where session_id = '" . zen_db_input($_SESSION['ppipn_key_to_remove']) . "'"); 432 433 $sql = "insert into " . TABLE_PAYPAL_SESSION . " (session_id, saved_session, expiry) values ( 434 '" . zen_db_input($_SESSION['ppipn_key_to_remove']) . "', 435 '" . base64_encode(serialize($_SESSION)) . "', 436 '" . (time() + (1*60*60*24*2)) . "')"; 437 438 $db->Execute($sql); 439 440 $my_currency = select_pp_currency(); 441 if(!empty($order->info['currency'])){ 442 $my_currency=$order->info['currency']; 443 } 444 $this->transaction_currency = $my_currency; 445 446 $this->transaction_amount = ($this->totalsum * $currencies->get_value($my_currency)); 447 448 $telephone = preg_replace('/\D/', '', $order->customer['telephone']); 449 if ($telephone != '') { 450 $optionsPhone['H_PhoneNumber'] = $telephone; 451 if (in_array($order->customer['country']['iso_code_2'], array('US','CA'))) { 452 $optionsPhone['night_phone_a'] = substr($telephone,0,3); 453 $optionsPhone['night_phone_b'] = substr($telephone,3,3); 454 $optionsPhone['night_phone_c'] = substr($telephone,6,4); 455 $optionsPhone['day_phone_a'] = substr($telephone,0,3); 456 $optionsPhone['day_phone_b'] = substr($telephone,3,3); 457 $optionsPhone['day_phone_c'] = substr($telephone,6,4); 458 } else { 459 $optionsPhone['night_phone_b'] = $telephone; 460 $optionsPhone['day_phone_b'] = $telephone; 461 } 462 } 463 464 $optionsCore = array( 465 'lc' => US, 466 //'lc' => $order->customer['country']['iso_code_2'], 467 'charset' => CHARSET, 468 'page_style' => MODULE_PAYMENT_PAYPAL_PAGE_STYLE, 469 'custom' => zen_session_name() . '=' . zen_session_id(), 470 'invoice' => $order->info['num'], 471 'business' => MODULE_PAYMENT_PAYPAL_BUSINESS_ID, 472 'return' => zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=paypal', 'SSL'), 473 'cancel_return' => zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 474 'shopping_url' => zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL'), 475 'notify_url' => zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true), 476 'redirect_cmd' => '_xclick','rm' => 2,'bn' => 'zencart','mrb' => 'R-6C7952342H795591R','pal' => '9E82WJBKKGPLQ', 477 ); 478 $optionsCust = array( 479 'first_name' => replace_accents($order->customer['firstname']), 480 'last_name' => replace_accents($order->customer['lastname']), 481 'address1' => replace_accents($order->customer['street_address']), 482 'city' => replace_accents($order->customer['city']), 483 'state' => zen_get_zone_code($order->customer['country']['id'], $order->customer['zone_id'], $order->customer['state']), 484 'zip' => $order->customer['postcode'], 485 'country' => $order->customer['country']['iso_code_2'], 486 'email' => $order->customer['email_address'], 487 ); 488 // address line 2 is optional 489 if ($order->customer['suburb'] != '') $optionsCust['address2'] = $order->customer['suburb']; 490 // different format for Japanese address layout: 491 if ($order->customer['country']['iso_code_2'] == 'JP') $optionsCust['zip'] = substr($order->customer['postcode'], 0, 3) . '-' . substr($order->customer['postcode'], 3); 492 if (MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED == 2) { 493 $optionsCust = array( 494 'first_name' => replace_accents($order->delivery['firstname'] != '' ? $order->delivery['firstname'] : $order->billing['firstname']), 495 'last_name' => replace_accents($order->delivery['lastname'] != '' ? $order->delivery['lastname'] : $order->billing['lastname']), 496 'address1' => replace_accents($order->delivery['street_address'] != '' ? $order->delivery['street_address'] : $order->billing['street_address']), 497 'city' => replace_accents($order->delivery['city'] != '' ? $order->delivery['city'] : $order->billing['city']), 498 'state' => ($order->delivery['country']['id'] != '' ? zen_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']) : zen_get_zone_code($order->billing['country']['id'], $order->billing['zone_id'], $order->billing['state'])), 499 'zip' => ($order->delivery['postcode'] != '' ? $order->delivery['postcode'] : $order->billing['postcode']), 500 'country' => ($order->delivery['country']['title'] != '' ? $order->delivery['country']['title'] : $order->billing['country']['title']), 501 'country_code' => ($order->delivery['country']['iso_code_2'] != '' ? $order->delivery['country']['iso_code_2'] : $order->billing['country']['iso_code_2']), 502 'email' => $order->customer['email_address'], 503 ); 504 if ($order->delivery['suburb'] != '') $optionsCust['address2'] = $order->delivery['suburb']; 505 if ($order->delivery['country']['iso_code_2'] == 'JP') $optionsCust['zip'] = substr($order->delivery['postcode'], 0, 3) . '-' . substr($order->delivery['postcode'], 3); 506 } 507 $optionsShip['no_shipping'] = MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED; 508 if (MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE == '1') $optionsShip['address_override'] = MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE; 509 // prepare cart contents details where possible 510 if (MODULE_PAYMENT_PAYPAL_DETAILED_CART == 'Yes') $optionsLineItems = ipn_getLineItemDetails(); 511 if (sizeof($optionsLineItems) > 0) { 512 $optionsLineItems['cmd'] = '_cart'; 513 // $optionsLineItems['num_cart_items'] = sizeof($order->products); 514 if (isset($optionsLineItems['shipping'])) { 515 $optionsLineItems['shipping_1'] = $optionsLineItems['shipping']; 516 unset($optionsLineItems['shipping']); 517 } 518 unset($optionsLineItems['subtotal']); 519 // if line-item details couldn't be kept due to calculation mismatches or discounts etc, default to aggregate mode 520 if (!isset($optionsLineItems['item_name_1']) || $optionsLineItems['creditsExist'] == TRUE) $optionsLineItems = array(); 521 //if ($optionsLineItems['amount'] != $this->transaction_amount) $optionsLineItems = array(); 522 // debug: 523 //ipn_debug_email('Line Item Details (if blank, this means there was a data mismatch or credits applied, and thus bypassed): ' . "\n" . print_r($optionsLineItems, true)); 524 unset($optionsLineItems['creditsExist']); 525 } 526 $optionsAggregate = array( 527 'cmd' => '_ext-enter', 528 'item_name' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_TITLE, 529 'item_number' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_ITEMNUM, 530 //'num_cart_items' => sizeof($order->products), 531 'amount' => number_format($this->transaction_amount, $currencies->get_decimal_places($my_currency)), 532 'shipping' => '0.00', 533 ); 534 if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') $optionsAggregate['tax'] = '0.00'; 535 if (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') $optionsAggregate['tax_cart'] = '0.00'; 536 $optionsTrans = array( 537 'upload' => (int)(sizeof($order->products) > 0), 538 'currency_code' => $my_currency, 539 //'paypal_order_id' => $paypal_order_id, 540 //'no_note' => '1', 541 //'invoice' => '', 542 ); 543 544 // if line-item info is invalid, use aggregate: 545 if (sizeof($optionsLineItems) > 0) $optionsAggregate = $optionsLineItems; 546 547 // prepare submission 548 $options = array_merge($optionsCore, $optionsCust, $optionsPhone, $optionsShip, $optionsTrans, $optionsAggregate); 549 //ipn_debug_email('Keys for submission: ' . print_r($options, true)); 550 551 // build the button fields 552 foreach ($options as $name => $value) { 553 // remove quotation marks 554 $value = str_replace('"', '', $value); 555 // check for invalid chars 556 if (preg_match('/[^a-zA-Z_0-9]/', $name)) { 557 ipn_debug_email('datacheck - ABORTING - preg_match found invalid submission key: ' . $name . ' (' . $value . ')'); 558 break; 559 } 560 // do we need special handling for & and = symbols? 561 //if (strpos($value, '&') !== false || strpos($value, '=') !== false) $value = urlencode($value); 562 563 $buttonArray[] = zen_draw_hidden_field($name, $value); 564 } 565 $process_button_string = implode("\n", $buttonArray) . "\n"; 566 567 $_SESSION['paypal_transaction_info'] = array($this->transaction_amount, $this->transaction_currency); 568 return $process_button_string; 569 } 570 571 } View Code
3. 在网站后台 Orders Status(地给你单状态)中,增加一项 Unpaid(未付款)选项。然后修改 Order.php 中 create 方法,指定如果生成订单的时候,客户选择的付款方式是 Paypal,那么此订单的状态将会是 Unpaid状态。代码如下:
<span> 1</span> <span>function</span> create(<span>$zf_ot_modules</span>, <span>$zf_mode</span> = 2<span>) { </span><span> 2</span> <span>global</span> <span>$db</span><span>; </span><span> 3</span> <span>$t1</span> = <span>date</span>("YmdGhs"<span>); </span><span> 4</span> <span>srand</span> ((<span>float</span>) <span>microtime</span>() * 10000000<span>); </span><span> 5</span> <span>$input</span> = <span>array</span> ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"<span>); </span><span> 6</span> <span>$rand_keys</span> = <span>array_rand</span> (<span>$input</span>, 2<span>); </span><span> 7</span> <span>$l1</span> = <span>$input</span>[<span>$rand_keys</span>[0<span>]]; </span><span> 8</span> <span>$l2</span> = <span>$input</span>[<span>$rand_keys</span>[1<span>]]; </span><span> 9</span> <span>$r1</span> = <span>rand</span>(0,9<span>); </span><span>10</span> <span>$ordernum</span> = <span>$t1</span>.<span>$l1</span>.<span>$l2</span>.<span>$r1</span><span>; </span><span>11</span> <span>12</span> <span>if</span> (<span>$this</span>->info['total'] == 0<span>) { </span><span>13</span> <span>if</span> (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0<span>) { </span><span>14</span>

핫 AI 도구

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

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

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

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

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PHP에서 Password_hash 및 Password_Verify 기능을 사용하여 보안 비밀번호 해싱을 구현해야하며 MD5 또는 SHA1을 사용해서는 안됩니다. 1) Password_hash는 보안을 향상시키기 위해 소금 값이 포함 된 해시를 생성합니다. 2) Password_verify 암호를 확인하고 해시 값을 비교하여 보안을 보장합니다. 3) MD5 및 SHA1은 취약하고 소금 값이 부족하며 현대 암호 보안에는 적합하지 않습니다.

PHP 유형은 코드 품질과 가독성을 향상시키기위한 프롬프트입니다. 1) 스칼라 유형 팁 : PHP7.0이므로 int, float 등과 같은 기능 매개 변수에 기본 데이터 유형을 지정할 수 있습니다. 2) 반환 유형 프롬프트 : 기능 반환 값 유형의 일관성을 확인하십시오. 3) Union 유형 프롬프트 : PHP8.0이므로 기능 매개 변수 또는 반환 값에 여러 유형을 지정할 수 있습니다. 4) Nullable 유형 프롬프트 : NULL 값을 포함하고 널 값을 반환 할 수있는 기능을 포함 할 수 있습니다.

PHP는 주로 절차 적 프로그래밍이지만 객체 지향 프로그래밍 (OOP)도 지원합니다. Python은 OOP, 기능 및 절차 프로그래밍을 포함한 다양한 패러다임을 지원합니다. PHP는 웹 개발에 적합하며 Python은 데이터 분석 및 기계 학습과 같은 다양한 응용 프로그램에 적합합니다.

PHP와 Python은 고유 한 장점과 단점이 있으며 선택은 프로젝트 요구와 개인 선호도에 달려 있습니다. 1.PHP는 대규모 웹 애플리케이션의 빠른 개발 및 유지 보수에 적합합니다. 2. Python은 데이터 과학 및 기계 학습 분야를 지배합니다.

PHP에서 전처리 문과 PDO를 사용하면 SQL 주입 공격을 효과적으로 방지 할 수 있습니다. 1) PDO를 사용하여 데이터베이스에 연결하고 오류 모드를 설정하십시오. 2) 준비 방법을 통해 전처리 명세서를 작성하고 자리 표시자를 사용하여 데이터를 전달하고 방법을 실행하십시오. 3) 쿼리 결과를 처리하고 코드의 보안 및 성능을 보장합니다.

PHP는 MySQLI 및 PDO 확장 기능을 사용하여 데이터베이스 작업 및 서버 측 로직 프로세싱에서 상호 작용하고 세션 관리와 같은 기능을 통해 서버 측로 로직을 처리합니다. 1) MySQLI 또는 PDO를 사용하여 데이터베이스에 연결하고 SQL 쿼리를 실행하십시오. 2) 세션 관리 및 기타 기능을 통해 HTTP 요청 및 사용자 상태를 처리합니다. 3) 트랜잭션을 사용하여 데이터베이스 작업의 원자력을 보장하십시오. 4) SQL 주입 방지, 디버깅을 위해 예외 처리 및 폐쇄 연결을 사용하십시오. 5) 인덱싱 및 캐시를 통해 성능을 최적화하고, 읽을 수있는 코드를 작성하고, 오류 처리를 수행하십시오.

PHP는 동적 웹 사이트를 구축하는 데 사용되며 해당 핵심 기능에는 다음이 포함됩니다. 1. 데이터베이스와 연결하여 동적 컨텐츠를 생성하고 웹 페이지를 실시간으로 생성합니다. 2. 사용자 상호 작용 및 양식 제출을 처리하고 입력을 확인하고 작업에 응답합니다. 3. 개인화 된 경험을 제공하기 위해 세션 및 사용자 인증을 관리합니다. 4. 성능을 최적화하고 모범 사례를 따라 웹 사이트 효율성 및 보안을 개선하십시오.

PHP는 웹 개발 및 빠른 프로토 타이핑에 적합하며 Python은 데이터 과학 및 기계 학습에 적합합니다. 1.PHP는 간단한 구문과 함께 동적 웹 개발에 사용되며 빠른 개발에 적합합니다. 2. Python은 간결한 구문을 가지고 있으며 여러 분야에 적합하며 강력한 라이브러리 생태계가 있습니다.
