PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | functions/hoock_func.php +954 -1165 1.4.122.12.4 View file →
@@ -1,1191 +1,980 @@
1 -<?php
2 -// Hoock functions
3 -add_action('usces_construct', 'usces_action_acting_construct', 10);
4 -add_action('usces_after_cart_instant', 'usces_action_acting_transaction', 10);
5 -
6 -function usces_action_acting_construct(){
7 -
8 - if(isset($_POST['X-TRANID']) && !isset($_POST['OPT'])){//remise
9 -
10 - $rand = $_POST['X-S_TORIHIKI_NO'];
11 - $datas = usces_get_order_acting_data($rand);
12 - $_GET['uscesid'] = $datas['sesid'];
13 - if( empty($datas['sesid']) ){
14 - usces_log('remise construct : error1', 'acting_transaction.log');
15 - }else{
16 - //usces_auth_order_acting_data($rand);
17 - usces_log('remise construct : '.$_POST['X-TRANID'], 'acting_transaction.log');
18 - usces_set_acting_notification_time( $rand );
19 - }
20 -
21 - }elseif( in_array($_SERVER['REMOTE_ADDR'], array('210.164.6.67', '202.221.139.50')) ){//zeus
22 -
23 - $rand = $_REQUEST['sendpoint'];
24 - $datas = usces_get_order_acting_data($rand);
25 - $_GET['uscesid'] = $datas['sesid'];
26 - if( empty($datas['sesid']) ){
27 - usces_log('zeus construct : error1', 'acting_transaction.log');
28 - }else{
29 - usces_log('zeus construct : '.$_REQUEST['sendpoint'], 'acting_transaction.log');
30 - }
31 -
32 - } elseif( isset($_POST['res_result']) && isset($_POST['res_pay_method']) && isset($_POST['order_id']) ) {//SoftBankPayment
33 -
34 - $datas = usces_get_order_acting_data( $_POST['order_id'] );
35 - $_GET['uscesid'] = $datas['sesid'];
36 - if( empty($datas['sesid']) ) {
37 - usces_log('SoftBankPayment construct : error1', 'acting_transaction.log');
38 - } else {
39 - usces_log('SoftBankPayment construct : '.$_POST['order_id'], 'acting_transaction.log');
40 - }
41 -
42 - } elseif( isset($_POST['SID']) && isset($_POST['FUKA']) && isset($_POST['CVS']) ) {//digitalcheck_conv
43 -
44 - $datas = usces_get_order_acting_data( $_POST['SID'] );
45 - $_GET['uscesid'] = $datas['sesid'];
46 - if( empty($datas['sesid']) ) {
47 - usces_log('digitalcheck construct : error1', 'acting_transaction.log');
48 - } else {
49 - usces_log('digitalcheck construct : '.$_POST['SID'], 'acting_transaction.log');
50 - }
51 -
52 - } elseif( isset($_REQUEST['SiteId']) && isset($_REQUEST['rand']) ) {//AnotherLane
53 -
54 - $datas = usces_get_order_acting_data( $_REQUEST['rand'] );
55 - $_GET['uscesid'] = $datas['sesid'];
56 - if( empty($datas['sesid']) ) {
57 - usces_log('anotherlane construct : error1', 'acting_transaction.log');
58 - } else {
59 - usces_log('anotherlane construct : '.$_REQUEST['rand'], 'acting_transaction.log');
60 - }
61 -
62 - } elseif( isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {//Veritrans
63 -
64 - $datas = usces_get_order_acting_data( $_POST['orderId'] );
65 - $_GET['uscesid'] = $datas['sesid'];
66 - if( empty($datas['sesid']) ) {
67 - usces_log('Veritrans construct : error1', 'acting_transaction.log');
68 - } else {
69 - usces_log('Veritrans construct : '.$_POST['orderId'], 'acting_transaction.log');
1 +<?php
2 +/**
3 + * Hoock functions.
4 + *
5 + * @package Welcart
6 + */
7 +
8 +add_action( 'usces_construct', 'usces_action_acting_construct', 10 );
9 +add_action( 'usces_after_cart_instant', 'usces_action_acting_transaction', 10 );
10 +// A3 (Layer 3 / uscesid removal): restore the shopper's cart/entry for settlement notifications
11 +// from the transaction-keyed DB store, uscesid-independently. Must run after usces_session_start()
12 +// (constructor end) and before usces_main()'s `new usces_cart()`, hence the usces_main hook.
13 +add_action( 'usces_main', 'usces_restore_acting_session_from_store', 1 );
14 +
15 +/**
16 + * Settlement Result Notification Processing.
17 + * usces_construct
18 + */
19 +function usces_action_acting_construct() {
20 + /* remise */
21 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) ) {
22 +
23 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
24 + $datas = array();
25 + /* 決済成功の時のみセッション復帰 */
26 + if ( 0 == $_POST['X-ERRLEVEL'] ) {
27 + $datas = usces_get_order_acting_data( $rand );
28 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
29 + if ( empty( $datas['sesid'] ) ) {
30 + /* sesidが無い場合はファイルログのみ */
31 + usces_log( 'remise construct : error1', 'acting_transaction.log' );
32 + } else {
33 + /* 復帰できた場合のログ */
34 + usces_log( 'remise construct OK : ' . wp_unslash( $_POST['X-TRANID'] ), 'acting_transaction.log' );
35 + }
70 36 }
71 -
72 - } elseif( isset($_POST['trading_id']) and isset($_POST['payment_status']) and !isset($_POST['purchase']) ) {//Paygent
73 37
74 - if( $_POST['payment_status'] == '10' ) {
75 - $datas = usces_get_order_acting_data( $_POST['trading_id'] );
76 - $_GET['uscesid'] = $datas['sesid'];
77 - if( empty($datas['sesid']) ) {
78 - usces_log('Paygent construct : error1', 'acting_transaction.log');
38 + /* digitalcheck_conv */
39 + } elseif ( isset( $_POST['SID'] ) && isset( $_POST['FUKA'] ) && isset( $_POST['CVS'] ) ) {
40 +
41 + $sid = wp_unslash( $_POST['SID'] );
42 + $datas = usces_get_order_acting_data( $sid );
43 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
44 + if ( empty( $datas['sesid'] ) ) {
45 + $log = array(
46 + 'acting' => 'digitalcheck',
47 + 'key' => $sid,
48 + 'result' => 'SESSION ERROR',
49 + 'data' => wp_unslash( $_POST ),
50 + );
51 + usces_save_order_acting_error( $log );
52 + usces_log( 'digitalcheck construct : error1', 'acting_transaction.log' );
53 + } else {
54 + usces_log( 'digitalcheck construct : ' . $sid, 'acting_transaction.log' );
55 + }
56 +
57 + /* AnotherLane */
58 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['rand'] ) ) {
59 +
60 + $rand = wp_unslash( $_REQUEST['rand'] );
61 + $datas = usces_get_order_acting_data( $rand );
62 + // A3: uscesid ブリッジは廃止。セッション復元は usces_restore_acting_session_from_store()(usces_main)で DBストアから実施.
63 + if ( empty( $datas['sesid'] ) ) {
64 + $log = array(
65 + 'acting' => 'anotherlane',
66 + 'key' => $rand,
67 + 'result' => 'SESSION ERROR',
68 + 'data' => wp_unslash( $_REQUEST ),
69 + );
70 + usces_save_order_acting_error( $log );
71 + usces_log( 'anotherlane construct : error1', 'acting_transaction.log' );
72 + } else {
73 + usces_log( 'anotherlane construct : ' . $rand, 'acting_transaction.log' );
74 + }
75 +
76 + /* Veritrans */
77 + } elseif ( isset( $_POST['orderId'] ) && isset( $_POST['merchantEncryptionKey'] ) ) {
78 +
79 + $orderid = wp_unslash( $_POST['orderId'] );
80 + $datas = usces_get_order_acting_data( $orderid );
81 + // A3: uscesid ブリッジは廃止($_GET['uscesid'] を読む処理は撤廃済みのため代入は無意味だった)。
82 + // ベリトランス Air-Web は選択可能な決済から除外済み(settlement.class.php)のため、DBストアからの
83 + // セッション復元(usces_restore_acting_session_from_store)の対象外とする.
84 + if ( empty( $datas['sesid'] ) ) {
85 + $log = array(
86 + 'acting' => 'veritrans',
87 + 'key' => $orderid,
88 + 'result' => 'SESSION ERROR',
89 + 'data' => wp_unslash( $_POST ),
90 + );
91 + usces_save_order_acting_error( $log );
92 + usces_log( 'Veritrans construct : error1', 'acting_transaction.log' );
93 + } else {
94 + usces_log( 'Veritrans construct : ' . $orderid, 'acting_transaction.log' );
95 + }
96 + }
97 +}
98 +
99 +/**
100 + * 決済通知(サーバー間・ブラウザ Cookie 無し)で、確定時に保存したカート/エントリを DBストア
101 + * (usces_access)から $_SESSION へ復元する。uscesid セッション橋渡しの置き換え(Layer 3 / A3)。
102 + *
103 + * usces_session_start()(コンストラクタ末尾)より後・usces_main() の `new usces_cart()` より前に
104 + * 実行する必要があるため usces_main フックに登録する(construct では直後の @session_start() に
105 + * 上書きされてしまうため)。復元後、usces_cart 生成 → usces_after_cart_instant
106 + * (usces_action_acting_transaction)が $usces->cart->get_cart() を参照して処理する。
107 + *
108 + * 対象はサーバー間通知でセッション復元が要る remise / digitalcheck_conv / AnotherLane。
109 + *
110 + * usces_main
111 + */
112 +function usces_restore_acting_session_from_store() {
113 + $rand = '';
114 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) && isset( $_POST['X-S_TORIHIKI_NO'] ) ) {
115 + /* remise: 決済成功時(X-ERRLEVEL == 0)のみ復元 */
116 + if ( isset( $_POST['X-ERRLEVEL'] ) && 0 == $_POST['X-ERRLEVEL'] ) {
117 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
118 + }
119 + } elseif ( isset( $_POST['SID'] ) && isset( $_POST['FUKA'] ) && isset( $_POST['CVS'] ) ) {
120 + /* digitalcheck_conv */
121 + $rand = wp_unslash( $_POST['SID'] );
122 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['rand'] ) ) {
123 + /* AnotherLane: 通知は $_REQUEST(GET/POST 両様)。旧 usces_action_acting_construct の
124 + * $_GET['uscesid']=$datas['sesid'] ブリッジの置き換え。KickType サーバー通知で order_processing()
125 + * がカートを読む前にここで DBストアから復元する。 */
126 + $rand = wp_unslash( $_REQUEST['rand'] );
127 + }
128 +
129 + if ( '' === $rand ) {
130 + return;
131 + }
132 +
133 + $datas = usces_get_order_acting_data( $rand );
134 + if ( empty( $datas ) || empty( $datas['order_data'] ) ) {
135 + return;
136 + }
137 +
138 + $order_data = wel_safe_maybe_unserialize( $datas['order_data'] );
139 + if ( ! is_array( $order_data ) ) {
140 + return;
141 + }
142 +
143 + if ( isset( $order_data['cart'] ) && is_array( $order_data['cart'] ) ) {
144 + /*
145 + * DBストア(usces_access)の cart は save_order_acting_data() が保存した
146 + * $usces->cart->get_cart() の「出力形式」= [ i => array( serial, post_id, sku, options,
147 + * price, unit_price, quantity, advance ) ](インデックス配列)。
148 + * 一方 $_SESSION['usces_cart'] の「内部形式」は
149 + * [ '<serial>' => array( 'price', 'unit_price', 'quant', 'advance' ) ](serial をキーにしたマップ)で、
150 + * usces_cart::get_cart()/key_unserialize() はこの内部形式を前提に読む
151 + * (キー=serial/数量キーは 'quant')。そのまま代入すると整数キー 0 が serial として
152 + * unserialize され false → array_keys(false) で致命的エラーになるため、内部形式へ変換して復元する。
153 + */
154 + $session_cart = array();
155 + foreach ( $order_data['cart'] as $item ) {
156 + if ( ! is_array( $item ) || ! isset( $item['serial'] ) ) {
157 + continue;
158 + }
159 + $session_cart[ $item['serial'] ] = array(
160 + 'price' => isset( $item['price'] ) ? $item['price'] : 0,
161 + 'unit_price' => isset( $item['unit_price'] ) ? $item['unit_price'] : 0,
162 + 'quant' => isset( $item['quantity'] ) ? $item['quantity'] : 0,
163 + 'advance' => isset( $item['advance'] ) ? $item['advance'] : '',
164 + );
165 + }
166 + $_SESSION['usces_cart'] = $session_cart;
167 + }
168 + if ( isset( $order_data['entry'] ) ) {
169 + $_SESSION['usces_entry'] = $order_data['entry'];
170 + }
171 + usces_log( 'acting session restored from DB store (uscesid-independent) : ' . $rand, 'acting_transaction.log' );
172 +}
173 +
174 +/**
175 + * 決済結果通知の送信元IPが許可リストに含まれるか判定する。
176 + *
177 + * @param string $remote_addr Source IP address of the notification.
178 + * @param array|string $allowed Allowed IP addresses / CIDR ranges.
179 + * @return bool True when the source IP is allowed.
180 + */
181 +function usces_acting_notice_ip_allowed( $remote_addr, $allowed ) {
182 + if ( empty( $remote_addr ) || empty( $allowed ) ) {
183 + return false;
184 + }
185 + $remote_long = ip2long( $remote_addr );
186 + if ( false === $remote_long ) {
187 + return false;
188 + }
189 + foreach ( (array) $allowed as $entry ) {
190 + $entry = trim( (string) $entry );
191 + if ( '' === $entry ) {
192 + continue;
193 + }
194 + if ( false !== strpos( $entry, '/' ) ) {
195 + list( $subnet, $bits ) = explode( '/', $entry, 2 );
196 + $subnet_long = ip2long( $subnet );
197 + $bits = (int) $bits;
198 + if ( false === $subnet_long || $bits < 1 || 32 < $bits ) {
199 + continue;
200 + }
201 + $mask = ( 0xFFFFFFFF << ( 32 - $bits ) ) & 0xFFFFFFFF;
202 + if ( ( $remote_long & $mask ) === ( $subnet_long & $mask ) ) {
203 + return true;
204 + }
205 + } elseif ( ip2long( $entry ) === $remote_long ) {
206 + return true;
207 + }
208 + }
209 + return false;
210 +}
211 +
212 +/**
213 + * Settlement Result Notification Processing.
214 + * usces_after_cart_instant
215 + */
216 +function usces_action_acting_transaction() {
217 + global $usces, $wpdb;
218 +
219 + /* remise_card */
220 + if ( isset( $_POST['X-TRANID'] ) && ! isset( $_POST['OPT'] ) ) {
221 + $data = array();
222 + foreach ( $_POST as $key => $value ) {
223 + $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
224 + }
225 + /* 決済エラーの場合は、エラーログを残してdie */
226 + if ( 0 != $data['X-ERRLEVEL'] ) {
227 + $log = array(
228 + 'acting' => 'remise_card',
229 + 'key' => $data['S_TORIHIKI_NO'],
230 + 'result' => $data['X-ERRCODE'],
231 + 'data' => $data,
232 + );
233 + usces_save_order_acting_error( $log );
234 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
235 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
236 + }
237 + usces_log( 'remise acting_transaction : ' . print_r( $data, true ), 'acting_transaction.log' );
238 +
239 + $rand = wp_unslash( $_POST['X-S_TORIHIKI_NO'] );
240 +
241 + /* カード情報更新 */
242 + if ( '0000000' === substr( $rand, 0, 7 ) ) { /* card up */
243 + usces_log( 'remise card_update : ' . print_r( $data, true ), 'acting_transaction.log' );
244 + if ( isset( $_POST['X-AC_S_KAIIN_NO'] ) ) {
245 + if ( isset( $_POST['X-EXPIRE'] ) ) {
246 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
247 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
248 + $usces->set_member_meta_value( 'limitofcard', $limitofcard, wp_unslash( $_POST['X-AC_S_KAIIN_NO'] ) );
249 + }
250 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
251 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ), wp_unslash( $_POST['X-AC_S_KAIIN_NO'] ) );
252 + }
253 + } elseif ( isset( $_POST['X-PAYQUICKID'] ) ) {
254 + $member_id = substr( $rand, 7 );
255 + if ( $member_id ) {
256 + $usces->set_member_meta_value( 'remise_pcid', wp_unslash( $_POST['X-PAYQUICKID'] ), (int) $member_id );
257 + if ( isset( $_POST['X-EXPIRE'] ) ) {
258 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
259 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
260 + $usces->set_member_meta_value( 'limitofcard', $limitofcard, (int) $member_id );
261 + }
262 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
263 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ), (int) $member_id );
264 + }
265 + }
266 + }
267 +
268 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
269 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
270 + }
271 +
272 + $cart = $usces->cart->get_cart();
273 + /* カートが無い(セッションが無い)場合、エラーログを残し、ルミーズにはerrorを返却 */
274 + if ( empty( $cart ) ) {
275 + usces_log( 'remise card error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
276 + $log = array(
277 + 'acting' => 'remise',
278 + 'key' => wp_unslash( $_POST['X-S_TORIHIKI_NO'] ),
279 + 'result' => 'SESSION TIME OUT',
280 + 'data' => wp_unslash( $_POST ),
281 + );
282 + usces_save_order_acting_error( $log );
283 + die( 'SESSION TIME OUT' );
284 +
285 + /* セッションが存在する場合は、STATUSを返却 */
286 + } else {
287 + if ( isset( $_POST['X-PAYQUICKID'] ) ) {
288 + $usces->set_member_meta_value( 'remise_pcid', wp_unslash( $_POST['X-PAYQUICKID'] ) );
289 + }
290 + if ( isset( $_POST['X-AC_MEMBERID'] ) ) {
291 + $usces->set_member_meta_value( 'remise_memid', wp_unslash( $_POST['X-AC_MEMBERID'] ) );
292 + }
293 + if ( isset( $_POST['X-EXPIRE'] ) ) {
294 + $expire = wp_unslash( $_POST['X-EXPIRE'] );
295 + $limitofcard = substr( $expire, 0, 2 ) . '/' . substr( $expire, 2, 2 );
296 + $usces->set_member_meta_value( 'limitofcard', $limitofcard );
297 + }
298 + if ( isset( $_POST['X-PARTOFCARD'] ) ) {
299 + $usces->set_member_meta_value( 'partofcard', wp_unslash( $_POST['X-PARTOFCARD'] ) );
300 + }
301 + usces_log( 'remise card transaction : ' . wp_unslash( $_POST['X-TRANID'] ), 'acting_transaction.log' );
302 + $status = ( isset( $_POST['CARIER_TYPE'] ) ) ? '900' : '800';
303 + die( '<SDBKDATA>STATUS=' . $status . '</SDBKDATA>' );
304 + }
305 +
306 + /* remise_conv */
307 + } elseif ( isset( $_POST['S_TORIHIKI_NO'] ) && isset( $_POST['REC_FLG'] ) ) {
308 + $data = array();
309 + foreach ( $_POST as $key => $value ) {
310 + $data[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'SJIS' );
311 + }
312 + REMISE_SETTLEMENT::get_instance()->acting_notice_ip_guard( $data );
313 +
314 + $table_name = $wpdb->prefix . 'usces_order';
315 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
316 +
317 + $mquery = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', wp_unslash( $_POST['S_TORIHIKI_NO'] ) );
318 + $order_id = $wpdb->get_var( $mquery );
319 + if ( null == $order_id ) {
320 + $log = array(
321 + 'acting' => 'remise_conv',
322 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
323 + 'result' => 'ORDER DATA KEY ERROR',
324 + 'data' => wp_unslash( $_POST ),
325 + );
326 + usces_save_order_acting_error( $log );
327 + usces_log( 'remise conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
328 + die( 'error1' );
329 + }
330 +
331 + $res = usces_change_order_receipt( $order_id, 'receipted' );
332 + if ( false === $res ) {
333 + $log = array(
334 + 'acting' => 'remise_conv',
335 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
336 + 'result' => 'ORDER DATA UPDATE ERROR',
337 + 'data' => wp_unslash( $_POST ),
338 + );
339 + usces_save_order_acting_error( $log );
340 + usces_log( 'remise conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
341 + die( 'error2' );
342 + }
343 +
344 + $datastr = serialize( $data );
345 + $mquery = $wpdb->prepare( "UPDATE $table_meta_name SET meta_value = %s WHERE meta_key = %s AND order_id = %d", $datastr, 'settlement_id', $order_id );
346 + $res = $wpdb->query( $mquery );
347 + if ( false === $res ) {
348 + $log = array(
349 + 'acting' => 'remise_conv',
350 + 'key' => wp_unslash( $_POST['S_TORIHIKI_NO'] ),
351 + 'result' => 'ORDER META DATA UPDATE ERROR',
352 + 'data' => wp_unslash( $_POST ),
353 + );
354 + usces_save_order_acting_error( $log );
355 + usces_log( 'remise conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
356 + die( 'error3' );
357 + }
358 +
359 + usces_action_acting_getpoint( $order_id );
360 +
361 + usces_log( 'remise conv transaction : ' . wp_unslash( $_POST['S_TORIHIKI_NO'] ), 'acting_transaction.log' );
362 + die( '<SDBKDATA>STATUS=800</SDBKDATA>' );
363 +
364 + /* jpayment_card */
365 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_card' == $_REQUEST['acting'] ) {
366 +
367 + /* jpayment_conv */
368 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_conv' == $_REQUEST['acting'] && isset( $_GET['ap'] ) ) {
369 + switch ( $_GET['ap'] ) {
370 + case 'CPL_PRE': /* コンビニペーパーレス決済識別コード */
371 + break;
372 +
373 + case 'CPL': /* 入金確定 */
374 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
375 + $acting = wp_unslash( $_REQUEST['acting'] );
376 + $data = array();
377 + foreach ( $_GET as $key => $value ) {
378 + $data[ $key ] = esc_sql( $value );
379 + }
380 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
381 +
382 + $table_name = $wpdb->prefix . 'usces_order';
383 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
384 +
385 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $cod );
386 + $order_id = $wpdb->get_var( $query );
387 + if ( null == $order_id ) {
388 + $log = array(
389 + 'acting' => $acting,
390 + 'key' => $cod,
391 + 'result' => 'ORDER DATA KEY ERROR',
392 + 'data' => $data,
393 + );
394 + usces_save_order_acting_error( $log );
395 + usces_log( 'ROBOT PAYMENT conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
396 + die( 'error1' );
397 + }
398 +
399 + $res = usces_change_order_receipt( $order_id, 'receipted' );
400 + if ( false === $res ) {
401 + $log = array(
402 + 'acting' => $acting,
403 + 'key' => $cod,
404 + 'result' => 'ORDER DATA UPDATE ERROR',
405 + 'data' => $data,
406 + );
407 + usces_save_order_acting_error( $log );
408 + usces_log( 'ROBOT PAYMENT conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
409 + die( 'error2' );
410 + }
411 +
412 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
413 + if ( false === $res ) {
414 + $log = array(
415 + 'acting' => $acting,
416 + 'key' => $cod,
417 + 'result' => 'ORDER META DATA UPDATE ERROR',
418 + 'data' => $data,
419 + );
420 + usces_save_order_acting_error( $log );
421 + usces_log( 'ROBOT PAYMENT conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
422 + die( 'error3' );
423 + }
424 +
425 + usces_action_acting_getpoint( $order_id );
426 +
427 + usces_log( 'ROBOT PAYMENT conv transaction : ' . $data['gid'], 'acting_transaction.log' );
428 + die( 'ROBOT PAYMENT' );
429 + break;
430 +
431 + case 'CVS_CAN': /* 入金取消 */
432 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
433 + $acting = wp_unslash( $_REQUEST['acting'] );
434 + $data = array();
435 + foreach ( $_GET as $key => $value ) {
436 + $data[ $key ] = esc_sql( $value );
437 + }
438 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
439 +
440 + $table_name = $wpdb->prefix . 'usces_order';
441 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
442 +
443 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'settlement_id', $cod );
444 + $order_id = $wpdb->get_var( $query );
445 + if ( null == $order_id ) {
446 + $log = array(
447 + 'acting' => $acting,
448 + 'key' => $cod,
449 + 'result' => 'ORDER DATA KEY ERROR',
450 + 'data' => $data,
451 + );
452 + usces_save_order_acting_error( $log );
453 + usces_log( 'ROBOT PAYMENT conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
454 + die( 'error1' );
455 + }
456 +
457 + $res = usces_change_order_receipt( $order_id, 'noreceipt' );
458 + if ( false === $res ) {
459 + $log = array(
460 + 'acting' => $acting,
461 + 'key' => $cod,
462 + 'result' => 'ORDER DATA UPDATE ERROR',
463 + 'data' => $data,
464 + );
465 + usces_save_order_acting_error( $log );
466 + usces_log( 'ROBOT PAYMENT conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
467 + die( 'error2' );
468 + }
469 +
470 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
471 + if ( false === $res ) {
472 + $log = array(
473 + 'acting' => $acting,
474 + 'key' => $cod,
475 + 'result' => 'ORDER META DATA UPDATE ERROR',
476 + 'data' => $data,
477 + );
478 + usces_save_order_acting_error( $log );
479 + usces_log( 'ROBOT PAYMENT conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
480 + die( 'error3' );
481 + }
482 +
483 + usces_action_acting_getpoint( $order_id, false );
484 +
485 + usces_log( 'ROBOT PAYMENT conv transaction : ' . $data['gid'], 'acting_transaction.log' );
486 + die( 'ROBOT PAYMENT' );
487 + break;
488 + }
489 +
490 + /* jpayment_bank */
491 + } elseif ( isset( $_REQUEST['acting'] ) && 'jpayment_bank' == $_REQUEST['acting'] && isset( $_GET['ap'] ) ) {
492 + switch ( $_GET['ap'] ) {
493 + case 'BANK': /* 受付完了 */
494 + break;
495 +
496 + case 'BAN_SAL': /* 入金完了 */
497 + JPAYMENT_SETTLEMENT::get_instance()->acting_notice_ip_guard();
498 + if ( isset( $_GET['mf'] ) && '1' == wp_unslash( $_GET['mf'] ) ) { /* 入金マッチングの場合 */
499 + $acting = wp_unslash( $_REQUEST['acting'] );
500 + $data = array();
501 + foreach ( $_GET as $key => $value ) {
502 + $data[ $key ] = esc_sql( $value );
503 + }
504 + $cod = ( isset( $data['cod'] ) ) ? $data['cod'] : '';
505 +
506 + $table_name = $wpdb->prefix . 'usces_order';
507 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
508 +
509 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'settlement_id', $cod );
510 + $order_id = $wpdb->get_var( $query );
511 + if ( null == $order_id ) {
512 + $log = array(
513 + 'acting' => $acting,
514 + 'key' => $cod,
515 + 'result' => 'ORDER DATA KEY ERROR',
516 + 'data' => $data,
517 + );
518 + usces_save_order_acting_error( $log );
519 + usces_log( 'ROBOT PAYMENT bank error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
520 + die( 'error1' );
521 + }
522 +
523 + $res = usces_change_order_receipt( $order_id, 'receipted' );
524 + if ( false === $res ) {
525 + $log = array(
526 + 'acting' => $acting,
527 + 'key' => $cod,
528 + 'result' => 'ORDER DATA UPDATE ERROR',
529 + 'data' => $data,
530 + );
531 + usces_save_order_acting_error( $log );
532 + usces_log( 'ROBOT PAYMENT bank error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
533 + die( 'error2' );
534 + }
535 +
536 + $res = $usces->set_order_meta_value( 'acting_' . $acting, serialize( $data ), $order_id );
537 + if ( false === $res ) {
538 + $log = array(
539 + 'acting' => $acting,
540 + 'key' => $cod,
541 + 'result' => 'ORDER META DATA UPDATE ERROR',
542 + 'data' => $data,
543 + );
544 + usces_save_order_acting_error( $log );
545 + usces_log( 'ROBOT PAYMENT bank error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
546 + die( 'error3' );
547 + }
548 +
549 + usces_action_acting_getpoint( $order_id );
550 + }
551 +
552 + usces_log( 'ROBOT PAYMENT bank transaction : ' . $data['gid'], 'acting_transaction.log' );
553 + die( 'ROBOT PAYMENT' );
554 + break;
555 + }
556 +
557 + /* PayPal ipn */
558 + } elseif ( ! isset( $_GET['acting_return'] ) && ( isset( $_GET['acting'] ) && 'paypal_ipn' == wp_unslash( $_GET['acting'] ) ) ) {
559 + if ( file_exists( $usces->options['settlement_path'] . 'paypal.php' ) ) {
560 + $data = array();
561 + foreach ( $_REQUEST as $key => $value ) {
562 + $data[ $key ] = $value;
563 + }
564 + usces_log( 'paypal_ipn in ' . print_r( $data, true ), 'acting_transaction.log' );
565 + require_once( $usces->options['settlement_path'] . 'paypal.php' );
566 + $ipn_res = paypal_ipn_check( $usces_paypal_url );
567 + if ( true === $ipn_res[0] ) {
568 + $res = $usces->order_processing( $ipn_res );
569 + if ( 'ordercompletion' == $res ) {
570 + $usces->cart->crear_cart();
571 + } else {
572 + usces_log( 'paypal_ipn error : ' . print_r( $data, true ), 'acting_transaction.log' );
573 + die( 'error1' );
574 + }
575 + do_action( 'usces_action_paypal_ipn', $res, $ipn_res );
576 + }
577 + usces_log( 'PayPal IPN transaction : ' . wp_unslash( $_REQUEST['txn_id'] ), 'acting_transaction.log' );
578 + }
579 + die( 'PayPal' );
580 +
581 + /* telecom edy 提供対象外のため無効化. CVE-2026-19887(PHP Object Injection)対応.
582 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && ( isset( $_REQUEST['acting'] ) && 'telecom_edy' == $_REQUEST['acting'] ) ) {
583 + $data = array();
584 + foreach ( $_REQUEST as $key => $value ) {
585 + $data[ $key ] = $value;
586 + }
587 + usces_log( 'telecom edy : ' . print_r( $data, true ), 'acting_transaction.log' );
588 +
589 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && isset( $_REQUEST['edy'] ) ) {
590 + $data = array();
591 + foreach ( $_REQUEST as $key => $value ) {
592 + $data[ $key ] = $value;
593 + }
594 + if ( 'yes' === wp_unslash( $_REQUEST['rel'] ) && isset( $_REQUEST['option'] ) ) {
595 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
596 + $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", wp_unslash( $_REQUEST['option'] ) );
597 + $mvalue = $wpdb->get_row( $mquery, ARRAY_A );
598 + $value = wel_safe_maybe_unserialize( $mvalue['meta_value'] );
599 + $_SESSION['usces_cart'] = $value['usces_cart'];
600 + $_SESSION['usces_entry'] = $value['usces_entry'];
601 + $_SESSION['usces_member'] = $value['usces_member'];
602 + $res = $usces->order_processing();
603 + if ( 'ordercompletion' == $res ) {
604 + $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", wp_unslash( $_REQUEST['option'] ) );
605 + $res = $wpdb->query( $query );
606 + usces_log( 'telecom edy - Payment confirmation : ' . print_r( $data, true ), 'acting_transaction.log' );
79 607 } else {
80 - usces_log('Paygent construct : '.$_POST['trading_id'], 'acting_transaction.log');
608 + $log = array(
609 + 'acting' => 'telecom_edy',
610 + 'key' => wp_unslash( $_REQUEST['option'] ),
611 + 'result' => 'ORDER DATA REGISTERED ERROR',
612 + 'data' => wp_unslash( $_REQUEST ),
613 + );
614 + usces_save_order_acting_error( $log );
615 + usces_log( 'telecom edy - Error 1 : ' . print_r( $data, true ), 'acting_transaction.log' );
81 616 }
617 + } else {
618 + $log = array(
619 + 'acting' => 'telecom_edy',
620 + 'key' => wp_unslash( $_REQUEST['option'] ),
621 + 'result' => wp_unslash( $_REQUEST['rel'] ),
622 + 'data' => wp_unslash( $_REQUEST ),
623 + );
624 + usces_save_order_acting_error( $log );
625 + usces_log( 'telecom edy - Error 2 : ' . print_r( $data, true ), 'acting_transaction.log' );
82 626 }
627 + die( 'SuccessOK' );
628 + */
83 629
84 - }
85 -}
86 -
87 -function usces_action_acting_transaction(){
88 - global $usces, $wpdb;
89 -
90 - //*** remise_card ***//
91 - if(isset($_POST['X-TRANID']) && !isset($_POST['OPT'])){
92 - foreach( $_POST as $key => $value ){
93 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
94 - }
95 - usces_log('remise acting_transaction : '.print_r($data, true), 'acting_transaction.log');
96 -
97 - $rand = $_POST['X-S_TORIHIKI_NO'];
98 -// if( empty($rand) ){
99 -// usces_log('remise card error1 : '.print_r($data, true), 'acting_transaction.log');
100 -// die('error1');
101 -// }else{
102 -// $res = usces_check_notification_time( $rand, 15 );
103 -// if( !$res )
104 -// die('error : time over');
105 -// }
106 -//
107 -// if( 0 !== (int)$_POST['X-ERRLEVEL'] ){
108 -// usces_log('remise card error2 : '.print_r($data, true), 'acting_transaction.log');
109 -// die('error2');
110 -// }
111 -
112 - if( '0000000' === substr($rand, 0, 7) ){//card up
113 - usces_log('remise card_update : '.print_r($data, true), 'acting_transaction.log');
114 - if( isset($_POST['X-EXPIRE']) ){
115 - $expire = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2);
116 - $usces->set_member_meta_value('limitofcard', $expire, $_POST['X-AC_S_KAIIN_NO']);
117 - }
118 - if( isset($_POST['X-PARTOFCARD']) )
119 - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD'], $_POST['X-AC_S_KAIIN_NO']);
120 -
121 -//20120510ysk start
122 - //die('<SDBKDATA>STATUS=800</SDBKDATA>');
123 - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800';
124 - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>');
125 -//20120510ysk end
126 - }
127 -
128 -//20110203ysk start
129 -// $res = $usces->order_processing();
130 -// if( 'error' == $res ){
131 -// usces_log('remise card error3 : '.print_r($data, true), 'acting_transaction.log');
132 -// die('error3');
133 -// }else{
134 - if( isset($_POST['X-PAYQUICKID']) )
135 - $usces->set_member_meta_value('remise_pcid', $_POST['X-PAYQUICKID']);
136 - if( isset($_POST['X-AC_MEMBERID']) )
137 - $usces->set_member_meta_value('remise_memid', $_POST['X-AC_MEMBERID']);
138 -//20120511ysk start
139 - if( isset($_POST['X-EXPIRE']) ) {
140 - $limitofcard = substr($_POST['X-EXPIRE'], 0, 2) . '/' . substr($_POST['X-EXPIRE'], 2, 2);
141 - $usces->set_member_meta_value('limitofcard', $limitofcard);
142 - }
143 - if( isset($_POST['X-PARTOFCARD']) )
144 - $usces->set_member_meta_value('partofcard', $_POST['X-PARTOFCARD']);
145 -//20120511ysk end
146 - usces_log('remise card transaction : '.$_POST['X-TRANID'], 'acting_transaction.log');
147 -//20120510ysk start
148 - //die('<SDBKDATA>STATUS=800</SDBKDATA>');
149 - $status = (isset($_POST['CARIER_TYPE'])) ? '900' : '800';
150 - die('<SDBKDATA>STATUS='.$status.'</SDBKDATA>');
151 -//20120510ysk end
152 -// }
153 -//20110203ysk end
154 -
155 - //*** remise_conv ***//
156 - }elseif( isset($_POST['S_TORIHIKI_NO']) && isset($_POST['REC_FLG']) ){
157 - foreach( $_POST as $key => $value ){
158 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
159 - }
160 -
161 - $table_name = $wpdb->prefix . "usces_order";
162 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
163 -
164 - $mquery = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_POST['S_TORIHIKI_NO']);
165 - $order_id = $wpdb->get_var( $mquery );
166 - if( $order_id == NULL ){
167 - usces_log('remise conv error1 : '.print_r($data, true), 'acting_transaction.log');
168 - die('error1');
169 - }
170 -
171 - $mquery = $wpdb->prepare("
172 - UPDATE $table_name SET order_status =
173 - CASE
174 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
175 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
176 - ELSE CONCAT('receipted,', order_status )
177 - END
178 - WHERE ID = %d", $order_id);
179 - $res = $wpdb->query( $mquery );
180 - if( $res === false ){
181 - usces_log('remise conv error2 : '.print_r($data, true), 'acting_transaction.log');
182 - die('error2');
183 - }
184 -
185 - $datastr = serialize( $data );
186 - $mquery = $wpdb->prepare(
187 - "UPDATE $table_meta_name SET meta_value = %s WHERE meta_key = %s AND order_id = %d", $datastr, 'settlement_id', $order_id);
188 - $res = $wpdb->query( $mquery );
189 - if( $res === false ){
190 - usces_log('remise conv error3 : '.print_r($data, true), 'acting_transaction.log');
191 - die('error3');
192 - }
193 -
194 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
195 -
196 - //usces_send_receipted_mail( $order_id, 'remise_conv' );
197 - usces_log('remise conv transaction : '.$_POST['S_TORIHIKI_NO'], 'acting_transaction.log');
198 - die('<SDBKDATA>STATUS=800</SDBKDATA>');
199 -
200 - //*** zeus_card ***//
201 - }elseif( isset($_REQUEST['acting']) && 'zeus_card' == $_REQUEST['acting'] && isset($_REQUEST['result']) && isset($_REQUEST['ordd']) ){
202 - foreach( $_REQUEST as $key => $value ){
203 - $data[$key] = $value;
204 - }
205 - usces_log('zeus card cgi : '.print_r($data, true), 'acting_transaction.log');
206 -
207 - $rand = $_GET['sendpoint'];
208 - if( empty($rand) ){
209 - usces_log('zeus card error1 : '.print_r($data, true), 'acting_transaction.log');
210 - die('error1');
211 - }
212 -
213 - if( 'OK' == $_REQUEST['result'] ){
214 - $acting_opts = $usces->options['acting_settings']['zeus'];
215 - if( $usces->is_member_logged_in() ) {
216 - if( isset($_GET['cardnumber']) ) {
217 - $usces->set_member_meta_value( 'zeus_partofcard', $_GET['cardnumber'] );
218 - if( 'on' == $acting_opts['quickcharge'] ) {
219 - $usces->set_member_meta_value( 'zeus_pcid', '8888888888888888' );
220 - }
221 - }
222 - }
223 - header("HTTP/1.0 200 OK");
224 - die('zeus');
225 -
226 - }else{
227 - header("HTTP/1.0 200 OK");
228 - die('error3');
229 - }
230 -
231 - //*** zeus_bank ***//
232 - }elseif( isset($_REQUEST['acting']) && 'zeus_bank' == $_REQUEST['acting'] && isset($_REQUEST['order_no']) && isset($_REQUEST['tracking_no']) ){
233 - foreach( $_REQUEST as $key => $value ){
234 - $data[$key] = $value;
235 - }
236 - usces_log('zeus bank cgi data : '.print_r($data,true), 'acting_transaction.log');
237 -
238 -//20130426ysk start 0000701
239 - if( '04' === $_REQUEST['status'] or '05' === $_REQUEST['status'] ) {
240 - usces_log( 'zeus bank error0 : status='.$_REQUEST['status'], 'acting_transaction.log' );
241 - die('error0');
242 - }
243 -//20130426ysk end
244 -
245 - $acting_opts = $usces->options['acting_settings']['zeus'];
246 -
247 - $table_name = $wpdb->prefix . "usces_order";
248 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
249 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
250 - $values = $wpdb->get_row( $mquery, ARRAY_A );
251 -
252 - if( $values == NULL ){
253 -
254 -//20110203ysk start
255 - $res = $usces->order_processing();
256 - if( 'error' == $res ){
257 - usces_log('zeus bank error1 : order_processing', 'acting_transaction.log');
258 - die('error1');
259 - }else{
260 - usces_log('zeus bank order : OK', 'acting_transaction.log');
261 - $order_id = $usces->cart->get_order_entry('ID');
262 - $value = serialize($_GET);
263 - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['tracking_no'], $value);
264 - $res = $wpdb->query( $query );
265 -
266 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['tracking_no']);
267 - $values = $wpdb->get_row( $mquery, ARRAY_A );
268 - $usces->cart->crear_cart();
269 - }
270 -//20110203ysk end
271 - }
272 -
273 - //usces_log('zeus construct_values2 : '.print_r($values,true), 'acting_transaction.log');
274 - $value = unserialize($values['meta_value']);
275 - $status = ( '03' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
276 - $order_id = $values['order_id'];
277 - //$add_point = true;//20120306ysk 0000324
278 - if( 'receipted,' == $status ){
279 - $mquery = $wpdb->prepare("
280 - UPDATE $table_name SET order_status =
281 - CASE
282 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
283 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
284 - ELSE CONCAT('receipted,', order_status )
285 - END
286 - WHERE ID = %d", $order_id);
287 - }else{
288 - $mquery = $wpdb->prepare("
289 - UPDATE $table_name SET order_status =
290 - CASE
291 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
292 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
293 - ELSE CONCAT('noreceipt,', order_status )
294 - END
295 - WHERE ID = %d", $order_id);
296 - //$add_point = false;//20120306ysk 0000324
297 - }
298 - $res = $wpdb->query( $mquery );
299 - if( false === $res ){
300 - //usces_log('zeus bank error2 : '.print_r($data, true), 'acting_transaction.log');
301 - usces_log('zeus bank error2 : update usces_order', 'acting_transaction.log');
302 - die('error2');
303 - }
304 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
305 - if( '03' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
306 -
307 - $upvalue = array( 'acting' => $_GET['acting'], 'order_no' => $_GET['order_no'], 'tracking_no' => $_GET['tracking_no'], 'status' => $_GET['status'], 'error_message' => $_GET['error_message'], 'money' => $_GET['money'] );
308 - $mquery = $wpdb->prepare("UPDATE $table_meta_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", serialize($upvalue), $order_id, 'acting_'.$_REQUEST['tracking_no']);
309 - //usces_log('mquery2 : '.print_r($mquery, true), 'acting_transaction.log');
310 - $res = $wpdb->query( $mquery );
311 - if(!$res){
312 - //usces_log('zeus bank error3 : '.print_r($data, true), 'acting_transaction.log');
313 - usces_log('zeus bank error3 : update usces_order_meta', 'acting_transaction.log');
314 - die('error3');
315 - }
316 -
317 - usces_log('zeus bank transaction : '.$_REQUEST['tracking_no'], 'acting_transaction.log');
318 - die('zeus');
319 -
320 - //*** zeus_conv ***//
321 - }elseif( isset($_REQUEST['acting']) && 'zeus_conv' == $_REQUEST['acting'] && isset($_REQUEST['status']) && isset($_REQUEST['sendpoint']) ){
322 - foreach( $_REQUEST as $key => $value ){
323 - $data[$key] = $value;
324 - }
325 - usces_log('zeus conv cgi data : '.print_r($data,true), 'acting_transaction.log');
326 -
327 - $acting_opts = $usces->options['acting_settings']['zeus'];
328 -
329 - $table_name = $wpdb->prefix . "usces_order";
330 - $table_meta_name = $wpdb->prefix . "usces_order_meta";
331 - $mquery = $wpdb->prepare("SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", 'acting_'.$_REQUEST['sendpoint']);
332 - $values = $wpdb->get_row( $mquery, ARRAY_A );
333 - if( $values == NULL ){
334 -
335 -//20110203ysk start
336 -/* $res = $usces->order_processing();
337 -
338 - if( 'error' == $res ){
339 - usces_log('zeus conv error1 : '.print_r($data, true), 'acting_transaction.log');
340 - die('error1');
341 - }else{
342 - $order_id = $usces->cart->get_order_entry('ID');
343 - $value = serialize($_GET);
344 - $query = $wpdb->prepare("INSERT INTO $table_meta_name (order_id, meta_key, meta_value) VALUES (%d, %s, %s)", $order_id, 'acting_'.$_REQUEST['sendpoint'], $value);
345 - $res = $wpdb->query( $query );
346 - usces_log('zeus conv ordered : OK', 'acting_transaction.log');
347 - }*/
348 -//20110203ysk end
349 -
350 - }else{
351 - if( '05' !== $_REQUEST['status'] ) {//20131128ysk 0000794
352 - $value = unserialize($values['meta_value']);
353 - $status = ( '04' === $_REQUEST['status'] ) ? 'receipted,' : 'noreceipt,';
354 - $order_id = $values['order_id'];
355 - //$add_point = true;//20120306ysk 0000324
356 - if( 'receipted,' == $status ){
357 - $mquery = $wpdb->prepare("
358 - UPDATE $table_name SET order_status =
359 - CASE
360 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
361 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
362 - ELSE CONCAT('receipted,', order_status )
363 - END
364 - WHERE ID = %d", $order_id);
365 - }else{
366 - $mquery = $wpdb->prepare("
367 - UPDATE $table_name SET order_status =
368 - CASE
369 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
370 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
371 - ELSE CONCAT('noreceipt,', order_status )
372 - END
373 - WHERE ID = %d", $order_id);
374 - //$add_point = false;//20120306ysk 0000324
375 - }
376 - $res = $wpdb->query( $mquery );
377 - if(!$res){
378 - usces_log('zeus conv error2 : '.print_r($data, true), 'acting_transaction.log');
379 - die('error2');
380 - }
381 -
382 - foreach( $_GET as $key => $v ){
383 - $newvalue[$key] = mb_convert_encoding($v, 'UTF-8', 'SJIS');
384 - }
385 - $value = serialize($newvalue);
386 - $mquery = $wpdb->prepare("UPDATE $table_meta_name SET meta_value = %s WHERE order_id = %d AND meta_key = %s", $value, $order_id, 'acting_'.$_REQUEST['sendpoint']);
387 - $res = $wpdb->query( $mquery );
388 - if(!$res){
389 - usces_log('zeus conv error3 : '.print_r($data, true), 'acting_transaction.log');
390 - die('error3');
391 - }
392 - //usces_action_acting_getpoint( $order_id, $add_point );//20120306ysk 0000324
393 - if( '04' === $_REQUEST['status'] ) usces_action_acting_getpoint( $order_id );//20140130ysk
394 - }
395 - }
396 -
397 - usces_log('zeus conv transaction : '.$_REQUEST['sendpoint'], 'acting_transaction.log');
398 - die('zeus');
399 -
400 -//20101018ysk start
401 - //*** jpayment_card ***//
402 - } elseif(isset($_REQUEST['acting']) && 'jpayment_card' == $_REQUEST['acting']) {
403 - //$args='';
404 - //foreach((array)$_GET as $key => $value) {
405 - // $args.='&('.$key.')=('.$value.')';
406 - //}
407 - //usces_log('jpayment card : '.$args, 'acting_transaction.log');
408 -
409 - //*** jpayment_conv ***//
410 - } elseif(isset($_REQUEST['acting']) && 'jpayment_conv' == $_REQUEST['acting'] && isset($_GET['ap'])) {
411 - //$args='';
412 - //foreach((array)$_GET as $key => $value) {
413 - // $args.='&('.$key.')=('.$value.')';
414 - //}
415 - //usces_log('jpayment conv : '.$args, 'acting_transaction.log');
416 - foreach( $_REQUEST as $key => $value ){
417 - $data[$key] = $value;
418 - }
419 -
420 - switch($_GET['ap']) {
421 - case 'CPL_PRE'://コンビニペーパーレス決済識別コード
422 - break;
423 -
424 - case 'CPL'://入金確定
425 - $table_name = $wpdb->prefix."usces_order";
426 - $table_meta_name = $wpdb->prefix."usces_order_meta";
427 -
428 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
429 - $order_id = $wpdb->get_var($query);
430 - if($order_id == NULL) {
431 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
432 - die('error1');
433 - }
434 -
435 - $query = $wpdb->prepare("
436 - UPDATE $table_name SET order_status =
437 - CASE
438 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
439 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
440 - ELSE CONCAT('receipted,', order_status )
441 - END
442 - WHERE ID = %d", $order_id);
443 - $res = $wpdb->query($query);
444 - if($res === false) {
445 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
446 - die('error2');
447 - }
448 -
449 - foreach($_GET as $key => $value) {
450 - $data[$key] = esc_sql($value);
451 - }
452 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
453 - if($res === false) {
454 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
455 - die('error3');
456 - }
457 -
458 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
459 -
460 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
461 - die('J-Payment');
462 - break;
463 -
464 - case 'CVS_CAN'://入金取消
465 - $table_name = $wpdb->prefix."usces_order";
466 - $table_meta_name = $wpdb->prefix."usces_order_meta";
467 -
468 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
469 - $order_id = $wpdb->get_var($query);
470 - if($order_id == NULL) {
471 - usces_log('jpayment conv error1 : '.print_r($data, true), 'acting_transaction.log');
472 - die('error1');
473 - }
474 -
475 - $query = $wpdb->prepare("
476 - UPDATE $table_name SET order_status =
477 - CASE
478 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
479 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
480 - ELSE CONCAT('noreceipt,', order_status )
481 - END
482 - WHERE ID = %d", $order_id);
483 - $res = $wpdb->query($query);
484 - if($res === false) {
485 - usces_log('jpayment conv error2 : '.print_r($data, true), 'acting_transaction.log');
486 - die('error2');
487 - }
488 -
489 - foreach($_GET as $key => $value) {
490 - $data[$key] = esc_sql($value);
491 - }
492 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
493 - if($res === false) {
494 - usces_log('jpayment conv error3 : '.print_r($data, true), 'acting_transaction.log');
495 - die('error3');
496 - }
497 -
498 - usces_action_acting_getpoint( $order_id, false );//20120306ysk 0000324
499 -
500 - usces_log('J-Payment conv transaction : '.$_GET['gid'], 'acting_transaction.log');
501 - die('J-Payment');
502 - break;
503 - }
504 -
505 - //*** jpayment_bank ***//
506 - } elseif(isset($_REQUEST['acting']) && 'jpayment_bank' == $_REQUEST['acting']) {
507 - //$args='';
508 - //foreach((array)$_GET as $key => $value) {
509 - // $args.='&('.$key.')=('.$value.')';
510 - //}
511 - //usces_log('jpayment bank : '.$args, 'acting_transaction.log');
512 - foreach( $_REQUEST as $key => $value ){
513 - $data[$key] = $value;
514 - }
515 -
516 - switch($_GET['ap']) {
517 - case 'BANK'://受付完了
518 - break;
519 -
520 - case 'BAN_SAL'://入金完了
521 - if($_GET['mf'] == '1') {//入金マッチングの場合
522 - $table_name = $wpdb->prefix."usces_order";
523 - $table_meta_name = $wpdb->prefix."usces_order_meta";
524 -
525 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $_GET['cod']);
526 - $order_id = $wpdb->get_var($query);
527 - if($order_id == NULL) {
528 - usces_log('jpayment bank error1 : '.print_r($data, true), 'acting_transaction.log');
529 - die('error1');
530 - }
531 -
532 - $query = $wpdb->prepare("
533 - UPDATE $table_name SET order_status =
534 - CASE
535 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
536 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
537 - ELSE CONCAT('receipted,', order_status )
538 - END
539 - WHERE ID = %d", $order_id);
540 - $res = $wpdb->query($query);
541 - if($res === false) {
542 - usces_log('jpayment bank error2 : '.print_r($data, true), 'acting_transaction.log');
543 - die('error2');
544 - }
545 -
546 - foreach($_GET as $key => $value) {
547 - $data[$key] = esc_sql($value);
548 - }
549 - $res = $usces->set_order_meta_value('acting_'.$_REQUEST['acting'], serialize($data), $order_id);
550 - if($res === false) {
551 - usces_log('jpayment bank error3 : '.print_r($data, true), 'acting_transaction.log');
552 - die('error3');
553 - }
554 -
555 - usces_action_acting_getpoint( $order_id );//20120306ysk 0000324
556 - }
557 -
558 - usces_log('J-Payment bank transaction : '.$_REQUEST['gid'], 'acting_transaction.log');
559 - die('J-Payment');
560 - break;
561 - }
562 -//20101018ysk end
563 - //*** epsilon ***//
564 - }elseif( !isset($_GET['acting_return']) && isset($_GET['trans_code']) && isset($_GET['user_id']) && isset($_GET['result']) && isset($_GET['order_number']) ){
565 - $query = 'trans_code=' . $_GET['trans_code'] . '&user_id=' . $_GET['user_id'] . '&result=' . $_GET['result'] . '&order_number=' . $_GET['order_number'];
566 - usces_log('epsilon (acting_transaction) : ' . $query, 'acting_transaction.log');
567 - $permalink_structure = get_option('permalink_structure');
568 - $delim = ( !$usces->use_ssl && $permalink_structure) ? '?' : '&';
569 -
570 - header('location: ' . USCES_CART_URL . $delim . 'acting=epsilon&acting_return=1&' . $query );
571 - exit;
572 -//20110208ysk start
573 - } elseif( !isset($_GET['acting_return']) && (isset($_GET['acting']) && 'paypal_ipn' == $_GET['acting']) ) {
574 - foreach( $_REQUEST as $key => $value ){
575 - $data[$key] = $value;
576 - }
577 - usces_log('paypal_ipn in '.print_r($data,true), 'acting_transaction.log');
578 - require_once($usces->options['settlement_path'] . 'paypal.php');
579 - $ipn_res = paypal_ipn_check($usces_paypal_url);
580 - if( $ipn_res[0] === true ){
581 - $res = $usces->order_processing( $ipn_res );
582 - if( 'ordercompletion' == $res ){
583 - $usces->cart->crear_cart();
584 - }else{
585 - usces_log('paypal_ipn error : '.print_r($data, true), 'acting_transaction.log');
586 - die('error1');
587 - }
588 - do_action('usces_action_paypal_ipn', $res, $ipn_res);
589 - }
590 - usces_log('PayPal IPN transaction : '.$_REQUEST['txn_id'], 'acting_transaction.log');
591 - die('PayPal');
592 -//20110523ysk start
593 - //*** paypal ipn ***//
594 - } elseif( isset($_REQUEST['ipn_track_id']) ) {//20131121ysk
595 - foreach( $_REQUEST as $key => $value ){
596 - $data[$key] = $value;
597 - }
598 - usces_log('paypal ipn : '.print_r($data, true), 'acting_transaction.log');
599 -//20140908ysk start
600 - //*** PayPal Webpayment Plus ***//
601 - if( isset($_POST['txn_type']) && 'pro_hosted' == $_POST['txn_type'] ) {
602 - $acting_opts = $usces->options['acting_settings']['paypal_wpp'];
603 - $key = isset( $_POST['custom'] ) ? $_POST['custom'] : '';
604 - usces_log( serialize($data), 'db', 'paypal_ipn', $key );
605 - $ipn_res = usces_paypal_ipn_check( $acting_opts['host_url'] );
606 - if( $ipn_res[0] === true ) {
607 - $order_id = $ipn_res['order_id'];
608 - usces_restore_order_acting_data( $order_id );
630 + /* telecom credit */
631 + } elseif ( isset( $_REQUEST['clientip'] ) && isset( $_REQUEST['sendid'] ) && isset( $_REQUEST['rel'] ) ) {
632 + $acting_clientip = ( isset( $usces->options['acting_settings']['telecom']['clientip'] ) ) ? (string) $usces->options['acting_settings']['telecom']['clientip'] : '';
633 + if ( '' === $acting_clientip || (string) wp_unslash( $_REQUEST['clientip'] ) !== $acting_clientip ) {
634 + /* 設定済みクライアントIPと一致しない通知は正規のものではないため記録せず終了 */
635 + die( 'SuccessOK' );
636 + }
637 + $data = array();
638 + foreach ( $_REQUEST as $key => $value ) {
639 + $data[ $key ] = $value;
640 + }
641 + if ( 'yes' === wp_unslash( $_REQUEST['rel'] ) && isset( $_REQUEST['option'] ) ) {
642 + } else {
643 + $log = array(
644 + 'acting' => 'telecom_card',
645 + 'key' => wp_unslash( $_REQUEST['option'] ),
646 + 'result' => wp_unslash( $_REQUEST['rel'] ),
647 + 'data' => wp_unslash( $_REQUEST ),
648 + );
649 + usces_save_order_acting_error( $log );
650 + }
651 + usces_log( 'telecom card : ' . print_r( $data, true ), 'acting_transaction.log' );
652 + die( 'SuccessOK' );
653 +
654 + /* digitalcheck card */
655 + } elseif ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) && 'acting_digitalcheck_card' == substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 ) ) {
656 + if ( isset( $_GET['acting_return'] ) && isset( $_GET['acting'] ) && 'digitalcheck_card' === $_GET['acting'] ) {
657 + return;
658 + }
659 +
660 + $data = array();
661 + foreach ( $_REQUEST as $key => $value ) {
662 + $data[ $key ] = $value;
663 + }
664 + $sid = ( isset( $data['SID'] ) ) ? $data['SID'] : '';
665 +
666 + if ( isset( $data['SEQ'] ) ) {
667 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
668 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
669 + $order_id = $wpdb->get_var( $query );
670 + if ( ! $order_id ) {
671 + $acting_opts = $usces->options['acting_settings']['digitalcheck'];
672 + $ip_user_id = substr( $data['FUKA'], 24 );
673 + if ( 'on' == $acting_opts['card_user_id'] && ! empty( $ip_user_id ) ) {
674 + $usces->set_member_meta_value( 'digitalcheck_ip_user_id', $ip_user_id, $ip_user_id );
675 + }
676 +
609 677 $res = $usces->order_processing();
610 - if( 'ordercompletion' == $res ) {
611 - usces_log( 'PayPal Webpayment Plus : Payment confirmation', 'acting_transaction.log' );
612 - $usces->cart->crear_cart();
678 + if ( 'ordercompletion' == $res ) {
679 + $order_id = $usces->cart->get_order_entry( 'ID' );
680 + $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
681 + $usces->set_order_meta_value( 'wc_trans_id', $sid, $order_id );
613 682 } else {
614 - usces_log( 'PayPal Webpayment Plus : Error', 'acting_transaction.log' );
683 + $log = array(
684 + 'acting' => 'digitalcheck_card',
685 + 'key' => $sid,
686 + 'result' => 'ORDER DATA REGISTERED ERROR',
687 + 'data' => wp_unslash( $_REQUEST ),
688 + );
689 + usces_save_order_acting_error( $log );
690 + // usces_log( 'digitalcheck card : order processing error', 'acting_transaction.log' );
615 691 }
616 692 }
617 - exit;
618 -//20140908ysk end
693 +
694 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
695 + die( "0\r\n" );
696 +
697 + } elseif ( isset( $data['purchase'] ) ) {
698 + return;
699 +
619 700 } else {
620 -//20131121ysk start
621 - $table_name = $wpdb->prefix."usces_order";
622 - $table_meta_name = $wpdb->prefix."usces_order_meta";
623 - if( isset($_REQUEST['txn_id']) or isset($_REQUEST['recurring_payment_id']) ) {
624 - if( ( isset($_REQUEST['payment_status']) and 'Completed' == $_REQUEST['payment_status'] ) or
625 - ( isset($_REQUEST['profile_status']) and 'Active' == $_REQUEST['profile_status'] ) ) {
626 - $settlement_id = ( isset($_REQUEST['recurring_payment_id']) ) ? $_REQUEST['recurring_payment_id'] : $_REQUEST['txn_id'];
627 - $query = $wpdb->prepare( "SELECT ID, order_status FROM $table_name INNER JOIN $table_meta_name ON ID = order_id WHERE meta_key = %s AND meta_value = %s", 'settlement_id', $settlement_id );
628 - $order_data = $wpdb->get_row( $query, ARRAY_A );
629 - if( $order_data ) {
630 - if( $usces->is_status( 'pending', $order_data['order_status'] ) ) {
631 - $order_status = str_replace( 'pending', 'receipted', $order_data['order_status'] );
632 - $query = $wpdb->prepare( "UPDATE $table_name SET order_status = %s WHERE ID = %d", $order_status, $order_data['ID'] );
633 - $res = $wpdb->query( $query );
634 - }
635 - do_action( 'usces_action_paypal_ipn_status_completed', $order_data );
701 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
702 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
703 + $order_id = $wpdb->get_var( $query );
704 + if ( $order_id ) {
705 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
706 + die( "0\r\n" );
707 + }
708 + }
709 +
710 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
711 + die( "0\r\n" );
712 +
713 + /* digitalcheck conv */
714 + } elseif ( isset( $_REQUEST['SID'] ) && isset( $_REQUEST['FUKA'] ) && 'acting_digitalcheck_conv' == substr( wp_unslash( $_REQUEST['FUKA'] ), 0, 24 ) ) {
715 + if ( isset( $_GET['acting_return'] ) && isset( $_GET['acting'] ) && 'digitalcheck_conv' === $_GET['acting'] ) {
716 + return;
717 + }
718 +
719 + $data = array();
720 + foreach ( $_REQUEST as $key => $value ) {
721 + $data[ $key ] = $value;
722 + }
723 + $sid = ( isset( $data['SID'] ) ) ? $data['SID'] : '';
724 +
725 + if ( isset( $data['SEQ'] ) ) {
726 + DIGITALCHECK_SETTLEMENT::get_instance()->acting_notice_ip_guard( $data );
727 + $table_name = $wpdb->prefix . 'usces_order';
728 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
729 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
730 + $order_id = $wpdb->get_var( $query );
731 + if ( null == $order_id ) {
732 + $log = array(
733 + 'acting' => 'digitalcheck_conv',
734 + 'key' => $sid,
735 + 'result' => 'ORDER DATA KEY ERROR',
736 + 'data' => wp_unslash( $_REQUEST ),
737 + );
738 + usces_save_order_acting_error( $log );
739 + usces_log( 'digitalcheck conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
740 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
741 + die( "9\r\n" );
742 + }
743 +
744 + if ( isset( $data['CVS'] ) ) { /* 入金 */
745 + $res = usces_change_order_receipt( $order_id, 'receipted' );
746 + if ( false === $res ) {
747 + $log = array(
748 + 'acting' => 'digitalcheck_conv',
749 + 'key' => $sid,
750 + 'result' => 'ORDER DATA UPDATE ERROR',
751 + 'data' => wp_unslash( $_REQUEST ),
752 + );
753 + usces_save_order_acting_error( $log );
754 + usces_log( 'digitalcheck conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
755 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
756 + die( "9\r\n" );
757 + }
758 +
759 + usces_action_acting_getpoint( $order_id );
760 +
761 + } else { /* 取消 */
762 + $res = usces_change_order_receipt( $order_id, 'noreceipt' );
763 + if ( false === $res ) {
764 + $log = array(
765 + 'acting' => 'digitalcheck_conv',
766 + 'key' => $sid,
767 + 'result' => 'ORDER DATA UPDATE ERROR',
768 + 'data' => wp_unslash( $_REQUEST ),
769 + );
770 + usces_save_order_acting_error( $log );
771 + usces_log( 'digitalcheck conv error3 : ' . print_r( $data, true ), 'acting_transaction.log' );
772 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
773 + die( "9\r\n" );
774 + }
775 +
776 + usces_action_acting_getpoint( $order_id, false );
777 + }
778 +
779 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
780 +
781 + $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid );
782 + $res = $wpdb->query( $dquery );
783 +
784 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
785 + die( "0\r\n" );
786 +
787 + } else {
788 + if ( isset( $data['CVS'] ) && isset( $data['SHNO'] ) ) { /* 決済 */
789 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
790 + $query = $wpdb->prepare( "SELECT `order_id` FROM $table_meta_name WHERE `meta_key` = %s AND `meta_value` = %s", 'SID', $sid );
791 + $order_id = $wpdb->get_var( $query );
792 + if ( $order_id ) {
793 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
794 +
795 + } else {
796 + $res = $usces->order_processing();
797 + if ( 'ordercompletion' == $res ) {
798 + $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
799 + $usces->set_order_meta_value( 'wc_trans_id', $sid, $order_id );
800 + } else {
801 + $log = array(
802 + 'acting' => 'digitalcheck_conv',
803 + 'key' => $sid,
804 + 'result' => 'ORDER DATA REGISTERED ERROR',
805 + 'data' => wp_unslash( $_REQUEST ),
806 + );
807 + usces_save_order_acting_error( $log );
808 + usces_log( 'digitalcheck conv : order processing error', 'acting_transaction.log' );
636 809 }
637 810 }
811 +
812 + header( 'Content-Type: text/plain; charset=Shift_JIS' );
813 + die( "0\r\n" );
814 +
815 + } elseif ( isset( $data['purchase'] ) ) {
816 +
817 + } else {
818 + $permalink_structure = get_option( 'permalink_structure' );
819 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
820 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=digitalcheck_conv&acting_return=1&SID=' . $sid );
821 + exit;
638 822 }
639 -//20131121ysk end
640 - die('PayPal');
641 823 }
642 -//20110523ysk end
643 -//20120413ysk start
644 - //*** SoftBankPayment ***//
645 - } elseif( !isset($_GET['acting_return']) && isset($_POST['res_result']) && isset($_POST['res_pay_method']) ) {
646 - //usces_log('SoftBankPayment : '.print_r($_REQUEST, true), 'acting_transaction.log');
647 - foreach( $_POST as $key => $value ) {
648 - $data[$key] = mb_convert_encoding($value, 'UTF-8', 'SJIS');
649 - }
650 - $acting = $data['free1'];
651 -
652 - switch( $data['res_result'] ) {
653 - case 'OK'://決済処理OK
654 - $table_meta_name = $wpdb->prefix."usces_order_meta";
655 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
656 - $order_id = $wpdb->get_var($query);
657 - if( !$order_id ) {
658 -
659 - $res = $usces->order_processing();
660 - if( 'ordercompletion' == $res ){
661 - //$usces->cart->crear_cart();
662 - } else {
663 - usces_log('SoftBankPayment '.$data['res_pay_method'].' order processing error : '.print_r($data, true), 'acting_transaction.log');
664 - die('NG,order processing error');
665 - }
666 - }
667 -
668 - //$acting_opts = $usces->options['acting_settings']['sbps'];
669 - //if( 'on' == $acting_opts['cust'] ) {
670 - // $usces->set_member_meta_value( 'sbps_cust_no', $data['res_sps_cust_no'], $data['cust_code'] );
671 - // $usces->set_member_meta_value( 'sbps_payment_no', $data['res_sps_payment_no'], $data['cust_code'] );
672 - //}
673 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [OK] transaction : '.$data['res_tracking_id'], 'acting_transaction.log');
674 - die('OK,');
675 - break;
676 -
677 - case 'PY'://入金結果通知
678 - $table_name = $wpdb->prefix."usces_order";
679 - $table_meta_name = $wpdb->prefix."usces_order_meta";
680 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
681 - $order_id = $wpdb->get_var($query);
682 - if( $order_id == NULL ) {
683 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error1 : '.print_r($data, true), 'acting_transaction.log');
684 - die('NG,order_id error');
685 - }
686 -
687 - $query = $wpdb->prepare("
688 - UPDATE $table_name SET order_status =
689 - CASE
690 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
691 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
692 - ELSE CONCAT('receipted,', order_status )
693 - END
694 - WHERE ID = %d", $order_id);
695 - $res = $wpdb->query($query);
696 - if( $res === false ) {
697 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error2 : '.print_r($data, true), 'acting_transaction.log');
698 - die('NG,usces_order update error');
699 - }
700 -
701 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
702 - if( $res === false ) {
703 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] error3 : '.print_r($data, true), 'acting_transaction.log');
704 - die('NG,usces_order_meta update error');
705 - }
706 -
707 - usces_action_acting_getpoint( $order_id );
708 -
709 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [PY] transaction : '.$order_id, 'acting_transaction.log');
710 - die('OK,');
711 -
712 - case 'CN'://期限切通知
713 - $table_name = $wpdb->prefix."usces_order";
714 - $table_meta_name = $wpdb->prefix."usces_order_meta";
715 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'res_tracking_id', $data['res_tracking_id']);
716 - $order_id = $wpdb->get_var($query);
717 - if( $order_id == NULL ) {
718 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error1 : '.print_r($data, true), 'acting_transaction.log');
719 - die('NG,order_id error');
720 - }
721 -
722 - $query = $wpdb->prepare("
723 - UPDATE $table_name SET order_status =
724 - CASE
725 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
726 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
727 - ELSE CONCAT('noreceipt,', order_status )
728 - END
729 - WHERE ID = %d", $order_id);
730 - $res = $wpdb->query($query);
731 - if( $res === false ) {
732 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error2 : '.print_r($data, true), 'acting_transaction.log');
733 - die('NG,usces_order update error');
734 - }
735 -
736 - $res = $usces->set_order_meta_value($acting, serialize($data), $order_id);
737 - if( $res === false ) {
738 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] error3 : '.print_r($data, true), 'acting_transaction.log');
739 - die('NG,usces_order_meta update error');
740 - }
741 -
742 - //usces_action_acting_getpoint( $order_id, false );
743 -
744 - usces_log('SoftBankPayment '.$data['res_pay_method'].' [CN] transaction : '.$order_id, 'acting_transaction.log');
745 - die('OK,');
746 -
747 - default:
748 - usces_log('SoftBankPayment '.$data['res_pay_method'].' ['.$data['res_result'].'] : '.print_r($data,true), 'acting_transaction.log');
749 - die('OK,');
750 - }
751 -//20120413ysk end
752 -//20121030ysk start
753 - //*** telecom credit ***//
754 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && (isset($_REQUEST['acting']) && 'telecom_edy' == $_REQUEST['acting']) ) {
755 - foreach( $_REQUEST as $key => $value ) {
756 - $data[$key] = $value;
757 - }
758 - usces_log('telecom edy : '.print_r($data, true), 'acting_transaction.log');
759 - //die('SuccessOK');
760 - } elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['edy']) ) {
761 - foreach( $_REQUEST as $key => $value ) {
762 - $data[$key] = $value;
763 - }
764 - if( $_REQUEST['rel'] === 'yes' && isset($_REQUEST['option']) ) {
765 - $table_meta_name = $wpdb->prefix."usces_order_meta";
766 - $mquery = $wpdb->prepare( "SELECT order_id, meta_value FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
767 - $mvalue = $wpdb->get_row( $mquery, ARRAY_A );
768 - $value = unserialize( $mvalue['meta_value'] );
769 - $_SESSION['usces_cart'] = $value['usces_cart'];
770 - $_SESSION['usces_entry'] = $value['usces_entry'];
771 - $_SESSION['usces_member'] = $value['usces_member'];
772 - $res = $usces->order_processing();
773 - if( 'ordercompletion' == $res ) {
774 - $query = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $_REQUEST['option'] );
775 - $res = $wpdb->query( $query );
776 - usces_log('telecom edy - Payment confirmation : '.print_r($data, true), 'acting_transaction.log');
777 - } else {
778 - usces_log('telecom edy - Error 1 : '.print_r($data, true), 'acting_transaction.log');
779 - }
780 - } else {
781 - usces_log('telecom edy - Error 2 : '.print_r($data, true), 'acting_transaction.log');
782 - }
783 - die('SuccessOK');
784 -//20121030ysk end
785 -//20120618ysk start
786 - //*** telecom credit ***//
787 - }elseif( isset($_REQUEST['clientip']) && isset($_REQUEST['sendid']) && isset($_REQUEST['rel']) ){
788 - foreach( $_REQUEST as $key => $value ){
789 - $data[$key] = $value;
790 - }
791 - usces_log('telecom card : '.print_r($data, true), 'acting_transaction.log');
792 - die('SuccessOK');
793 -//20120618ysk end
794 -//20121206ysk start
795 - //*** digitalcheck card ***//
796 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_card' ) {
797 - foreach( $_REQUEST as $key => $value ) {
798 - $data[$key] = $value;
799 - }
800 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
801 -//usces_log('digitalcheck card : '.print_r($data, true), 'digitalcheck.log');
802 -
803 - if( isset($data['SEQ']) ) {
804 - $acting_opts = $usces->options['acting_settings']['digitalcheck'];
805 - $ip_user_id = substr($data['FUKA'], 24);
806 -//usces_log('ip_user_id : '.$ip_user_id, 'digitalcheck.log');
807 - if( 'on' == $acting_opts['card_user_id'] and !empty($ip_user_id) ) {
808 - $usces->set_member_meta_value('digitalcheck_ip_user_id', $ip_user_id, $ip_user_id);
824 +
825 + /* mizuho card */
826 + } elseif ( ( isset( $_GET['p_ver'] ) && '0200' == wp_unslash( $_GET['p_ver'] ) ) && ( isset( $_GET['bkcode'] ) && 'bg01' == wp_unslash( $_GET['bkcode'] ) ) ) {
827 + usces_log( 'mizuho card : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
828 + $stran = ( array_key_exists( 'stran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['stran'] ) : '';
829 + $mbtran = ( array_key_exists( 'mbtran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['mbtran'] ) : '';
830 + $rsltcd = ( array_key_exists( 'rsltcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltcd'] ) : '';
831 + $rsltdcd = ( array_key_exists( 'rsltdcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltdcd'] ) : '';
832 + $permalink_structure = get_option( 'permalink_structure' );
833 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
834 + if ( '108' == substr( $rsltcd, 0, 3 ) || '208' == substr( $rsltcd, 0, 3 ) || '308' == substr( $rsltcd, 0, 3 ) ) { /* キャンセル */
835 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
836 + } elseif ( '109' == substr( $rsltcd, 0, 3 ) || '209' == substr( $rsltcd, 0, 3 ) || '309' == substr( $rsltcd, 0, 3 ) ) { /* エラー */
837 + $log = array(
838 + 'acting' => 'mizuho_card',
839 + 'key' => $stran,
840 + 'result' => $rsltcd,
841 + 'data' => wp_unslash( $_GET ),
842 + );
843 + usces_save_order_acting_error( $log );
844 + usces_log( 'mizuho card : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
845 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=0&rsltdcd=' . $rsltdcd );
846 + } else {
847 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=1&stran=' . $stran . '&mbtran=' . $mbtran . '&rsltcd=' . $rsltcd );
848 + }
849 + die();
850 +
851 + /* mizuho conv 提供対象外のため無効化。
852 + } elseif ( ( isset( $_GET['p_ver'] ) && '0200' == wp_unslash( $_GET['p_ver'] ) ) && ( isset( $_GET['bkcode'] ) && ( 'cv01' == wp_unslash( $_GET['bkcode'] ) || 'cv02' == wp_unslash( $_GET['bkcode'] ) ) ) ) {
853 + usces_log( 'mizuho conv : ' . print_r( $_GET, true ), 'acting_transaction.log' );
854 + $stran = ( array_key_exists( 'stran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['stran'] ) : '';
855 + $mbtran = ( array_key_exists( 'mbtran', $_REQUEST ) ) ? wp_unslash( $_REQUEST['mbtran'] ) : '';
856 + $bktrans = ( array_key_exists( 'bktrans', $_REQUEST ) ) ? wp_unslash( $_REQUEST['bktrans'] ) : '';
857 + $tranid = ( array_key_exists( 'tranid', $_REQUEST ) ) ? wp_unslash( $_REQUEST['tranid'] ) : '';
858 + $tdate = ( array_key_exists( 'tdate', $_REQUEST ) ) ? wp_unslash( $_REQUEST['tdate'] ) : '';
859 + $rsltcd = ( array_key_exists( 'rsltcd', $_REQUEST ) ) ? wp_unslash( $_REQUEST['rsltcd'] ) : '';
860 + $permalink_structure = get_option( 'permalink_structure' );
861 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
862 + if ( '' != $tdate ) { // 入金通知
863 + $data = array();
864 + foreach ( $_REQUEST as $key => $value ) {
865 + $data[ $key ] = $value;
809 866 }
810 -
811 - $res = $usces->order_processing();
812 - if( 'ordercompletion' == $res ) {
813 - $order_id = $usces->cart->get_order_entry('ID');
814 - $usces->set_order_meta_value( 'acting_digitalcheck_card', serialize( $data ), $order_id );
815 - } else {
816 - usces_log('digitalcheck card : order processing error', 'acting_transaction.log');
817 - }
818 -
819 - header('content-type : text/plain;charset=Shift_JIS');
820 - die("0");
821 - }
822 -
823 - //*** digitalcheck conv ***//
824 - } elseif( isset($_REQUEST['SID']) && isset($_REQUEST['FUKA']) && substr($_REQUEST['FUKA'], 0, 24) == 'acting_digitalcheck_conv' ) {
825 - foreach( $_REQUEST as $key => $value ) {
826 - $data[$key] = $value;
827 - }
828 - $sid = ( isset($data['SID']) ) ? $data['SID'] : '';
829 -//usces_log("digitalcheck conv : ".print_r($_REQUEST,true), 'digitalcheck.log');
830 -
831 - if( isset($data['SEQ']) ) {
832 - $table_name = $wpdb->prefix."usces_order";
833 - $table_meta_name = $wpdb->prefix."usces_order_meta";
834 -
835 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
836 - $order_id = $wpdb->get_var( $query );
837 - if( $order_id == NULL ) {
838 - usces_log( 'digitalcheck conv error1 : '.print_r($data, true), 'acting_transaction.log' );
839 - header('content-type : text/plain;charset=Shift_JIS');
840 - die('9');
841 - }
842 -
843 - if( isset($data['CVS']) ) {//入金
844 - $mquery = $wpdb->prepare("
845 - UPDATE $table_name SET order_status =
846 - CASE
847 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
848 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
849 - ELSE CONCAT('receipted,', order_status )
850 - END
851 - WHERE ID = %d", $order_id );
852 - $res = $wpdb->query( $mquery );
853 - if( $res === false ) {
854 - usces_log('digitalcheck conv error2 : '.print_r($data, true), 'acting_transaction.log');
855 - header('content-type : text/plain;charset=Shift_JIS');
856 - die('9');
857 - }
858 -
859 - usces_action_acting_getpoint( $order_id );
860 -
861 - } else {//取消
862 - $mquery = $wpdb->prepare("
863 - UPDATE $table_name SET order_status =
864 - CASE
865 - WHEN LOCATE('receipted', order_status) > 0 THEN REPLACE(order_status, 'receipted', 'noreceipt')
866 - WHEN LOCATE('noreceipt', order_status) > 0 THEN order_status
867 - ELSE CONCAT('noreceipt,', order_status )
868 - END
869 - WHERE ID = %d", $order_id );
870 - $res = $wpdb->query( $mquery );
871 - if( $res === false ) {
872 - usces_log('digitalcheck conv error3 : '.print_r($data, true), 'acting_transaction.log');
873 - header('content-type : text/plain;charset=Shift_JIS');
874 - die('9');
875 - }
876 -
877 - usces_action_acting_getpoint( $order_id, false );
878 - }
879 -
880 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
881 -
882 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sid );
883 - $res = $wpdb->query( $dquery );
884 -
885 - header('content-type : text/plain;charset=Shift_JIS');
886 - die("0");
887 -
888 - } else {
889 - if( isset($data['CVS']) and isset($data['SHNO']) ) {//決済
890 - $table_meta_name = $wpdb->prefix."usces_order_meta";
891 - $query = $wpdb->prepare("SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'SID', $sid );
892 - $order_id = $wpdb->get_var($query);
893 - if( $order_id ) {
894 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
895 -
896 - } else {
897 - $res = $usces->order_processing();
898 - if( 'ordercompletion' == $res ) {
899 - $order_id = $usces->cart->get_order_entry('ID');
900 - $usces->set_order_meta_value( 'acting_digitalcheck_conv', serialize( $data ), $order_id );
901 - } else {
902 - usces_log('digitalcheck conv : order processing error', 'acting_transaction.log');
903 - }
904 - }
905 - header('content-type : text/plain;charset=Shift_JIS');
906 - die("0");
907 -
908 - } elseif( isset($data['purchase']) ) {
909 -
910 - } else {
911 - $permalink_structure = get_option('permalink_structure');
912 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
913 - header( 'location: '.USCES_CART_URL.$delim.'acting=digitalcheck_conv&acting_return=1&SID='.$sid );
914 - exit;
915 - }
916 - }
917 -//20121206ysk end
918 -//20130225ysk start
919 - //*** mizuho card ***//
920 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && $_GET['bkcode'] == 'bg01' ) ) {
921 - //usces_log('mizuho card : '.print_r($_GET,true),'mizuho.log');
922 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
923 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
924 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
925 - $rsltdcd = ( array_key_exists('rsltdcd', $_REQUEST) ) ? $_REQUEST['rsltdcd'] : '';
926 - $permalink_structure = get_option( 'permalink_structure' );
927 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
928 - if( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3 ) ) {//キャンセル
929 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
930 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
931 - usces_log( 'mizuho card : '.print_r( $_GET, true ), 'acting_transaction.log' );
932 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0&rsltdcd='.$rsltdcd );
933 - } else {
934 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&rsltcd='.$rsltcd );
935 - }
936 - die();
937 -
938 - //*** mizuho conv ***//
939 - } elseif( ( isset($_GET['p_ver']) && $_GET['p_ver'] == '0200' ) && ( isset($_GET['bkcode']) && ( $_GET['bkcode'] == 'cv01' or $_GET['bkcode'] == 'cv02' ) ) ) {
940 - //usces_log('mizuho conv : '.print_r($_GET,true),'mizuho.log');
941 - $stran = ( array_key_exists('stran', $_REQUEST) ) ? $_REQUEST['stran'] : '';
942 - $mbtran = ( array_key_exists('mbtran', $_REQUEST) ) ? $_REQUEST['mbtran'] : '';
943 - $bktrans = ( array_key_exists('bktrans', $_REQUEST) ) ? $_REQUEST['bktrans'] : '';
944 - $tranid = ( array_key_exists('tranid', $_REQUEST) ) ? $_REQUEST['tranid'] : '';
945 - $tdate = ( array_key_exists('tdate', $_REQUEST) ) ? $_REQUEST['tdate'] : '';
946 - $rsltcd = ( array_key_exists('rsltcd', $_REQUEST) ) ? $_REQUEST['rsltcd'] : '';
947 - $permalink_structure = get_option( 'permalink_structure' );
948 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
949 - if( '' != $tdate ) {//入金通知
950 - foreach( $_REQUEST as $key => $value ) {
951 - $data[$key] = $value;
952 - }
953 - if( $rsltcd == "0000000000000" ) {
954 - $table_name = $wpdb->prefix."usces_order";
955 - $table_meta_name = $wpdb->prefix."usces_order_meta";
956 -
957 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran );
958 - $order_id = $wpdb->get_var( $query );
959 - if( $order_id == NULL ) {
960 - usces_log( 'mizuho conv error1 : '.print_r($data, true), 'acting_transaction.log' );
961 -
962 - } else {
963 - $mquery = $wpdb->prepare("
964 - UPDATE $table_name SET order_status =
965 - CASE
966 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
967 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
968 - ELSE CONCAT('receipted,', order_status )
969 - END
970 - WHERE ID = %d", $order_id );
971 - $res = $wpdb->query( $mquery );
972 - if( $res === false ) {
973 - usces_log( 'mizuho conv error2 : '.print_r($data, true), 'acting_transaction.log' );
974 -
975 - } else {
976 - usces_action_acting_getpoint( $order_id );
977 -
978 - $usces->set_order_meta_value( 'acting_mizuho_conv', serialize($data), $order_id );
979 -
980 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran );
981 - $res = $wpdb->query( $dquery );
982 - }
983 - }
984 -
985 - } else {
986 - //header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
987 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
988 - }
989 -
990 - } elseif( '108' == substr($rsltcd, 0, 3) or '208' == substr($rsltcd, 0, 3) or '308' == substr($rsltcd, 0, 3) ) {//キャンセル
991 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
992 - } elseif( '109' == substr($rsltcd, 0, 3) or '209' == substr($rsltcd, 0, 3) or '309' == substr($rsltcd, 0, 3) ) {//エラー
993 - usces_log( 'mizuho conv : '.print_r( $_GET, true ), 'acting_transaction.log' );
994 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_card&acting_return=0' );
995 - } else {
996 - header( 'location: '.USCES_CART_URL.$delim.'acting=mizuho_conv&acting_return=1&stran='.$stran.'&mbtran='.$mbtran.'&bktrans='.$_GET['bktrans'].'&tranid='.$tranid.'&rsltcd='.$rsltcd );
997 - }
998 - die();
999 -//20130225ysk end
1000 -//20131220ysk start
1001 - //*** AnotherLane credit ***//
1002 - } elseif( isset($_GET['SiteId']) && isset($_GET['TransactionId']) && isset($_GET['Result']) ) {
1003 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
1004 - foreach( $_GET as $key => $value ) {
1005 - $data[$key] = $value;
1006 - }
1007 - if( $acting_opts['siteid'] == $_GET['SiteId'] && 'OK' == $_GET['Result'] ) {
1008 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1009 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'TransactionId', $data['TransactionId'] );
1010 - $order_id = $wpdb->get_var( $query );
1011 - if( !$order_id ) {
1012 - $res = $usces->order_processing();
1013 - if( 'ordercompletion' == $res ) {
1014 - //$usces->cart->crear_cart();
1015 - usces_log( 'AnotherLane [OK] transaction : '.$data['TransactionId'], 'acting_transaction.log' );
1016 - } else {
1017 - usces_log( 'AnotherLane order processing error : '.print_r($data, true), 'acting_transaction.log' );
1018 - }
1019 - }
1020 - }
1021 - exit;
1022 -
1023 - } elseif( isset($_GET['ali_back']) && isset($_POST['SiteId']) && isset($_POST['Result']) ) {
1024 - $acting_opts = $usces->options['acting_settings']['anotherlane'];
1025 - if( $acting_opts['siteid'] == $_POST['SiteId'] && 'NG' == $_POST['Result'] ) {
1026 - $permalink_structure = get_option( 'permalink_structure' );
1027 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
1028 - header( 'location: '.USCES_CART_URL.$delim.'confirm=1' );
1029 - exit;
1030 - } elseif( $acting_opts['siteid'] == $_POST['SiteId'] && 'OK' == $_POST['Result'] ) {
1031 - $permalink_structure = get_option( 'permalink_structure' );
1032 - $delim = ( !$usces->use_ssl && $permalink_structure ) ? '?' : '&';
1033 - header( 'location: '.USCES_CART_URL.$delim.'acting=anotherlane_card&acting_return=1' );
1034 - exit;
1035 - }
1036 -//20131220ysk end
1037 -//20140206ysk start
1038 - //*** Veritrans card ***//
1039 - } elseif( isset($_GET['acting']) and 'veritrans_card' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1040 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1041 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1042 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1043 - $order_id = $wpdb->get_var( $query );
1044 - if( !$order_id ) {
1045 - $res = $usces->order_processing();
1046 - if( 'ordercompletion' == $res ) {
1047 - do_action( 'usces_action_veritrans_card_completion' );
1048 - $usces->cart->crear_cart();
1049 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
1050 - } else {
1051 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), 'acting_transaction.log' );
1052 - }
1053 - }
1054 - }
1055 - exit;
1056 -
1057 - //*** Veritrans conv ***//
1058 - } elseif( isset($_GET['acting']) and 'veritrans_conv' == $_GET['acting'] and isset($_POST['orderId']) and isset($_POST['merchantEncryptionKey']) ) {
1059 - //決済結果通知
1060 - if( isset($_POST['mStatus']) and 'success' == $_POST['mStatus'] ) {
1061 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1062 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $_POST['orderId'] );
1063 - $order_id = $wpdb->get_var( $query );
1064 - if( !$order_id ) {
1065 - $res = $usces->order_processing();
1066 - if( 'ordercompletion' == $res ) {
1067 - do_action( 'usces_action_veritrans_conv_completion' );
1068 - $usces->cart->crear_cart();
1069 - usces_log( 'Veritrans [OK] transaction : '.$_POST['orderId'], 'acting_transaction.log' );
1070 - } else {
1071 - usces_log( 'Veritrans order processing error : '.print_r( $_POST, true ), 'acting_transaction.log' );
1072 - }
1073 - }
1074 - }
1075 - exit;
1076 -
1077 - } elseif( isset($_REQUEST['numberOfNotify']) and isset($_REQUEST['pushTime']) and isset($_REQUEST['pushId']) ) {
1078 - //支払通知
1079 - $data = array();
1080 - foreach( $_REQUEST as $key => $value ) {
1081 - $num = substr( $key, -4 );
1082 - if( preg_match( "/^[0-9]+$/", $num ) ) {
1083 - $nkey = substr( $key, 0, strpos( $key, $num ) );
1084 - $data[$nkey][(int)$num] = $value;
1085 - } else {
1086 - $data[$key] = $value;
1087 - }
1088 - }
1089 -
1090 - $count = count( $data['orderId'] );
1091 - if( 0 < $count ) {
1092 - $table_name = $wpdb->prefix."usces_order";
1093 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1094 -
1095 - for( $i = 0; $i < $count; $i++ ) {
1096 - if( isset( $data['orderId'][$i] ) ) {
1097 - $sdata = array();
1098 - $sdata['acting'] = 'veritrans_conv';
1099 - $sdata['orderId'] = $data['orderId'][$i];
1100 - $sdata['cvsType'] = isset( $data['cvsType'][$i] ) ? $data['cvsType'][$i] : '';
1101 - $sdata['receiptNo'] = isset( $data['receiptNo'][$i] ) ? $data['receiptNo'][$i] : '';
1102 - $sdata['receiptDate'] = isset( $data['receiptDate'][$i] ) ? $data['receiptDate'][$i] : '';
1103 - $sdata['rcvAmount'] = isset( $data['rcvAmount'][$i] ) ? $data['rcvAmount'][$i] : '';
1104 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'orderId', $sdata['orderId'] );
1105 - $order_id = $wpdb->get_var( $query );
1106 - if( $order_id == NULL ) {
1107 - usces_log( 'Veritrans conv error1 : '.print_r( $sdata, true ), 'acting_transaction.log' );
1108 -
1109 - } else {
1110 - $mquery = $wpdb->prepare("
1111 - UPDATE $table_name SET order_status =
1112 - CASE
1113 - WHEN LOCATE('noreceipt', order_status) > 0 THEN REPLACE(order_status, 'noreceipt', 'receipted')
1114 - WHEN LOCATE('receipted', order_status) > 0 THEN order_status
1115 - ELSE CONCAT('receipted,', order_status )
1116 - END
1117 - WHERE ID = %d", $order_id );
1118 - $res = $wpdb->query( $mquery );
1119 - if( $res === false ) {
1120 - usces_log( 'Veritrans conv error2 : '.print_r( $sdata, true ), 'acting_transaction.log' );
1121 -
1122 - } else {
1123 - usces_action_acting_getpoint( $order_id );
1124 -
1125 - $usces->set_order_meta_value( 'acting_veritrans_conv', serialize( $sdata ), $order_id );
1126 -
1127 - $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $sdata['orderId'] );
1128 - $res = $wpdb->query( $dquery );
1129 - }
1130 - }
1131 - }
1132 - }
1133 - }
1134 - exit;
1135 -//20140206ysk end
1136 -//20140725ysk start
1137 - //} else if( array_key_exists( 'seq_payment_id', $_REQUEST ) and array_key_exists( 'trading_id', $_REQUEST ) and array_key_exists( 'payment_type', $_REQUEST ) ) {
1138 - } else if( isset($_POST['trading_id']) and isset($_POST['payment_status']) and !isset($_POST['purchase']) ) {
1139 - foreach( $_POST as $key => $value ) {
1140 - $data[$key] = $value;
1141 - }
867 + if ( '0000000000000' == $rsltcd ) {
868 + $table_name = $wpdb->prefix . 'usces_order';
869 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
1142 870
1143 - $payment_type = ( array_key_exists( 'payment_type', $_POST ) ) ? $_POST['payment_type'] : '';
1144 - switch( $payment_type ) {
1145 - case '02':
1146 - if( $_POST['payment_status'] == '10' ) {
1147 - usces_restore_order_acting_data( $_POST['trading_id'] );
1148 - usces_log( serialize($data), 'db', 'paygent_card', $_POST['trading_id'] );
1149 - $res = $usces->order_processing();
1150 - if( 'ordercompletion' == $res ) {
1151 - $order_id = $usces->cart->get_order_entry('ID');
1152 - $usces->set_order_meta_value( 'acting_paygent_card', serialize($data), $order_id );
1153 - $usces->cart->crear_cart();
871 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'stran', $stran );
872 + $order_id = $wpdb->get_var( $query );
873 + if ( null == $order_id ) {
874 + $log = array(
875 + 'acting' => 'mizuho_conv',
876 + 'key' => $stran,
877 + 'result' => 'ORDER DATA KEY ERROR',
878 + 'data' => wp_unslash( $_GET ),
879 + );
880 + usces_save_order_acting_error( $log );
881 + usces_log( 'mizuho conv error1 : ' . print_r( $data, true ), 'acting_transaction.log' );
1154 882 } else {
1155 - usces_log( 'Paygent card error : '.print_r( $data, true ), 'acting_transaction.log' );
883 + $res = usces_change_order_receipt( $order_id, 'receipted' );
884 + if ( false === $res ) {
885 + $log = array(
886 + 'acting' => 'mizuho_conv',
887 + 'key' => $stran,
888 + 'result' => 'ORDER DATA UPDATE ERROR',
889 + 'data' => wp_unslash( $_GET ),
890 + );
891 + usces_save_order_acting_error( $log );
892 + usces_log( 'mizuho conv error2 : ' . print_r( $data, true ), 'acting_transaction.log' );
893 +
894 + } else {
895 + usces_action_acting_getpoint( $order_id );
896 +
897 + $usces->set_order_meta_value( 'acting_mizuho_conv', serialize( $data ), $order_id );
898 +
899 + $dquery = $wpdb->prepare( "DELETE FROM $table_meta_name WHERE meta_key = %s", $stran );
900 + $res = $wpdb->query( $dquery );
901 + }
1156 902 }
903 + } else {
904 + usces_log( 'mizuho conv : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
1157 905 }
1158 - break;
906 + } elseif ( '108' == substr( $rsltcd, 0, 3 ) || '208' == substr( $rsltcd, 0, 3 ) || '308' == substr( $rsltcd, 0, 3 ) ) { // キャンセル
907 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
908 + } elseif ( '109' == substr( $rsltcd, 0, 3 ) || '209' == substr( $rsltcd, 0, 3 ) || '309' == substr( $rsltcd, 0, 3 ) ) { // エラー
909 + $log = array(
910 + 'acting' => 'mizuho_conv',
911 + 'key' => $stran,
912 + 'result' => $rsltcd,
913 + 'data' => wp_unslash( $_GET ),
914 + );
915 + usces_save_order_acting_error( $log );
916 + usces_log( 'mizuho conv : ' . print_r( wp_unslash( $_GET ), true ), 'acting_transaction.log' );
917 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_card&acting_return=0' );
918 + } else {
919 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=mizuho_conv&acting_return=1&stran=' . $stran . '&mbtran=' . $mbtran . '&bktrans=' . wp_unslash( $_GET['bktrans'] ) . '&tranid=' . $tranid . '&rsltcd=' . $rsltcd );
920 + }
921 + die();
922 + */
1159 923
1160 - case '03':
1161 - usces_log( serialize($data), 'db', 'paygent_conv', $_POST['trading_id'] );
1162 - $table_meta_name = $wpdb->prefix."usces_order_meta";
1163 - $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'trading_id', $_POST['trading_id'] );
1164 - $order_id = $wpdb->get_var( $query );
1165 - if( $order_id ) {
1166 - $table_name = $wpdb->prefix."usces_order";
1167 - $query = $wpdb->prepare( "
1168 - UPDATE $table_name SET order_status =
1169 - CASE
1170 - WHEN LOCATE( 'noreceipt', order_status ) > 0 THEN REPLACE( order_status, 'noreceipt', 'receipted' )
1171 - WHEN LOCATE( 'receipted', order_status ) > 0 THEN order_status
1172 - ELSE CONCAT( 'receipted,', order_status )
1173 - END
1174 - WHERE ID = %d", $order_id );
1175 - $res = $wpdb->query( $query );
1176 - if( $res === false ) {
1177 - usces_log( 'Paygent conv error : '.print_r( $data, true ), 'acting_transaction.log' );
924 + /* AnotherLane credit */
925 + } elseif ( isset( $_REQUEST['SiteId'] ) && isset( $_REQUEST['TransactionId'] ) && isset( $_REQUEST['Result'] ) ) {
926 + $data = array();
927 + foreach ( $_REQUEST as $key => $value ) {
928 + $data[ $key ] = $value;
929 + }
1178 930
931 + $acting_opts = $usces->options['acting_settings']['anotherlane'];
932 + if ( ! isset( $_REQUEST['KickType'] ) && isset( $_REQUEST['TransactionId'] ) ) {
933 + $permalink_structure = get_option( 'permalink_structure' );
934 + $delim = ( ! $usces->use_ssl && $permalink_structure ) ? '?' : '&';
935 + if ( $acting_opts['siteid'] == wp_unslash( $_REQUEST['SiteId'] ) && 'NG' == wp_unslash( $_REQUEST['Result'] ) ) {
936 + $log = array(
937 + 'acting' => 'anotherlane_card',
938 + 'key' => wp_unslash( $_REQUEST['TransactionId'] ),
939 + 'result' => wp_unslash( $_REQUEST['Result'] ),
940 + 'data' => wp_unslash( $_REQUEST ),
941 + );
942 + usces_save_order_acting_error( $log );
943 + header( 'location: ' . USCES_CART_URL . $delim . 'confirm=1' );
944 + exit;
945 + } elseif ( $acting_opts['siteid'] == wp_unslash( $_REQUEST['SiteId'] ) && 'OK' == wp_unslash( $_REQUEST['Result'] ) ) {
946 + header( 'location: ' . USCES_CART_URL . $delim . 'acting=anotherlane_card&acting_return=1' );
947 + exit;
948 + }
949 + } elseif ( isset( $_REQUEST['KickType'] ) && $acting_opts['siteid'] == wp_unslash( $_GET['SiteId'] ) && 'OK' == wp_unslash( $_GET['Result'] ) ) {
950 + $table_meta_name = $wpdb->prefix . 'usces_order_meta';
951 + $query = $wpdb->prepare( "SELECT order_id FROM $table_meta_name WHERE meta_key = %s AND meta_value = %s", 'TransactionId', $data['TransactionId'] );
952 + $order_id = $wpdb->get_var( $query );
953 + if ( ! $order_id ) {
954 + $res = $usces->order_processing();
955 + if ( 'ordercompletion' == $res ) {
956 + $usces->set_order_meta_value( 'wc_trans_id', $data['TransactionId'], $order_id );
957 + usces_log( 'AnotherLane [OK] transaction : ' . $data['TransactionId'], 'acting_transaction.log' );
1179 958 } else {
1180 - usces_action_acting_getpoint( $order_id );
1181 - $usces->set_order_meta_value( 'acting_paygent_conv', serialize( $data ), $order_id );
1182 - $usces->cart->crear_cart();
959 + $log = array(
960 + 'acting' => 'anotherlane_card',
961 + 'key' => $data['TransactionId'],
962 + 'result' => 'ORDER DATA REGISTERED ERROR',
963 + 'data' => wp_unslash( $_GET ),
964 + );
965 + usces_save_order_acting_error( $log );
966 + usces_log( 'AnotherLane order processing error : ' . print_r( $data, true ), 'acting_transaction.log' );
1183 967 }
1184 968 }
1185 - break;
969 + } else {
970 + $log = array(
971 + 'acting' => 'anotherlane_card',
972 + 'key' => $data['TransactionId'],
973 + 'result' => $data['Result'],
974 + 'data' => wp_unslash( $_GET ),
975 + );
976 + usces_save_order_acting_error( $log );
1186 977 }
1187 - die( 'result=0' );
1188 -//20140725ysk end
1189 - }
1190 -}
1191 -?>
978 + exit;
979 + }
980 +}