首頁 > 後端開發 > php教程 > zencart先生成訂單後付款,類似淘寶後台修改訂單價格

zencart先生成訂單後付款,類似淘寶後台修改訂單價格

WBOY
發布: 2016-08-08 09:21:19
原創
1655 人瀏覽過

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/modulpales/payment/paypal. php

3. includes/classes/order.php

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

5.includes/modules/pages/account_phptory_info/account_his你的範本目錄/templates/tpl_account_history_info_default.php

7. includes/templates/你的範本目錄/templates/tpl_account_history_default.php

8. ipn_main_handler.phptory.

因為先生成訂單再付款,付款步驟就會比原來又多了一步,為了簡化付款流程,我安裝了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>if</span> ( (zen_not_null(<span>$module</span>)) && (<span>in_array</span>(<span>$module</span>.'.php', <span>$this</span>->modules)) && (<span>isset</span>(<span>$GLOBALS</span>[<span>$module</span>]-><span>paynow_action_url)) ) {
        </span><span>$this</span>->paynow_action_url = <span>$GLOBALS</span>[<span>$module</span>]-><span>paynow_action_url;        
}</span>
登入後複製

要增加paynow_button($order_id)函數,請在paymentment函數之後加上如下的程式碼:

<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修改後的文件如下:

<span> 1</span> <span>php
</span><span>2</span><span>/*</span><span>*
</span><span> 3</span><span> * paypal.php PayPal 網站付款標準(IPN)方法的付款模組類
</span><span> 4</span><span> *
</span><span> 5</span><span> * @package paymentMethod
</span><span> 6</span><span> * @copyright 版權所有 2003-2010 Zen Cart 開發團隊
</span><span> 7</span><span> * @copyright 部分版權所有 2003 osCommerce
</span><span> 8</span><span> * @license http://www.zen-cart.com/license/2_0.txt GNU 公共授權 V2.0
</span><span> 9</span><span> * @version $Id: paypal.php 15735 2010-03-29 07:13:53Z drbyte $
</span><span> 10</span><span>*/</span><span> 11</span><span> 12</span><span>define</span>('MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE', 'true'<span>);
</span><span>13</span><span>14</span><span>/*</span><span>*
</span><span> 15</span><span> * 確保加載依賴項
</span><span> 16</span><span>*/</span><span> 17</span><span>include_once</span>((IS_ADMIN_FLAG === <span>true</span> ?
<span></span>18<span></span>19<span></span>/*<span></span>*
<span></span> 20<span></span> * paypal.php PayPal 網站付款標準(IPN)方法的付款模組類
<span></span> 21<span></span> *
<span></span> 22<span></span>*/<span></span> 23<span></span>類<span>貝寶</span>擴充<span></span>基地{
<span></span>24<span></span>/*<span></span>*
<span></span> 25<span></span> * 代表付款方式的字串
<span></span> 26<span></span> *
<span></span> 27<span></span> * @var 字串
<span></span> 28<span></span>*/<span></span> 29<span></span>var<span></span>$代碼<span></span>;
<span></span> 30<span></span>/*<span></span>*
<span></span> 31<span></span> * $title 是此付款方式的顯示名稱
<span></span> 32<span></span> *
<span></span> 33<span></span> * @var 字串
<span></span> 34<span></span>*/<span></span> 35<span></span>var<span></span>$title<span></span>;
<span></span> 36<span></span>/*<span></span>*
<span></span> 37<span></span> * $description 是此付款方式的軟名稱
<span></span> 38<span></span> *
<span></span> 39<span></span> * @var 字串
<span></span> 40<span></span>*/<span></span> 41<span></span>var<span></span>$描述<span></span>;
<span></span> 42<span></span>/*<span></span>*
<span></span> 43<span></span> * $enabled 決定此模組是否在目錄中顯示...。
<span></span> 44<span></span> *
<span></span> 45<span></span> * @var 布林值
<span></span> 46<span></span>*/<span></span> 47<span></span>var<span></span>$啟用<span></span>;
<span></span> 48<span></span>/*<span></span>*
<span></span> 49<span></span> * 建構函數
<span></span> 50<span></span> *
<span></span> 51<span></span> * @param int $paypal_ipn_id
<span></span> 52<span></span> * @return paypal
<span></span> 53<span></span>*/<span></span> 54<span></span>函數<span> paypal(</span>$paypal_ipn_id<span> = ''</span>) {
<span></span> 55<span></span>全域<span></span>$order<span>, </span>$messageStack<span></span>;
<span></span> 56<span></span>$這個<span>->code = 'paypal'</span>;
<span></span> 57<span></span>$這個<span>->codeVersion = '1.3.9'</span>;
<span></span> 58<span></span>if<span> (IS_ADMIN_FLAG === </span>true<span></span>) {
<span></span> 59<span></span>$這個<span>->title = MODULE_PAYMENT_PAYPAL_TEXT_ADMIN_TITLE; </span>//<span></span> 管理<span>define</span>('MODULE_PAYMENT_PAYPAL_IPN_DEBUG') && MODULE_PAYMENT_PAYPAL_IPN_DEBUG ! = '關閉') <span>$這個</span>->標題.= '; (調試模式處於活動狀態)'<span>;
</span><span> 61</span><span>if</span> (IS_ADMIN_FLAG === <span>true</span> && MODULE_PAYMENT_PAYPAL_TESTING == '測試') <span>$this</span>-> 活動模式'<span>;
</span><span> 62</span> } <span>否則</span><span> {
</span><span> 63</span><span>$這個</span>->title = MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_TITLE; <span>//</span><span> 目錄中的付款模組標題</span><span> }</span><span> 65</span><span>$這個</span>->描述=<span> MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
</span><span> 66</span><span>$這個</span>->sort_order =<span> MODULE_PAYMENT_PAYPAL_SORT_ORDER;
</span><span> 67</span><span>$這個</span>->啟用 = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? <span>true</span> : <span>false</span><span>);
</span><span> 68</span><span>if</span> ((int)MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID > 0<span>) {
</span><span> 69</span><span>$這個</span>->order_status =<span> MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID;
</span><span>70</span><span>}
</span><span> 71</span><span>if</span> (<span>is_object</span>(<span>$order</span>)) <span>$this</span>-><span>update_status();
</span><span> 72</span><span>$這個</span>->paynow_action_url = 'https://' .<span> MODULE_PAYMENT_PAYPAL_HANDLER;
</span><span> 73</span><span> 74</span><span>if</span> (PROJECT_VERSION_MAJOR != '1' && <span>substr</span>(PROJECT_VERSION_MINOR, 0, <span>substr</span>(PROJECT_VERSION_MINOR, 0, 3) != '3. <span>;
</span><span> 75</span><span> 76</span><span>//</span><span>驗證表結構</span><span> 77</span><span>if</span> (IS_ADMIN_FLAG === <span></span>if<span> (IS_ADMIN_FLAG === </span>
<span></span>78<span></span>}
<span></span>79<span></span>/*<span></span>*
<span></span> 80<span></span> * 計算區域匹配和標誌設定以確定此模組是否應向客戶顯示
<span></span> 81<span></span> *
<span></span> 82<span></span>*/<span></span> 83<span></span>函數<span></span> update_status() {
<span></span> 84<span></span>全球<span></span>$訂單<span>,</span>$db<span></span>;
<span></span> 85<span></span> 86<span></span>if<span> ( (</span>$this<span>->啟用 == </span>true<span>) && ((int)MODULE_PAYMENT_PAYPALAL_LAL_LALLAL_Lool
</span><span> 87</span><span>$check_flag</span> = <span>false</span><span>;
</span><span> 88</span><span>$check_query</span> = <span>$db</span>->執行("從" . TABLE_ZONES_TO_GEO_ZONES . " 中選擇zone_id ,其中geo_zone_PAY_" ONEL. <span>$order . </span>-> billing['country']['id'] . "' 按zone_id 排序"<span>);
</span><span> 89</span><span>while</span> (!<span>$check_query</span>-><span>EOF) {
</span><span> 90</span><span>if</span> (<span>$check_query</span>->fields['zone_id'] ) {
<span> 91</span><span>$check_flag</span> = <span>true</span><span>;
</span><span> 92</span><span>休息</span><span>;
</span><span> 93</span> } <span>elseif</span> (<span>$check_query</span>->fields['zone_id'] == <span>$order</span>->billing['zone_id'<span>]) {
</span><span> 94</span><span>$check_flag</span> = <span>true</span><span>;
</span><span>95</span><span>休息</span><span>;
</span><span>96</span><span>}
</span><span> 97</span><span>$check_query</span>-><span>MoveNext();
</span><span>98</span><span>}
</span><span> 99</span><span>100</span><span>if</span> (<span>$check_flag</span> == <span>false</span><span>) {
</span><span>101</span><span>$這個</span>->啟用=<span>false</span><span>;
</span><span>102</span><span>}
</span><span>103</span><span>}
</span><span>104</span><span>}
</span><span>105</span><span>/*</span><span>*
</span><span>106</span><span> * JS 驗證,如果選擇使用此模組,則會對資料輸入進行錯誤檢查
</span><span>107</span><span> *(號碼、所有者和 CVV 長度)
</span><span>108</span><span>*
</span><span>109</span><span> * @return 字串
</span><span>110</span><span>*/</span><span>111</span><span>函數</span><span> javascript_validation() {
</span><span>112</span><span>回傳</span><span>假</span><span>;
</span><span>113</span><span>}
</span><span>114</span><span>/*</span><span>*
</span><span>115</span><span> * 在結帳付款頁面上顯示付款方式名稱以及信用卡資訊提交欄位(如果有)
</span><span>116</span><span>*
</span><span>117</span><span> * @return 數組
</span><span>118</span><span>*/</span><span>119</span><span>函數</span><span>選擇(){
</span><span>120</span><span>return</span><span>array</span>('id' => <span>$這個</span>->程式碼,
<span>121</span> '模組' => MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_LOGO,
<span>122</span>'圖示'=><span>MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_LOGO
</span><span>123</span><span>);
</span><span>124</span><span>}</span><span>125</span><span>/*</span><span>*
</span><span>126</span><span> * 通常會評估信用卡類型是否被接受以及信用卡號碼和到期日期的有效性
</span><span>127</span><span> * 由於 paypal 模組不收集信息,因此會跳過此步驟。
</span><span>128</span><span> *
</span><span>129</span><span> * @return 布林值
</span><span>130</span><span>*/</span><span>131</span><span>函數</span><span> pre_confirmation_check() {
</span><span>132</span><span>回傳</span><span>假</span><span>;
</span><span>133</span><span>}
</span><span>134</span><span>/*</span><span>*
</span><span>135</span><span> * 在結帳確認頁面顯示信用卡資訊
</span><span>136</span><span> * 由於在轉發到 paypal 網站之前不會為 paypal 收集任何內容,因此跳過
</span><span>137</span><span> *
</span><span>138</span><span> * @return 布林值
</span><span>139</span><span>*/</span><span>140</span><span>函數</span><span>確認(){
</span><span>141</span><span>回傳</span><span>假</span><span>;
</span><span>142</span><span>}
</span><span>143</span><span>/*</span><span>*
</span><span>144</span><span> * 建立在訂單確認畫面上按下「提交」按鈕時要處理的資料和操作。
</span><span>145</span><span> * 這會將資料傳送到支付網關進行處理。
</span><span>146</span><span> *(這些是結帳確認頁上的隱藏欄位)
</span><span>147</span><span> *
</span><span>148</span><span> * @return 字串
</span><span>149</span><span>*/</span><span>150</span><span>函數</span><span>process_button() {
</span><span>151</span><span>回傳</span><span>假</span><span>;
</span><span>152</span><span>}
</span><span>153</span><span>/*</span><span>*
</span><span>154</span><span> * 確定造訪 PayPal 網站時所使用的語言
</span><span>155</span><span>*/</span><span>156</span><span>函數</span><span> getLanguageCode() {
</span><span>157</span><span>全球</span><span>$訂單</span><span>;
</span><span>158</span><span>$lang_code</span> = ''<span>;
</span><span>159</span><span>$orderISO</span> = zen_get_countries(<span>$order</span>->customer['country']['id'], <span>true</span><span>);
</span><span>160</span><span>$storeISO</span> = zen_get_countries(STORE_COUNTRY, <span>true</span><span>);
</span><span>161</span><span>if</span> (<span>in_array</span>(<span>strtoupper</span>(<span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO</span>['countries_iso_code_2']), <span>$orderISO的, 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'</span>))) {
<span></span>162<span></span>$lang_code<span> = </span>strtoupper<span>(</span>$orderISO<span>['countries_iso_code_2'</span>]);
<span> (</span>163<span> } </span>elseif<span> (</span>in_array<span>(</span>strtoupper<span>(</span>$storeISO<span>['countries_iso_code_2']), </span>$storeISO<span>['countries_iso_code_2']), </span>$storeISO<span>['countries_iso_code_2']), </span>$storeISO<span>['countries_iso_code_2']), </span>$storeISO<span>['countries_iso_code_2']), </span>, '澳洲) ', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'<span>))) {
</span><span>164</span><span>$lang_code</span> = <span>strtoupper</span>(<span>$storeISO</span>['countries_iso_code_2'<span>]);
</span> (<span>165</span> } <span>elseif</span> (<span>in_array</span>(<span>strtoupper</span>(<span>$_SESSION</span>['languages_code']), <span>$_SESSION</span>['languages_code']), <span>array, 'FRf' ) ', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'</span>))) {
<span></span>166<span></span>$lang_code<span> = </span>$_SESSION<span>['語言代碼'</span>];
<span></span>167<span></span>if<span> (</span>strtoupper<span>(</span>$lang_code<span>) == 'EN') </span>$lang_code<span> = 'US'</span>;
<span></span>168<span></span>}
<span></span>169<span></span>//<span></span>return $orderISO['countries_iso_code_2'];<span></span>170<span></span>return<span></span>strtoupper<span>);
</span><span>171</span><span>}
</span><span>172</span><span>/*</span><span>*
</span><span>173</span><span> * 將交易資訊儲存到訂單並處理從支付網關返回的任何結果
</span><span>174</span><span>*/</span><span>175</span><span>函數</span><span> before_process() {
</span><span>176</span><span>回傳</span><span>假</span><span>;
</span><span>177</span><span>}
</span><span>178</span><span>/*</span><span>*
</span><span>179</span><span> * 檢查推薦人
</span><span>180</span><span> *
</span><span>181</span><span> * @param string $zf_domain
</span><span>182</span><span> * @return 布林值
</span><span>183</span><span>*/</span><span>184🎜🎜函數🎜 check_referrer(🎜$zf_domain🎜🎜) {
🎜🎜185🎜🎜回傳🎜🎜特見面🎜🎜;
🎜🎜186🎜🎜}</span><span>187</span><span>/*</span><span>*
</span><span>188</span><span> * 建置管理頁面元件
</span><span>189</span><span>*
</span><span>190</span><span> * @param int $zf_order_id
</span><span>191</span><span> * @return 字串
</span><span>192</span><span>*/</span><span>193</span><span>函數</span> admin_notification(<span>$zf_order_id</span><span>) {
</span><span>194</span><span>全球</span><span>$db</span><span>;
</span><span>195</span><span>$輸出</span> = ''<span>;
</span><span>196</span><span>$sql</span> = "從 " 選擇 * 。表_PAYPAL。 「其中 order_id = '」。 (int)<span>$zf_order_id</span> . "' 按 paypal_ipn_id DESC LIMIT 1 訂購"<span>;
</span><span>197</span><span>$ipn</span> = <span>$db</span>->執行(<span>$sql</span><span>);
</span><span>198</span><span>if</span> (<span>$ipn</span>->RecordCount() > 0 && <span>file_exists</span>(DIR_FS_CATALOG . DIR_WS_MODULES .A. 。 paypal_admin_notification.php'<span>);
</span><span>199</span><span>回報</span><span>$輸出</span><span>;
</span><span>200</span><span>}
</span><span>201</span><span>/*</span><span>*
</span><span>202</span><span> * 後處理活動
</span><span>203</span><span> * 當訂單從處理器返回時,如果 PDT 成功,則會將結果儲存在 order-status-history 中,並記錄資料以供後續參考
</span><span>204</span><span>*
</span><span>205</span><span> * @return 布林值
</span><span>206</span><span>*/</span><span>207</span><span>函數</span><span>after_process() {
</span><span>208</span><span>回傳</span><span>假</span><span>;
</span><span>209</span><span>}
</span><span>210</span><span>/*</span><span>*
</span><span>211</span><span> * 用於顯示錯誤訊息詳細信息
</span><span>212</span><span>*
</span><span>213</span><span> * @return 布林值
</span><span>214</span><span>*/</span><span>215</span><span>函數</span><span>output_error() {
</span><span>216</span><span>回傳</span><span>假</span><span>;
</span><span>217</span><span>}
</span><span>218</span><span>/*</span><span>*
</span><span>219</span><span> * 檢查模組是否安裝
</span><span>220</span><span>*
</span><span>221</span><span> * @return 布林值
</span><span>222</span><span>*/</span><span>223</span><span>函數</span><span>檢查(){
</span><span>224</span><span>全球</span><span>$db</span><span>;
</span><span>225</span><span>if</span> (IS_ADMIN_FLAG === <span>true</span><span>) {
</span><span>226</span><span>全球</span><span>$嗅探器</span><span>;
</span><span>227</span><span>if</span> (<span>$sniffer</span>->field_exists(TABLE_PAYPAL, 'zen_order_id')) <span>$db</span>->執行("ALTER TABLE" .TABL. NULL 預設'0'"<span>);
</span><span>228</span><span>}
</span><span>229</span><span>if</span> (!<span>isset</span>(<span>$這個</span>-><span>_check)) {
</span><span>230</span><span>$check_query</span> = <span>$db</span>->執行(“從“.TABLE_CONFIGURATION.”選擇configuration_value,其中configuration_key ='MODULE_PAYMENT_LE_PAYMENT_PAYuration_value,
<span></span>231<span></span>$this<span>->_check = </span>$check_query<span>-></span>RecordCount();
<span></span>232<span></span>}
<span></span>233<span></span>回傳<span></span>$這個<span>-></span>_check;
<span></span>234<span></span>}
<span></span>235<span></span>/*<span></span>*
<span></span>236<span></span> * 安裝支付模組及其配置設置
<span></span>237<span></span>*
<span></span>238<span></span>*/<span></span>239<span></span>函數<span></span> install() {
<span></span>240<span></span>全域<span></span>$db<span>,</span>$messageStack<span></span>;
<span></span>241<span></span>if<span> (</span>定義<span>('MODULE_PAYMENT_PAYPAL_STATUS'</span>)) {
<span></span>242<span></span>$messageStack<span>->add_session('PayPal 網站付款標準模組已安裝。', '錯誤'</span>);
<span></span>243<span> zen_redirect(zen_href_link(FILENAME_MODULES, 'set= payment&module=paypal', 'NONSSL'</span>));
<span></span>244<span></span>回傳<span>『失敗』</span>;
<span></span>245<span></span>}
<span></span>246<span></span>if<span>(</span>定義<span>('MODULE_PAYMENT_PAYPALWPP_STATUS'</span>)){
<span></span>247<span></span>$messageStack<span>->add_session('注意:PayPal Express Checkout 模組已安裝。如果安裝了 Express,則不需要 Standard。', 'error'</span>);
<span></span>248<span> zen_redirect(zen_href_link(FILENAME_MODULES, 'set= payment&module=paypalwpp', 'NONSSL'</span>));
<span></span>249<span></span>回傳<span>『失敗』</span>;
<span></span>250<span></span>}<span>251</span><span>$db</span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_fid_idues),configuration_value,configuration_description,configuration_m_idues),$_idue,P. PAL_STATUS', 'True ', '您想接受PayPal 付款嗎?
<span></span>252<span></span>$db<span>->執行(「插入到」。TABLE_CONFIGURATION。「(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_Date_value,configuration_description,configuration_group_id,sort_Date_value, ','”。 STORE_OWNER_EMAIL_ADDRESS ."', '您的PayPal 帳戶的主電子郵件地址。<br>注意:這必須與您的PayPal 帳戶設定中的主電子郵件地址完全匹配。區分大小寫,因此請在paypal .com 檢查您的PayPal 個人資料首選項,並確保在此輸入完全相同的主要電子郵件地址。
</span><span>253</span><span>$db</span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_m_idues),configuration_value,configuration_description,configuration_m_idues),_$idueP. _CURRENCY','選擇的貨幣', '訂單應以哪種貨幣發送至PayPal? array('所選貨幣', '僅美元', '僅澳元', '僅加元', '僅歐元', '僅英鎊', '僅瑞士法郎', '僅捷克克朗', '僅丹麥克朗', '僅港幣', '僅匈牙利福林', '僅日元', '僅挪威克朗', '僅新西蘭元', '僅波蘭茲羅提', '僅瑞典克朗', '僅新加坡元', '僅泰銖', '僅墨西哥比索', '僅ILS', '僅PHP', '僅TWD', '僅BRL', '僅MYR'), ', now())"<span>);
</span><span>254</span><span>$db</span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_Func_idsort_orderuration_value,configuration_description,configuration_Func_idsort_order,_idue),func. ENT_PAYPAL_ZONE' , ' 0', '如果選擇了某個區域,則僅對該區域啟用此付款方式。
<span></span>255<span></span>$db<span>->執行("插入" . TABLE_CONFIGURATION ." (configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_idation_key,configuration_value,configuration_description,configuration_group_iduesort_,value_value,dfunc_de PAYMENT_PAYPAL_PROCESSING_STATUS_ID ', '" . DEFAULT_ORDERS_STATUS_ID . "', '將使用此支付模組發出的尚未完成的訂單的狀態設定為此值<br>(推薦'待處理')', '6', '5' , ' zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"</span>);
<span></span>256<span></span>$db<span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_Func_idsort_orderuration_value,configuration_description,configuration_Func_idsort_order,set_function,d MENT_PAYPAL_ORDER_STATUS_ID ', '2', '將使用此付款模組下的已完成付款的訂單狀態設定為該值<br>(建議'正在處理')', '6', '6', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name ', now())"</span>);
<span></span>257<span></span>$db<span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_),_value. AYMENT_PAYPAL_REFUND_ORDER_STATUS_ID ', '1', '將使用此付款模組已退款的訂單狀態設定為此值<br>(推薦'Pending')', '6', '7', 'zen_cfg_pull_down_order_statuses(' , 'zen_get_order_status_name' , now())"</span>);
<span></span>258<span></span>$db<span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_idation_key,configuration_value,configuration_description,configuration_group_id.sort_fate_value,PAY_description,configuration_group_id,sort_,date_Fid) 顯示的排序順序。 _ORDER', '0 ', '顯示順序最低的先顯示。
</span><span>259</span><span>$db</span>-> 執行(「插入「。TABLE_CONFIGURATION。」(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_order,set_function,date_added)值('799))值('MODULE_MENT_function,date_added)值('799)'MODULE_PAY_MENT_F:P:PESS_P.P.P. Cart 中選擇的客戶送貨地址將覆蓋客戶PayPal 儲存的地址簿。 PayPal 視為未提供,或覆蓋=0)<br>0=無覆蓋<br>1=ZC 位址覆蓋PayPal 位址選擇', '6', '18', 'zen_cfg_select_option (陣列('0', '1'), ', now())"<span>);
</span><span>260</span><span>$db</span>->執行("插入" . TABLE_CONFIGURATION 。 PAL_ADDRESS_REQUIRED' , '2', '買家送貨地址。 br />0=提示<br>1=不詢問<br>2=必填<br>><br>gt;<strong>注意:如果您允許客戶輸入自己的送貨地址,然後請確保您在填寫訂單時親自手動驗證PayPal 確認詳細資料以驗證正確的地址。地址。
<span></span>261<span></span>$db<span>->執行("插入" . TABLE_CONFIGURATION . " (configuration_title,configuration_key,configuration_value,configuration_description,configuration_b_idues),configuration_value,configuration_description,configuration_m_iduesf,date_iduesf,date_Functions_Fate_idue)')7_idues),7_idue)」中的詳細行車項目_PAYPAL_DETAILED_CART ', '否', '您想向PayPal 提供訂單項詳細信息嗎? 。
</span><span>262</span><span>$db</span>->執行(「插入到」。TABLE_CONFIGURATION。」(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_pate_value, '主要' , '設定付款頁面的自訂付款頁面樣式page_style 的值與您在新增或編輯頁面樣式時選擇的頁面樣式名稱相同您可以從我的個人資料子標籤新增和編輯自訂付款頁面樣式。的帳戶標籤如果您希望始終引用您的主要樣式,請將其設定為「主要」。 ',現在())"<span>);
</span><span>263</span><span>$db</span>->執行(「插入到」。TABLE_CONFIGURATION。「(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_Pet_value,configuration_description,configuration_group_id,sort_Pet_value,configuration_description,configuration_group_id,sort_Pet_Lfunction; <br>預設:<br><code>www.paypal.com/cgi-bin/webscr</code><br>或<br>gt;<code> www.paypal.com/us/ cgi-bin/webscr</code><br>或英國,<br>><code>www.paypal.com/uk/cgi-bin/ webscr</code>', 'MODULE_PAYMENT_PAYPAL_HANDLER', 'www .paypal.com/cgi-bin/webscr', '選擇PayPal 即時處理的URL', '6', '73', '', now()) 「<span>);
</span><span>264</span><span>//</span><span>沙箱:www.sandbox.paypal.com/cgi-bin/webscr</span><span>265</span><span>$db</span>->執行(「插入到config集」CONiLE_<span>_db</span>->執行(「插入到config」CONpAB。 configuration_value、configuration_description、configuration_group_id、sort_order、date_added、use_function)值('PDT 令牌(付款資料傳輸)'、'MODULE_PAYMENT_PAYPAL_PDTTOKEN'、''、'在此輸入您的PDT 令牌值,以便在處理後立即啟動交易(如果它們通過)驗證)。
<span></span>266<span></span>//<span></span> Paypal 測試選項在這裡<span></span>267<span></span>$db<span>->執行(「插入「。TABLE_CONFIGURATION。」(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort_order,set_function,date_added)值('BUG」,'MODULE_order,SENT_function,date_added)值('BUGBUG','MODULE_PAYMENT_P:PUGBUG'BUG'BUG。 br />注意:這真的會讓您的電子郵件收件匣變得混亂!前往商店所有者地址.<br>不建議使用電子郵件選項。 ('Off) ','日誌檔案','日誌與電子郵件'), ', now())"<span>);
</span><span>268</span><span>$db</span>->執行(「插入」。TABLE_CONFIGURATION.「(configuration_title,configuration_key,configuration_value,configuration_description,configuration_group_id,sort,configuration_value,configuration_description,configuration_group_id,sortort_date_value,configuration_description,configuration_group_id,sortort_date_EMAue,configuration_description,configuration_group_id,sortort_date_EMAue, _ADDRESS','” . STORE_OWNER_EMAIL_ADDRESS."', '用於PayPal 偵錯的電子郵件地址', '6', '72', now())"<span>);
</span><span>269</span><span>270</span><span>$這個</span>->notify('NOTIFY_PAYMENT_PAYPAL_INSTALLED'<span>);
</span><span>271</span><span>}
</span><span>272</span><span>/*</span><span>*
</span><span>273</span><span> * 刪除模組及其所有設置
</span><span>274</span><span>*
</span><span>275</span><span>*/</span><span>276</span><span>函數</span><span>刪除(){
</span><span>277</span><span>全球</span><span>$db</span><span>;
</span><span>278</span><span>$db</span>->執行("從 " . TABLE_CONFIGURATION . " 中刪除,其中 configuration_key LIKE 'MODULE_PAYMENT_PAYPAL_%'"<span>);
</span><span>279</span><span>$這個</span>->notify('NOTIFY_PAYMENT_PAYPAL_UNINSTALLED'<span>);
</span><span>280</span><span>}
</span><span>281</span><span>/*</span><span>*
</span><span>282</span><span> * 用於配置模組的配置鍵的內部列表
</span><span>283</span><span>*
</span><span>284</span><span> * @return 陣列
</span><span>285</span><span>*/</span><span>286</span><span>函數</span><span>鍵(){
</span><span>287</span><span>$keys_list</span> = <span>數組</span><span>(
</span><span>288</span> 'MODULE_PAYMENT_PAYPAL_STATUS',
<span>289</span>“MODULE_PAYMENT_PAYPAL_BUSINESS_ID”,
<span>290</span>“MODULE_PAYMENT_PAYPAL_PDTTOKEN”,
<span>291</span>“MODULE_PAYMENT_PAYPAL_CURRENCY”,
<span>292</span>“MODULE_PAYMENT_PAYPAL_ZONE”,
<span>293</span>“MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID”,
<span>294</span>“MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID”,
<span>295</span>“MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID”,
<span>296</span>“MODULE_PAYMENT_PAYPAL_SORT_ORDER”,
<span>297</span>“MODULE_PAYMENT_PAYPAL_DETAILED_CART”,
<span>298</span>“MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE”,
<span>299</span>“MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED”,
<span>300</span>'MODULE_PAYMENT_PAYPAL_PAGE_STYLE',
<span>301</span>'MODULE_PAYMENT_PAYPAL_HANDLER',
<span>302</span>'MODULE_PAYMENT_PAYPAL_IPN_DEBUG',
<span>303</span><span>);
</span><span>304</span><span>305</span><span>//</span><span> Paypal 測試/除錯選項在這裡:</span><span>306</span><span>if</span> (IS_ADMIN_FLAGAG=mag
<span></span>307<span></span>if<span> (</span>isset<span>(</span>$_GET<span>['debug']) && </span>$_GET<span>['debug']=='on'</span>) {
<span></span>308<span></span>$keys_list<span>[]='MODULE_PAYMENT_PAYPAL_DEBUG_EMAIL_ADDRESS'; </span>/*<span></span> 默認為商店所有者電子郵件地址 <span>
</span><span>310</span><span>}
</span><span>311</span><span>回傳</span><span>$keys_list</span><span>;
</span><span>312</span><span>}</span><span>313</span><span>314</span><span>function</span>_getPDTresults(<span>$orderAmount</span>, <span>$my_currency</span>, <span>$pdtTXTX
</span><span>315</span><span>全球</span><span>$db</span><span>;
</span><span>316</span><span>$ipnData</span> = ipn_postback('PDT', <span>$pdtTX</span><span>);
</span><span>317</span><span>$respdata</span> = <span>$ipnData</span>['info'<span>];
</span><span>318</span><span>319</span><span>//</span><span>解析資料</span><span>320</span><span>$lines</span> = <span>explode</span>("n", <span>
</span><span>321</span><span>$這個</span>->pdtData = <span>array</span><span>();
</span><span>322</span><span>for</span> (<span>$i</span>=1; <span>$i</span>count</span>(<span>$行數</span>);<span>$i</span>++<span>)
</span><span>323</span><span>if</span> (!<span>strstr</span>(<span>$lines</span>[<span>$i</span>], "=")) <span>繼續</span><span>;
</span><span>324</span><span>list</span>(<span>$key</span>,<span>$val</span>) = <span>爆炸</span>("=, <span>$lines</span>[<span>$i</span>("=, <span>$lines</span>[<span>$i</span>
<span></span>325<span></span>$this<span>->pdtData[</span>urldecode<span>(</span>$key<span>)] = </span>urldecode<span>(</span>$val<span></span>);
<span></span>326<span></span>}
<span></span>327<span></span>328<span></span>if<span> (</span>$this<span>->pdtData['txn_id'] == '' || </span>$this<span>->pdtData[' payDataus'
</span><span>329</span> ipn_debug_email('PDT 傳回無效資料。必須等待 IPN 處理。' . "n" . <span>print_r</span>(<span>$this</span>->pdtData, <span>true</span>(<span>$this</span>->pdtData, <span>true</span>
<span></span>330<span></span>回傳<span></span>FALSE<span></span>;
<span></span>331<span> } </span>否則<span></span> {
<span></span>332<span> ipn_debug_email('PDT 回傳資料 ' . </span>print_r<span>(</span>$this<span>->pdtData, </span>true<span></span>));
<span></span>333<span></span>}
<span></span>334<span></span>335<span></span>$_POST<span>['mc_gross'] = </span>$this<span>->pdtData['mc_gross'</span>];
<span>['mc_currency'] = </span>$this<span>->pdtData['mc_currency'</span>];
<span></span>337<span></span>$_POST<span>['business'] = </span>$this<span>->pdtData['business'</span>];
<span>['receiver_email'] = </span>$this<span>->pdtData['receiver_email'</span>];
<span></span>339<span></span>340<span></span>$PDTstatus<span> = (ipn_validate_transaction(</span>$respdata<span>, </span>$this<span>->pdtData, ' </span>, “PDT”) && <span>$this</span>->pdtData[' payment_status'] == '已完成'<span>);
</span><span>341</span><span>if</span> (<span>$this</span>->pdtData[' payment_status'] != '' && <span>$this</span>->pdtData[' payment_status']&
<span></span>342<span> ipn_debug_email('PDT 警告:: 訂單未標記為「已完成」。檢查待處理原因或等待IPN 完成。' . "n" . '[ payment_status] =DataData$ .</span>$this<span>- >pDatapthis [' payment_status'] . '[pending_reason] => ' . </span>$this<span>->pdtData['pending_reason'</span>]);
<span></span>343<span></span>}
<span></span>344<span></span>345<span></span>$sql<span> = "</span>選擇 order_id、paypal_ipn_id、 payment_status、txn_type、pending_reason
<span></span>346<span> 來自「.TABLE_PAYPAL」。
</span>347<span></span> 哪裡 txn_id = :transactionID 或parent_txn_id = :transactionID
<span></span>348<span> ORDER BY order_id DESC "</span>;
<span></span>349<span></span>$sql<span> = </span>$db<span>->bindVars(</span>$sql<span>, ':transactionID', </span>$this<span>->pdtData['txn_id'], '</span>$this<span>->pdtData['txn_id'], '
</span><span>350</span><span>$ipn_id</span> = <span>$db</span>->執行(<span>$sql</span><span>);
</span><span>351</span><span>if</span> (<span>$ipn_id</span>->RecordCount() != 0<span>) {
</span><span>352</span> ipn_debug_email('PDT WARNING :: 交易已經存在。也許 IPN 已經添加了它。PDT 處理結束。'<span>);
</span><span>353</span><span>$pdtTXN_is_unique</span> = <span>false</span><span>;
</span><span>354</span> } <span>否則</span><span> {
</span><span>355</span><span>$pdtTXN_is_unique</span> = <span>true</span><span>;
</span><span>356</span><span>}
</span><span>357</span><span>358</span><span>$PDTstatus</span> = (<span>$pdtTXN_is_unique</span> && <span>$PDTstatus</span><span>);
</span><span>359</span><span>360</span><span>回傳</span><span>$PDTstatus</span><span>;
</span><span>361</span><span>}</span><span>362</span><span>363</span><span>364</span><span>函數</span><span>tableCheckup() {
</span><span>365</span><span>全球</span><span>$db</span>,<span>$sniffer</span><span>;
</span><span>366</span><span>$fieldOkay1</span> = (<span>method_exists</span>(<span>$sniffer</span>, 'field_type')) ? <span>$sniffer</span>->field_type(TABLE_PAYPAL, 'txn_id', 'varchar(20)', <span>true</span>) : -1<span>;
</span><span>367</span><span>$fieldOkay2</span> = (<span>$sniffer</span>->field_exists(TABLE_PAYPAL, 'module_name')) ? <span>真實</span>:-1<span>;
</span><span>368</span><span>$fieldOkay3</span> = (<span>$sniffer</span>->field_exists(TABLE_PAYPAL, 'order_id')) ? <span>真實</span>:-1<span>;
</span><span>369</span><span>370</span><span>if</span> (<span>$fieldOkay1</span> == -1<span>) {
</span><span>371</span><span>$sql</span> = "顯示來自 " .<span> TABLE_PAYPAL 的欄位;
</span><span>372</span><span>$結果</span> = <span>$db</span>->執行(<span>$sql</span><span>);
</span><span>373</span><span>while</span> (!<span>$結果</span>-><span>EOF) {
</span><span>374</span><span>if</span> (<span>$result</span>->fields['Field'] == 'txn_id'<span>) {
</span><span>375</span><span>if</span> (<span>$結果</span>->fields['Type'] == 'varchar(20)'<span>) {
</span><span>376</span><span>$fieldOkay1</span> = <span>true</span>; <span>//</span><span> 存在且符合所需類型,因此請跳至其他檢查</span><span>3777</span> 存在且符合所需類型,因此請跳至其他檢查<span></span>3777<span> } </span>
<span></span>378<span></span>$fieldOkay1<span> = </span>$結果<span>->fields['Type']; </span>//<span></span>不匹配,所以返回它「是什麼」<span></span>
<span></span>380<span></span>}
<span></span>381<span></span>}
<span></span>382<span></span>$結果<span>-></span>MoveNext();
<span></span>383<span></span>}
<span></span>384<span></span>}
<span></span>385<span></span>386<span></span>if<span> (</span>$fieldOkay1<span> !== </span>true<span></span>) {
<span></span>387<span></span>//<span></span> 對v1.3.7.x 的表結構的臨時修復- 可能會在以後的版本中刪除<span></span>388<span></span>$db<span>->Execute(ALTER388" ALTER TABV.P. CHANGE payment_type payment_type varchar(40) NOT NULL 預設''"</span>);
<span></span>389<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE txn_type txn_type varchar(40) NOT NULL default ''"</span>);
<span></span>390<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payment_status payment_status varchar(32) NOT NULL default ''"</span>);
<span></span>391<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE Reason_code Reason_code varchar(40) 預設NULL"</span>);
<span></span>392<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGEending_reasonending_reason varchar(32) 預設NULL"</span>);
<span></span>393<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE 發票 發票 varchar(128) 預設 NULL" </span>);
<span></span>394<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payer_business_name payer_business_name varchar(128) default NULL"</span>);
<span></span>395<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE 位址名稱 位址名稱 varchar(64) 預設 NULL"</span>);
<span></span>396<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_street address_street varchar(254) default NULL" </span>);
<span></span>397<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_city address_city varchar(120) default NULL"</span>);
<span></span>398<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE address_state address_state varchar(120) default NULL"</span>);
<span></span>399<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE payer_email payer_email varchar(128) NOT NULL default ''"</span>);
<span></span>400<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE Business Business varchar(128) NOT NULL default ''"</span>);
<span></span>401<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE receive_email receive_email varchar(128) NOT NULL default ''"</span>);
<span></span>402<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE txn_id txn_id varchar(20) NOT NULL default ''"</span>);
<span></span>403<span></span>$db<span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE Parent_txn_id Parent_txn_id varchar(20) 預設 NULL"</span>);
<span></span>404<span></span>}<span>405</span><span>if</span> (<span>$fieldOkay2</span> !== <span>true</span><span>) {
</span><span>406</span><span>$db</span>->執行("ALTER TABLE " . TABLE_PAYPAL . " ADD COLUMN module_name varchar(40) NOT NULL default '' after txn_type"<span>);
</span><span>407</span><span>$db</span>->執行("ALTER TABLE " . TABLE_PAYPAL . " ADD COLUMN module_mode varchar(40) NOT NULL default '' after module_name"<span>);
</span><span>408</span><span>}
</span><span>409</span><span>if</span> (<span>$fieldOkay3</span> !== <span>true</span><span>) {
</span><span>410</span><span>$db</span>->執行("ALTER TABLE " . TABLE_PAYPAL . " CHANGE zen_order_id order_id int(11) NOT NULL default '0'"<span>);
</span><span>411</span><span>}
</span><span>412</span><span>}
</span><span>413</span><span>414</span><span>函數</span> paynow_button(<span>$order_id</span><span>) {
</span><span>415</span><span>全球</span><span>$db</span>,<span>$訂單</span>,<span>$貨幣</span>,<span>$貨幣</span><span>;
</span><span>416</span><span>require_once</span>(DIR_WS_CLASSES . 'order.php'<span>);
</span><span>417</span><span>$訂單</span> = <span>新</span>訂單(<span>$order_id</span><span>);
</span><span>418</span><span>$選項</span> = <span>數組</span><span>();
</span><span>419</span><span>$optionsCore</span> = <span>數組</span><span>();
</span><span>420</span><span>$options電話</span> = <span>數組</span><span>();
</span><span>421</span><span>$optionsShip</span> = <span>數組</span><span>();
</span><span>422</span><span>$optionsLineItems</span> = <span>數組</span><span>();
</span><span>423</span><span>$optionsAggregate</span> = <span>數組</span><span>();
</span><span>424</span><span>$optionsTrans</span> = <span>數組</span><span>();
</span><span>425</span><span>$buttonArray</span> = <span>array</span><span>();
</span><span>426</span><span>427</span><span>$這個</span>->總和 = <span>$訂單</span>->資訊['總計'<span>];
</span><span>428</span><span>429</span><span>//</span><span>永久保存會話內容,以防 PayPal 丟失會話</span><span>430</span><span>$_SESSION</span>['pipn_ppp_pppmm;
<span></span>431<span></span>$db<span>->執行("從 " . TABLE_PAYPAL_SESSION . " 中刪除,其中 session_id = '" . zen_db_input(</span>$_SESSION<span>
</span><span>432</span><span>433</span><span>$sql</span> = "插入" . TABLE_PAYPAL_SESSION 。 「<span>(session_id、saved_session、expiry)值(
</span><span>434</span> '" . zen_db_input(<span>$_SESSION</span>['ppipn_key_to_remove']) . "<span>',
</span><span>435</span> '" . <span>base64_encode</span>(<span>serialize</span>(<span>$_SESSION</span>)) . "<span>',
</span><span>436</span> '" . (<span>時間</span>() + (1*60*60*24*2)) . "')"<span>;
</span><span>437</span><span>438</span><span>$db</span>->執行(<span>$sql</span><span>);
</span><span>439</span><span>440</span><span>$my_currency</span> =<span> select_pp_currency();
</span><span>441</span><span>if</span>(!<span>空</span>(<span>$訂單</span>->資訊['貨幣'<span>])){
</span><span>442</span><span>$my_currency</span>=<span>$order</span>->info['currency'<span>];
</span><span>443</span><span>}
</span><span>444</span><span>$這個</span>->transaction_currency = <span>$my_currency</span><span>;
</span><span>445</span><span>446</span><span>$這個</span>->交易金額 = (<span>$這個</span>->總金額 * <span>$貨幣</span>->get_value(<span>$my_currency</span>$貨幣<span>->get_value(</span>$my_currency);
<span></span>447<span></span>448<span></span>$電話<span> = </span>preg_replace<span>('/D/', '', </span>$訂單<span>->客戶['電話'</span>]);
<span></span>449<span></span>if<span> (</span>$電話<span> != ''</span>) {
<span></span>450<span></span>$options電話<span>['H_PhoneNumber'] = </span>$電話<span></span>;
<span></span>451<span></span>if<span> (</span>in_array<span>(</span>$order<span>->客戶['國']['iso_code_2'], </span>array<span>('美國','加拿大'</span>)) {))
<span></span>452<span></span>$options電話<span>['night_phone_a'] = </span>substr<span>(</span>$電話<span>,0,3</span>);
<span></span>453<span></span>$options電話<span>['night_phone_b'] = </span>substr<span>(</span>$電話<span>,3,3</span>);
<span></span>454<span></span>$options電話<span>['night_phone_c'] = </span>substr<span>(</span>$電話<span>,6,4</span>);
<span></span>455<span></span>$options電話<span>['day_phone_a'] = </span>substr<span>(</span>$電話<span>,0,3</span>);
<span></span>456<span></span>$options電話<span>['day_phone_b'] = </span>substr<span>(</span>$電話<span>,3,3</span>);
<span></span>457<span></span>$options電話<span>['day_phone_c'] = </span>substr<span>(</span>$電話<span>,6,4</span>);
<span></span>458<span>}<span>否則</span><span> {
</span><span>459</span><span>$options電話</span>['night_phone_b'] = <span>$電話</span><span>;
</span><span>460</span><span>$options電話</span>['day_phone_b'] = <span>$電話</span><span>;
</span><span>461</span><span>}
</span><span>462</span><span>}</span><span>463</span><span>464</span><span>$optionsCore</span> = <span>備份</span><span>(
</span><span>465</span> 'lc' =>我們,
<span>466</span><span>//</span><span>'lc' => $order->customer['country']['iso_code_2'],</span><span>467</span> 'charset' =>;字元集,
<span>468</span> 'page_style' => MODULE_PAYMENT_PAYPAL_PAGE_STYLE,
<span>469</span>'自訂'=> zen_session_name() 。
<span>470</span>'發票'=> <span>$order</span>->info['num'],
<span>471</span>「生意」=> MODULE_PAYMENT_PAYPAL_BUSINESS_ID,
<span>472</span>'返回'=> zen_href_link(FILENAME_CHECKOUT_PROCESS, 'referer=paypal', 'SSL'),
<span>473</span> 'cancel_return' => zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'),
<span>474</span> 'shopping_url' => zen_href_link(FILENAME_SHOPPING_CART, '', 'SSL'),
<span>475</span> 'notify_url' => zen_href_link('ipn_main_handler.php', '', 'SSL',<span>false</span>,<span>false</span>,<span>true</span>),
<span>476</span> 'redirect_cmd' => '_xclick','rm' => 2、'bn' => 'zencart','mrb' =>; 'R-6C7952342H795591R', '朋友' => '9E82WJBKKGPLQ',
<span>477</span><span>);
</span><span>478</span><span>$optionsCust</span> = <span>備份</span><span>(
</span><span>479</span>'名字'=> Replace_accents(<span>$order</span>->customer['firstname']),
<span>480</span>'last_name'=> Replace_acents(<span>$order</span>->customer['lastname']),
<span>481</span>'地址1'=> Replace_accents(<span>$order</span>->customer['street_address']),
<span>482</span>'城市'=> Replace_accents(<span>$order</span>->customer['city']),
<span>483</span>'狀態'=> zen_get_zone_code(<span>$order</span>->客戶['country']['id'], <span>$order</span>->客戶['zone_id'], <span>$order</span>->['狀態']),
<span>484</span>'zip'=> <span>$訂單</span>->客戶['郵遞區號'],
<span>485</span>「國家」=> <span>$訂單</span>->客戶['國家']['iso_code_2'],
<span>486</span>「電子郵件」=> <span>$ 訂單</span>->客戶['email_address'],
<span>487</span><span>);
</span><span>488</span><span>//</span><span>地址第2行是可選的</span><span>489</span><span>if ] = </span>$訂單<span>->顧客['郊區'</span>];
<span></span>490<span></span>//<span></span>日文地址版面的不同格式:<span></span>491<span></span>if<span> (</span>$order<span>->customer['countcountry']['iso_</span>$order<span>->customer['country']['iso_Dis; </span>['zip'] = <span>substr</span>(<span>$order</span>->customer['postcode'], 0, 3) . <span>substr</span>(<span>$訂單</span>->客戶['郵遞區號'], 3<span>);
</span><span>492</span><span>if</span> (MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED == 2<span>) {
</span><span>493</span><span>$optionsCust</span> = <span>備份</span><span>(
</span><span>494</span>'名字'=> Replace_acents(<span>$order</span>->delivery['firstname'] != '' ? <span>$order</span>->delivery['firstname'] : order order ?名']),
<span>495</span> 'last_name' => Replace_accents(<span>$order</span>->發貨['lastname'] != '' ? <span>$order</span>->發貨['lastname'] : <span>$order</span>->[ '姓']),
<span>496</span>'地址1'=> Replace_accents(<span>$order</span>->發貨['street_address'] != '' ? <span>$order</span>->發貨['street_address'] : <span>$order</span>->發貨['street_address'] : <span>$> ['街道地址']),
</span>497<span>「城市」=> Replace_accents(</span>$order<span>->送貨['city'] != '' ? </span>$order<span>->送貨['city'] : </span>$order<span>->>[ 'city' ']),
</span>498<span>'狀態'=> (</span>$order<span>->出貨['country']['id'] != '' ? zen_get_zone_code(</span>$order<span>->出貨['country']['id ') '], </span>$order<span>->送貨['zone_id'], </span>$order<span>->送貨['state']) : zen_get_zone_code(</span>$order<span>->帳單['country'][' id'], </span>$order<span>-> 儀表['zone_id'], </span>$order<span>->儀表['state'])),
</span>499<span>'zip'=> (</span>$訂單<span>->貨運['郵遞區號'] != '' ? </span>$訂單<span>->貨運['郵遞區號'] : </span>$訂單<span>->發票['郵遞區號']),
</span>500<span>「國家」=> (</span>$訂單<span>->出貨['國家']['標題'] != '' ? </span>$訂單<span>-> 送貨['國家']['標題'] : <span>$訂單</span>->帳單['國家']['標題']),
<span>501</span> '國家/地區代碼' => (<span>$訂單</span>->送貨['國家']['iso_code_2'] != '' ? <span>$訂單</span>->送貨['國家'][' iso_code_2'] : <span>$訂單</span>->計費['國家']['iso_code_2']),
<span>502</span>「電子郵件」=> <span>$訂單</span>->客戶['email_address'],
<span>503</span><span>);
</span><span>504</span><span>if</span> (<span>$訂單</span>->送貨['郊區'] != '') <span>$optionsCust</span>['address2'] = <span>$> ;
</span><span>505</span><span>if</span> (<span>$order</span>->delivery['country']['iso_code_2'] == 'JP') <span>$optionsCust</span>['zip']sub = <span>( > 送貨['郵遞區號'], 0, 3) . '-'。 </span>substr<span>(</span>$訂單<span>->送貨['郵遞區號'], 3</span>);
<span></span>506<span></span>}
<span></span>507<span></span>$optionsShip<span>['no_shipping'] =</span> MODULE_PAYMENT_PAYPAL_ADDRESS_REQUIRED;
<span></span>508<span></span>if<span> (MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE == '1') </span>$optionsShip<span>['address_override'] =</span> MODULE_PAYMENTWESSPESS_ADS;
<span></span>509<span></span>//<span></span>盡可能準備購物車內容詳細資料<span></span>510<span></span>if<span> (MODULE_PAYMENT_PAYPAL_DETAILED_CARTif</span> (MODULE_PAYMENT_PAYPAL_DETAILED_CARTd s();
<span></span>511<span></span>if<span> (</span>sizeof<span>(</span>$optionsLineItems<span>) > 0</span>) {
<span></span>512<span></span>$optionsLineItems<span>['cmd'] = '_cart'</span>;
<span></span>513<span></span>//<span></span> $optionsLineItems['num_cart_items'] = sizeof($order->products);<span></span>514<span></span>if<span> </span>]) ) {
<span></span>515<span></span>$optionsLineItems<span>['shipping_1'] = </span>$optionsLineItems<span>['shipping'</span>];
<span></span>516<span></span>unset<span>(</span>$optionsLineItems<span>['shipping'</span>]);
<span></span>517<span></span>}
<span></span>518<span></span>unset<span>(</span>$optionsLineItems<span>['小計'</span>]);
<span></span>519<span></span>//<span></span> 如果由於計算不匹配或折扣等原因無法保留行項目詳細信息,則默認聚合模式<span></span>520<span></span>if<span> (!</span>isset<span>520</span><span>if</span> (! ']) || <span>$optionsLineItems</span>['creditsExist'] == <span>TRUE</span>) <span>$optionsLineItems</span> = <span>array</span><span>();
</span><span>521</span><span>//</span><span>if ($optionsLineItems['amount'] != $this->transaction_amount) $optionsLineItems = array();
</span><span>522</span><span> // 除錯:
</span><span>523</span><span> //ipn_debug_email('行項目詳細資訊(如果為空,這表示存在資料不符或應用了積分,因此被繞過): ' . "n" . print_r($optionsLineItems, true) );</span><span>分段閱讀_第524 章
</span><span>525</span><span>}</span><span>526</span><span>$optionsAggregate</span> = <span>數組</span><span>(
</span><span>527</span>'cmd'=> '_ext-輸入',
<span>528</span> 'item_name' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_TITLE,
<span>529</span> 'item_number' => MODULE_PAYMENT_PAYPAL_PURCHASE_DESCRIPTION_ITEMNUM,
<span>530</span><span>//</span><span>'num_cart_items' => sizeof($order->產品),</span><span>531</span> '金額' =>; <span>數字格式</span>(<span> ->get_decimal_places(</span>$my_currency<span>)),
</span>532<span>'運輸'=> '0.00',
</span>533<span></span>);
<span></span>534<span></span>if<span> (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') </span>$optionsAggregate<span>['tax'] = '0.00'</span>;
<span></span>535<span></span>if<span> (MODULE_PAYMENT_PAYPAL_TAX_OVERRIDE == 'true') </span>$optionsAggregate<span>['tax_cart'] = '0.00'</span>;
<span></span>536<span></span>$optionsTrans<span> = </span>數組<span></span>(
<span></span>537<span>'上傳'=> (int)(</span>sizeof<span>(</span>$訂單<span>->產品)> 0),
</span>538<span> 'currency_code' => </span>$my_currency<span>,
</span>539<span></span>//<span></span>'paypal_order_id' => $paypal_order_id,
<span></span>540<span></span> //'no_note' =>; '1',
<span></span>541<span></span> //'發票'=>; '',<span></span>542<span></span>);
<span></span>543<span></span>544<span></span>//<span></span>如果訂單項目資訊無效,請使用聚合:<span></span>545<span></span>if<span> (Agof3)$mize</span>545<span></span>if<span> ( </span>=<span> $optionsLineItems </span><span>;
</span><span>546</span><span>547</span><span>//</span><span>準備提交</span><span>548</span><span>$options</span> = <span> optionsPhone </span>, <span>$optionsShip</span>, <span>$optionsTrans </span>, <span>$optionsAggregate</span><span>);
</span><span>549</span><span>//</span><span>ipn_debug_email('提交金鑰:' . print_r($options, true));
</span><span>550</span><span>551</span><span> // 建置按鈕欄位</span><span>552</span><span>foreach</span> (<span>$options</span><span>as</span> <span> (</span>$options<span></span>as<span></span>
<span></span>553<span></span>//<span></span>去掉引號<span></span>554<span></span>$value<span> = </span>str_replace<span>('"', '', </span> = <span>str_replace</span>('"', '', <span> = </span>str_replace<span>('"', '', </span> = <span>str_replace</span>('"', '', <span> = </span>str_replace<span>('"', '', </span> = <span>str_
</span><span>555</span><span>//</span><span>檢查無效字元</span><span>556</span><span>if</span> (<span>preg_match</span>('/[^a-zA-Z_0-9],'/
<span></span>557<span> ipn_debug_email('datacheck - 正在中止 - preg_match 發現無效的提交密鑰:' . </span>$name<span> . ' (' . </span>$value<span> . ')'</span>);
<span></span>558<span></span>休息<span></span>;
<span></span>559<span></span>}
<span></span>560<span></span>//<span></span> 我們需要對 & 和 = 符號進行特殊處理嗎?
<span></span>561<span></span> //if (strpos($value, '&') !== false || strpos($value, '=') !== false) $value = urlencode($value);<span></span>562 <span></span>563<span></span>$bu</span></span></strong>
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板