찾다
백엔드 개발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 帐号交易信息看到客户购买了哪些物品。

 

二. 使用 Paypal Sessions Viewer 插件找回 Paypal 漏掉的订单。

原理:zencart 购物车的物品,通过 paypal 方式付款,会在 paypal_session 表中保存此次付款的所有记录,如果付款成功后,从 paypal 网站跳转到购物网站并生成了订单时,zencart系统会自动删除这条 paypal_session 记录,如果没有成功跳转到购物网站,没有成功生成订单,那这条付款记录数据就会一直保存在数据库,当使用 Paypal Session Viewer 插件,就能查看这条记录的所有数据,包括客户信息,购物时间,商品信息,如果你确定已收到款,就可以把这条 paypal_session 信息转移到订单中,生成一个订单。

插件下载地址:http://www.zen-cart.cn/english-version-modules/admin-tools/paypal-sessions-viewer

 

三. 修改付款流程,先生成订单后付款。

原理:用过zen-cart的人都知道,zen-cart中下单步骤是下面这样的(其中[]中的表示不是必须的):

1. 购物车(shopping cart)

2. [货运方式(delivery method)]

3. 支付方式(payment method)

4. 订单确认(confirmation)

5. [第三方网站支付]

6. 订单处理(checkout process)——这一步比较重要,因为会在这里将购物车中的信息写入订单

7. 下单成功(checkout success)

这样的流程在正常情况下是没有任何问题的。但是,从第5步到第6部的过程中,用户可能以为付款成功就直接关闭掉网页了,或者由于网络原因造成不能正常跳转到checkout_process页面,这样造成的后果是很严重的,因为订单不能被正常的创建。基于上述的分析, 我们希望稍微地改变一下流程,即在支付之前订单已经创建好了,这样就算在支付时不能从第三方支付网站跳转回来,我们也不会存在用户付款成功却在后台没有订单的情况了。

本人是参照东国先生的这篇 修改zen-cart下单和付款流程以防止漏单 教程去修改的,因为这个教程比较老,而且也没有很全面,所以我根据自己的实际需求,把他做的更完善,更细节化。

经过修改后的蓝图基本是下面这样的:

1. 在checkour_confirmation页面确认订单后,都会直接proccess,并且进入 account_history_info 页面,可以在这里进入付款页面。如下图所示:

2. 如果当时客户没能付款,也可进入自己的后台对历史订单进行付款。如下图所示:

 

3. 未付款的订单,可以在后台修改价格,像淘宝一样拍下宝贝后,店主给你修改价格后再付款一样。如下图所示:

下面我们来正式修改代码,首先我列举出所有要修改的文件:

1. includes/classes/payment.php

2. includes/modules/payment/paypal.php

3. includes/classes/order.php

4. includes/modules/pages/checkout_process/header_php.php

5. includes/modules/pages/account_history_info/header_php.php

6. includes/templates/你的模板目录/templates/tpl_account_history_info_default.php

7. includes/templates/你的模板目录/templates/tpl_account_history_default.php

8. ipn_main_handler.php

9. admin(后台目录)/orders.php

因为先生成订单再付款,付款步骤就会比原来又多了一步,为了简化付款流程,我安装了 Fast And Easy Checkout For Zencart(快速支付) 插件,安装此插件之前,需要安装另外一个插件 Css Js Loader For Zencart,这是快速支付插件的依赖插件。快速支付与先生成订单后支付没什么因果关系,所以如果你不想安装的话完全可以不理。

按步骤修改上面列举的文件:

1. 首先我们需要对现有的支付模块进行一个改造。需要对支付方式的class增加一个字段paynow_action_url,用来表示进行支付的页面 url,另外还需要增加一个函数,paynow_button($order_id),来获取支付表单的参数隐藏域代码。

要增加 paynow_action_url 变量,请在类payment的构造函数中最后加上下面的代码:    

<span style="color: #0000ff;">if</span> ( (zen_not_null(<span style="color: #800080;">$module</span>)) && (<span style="color: #008080;">in_array</span>(<span style="color: #800080;">$module</span>.'.php', <span style="color: #800080;">$this</span>->modules)) && (<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$GLOBALS</span>[<span style="color: #800080;">$module</span>]-><span style="color: #000000;">paynow_action_url)) ) {        </span><span style="color: #800080;">$this</span>->paynow_action_url = <span style="color: #800080;">$GLOBALS</span>[<span style="color: #800080;">$module</span>]-><span style="color: #000000;">paynow_action_url;        }</span>

 

要增加paynow_button($order_id)函数,请在payment类的最后一个函数之后加上如下的代码:

<span style="color: #0000ff;">function</span> paynow_button(<span style="color: #800080;">$order_id</span><span style="color: #000000;">){    </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">is_array</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">modules)) {      </span><span style="color: #0000ff;">if</span> (<span style="color: #008080;">is_object</span>(<span style="color: #800080;">$GLOBALS</span>[<span style="color: #800080;">$this</span>-><span style="color: #000000;">selected_module])) {        </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$GLOBALS</span>[<span style="color: #800080;">$this</span>->selected_module]->paynow_button(<span style="color: #800080;">$order_id</span><span style="color: #000000;">);      }    }}</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修改后的文件如下:

<span style="color: #008080;">  1</span> <span style="color: #000000;">php</span><span style="color: #008080;">  2</span> <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">  3</span> <span style="color: #008000;"> * paypal.php payment module class for PayPal Website Payments Standard (IPN) method</span><span style="color: #008080;">  4</span> <span style="color: #008000;"> *</span><span style="color: #008080;">  5</span> <span style="color: #008000;"> * @package paymentMethod</span><span style="color: #008080;">  6</span> <span style="color: #008000;"> * @copyright Copyright 2003-2010 Zen Cart Development Team</span><span style="color: #008080;">  7</span> <span style="color: #008000;"> * @copyright Portions Copyright 2003 osCommerce</span><span style="color: #008080;">  8</span> <span style="color: #008000;"> * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0</span><span style="color: #008080;">  9</span> <span style="color: #008000;"> * @version $Id: paypal.php 15735 2010-03-29 07:13:53Z drbyte $</span><span style="color: #008080;"> 10</span>  <span style="color: #008000;">*/</span><span style="color: #008080;"> 11</span> <span style="color: #008080;"> 12</span> <span style="color: #008080;">define</span>('MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE', 'true'<span style="color: #000000;">);</span><span style="color: #008080;"> 13</span> <span style="color: #008080;"> 14</span> <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 15</span> <span style="color: #008000;"> *  ensure dependencies are loaded</span><span style="color: #008080;"> 16</span>  <span style="color: #008000;">*/</span><span style="color: #008080;"> 17</span>   <span style="color: #0000ff;">include_once</span>((IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span> ? DIR_FS_CATALOG_MODULES : DIR_WS_MODULES) . 'payment/paypal/paypal_functions.php'<span style="color: #000000;">);</span><span style="color: #008080;"> 18</span> <span style="color: #008080;"> 19</span> <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 20</span> <span style="color: #008000;"> * paypal.php payment module class for PayPal Website Payments Standard (IPN) method</span><span style="color: #008080;"> 21</span> <span style="color: #008000;"> *</span><span style="color: #008080;"> 22</span>  <span style="color: #008000;">*/</span><span style="color: #008080;"> 23</span> <span style="color: #0000ff;">class</span> paypal <span style="color: #0000ff;">extends</span><span style="color: #000000;"> base {</span><span style="color: #008080;"> 24</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 25</span> <span style="color: #008000;">   * string representing the payment method</span><span style="color: #008080;"> 26</span> <span style="color: #008000;">   *</span><span style="color: #008080;"> 27</span> <span style="color: #008000;">   * @var string</span><span style="color: #008080;"> 28</span>    <span style="color: #008000;">*/</span><span style="color: #008080;"> 29</span>   <span style="color: #0000ff;">var</span> <span style="color: #800080;">$code</span><span style="color: #000000;">;</span><span style="color: #008080;"> 30</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 31</span> <span style="color: #008000;">   * $title is the displayed name for this payment method</span><span style="color: #008080;"> 32</span> <span style="color: #008000;">   *</span><span style="color: #008080;"> 33</span> <span style="color: #008000;">   * @var string</span><span style="color: #008080;"> 34</span>     <span style="color: #008000;">*/</span><span style="color: #008080;"> 35</span>   <span style="color: #0000ff;">var</span> <span style="color: #800080;">$title</span><span style="color: #000000;">;</span><span style="color: #008080;"> 36</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 37</span> <span style="color: #008000;">   * $description is a soft name for this payment method</span><span style="color: #008080;"> 38</span> <span style="color: #008000;">   *</span><span style="color: #008080;"> 39</span> <span style="color: #008000;">   * @var string</span><span style="color: #008080;"> 40</span>     <span style="color: #008000;">*/</span><span style="color: #008080;"> 41</span>   <span style="color: #0000ff;">var</span> <span style="color: #800080;">$description</span><span style="color: #000000;">;</span><span style="color: #008080;"> 42</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 43</span> <span style="color: #008000;">   * $enabled determines whether this module shows or not... in catalog.</span><span style="color: #008080;"> 44</span> <span style="color: #008000;">   *</span><span style="color: #008080;"> 45</span> <span style="color: #008000;">   * @var boolean</span><span style="color: #008080;"> 46</span>     <span style="color: #008000;">*/</span><span style="color: #008080;"> 47</span>   <span style="color: #0000ff;">var</span> <span style="color: #800080;">$enabled</span><span style="color: #000000;">;</span><span style="color: #008080;"> 48</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 49</span> <span style="color: #008000;">    * constructor</span><span style="color: #008080;"> 50</span> <span style="color: #008000;">    *</span><span style="color: #008080;"> 51</span> <span style="color: #008000;">    * @param int $paypal_ipn_id</span><span style="color: #008080;"> 52</span> <span style="color: #008000;">    * @return paypal</span><span style="color: #008080;"> 53</span>     <span style="color: #008000;">*/</span><span style="color: #008080;"> 54</span>   <span style="color: #0000ff;">function</span> paypal(<span style="color: #800080;">$paypal_ipn_id</span> = ''<span style="color: #000000;">) {</span><span style="color: #008080;"> 55</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$order</span>, <span style="color: #800080;">$messageStack</span><span style="color: #000000;">;</span><span style="color: #008080;"> 56</span>     <span style="color: #800080;">$this</span>->code = 'paypal'<span style="color: #000000;">;</span><span style="color: #008080;"> 57</span>     <span style="color: #800080;">$this</span>->codeVersion = '1.3.9'<span style="color: #000000;">;</span><span style="color: #008080;"> 58</span>     <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span><span style="color: #000000;">) {</span><span style="color: #008080;"> 59</span>       <span style="color: #800080;">$this</span>->title = MODULE_PAYMENT_PAYPAL_TEXT_ADMIN_TITLE; <span style="color: #008000;">//</span><span style="color: #008000;"> Payment Module title in Admin</span><span style="color: #008080;"> 60</span>       <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span> && <span style="color: #008080;">defined</span>('MODULE_PAYMENT_PAYPAL_IPN_DEBUG') && MODULE_PAYMENT_PAYPAL_IPN_DEBUG != 'Off') <span style="color: #800080;">$this</span>->title .= '<span class="alert"> (debug mode active)</span>'<span style="color: #000000;">;</span><span style="color: #008080;"> 61</span>       <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span> && MODULE_PAYMENT_PAYPAL_TESTING == 'Test') <span style="color: #800080;">$this</span>->title .= '<span class="alert"> (dev/test mode active)</span>'<span style="color: #000000;">;</span><span style="color: #008080;"> 62</span>     } <span style="color: #0000ff;">else</span><span style="color: #000000;"> {</span><span style="color: #008080;"> 63</span>       <span style="color: #800080;">$this</span>->title = MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_TITLE; <span style="color: #008000;">//</span><span style="color: #008000;"> Payment Module title in Catalog</span><span style="color: #008080;"> 64</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 65</span>     <span style="color: #800080;">$this</span>->description =<span style="color: #000000;"> MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;</span><span style="color: #008080;"> 66</span>     <span style="color: #800080;">$this</span>->sort_order =<span style="color: #000000;"> MODULE_PAYMENT_PAYPAL_SORT_ORDER;</span><span style="color: #008080;"> 67</span>     <span style="color: #800080;">$this</span>->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? <span style="color: #0000ff;">true</span> : <span style="color: #0000ff;">false</span><span style="color: #000000;">);</span><span style="color: #008080;"> 68</span>     <span style="color: #0000ff;">if</span> ((int)MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID > 0<span style="color: #000000;">) {</span><span style="color: #008080;"> 69</span>       <span style="color: #800080;">$this</span>->order_status =<span style="color: #000000;"> MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID;</span><span style="color: #008080;"> 70</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 71</span>     <span style="color: #0000ff;">if</span> (<span style="color: #008080;">is_object</span>(<span style="color: #800080;">$order</span>)) <span style="color: #800080;">$this</span>-><span style="color: #000000;">update_status();</span><span style="color: #008080;"> 72</span>     <span style="color: #800080;">$this</span>->paynow_action_url = 'https://' .<span style="color: #000000;"> MODULE_PAYMENT_PAYPAL_HANDLER;</span><span style="color: #008080;"> 73</span> <span style="color: #008080;"> 74</span>     <span style="color: #0000ff;">if</span> (PROJECT_VERSION_MAJOR != '1' && <span style="color: #008080;">substr</span>(PROJECT_VERSION_MINOR, 0, 3) != '3.9') <span style="color: #800080;">$this</span>->enabled = <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;"> 75</span> <span style="color: #008080;"> 76</span>     <span style="color: #008000;">//</span><span style="color: #008000;"> verify table structure</span><span style="color: #008080;"> 77</span>     <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span>) <span style="color: #800080;">$this</span>-><span style="color: #000000;">tableCheckup();</span><span style="color: #008080;"> 78</span> <span style="color: #000000;">  }</span><span style="color: #008080;"> 79</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;"> 80</span> <span style="color: #008000;">   * calculate zone matches and flag settings to determine whether this module should display to customers or not</span><span style="color: #008080;"> 81</span> <span style="color: #008000;">    *</span><span style="color: #008080;"> 82</span>     <span style="color: #008000;">*/</span><span style="color: #008080;"> 83</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> update_status() {</span><span style="color: #008080;"> 84</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$order</span>, <span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;"> 85</span> <span style="color: #008080;"> 86</span>     <span style="color: #0000ff;">if</span> ( (<span style="color: #800080;">$this</span>->enabled == <span style="color: #0000ff;">true</span>) && ((int)MODULE_PAYMENT_PAYPAL_ZONE > 0<span style="color: #000000;">) ) {</span><span style="color: #008080;"> 87</span>       <span style="color: #800080;">$check_flag</span> = <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;"> 88</span>       <span style="color: #800080;">$check_query</span> = <span style="color: #800080;">$db</span>->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_ZONE . "' and zone_country_id = '" . <span style="color: #800080;">$order</span>->billing['country']['id'] . "' order by zone_id"<span style="color: #000000;">);</span><span style="color: #008080;"> 89</span>       <span style="color: #0000ff;">while</span> (!<span style="color: #800080;">$check_query</span>-><span style="color: #000000;">EOF) {</span><span style="color: #008080;"> 90</span>         <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$check_query</span>->fields['zone_id'] ) {<span style="color: #008080;"> 91</span>           <span style="color: #800080;">$check_flag</span> = <span style="color: #0000ff;">true</span><span style="color: #000000;">;</span><span style="color: #008080;"> 92</span>           <span style="color: #0000ff;">break</span><span style="color: #000000;">;</span><span style="color: #008080;"> 93</span>         } <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$check_query</span>->fields['zone_id'] == <span style="color: #800080;">$order</span>->billing['zone_id'<span style="color: #000000;">]) {</span><span style="color: #008080;"> 94</span>           <span style="color: #800080;">$check_flag</span> = <span style="color: #0000ff;">true</span><span style="color: #000000;">;</span><span style="color: #008080;"> 95</span>           <span style="color: #0000ff;">break</span><span style="color: #000000;">;</span><span style="color: #008080;"> 96</span> <span style="color: #000000;">        }</span><span style="color: #008080;"> 97</span>         <span style="color: #800080;">$check_query</span>-><span style="color: #000000;">MoveNext();</span><span style="color: #008080;"> 98</span> <span style="color: #000000;">      }</span><span style="color: #008080;"> 99</span> <span style="color: #008080;">100</span>       <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$check_flag</span> == <span style="color: #0000ff;">false</span><span style="color: #000000;">) {</span><span style="color: #008080;">101</span>         <span style="color: #800080;">$this</span>->enabled = <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">102</span> <span style="color: #000000;">      }</span><span style="color: #008080;">103</span> <span style="color: #000000;">    }</span><span style="color: #008080;">104</span> <span style="color: #000000;">  }</span><span style="color: #008080;">105</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">106</span> <span style="color: #008000;">   * JS validation which does error-checking of data-entry if this module is selected for use</span><span style="color: #008080;">107</span> <span style="color: #008000;">   * (Number, Owner, and CVV Lengths)</span><span style="color: #008080;">108</span> <span style="color: #008000;">   *</span><span style="color: #008080;">109</span> <span style="color: #008000;">   * @return string</span><span style="color: #008080;">110</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">111</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> javascript_validation() {</span><span style="color: #008080;">112</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">113</span> <span style="color: #000000;">  }</span><span style="color: #008080;">114</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">115</span> <span style="color: #008000;">   * Displays payment method name along with Credit Card Information Submission Fields (if any) on the Checkout Payment Page</span><span style="color: #008080;">116</span> <span style="color: #008000;">   *</span><span style="color: #008080;">117</span> <span style="color: #008000;">   * @return array</span><span style="color: #008080;">118</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">119</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> selection() {</span><span style="color: #008080;">120</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">array</span>('id' => <span style="color: #800080;">$this</span>->code,<span style="color: #008080;">121</span>                  'module' => MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_LOGO,<span style="color: #008080;">122</span>                  'icon' =><span style="color: #000000;"> MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_LOGO</span><span style="color: #008080;">123</span> <span style="color: #000000;">                 );</span><span style="color: #008080;">124</span> <span style="color: #000000;">  }</span><span style="color: #008080;">125</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">126</span> <span style="color: #008000;">   * Normally evaluates the Credit Card Type for acceptance and the validity of the Credit Card Number & Expiration Date</span><span style="color: #008080;">127</span> <span style="color: #008000;">   * Since paypal module is not collecting info, it simply skips this step.</span><span style="color: #008080;">128</span> <span style="color: #008000;">   *</span><span style="color: #008080;">129</span> <span style="color: #008000;">   * @return boolean</span><span style="color: #008080;">130</span>    <span style="color: #008000;">*/</span><span style="color: #008080;">131</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> pre_confirmation_check() {</span><span style="color: #008080;">132</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">133</span> <span style="color: #000000;">  }</span><span style="color: #008080;">134</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">135</span> <span style="color: #008000;">   * Display Credit Card Information on the Checkout Confirmation Page</span><span style="color: #008080;">136</span> <span style="color: #008000;">   * Since none is collected for paypal before forwarding to paypal site, this is skipped</span><span style="color: #008080;">137</span> <span style="color: #008000;">   *</span><span style="color: #008080;">138</span> <span style="color: #008000;">   * @return boolean</span><span style="color: #008080;">139</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">140</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> confirmation() {</span><span style="color: #008080;">141</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">142</span> <span style="color: #000000;">  }</span><span style="color: #008080;">143</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">144</span> <span style="color: #008000;">   * Build the data and actions to process when the "Submit" button is pressed on the order-confirmation screen.</span><span style="color: #008080;">145</span> <span style="color: #008000;">   * This sends the data to the payment gateway for processing.</span><span style="color: #008080;">146</span> <span style="color: #008000;">   * (These are hidden fields on the checkout confirmation page)</span><span style="color: #008080;">147</span> <span style="color: #008000;">   *</span><span style="color: #008080;">148</span> <span style="color: #008000;">   * @return string</span><span style="color: #008080;">149</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">150</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> process_button() {</span><span style="color: #008080;">151</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">152</span> <span style="color: #000000;">  }</span><span style="color: #008080;">153</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">154</span> <span style="color: #008000;">   * Determine the language to use when visiting the PayPal site</span><span style="color: #008080;">155</span>    <span style="color: #008000;">*/</span><span style="color: #008080;">156</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> getLanguageCode() {</span><span style="color: #008080;">157</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$order</span><span style="color: #000000;">;</span><span style="color: #008080;">158</span>     <span style="color: #800080;">$lang_code</span> = ''<span style="color: #000000;">;</span><span style="color: #008080;">159</span>     <span style="color: #800080;">$orderISO</span> = zen_get_countries(<span style="color: #800080;">$order</span>->customer['country']['id'], <span style="color: #0000ff;">true</span><span style="color: #000000;">);</span><span style="color: #008080;">160</span>     <span style="color: #800080;">$storeISO</span> = zen_get_countries(STORE_COUNTRY, <span style="color: #0000ff;">true</span><span style="color: #000000;">);</span><span style="color: #008080;">161</span>     <span style="color: #0000ff;">if</span> (<span style="color: #008080;">in_array</span>(<span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$orderISO</span>['countries_iso_code_2']), <span style="color: #0000ff;">array</span>('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'<span style="color: #000000;">))) {</span><span style="color: #008080;">162</span>       <span style="color: #800080;">$lang_code</span> = <span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$orderISO</span>['countries_iso_code_2'<span style="color: #000000;">]);</span><span style="color: #008080;">163</span>     } <span style="color: #0000ff;">elseif</span> (<span style="color: #008080;">in_array</span>(<span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$storeISO</span>['countries_iso_code_2']), <span style="color: #0000ff;">array</span>('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'<span style="color: #000000;">))) {</span><span style="color: #008080;">164</span>       <span style="color: #800080;">$lang_code</span> = <span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$storeISO</span>['countries_iso_code_2'<span style="color: #000000;">]);</span><span style="color: #008080;">165</span>     } <span style="color: #0000ff;">elseif</span> (<span style="color: #008080;">in_array</span>(<span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$_SESSION</span>['languages_code']), <span style="color: #0000ff;">array</span>('EN', 'US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'<span style="color: #000000;">))) {</span><span style="color: #008080;">166</span>       <span style="color: #800080;">$lang_code</span> = <span style="color: #800080;">$_SESSION</span>['languages_code'<span style="color: #000000;">];</span><span style="color: #008080;">167</span>       <span style="color: #0000ff;">if</span> (<span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$lang_code</span>) == 'EN') <span style="color: #800080;">$lang_code</span> = 'US'<span style="color: #000000;">;</span><span style="color: #008080;">168</span> <span style="color: #000000;">    }</span><span style="color: #008080;">169</span>     <span style="color: #008000;">//</span><span style="color: #008000;">return $orderISO['countries_iso_code_2'];</span><span style="color: #008080;">170</span>     <span style="color: #0000ff;">return</span> <span style="color: #008080;">strtoupper</span>(<span style="color: #800080;">$lang_code</span><span style="color: #000000;">);</span><span style="color: #008080;">171</span> <span style="color: #000000;">  }</span><span style="color: #008080;">172</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">173</span> <span style="color: #008000;">   * Store transaction info to the order and process any results that come back from the payment gateway</span><span style="color: #008080;">174</span>    <span style="color: #008000;">*/</span><span style="color: #008080;">175</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> before_process() {</span><span style="color: #008080;">176</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">177</span> <span style="color: #000000;">  }</span><span style="color: #008080;">178</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">179</span> <span style="color: #008000;">    * Checks referrer</span><span style="color: #008080;">180</span> <span style="color: #008000;">    *</span><span style="color: #008080;">181</span> <span style="color: #008000;">    * @param string $zf_domain</span><span style="color: #008080;">182</span> <span style="color: #008000;">    * @return boolean</span><span style="color: #008080;">183</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">184</span>   <span style="color: #0000ff;">function</span> check_referrer(<span style="color: #800080;">$zf_domain</span><span style="color: #000000;">) {</span><span style="color: #008080;">185</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #000000;">;</span><span style="color: #008080;">186</span> <span style="color: #000000;">  }</span><span style="color: #008080;">187</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">188</span> <span style="color: #008000;">    * Build admin-page components</span><span style="color: #008080;">189</span> <span style="color: #008000;">    *</span><span style="color: #008080;">190</span> <span style="color: #008000;">    * @param int $zf_order_id</span><span style="color: #008080;">191</span> <span style="color: #008000;">    * @return string</span><span style="color: #008080;">192</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">193</span>   <span style="color: #0000ff;">function</span> admin_notification(<span style="color: #800080;">$zf_order_id</span><span style="color: #000000;">) {</span><span style="color: #008080;">194</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;">195</span>     <span style="color: #800080;">$output</span> = ''<span style="color: #000000;">;</span><span style="color: #008080;">196</span>     <span style="color: #800080;">$sql</span> = "select * from " . TABLE_PAYPAL . " where order_id = '" . (int)<span style="color: #800080;">$zf_order_id</span> . "' order by paypal_ipn_id DESC LIMIT 1"<span style="color: #000000;">;</span><span style="color: #008080;">197</span>     <span style="color: #800080;">$ipn</span> = <span style="color: #800080;">$db</span>->Execute(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">198</span>     <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$ipn</span>->RecordCount() > 0 && <span style="color: #008080;">file_exists</span>(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/paypal_admin_notification.php')) <span style="color: #0000ff;">require</span>(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/paypal_admin_notification.php'<span style="color: #000000;">);</span><span style="color: #008080;">199</span>     <span style="color: #0000ff;">return</span> <span style="color: #800080;">$output</span><span style="color: #000000;">;</span><span style="color: #008080;">200</span> <span style="color: #000000;">  }</span><span style="color: #008080;">201</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">202</span> <span style="color: #008000;">   * Post-processing activities</span><span style="color: #008080;">203</span> <span style="color: #008000;">   * When the order returns from the processor, if PDT was successful, this stores the results in order-status-history and logs data for subsequent reference</span><span style="color: #008080;">204</span> <span style="color: #008000;">   *</span><span style="color: #008080;">205</span> <span style="color: #008000;">   * @return boolean</span><span style="color: #008080;">206</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">207</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> after_process() {</span><span style="color: #008080;">208</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">209</span> <span style="color: #000000;">  }</span><span style="color: #008080;">210</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">211</span> <span style="color: #008000;">   * Used to display error message details</span><span style="color: #008080;">212</span> <span style="color: #008000;">   *</span><span style="color: #008080;">213</span> <span style="color: #008000;">   * @return boolean</span><span style="color: #008080;">214</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">215</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> output_error() {</span><span style="color: #008080;">216</span>     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;</span><span style="color: #008080;">217</span> <span style="color: #000000;">  }</span><span style="color: #008080;">218</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">219</span> <span style="color: #008000;">   * Check to see whether module is installed</span><span style="color: #008080;">220</span> <span style="color: #008000;">   *</span><span style="color: #008080;">221</span> <span style="color: #008000;">   * @return boolean</span><span style="color: #008080;">222</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">223</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> check() {</span><span style="color: #008080;">224</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;">225</span>     <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span><span style="color: #000000;">) {</span><span style="color: #008080;">226</span>       <span style="color: #0000ff;">global</span> <span style="color: #800080;">$sniffer</span><span style="color: #000000;">;</span><span style="color: #008080;">227</span>       <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$sniffer</span>->field_exists(TABLE_PAYPAL, 'zen_order_id'))  <span style="color: #800080;">$db</span>->Execute("ALTER TABLE " . TABLE_PAYPAL . " CHANGE COLUMN zen_order_id order_id int(11) NOT NULL default '0'"<span style="color: #000000;">);</span><span style="color: #008080;">228</span> <span style="color: #000000;">    }</span><span style="color: #008080;">229</span>     <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$this</span>-><span style="color: #000000;">_check)) {</span><span style="color: #008080;">230</span>       <span style="color: #800080;">$check_query</span> = <span style="color: #800080;">$db</span>->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'"<span style="color: #000000;">);</span><span style="color: #008080;">231</span>       <span style="color: #800080;">$this</span>->_check = <span style="color: #800080;">$check_query</span>-><span style="color: #000000;">RecordCount();</span><span style="color: #008080;">232</span> <span style="color: #000000;">    }</span><span style="color: #008080;">233</span>     <span style="color: #0000ff;">return</span> <span style="color: #800080;">$this</span>-><span style="color: #000000;">_check;</span><span style="color: #008080;">234</span> <span style="color: #000000;">  }</span><span style="color: #008080;">235</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">236</span> <span style="color: #008000;">   * Install the payment module and its configuration settings</span><span style="color: #008080;">237</span> <span style="color: #008000;">    *</span><span style="color: #008080;">238</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">239</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> install() {</span><span style="color: #008080;">240</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span>, <span style="color: #800080;">$messageStack</span><span style="color: #000000;">;</span><span style="color: #008080;">241</span>     <span style="color: #0000ff;">if</span> (<span style="color: #008080;">defined</span>('MODULE_PAYMENT_PAYPAL_STATUS'<span style="color: #000000;">)) {</span><span style="color: #008080;">242</span>       <span style="color: #800080;">$messageStack</span>->add_session('PayPal Website Payments Standard module already installed.', 'error'<span style="color: #000000;">);</span><span style="color: #008080;">243</span>       zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=paypal', 'NONSSL'<span style="color: #000000;">));</span><span style="color: #008080;">244</span>       <span style="color: #0000ff;">return</span> 'failed'<span style="color: #000000;">;</span><span style="color: #008080;">245</span> <span style="color: #000000;">    }</span><span style="color: #008080;">246</span>     <span style="color: #0000ff;">if</span> (<span style="color: #008080;">defined</span>('MODULE_PAYMENT_PAYPALWPP_STATUS'<span style="color: #000000;">)) {</span><span style="color: #008080;">247</span>       <span style="color: #800080;">$messageStack</span>->add_session('NOTE: PayPal Express Checkout module already installed. You don\'t need Standard if you have Express installed.', 'error'<span style="color: #000000;">);</span><span style="color: #008080;">248</span>       zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=paypalwpp', 'NONSSL'<span style="color: #000000;">));</span><span style="color: #008080;">249</span>       <span style="color: #0000ff;">return</span> 'failed'<span style="color: #000000;">;</span><span style="color: #008080;">250</span> <span style="color: #000000;">    }</span><span style="color: #008080;">251</span>     <span style="color: #800080;">$db</span>->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable PayPal Module', 'MODULE_PAYMENT_PAYPAL_STATUS', 'True', 'Do you want to accept PayPal payments?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"<span style="color: #000000;">);</span><span style="color: #008080;">252</span>     <span style="color: #800080;">$db</span>->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Business ID', 'MODULE_PAYMENT_PAYPAL_BUSINESS_ID','".STORE_OWNER_EMAIL_ADDRESS."', 'Primary email address for your PayPal account.<br>NOTE: This must match <strong>EXACTLY </strong>the primary email address on your PayPal account settings.  It <strong>IS case-sensitive</strong>, 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())"<span style="color: #000000;">);</span><span style="color: #008080;">253</span>     <span style="color: #800080;">$db</span>->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? <br>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())"<span style="color: #000000;">);</span><span style="color: #008080;">254</span>     <span style="color: #800080;">$db</span>->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())"<span style="color: #000000;">);</span><span style="color: #008080;">255</span>     <span style="color: #800080;">$db</span>->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<br>(\'Pending\' recommended)', '6', '5', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"<span style="color: #000000;">);</span><span style="color: #008080;">256</span>     <span style="color: #800080;">$db</span>->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<br>(\'Processing\' recommended)', '6', '6', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"<span style="color: #000000;">);</span><span style="color: #008080;">257</span>     <span style="color: #800080;">$db</span>->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<br>(\'Pending\' recommended)', '6', '7', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"<span style="color: #000000;">);</span><span style="color: #008080;">258</span>     <span style="color: #800080;">$db</span>->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())"<span style="color: #000000;">);</span><span style="color: #008080;">259</span>     <span style="color: #800080;">$db</span>->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.<br>(An invalid address will be treated by PayPal as not-supplied, or override=0)<br>0=No Override<br>1=ZC address overrides PayPal address choices', '6', '18', 'zen_cfg_select_option(array(\'0\',\'1\'), ', now())"<span style="color: #000000;">);</span><span style="color: #008080;">260</span>     <span style="color: #800080;">$db</span>->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.<br>0=Prompt<br>1=Not Asked<br>2=Required<br><br><strong>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.</strong>', '6', '20', 'zen_cfg_select_option(array(\'0\',\'1\',\'2\'), ', now())"<span style="color: #000000;">);</span><span style="color: #008080;">261</span>     <span style="color: #800080;">$db</span>->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())"<span style="color: #000000;">);</span><span style="color: #008080;">262</span>     <span style="color: #800080;">$db</span>->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())"<span style="color: #000000;">);</span><span style="color: #008080;">263</span>     <span style="color: #800080;">$db</span>->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<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>', 'MODULE_PAYMENT_PAYPAL_HANDLER', 'www.paypal.com/cgi-bin/webscr', 'Choose the URL for PayPal live processing', '6', '73', '', now())"<span style="color: #000000;">);</span><span style="color: #008080;">264</span>     <span style="color: #008000;">//</span><span style="color: #008000;"> sandbox:  www.sandbox.paypal.com/cgi-bin/webscr</span><span style="color: #008080;">265</span>     <span style="color: #800080;">$db</span>->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')"<span style="color: #000000;">);</span><span style="color: #008080;">266</span>     <span style="color: #008000;">//</span><span style="color: #008000;"> Paypal testing options here</span><span style="color: #008080;">267</span>     <span style="color: #800080;">$db</span>->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? <br>NOTE: This can REALLY clutter your email inbox!<br>Logging goes to the /includes/modules/payment/paypal/logs folder<br>Email goes to the store-owner address.<br>Email option NOT recommended.<br><strong>Leave OFF for normal operation.</strong>', '6', '71', 'zen_cfg_select_option(array(\'Off\',\'Log File\',\'Log and Email\'), ', now())"<span style="color: #000000;">);</span><span style="color: #008080;">268</span>     <span style="color: #800080;">$db</span>->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())"<span style="color: #000000;">);</span><span style="color: #008080;">269</span> <span style="color: #008080;">270</span>     <span style="color: #800080;">$this</span>->notify('NOTIFY_PAYMENT_PAYPAL_INSTALLED'<span style="color: #000000;">);</span><span style="color: #008080;">271</span> <span style="color: #000000;">  }</span><span style="color: #008080;">272</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">273</span> <span style="color: #008000;">   * Remove the module and all its settings</span><span style="color: #008080;">274</span> <span style="color: #008000;">    *</span><span style="color: #008080;">275</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">276</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> remove() {</span><span style="color: #008080;">277</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;">278</span>     <span style="color: #800080;">$db</span>->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE\_PAYMENT\_PAYPAL\_%'"<span style="color: #000000;">);</span><span style="color: #008080;">279</span>     <span style="color: #800080;">$this</span>->notify('NOTIFY_PAYMENT_PAYPAL_UNINSTALLED'<span style="color: #000000;">);</span><span style="color: #008080;">280</span> <span style="color: #000000;">  }</span><span style="color: #008080;">281</span>   <span style="color: #008000;">/*</span><span style="color: #008000;">*</span><span style="color: #008080;">282</span> <span style="color: #008000;">   * Internal list of configuration keys used for configuration of the module</span><span style="color: #008080;">283</span> <span style="color: #008000;">   *</span><span style="color: #008080;">284</span> <span style="color: #008000;">   * @return array</span><span style="color: #008080;">285</span>     <span style="color: #008000;">*/</span><span style="color: #008080;">286</span>   <span style="color: #0000ff;">function</span><span style="color: #000000;"> keys() {</span><span style="color: #008080;">287</span>     <span style="color: #800080;">$keys_list</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(</span><span style="color: #008080;">288</span>                        'MODULE_PAYMENT_PAYPAL_STATUS',<span style="color: #008080;">289</span>                        'MODULE_PAYMENT_PAYPAL_BUSINESS_ID',<span style="color: #008080;">290</span>                        'MODULE_PAYMENT_PAYPAL_PDTTOKEN',<span style="color: #008080;">291</span>                        'MODULE_PAYMENT_PAYPAL_CURRENCY',<span style="color: #008080;">292</span>                        'MODULE_PAYMENT_PAYPAL_ZONE',<span style="color: #008080;">293</span>                        'MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID',<span style="color: #008080;">294</span>                        'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID',<span style="color: #008080;">295</span>                        'MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID',<span style="color: #008080;">296</span>                        'MODULE_PAYMENT_PAYPAL_SORT_ORDER',<span style="color: #008080;">297</span>                        'MODULE_PAYMENT_PAYPAL_DETAILED_CART',<span style="color: #008080;">298</span>                        'MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE' ,<span style="color: #008080;">299</span>                        'MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED' ,<span style="color: #008080;">300</span>                        'MODULE_PAYMENT_PAYPAL_PAGE_STYLE' ,<span style="color: #008080;">301</span>                        'MODULE_PAYMENT_PAYPAL_HANDLER',<span style="color: #008080;">302</span>                        'MODULE_PAYMENT_PAYPAL_IPN_DEBUG',<span style="color: #008080;">303</span> <span style="color: #000000;">                        );</span><span style="color: #008080;">304</span> <span style="color: #008080;">305</span>     <span style="color: #008000;">//</span><span style="color: #008000;"> Paypal testing/debug options go here:</span><span style="color: #008080;">306</span>     <span style="color: #0000ff;">if</span> (IS_ADMIN_FLAG === <span style="color: #0000ff;">true</span><span style="color: #000000;">) {</span><span style="color: #008080;">307</span>       <span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_GET</span>['debug']) && <span style="color: #800080;">$_GET</span>['debug']=='on'<span style="color: #000000;">) {</span><span style="color: #008080;">308</span>         <span style="color: #800080;">$keys_list</span>[]='MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS';  <span style="color: #008000;">/*</span><span style="color: #008000;"> this defaults to store-owner-email-address </span><span style="color: #008000;">*/</span><span style="color: #008080;">309</span> <span style="color: #000000;">      }</span><span style="color: #008080;">310</span> <span style="color: #000000;">    }</span><span style="color: #008080;">311</span>     <span style="color: #0000ff;">return</span> <span style="color: #800080;">$keys_list</span><span style="color: #000000;">;</span><span style="color: #008080;">312</span> <span style="color: #000000;">  }</span><span style="color: #008080;">313</span> <span style="color: #008080;">314</span>   <span style="color: #0000ff;">function</span> _getPDTresults(<span style="color: #800080;">$orderAmount</span>, <span style="color: #800080;">$my_currency</span>, <span style="color: #800080;">$pdtTX</span><span style="color: #000000;">) {</span><span style="color: #008080;">315</span>     <span style="color: #0000ff;">global</span> <span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;">316</span>     <span style="color: #800080;">$ipnData</span>  = ipn_postback('PDT', <span style="color: #800080;">$pdtTX</span><span style="color: #000000;">);</span><span style="color: #008080;">317</span>     <span style="color: #800080;">$respdata</span> = <span style="color: #800080;">$ipnData</span>['info'<span style="color: #000000;">];</span><span style="color: #008080;">318</span> <span style="color: #008080;">319</span>     <span style="color: #008000;">//</span><span style="color: #008000;"> parse the data</span><span style="color: #008080;">320</span>     <span style="color: #800080;">$lines</span> = <span style="color: #008080;">explode</span>("\n", <span style="color: #800080;">$respdata</span><span style="color: #000000;">);</span><span style="color: #008080;">321</span>     <span style="color: #800080;">$this</span>->pdtData = <span style="color: #0000ff;">array</span><span style="color: #000000;">();</span><span style="color: #008080;">322</span>     <span style="color: #0000ff;">for</span> (<span style="color: #800080;">$i</span>=1; <span style="color: #800080;">$i</span>count(<span style="color: #800080;">$lines</span>);<span style="color: #800080;">$i</span>++<span style="color: #000000;">){</span><span style="color: #008080;">323</span>       <span style="color: #0000ff;">if</span> (!<span style="color: #008080;">strstr</span>(<span style="color: #800080;">$lines</span>[<span style="color: #800080;">$i</span>], "=")) <span style="color: #0000ff;">continue</span><span style="color: #000000;">;</span><span style="color: #008080;">324</span>       <span style="color: #0000ff;">list</span>(<span style="color: #800080;">$key</span>,<span style="color: #800080;">$val</span>) = <span style="color: #008080;">explode</span>("=", <span style="color: #800080;">$lines</span>[<span style="color: #800080;">$i</span><span style="color: #000000;">]);</span><span style="color: #008080;">325</span>       <span style="color: #800080;">$this</span>->pdtData[<span style="color: #008080;">urldecode</span>(<span style="color: #800080;">$key</span>)] = <span style="color: #008080;">urldecode</span>(<span style="color: #800080;">$val</span><span style="color: #000000;">);</span><span style="color: #008080;">326</span> <span style="color: #000000;">    }</span><span style="color: #008080;">327</span> <span style="color: #008080;">328</span>     <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$this</span>->pdtData['txn_id'] == '' || <span style="color: #800080;">$this</span>->pdtData['payment_status'] == ''<span style="co"></span>
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
세션을 저장하기 위해 데이터베이스를 사용하면 어떤 장점이 있습니까?세션을 저장하기 위해 데이터베이스를 사용하면 어떤 장점이 있습니까?Apr 24, 2025 am 12:16 AM

데이터베이스 스토리지 세션 사용의 주요 장점에는 지속성, 확장 성 및 보안이 포함됩니다. 1. 지속성 : 서버가 다시 시작 되더라도 세션 데이터는 변경되지 않아도됩니다. 2. 확장 성 : 분산 시스템에 적용하여 세션 데이터가 여러 서버간에 동기화되도록합니다. 3. 보안 : 데이터베이스는 민감한 정보를 보호하기 위해 암호화 된 스토리지를 제공합니다.

PHP에서 사용자 정의 세션 처리를 어떻게 구현합니까?PHP에서 사용자 정의 세션 처리를 어떻게 구현합니까?Apr 24, 2025 am 12:16 AM

SessionHandlerInterface 인터페이스를 구현하여 PHP에서 사용자 정의 세션 처리 구현을 수행 할 수 있습니다. 특정 단계에는 다음이 포함됩니다. 1) CustomsessionHandler와 같은 SessionHandlerInterface를 구현하는 클래스 만들기; 2) 인터페이스의 방법 (예 : Open, Close, Read, Write, Despare, GC)의 수명주기 및 세션 데이터의 저장 방법을 정의하기 위해 방법을 다시 작성합니다. 3) PHP 스크립트에 사용자 정의 세션 프로세서를 등록하고 세션을 시작하십시오. 이를 통해 MySQL 및 Redis와 같은 미디어에 데이터를 저장하여 성능, 보안 및 확장 성을 향상시킬 수 있습니다.

세션 ID 란 무엇입니까?세션 ID 란 무엇입니까?Apr 24, 2025 am 12:13 AM

SessionId는 웹 애플리케이션에 사용되는 메커니즘으로 사용자 세션 상태를 추적합니다. 1. 사용자와 서버 간의 여러 상호 작용 중에 사용자의 신원 정보를 유지하는 데 사용되는 무작위로 생성 된 문자열입니다. 2. 서버는 쿠키 또는 URL 매개 변수를 통해 클라이언트로 생성하여 보낸다. 3. 생성은 일반적으로 임의의 알고리즘을 사용하여 독창성과 예측 불가능 성을 보장합니다. 4. 실제 개발에서 Redis와 같은 메모리 내 데이터베이스를 사용하여 세션 데이터를 저장하여 성능 및 보안을 향상시킬 수 있습니다.

무국적 환경 (예 : API)에서 세션을 어떻게 처리합니까?무국적 환경 (예 : API)에서 세션을 어떻게 처리합니까?Apr 24, 2025 am 12:12 AM

JWT 또는 쿠키를 사용하여 API와 같은 무국적 환경에서 세션을 관리 할 수 ​​있습니다. 1. JWT는 무국적자 및 확장 성에 적합하지만 빅 데이터와 관련하여 크기가 크다. 2. 쿠키는보다 전통적이고 구현하기 쉽지만 보안을 보장하기 위해주의해서 구성해야합니다.

세션과 관련된 크로스 사이트 스크립팅 (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. 세션 이름을 설정 한 후 세션을 시작하여 세션을 시작하십시오. 세션 이름을 구성하면 여러 응용 프로그램 간의 세션 데이터 충돌을 피하고 보안을 향상시킬 수 있지만 세션 이름의 독창성, 보안, 길이 및 설정 타이밍에주의를 기울일 수 있습니다.

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 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

SublimeText3 중국어 버전

SublimeText3 중국어 버전

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

SecList

SecList

SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.