PluginProbe
Welcart e-Commerce / 1.4.11
Welcart e-Commerce v1.4.11
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
usc-e-shop / functions / settlement_func.php

settlement_func.php in Welcart e-Commerce 1.4.11, at functions/settlement_func.php

333 lines 12.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 add_action( 'usces_action_memberinfo_page_header', 'usces_action_settlement_memberinfo_page_header' );
4 add_filter( 'usces_filter_template_redirect', 'usces_filter_settlement_template_redirect' );
5 add_filter( 'usces_filter_delivery_secure_form_howpay', 'usces_filter_update_settlement_form_howpay' );
6 add_filter( 'usces_filter_available_payment_method', 'usces_filter_settlement_available_payment_method' );
7
8 function usces_filter_update_settlement_form_howpay( $html ) {
9 if( isset($_GET['page'] ) and 'member_update_settlement' == $_GET['page'] ) {
10 $html = '';
11 }
12 return $html;
13 }
14
15 function usces_filter_settlement_available_payment_method( $payments ) {
16 global $usces;
17
18 if( $usces->is_member_page($_SERVER['REQUEST_URI']) ) {
19 $payment_method = array();
20 foreach( (array)$payments as $id => $payment ) {
21 if( 'acting_zeus_card' == $payment['settlement'] ) {
22 $payment_method[$id] = $payments[$id];
23 break;
24 }
25 }
26 if( !empty($payment_method) ) $payments = $payment_method;
27 }
28 return $payments;
29 }
30
31 function usces_action_settlement_memberinfo_page_header() {
32 global $usces;
33
34 if( defined('WCEX_MOBILE') ) {
35 global $wcmb;
36 if( DOCOMO === $wcmb['device_div'] || SOFTBANK === $wcmb['device_div'] || KDDI === $wcmb['device_div'] ) return;
37 }
38
39 $html = '';
40 $member = $usces->get_member();
41 $pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] );
42 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
43 if( !empty($pcid) && !empty($partofcard) ) {
44 $update_settlement_url = add_query_arg( array( 'page' => 'member_update_settlement', 're-enter' => 1 ), USCES_MEMBER_URL );
45 $html .= '
46 <div class="gotoedit">
47 <a href="'.$update_settlement_url.'">'.__("Change the credit card is here >>", 'usces').'</a>
48 </div>';
49 }
50 echo $html;
51 }
52
53 function usces_filter_settlement_template_redirect() {
54 global $usces;
55
56 if( $usces->is_member_page($_SERVER['REQUEST_URI']) ) {
57 if( $usces->options['membersystem_state'] != 'activate' ) return;
58
59 if( $usces->is_member_logged_in() and ( isset($_REQUEST['page']) and 'member_update_settlement' == $_REQUEST['page'] ) ) {
60 $usces->page = 'member_update_settlement';
61 usces_member_update_settlement_form();
62 exit;
63 }
64 }
65 return;
66 }
67
68 function usces_member_update_settlement_form() {
69 global $usces;
70
71 $member = $usces->get_member();
72 $acting_opts = $usces->options['acting_settings']['zeus'];
73 $script = '';
74 $message = '';
75
76 if( isset($_POST['update']) ) {
77 $interface = parse_url( $acting_opts['card_url'] );
78 $rand = usces_rand();
79
80 $vars = 'send=mall';
81 $vars .= '&clientip='.$acting_opts['clientip'];
82 $cardnumber = ( empty($_POST['cnum1']) ) ? $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] ) : $_POST['cnum1'];
83 $vars .= '&cardnumber='.$cardnumber;
84 if( 1 == $usces->options['acting_settings']['zeus']['security'] ) {
85 $vars .= '&seccode='.$_POST['securecode'];
86 }
87 $vars .= '&expyy='.substr( $_POST['expyy'], 2 );
88 $vars .= '&expmm='.$_POST['expmm'];
89 $vars .= '&telno='.str_replace( '-', '', $member['tel'] );
90 $vars .= '&email='.$member['mailaddress1'];
91 $vars .= '&sendid='.$member['ID'];
92 if( !empty($_POST['username_card']) ) {
93 $vars .= '&username='.$_POST['username_card'];
94 }
95 $vars .= '&money=0';
96 $vars .= '&sendpoint='.$rand;
97 $vars .= '&printord=';
98 $vars .= '&return_value=yes';
99 //if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ) {
100 // $vars .= '&div='.$_POST['div'];
101 //}
102
103 $header = "POST ".$interface['path']." HTTP/1.1\r\n";
104 $header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n";
105 $header .= "User-Agent: PHP Script\r\n";
106 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
107 $header .= "Content-Length: ".strlen( $vars )."\r\n";
108 $header .= "Connection: close\r\n\r\n";
109 $header .= $vars;
110 $fp = fsockopen( 'ssl://'.$interface['host'], 443, $errno, $errstr, 30 );
111
112 $err_code = '';
113 $settltment_errmsg = '';
114
115 if( $fp ) {
116 $page = '';
117 fwrite( $fp, $header );
118 while( !feof( $fp ) ) {
119 $scr = fgets( $fp, 1024 );
120 $page .= $scr;
121 }
122 fclose( $fp );
123
124 if( false !== strpos( $page, 'Success_order') ) {
125 usces_log( 'zeus card : Settlement update', 'acting_transaction.log' );
126 //$usces->error_message = __( 'The update was completed.', 'usces' );
127 $usces->error_message = '';
128 $message = __( 'The update was completed.', 'usces' );
129 if( !empty($_POST['cnum1']) ) {
130 $partofcard = substr( $_POST['cnum1'], -4 );
131 $usces->set_member_meta_value( 'zeus_partofcard', $partofcard );
132 }
133 //$limitofcard = $_POST['expmm'].'/'.substr( $_POST['expyy'], -2 );
134 $usces->set_member_meta_value( 'zeus_limitofcard', $_POST['expyy'].'/'.$_POST['expmm'] );
135 usces_send_update_settlement_mail();
136 } else {
137 $err_code = usces_get_err_code( $page );
138 usces_log( 'zeus card : Certification Error : '.$err_code, 'acting_transaction.log' );
139 $usces->error_message = __( 'failure in update', 'usces' );
140 }
141 } else {
142 usces_log( 'zeus card : Socket Error', 'acting_transaction.log' );
143 $usces->error_message = __( 'failure in update', 'usces' );
144 }
145 }
146
147 $partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] );
148 //if( 4 == strlen($partofcard) ) $_POST['cnum1'] = '************'.$partofcard;
149 $limitofcard = $usces->get_member_meta_value( 'zeus_limitofcard', $member['ID'] );
150 list( $expyy, $expmm ) = explode( '/', $limitofcard );
151 if( is_numeric($expyy) ) $_POST['expyy'] = $expyy;
152 if( is_numeric($expmm) ) $_POST['expmm'] = $expmm;
153
154 $update_settlement_url = add_query_arg( array( 'page' => 'member_update_settlement', 'settlement' => 1, 're-enter' => 1 ), USCES_MEMBER_URL );
155 /*
156 $script .= "
157 <script type=\"text/javascript\">
158 jQuery( function($) {
159 $(\"input[name='howpay']\").change(function() {
160 if( '' != $(\"select[name='cbrand'] option:selected\").val() ){
161 $(\"#div_zeus\").css({\"display\": \"\"});
162 }
163 if( '1' == $(\"input[name='howpay']:checked\").val() ){
164 $(\"#cbrand_zeus\").css({\"display\": \"none\"});
165 $(\"#div_zeus\").css({\"display\": \"none\"});
166 }else{
167 $(\"#cbrand_zeus\").css({\"display\": \"\"});
168 }
169 });
170
171 $(\"select[name='cbrand']\").change(function() {
172 $(\"#div_zeus\").css({\"display\": \"\"});
173 if( '1' == $(\"select[name='cbrand'] option:selected\").val() ){
174 $(\"#brand1\").css({\"display\": \"\"});
175 $(\"#brand2\").css({\"display\": \"none\"});
176 $(\"#brand3\").css({\"display\": \"none\"});
177 }else if( '2' == $(\"select[name='cbrand'] option:selected\").val() ){
178 $(\"#brand1\").css({\"display\": \"none\"});
179 $(\"#brand2\").css({\"display\": \"\"});
180 $(\"#brand3\").css({\"display\": \"none\"});
181 }else if( '3' == $(\"select[name='cbrand'] option:selected\").val() ){
182 $(\"#brand1\").css({\"display\": \"none\"});
183 $(\"#brand2\").css({\"display\": \"none\"});
184 $(\"#brand3\").css({\"display\": \"\"});
185 }else{
186 $(\"#brand1\").css({\"display\": \"none\"});
187 $(\"#brand2\").css({\"display\": \"none\"});
188 $(\"#brand3\").css({\"display\": \"none\"});
189 }
190 });
191
192 if( '1' == $(\"input[name='howpay']:checked\").val() ){
193 $(\"#cbrand_zeus\").css({\"display\": \"none\"});
194 $(\"#div_zeus\").css({\"display\": \"none\"});
195 }else{
196 $(\"#cbrand_zeus\").css({\"display\": \"\"});
197 $(\"#div_zeus\").css({\"display\": \"\"});
198 }
199
200 if( '1' == $(\"select[name='cbrand'] option:selected\").val() ){
201 $(\"#brand1\").css({\"display\": \"\"});
202 $(\"#brand2\").css({\"display\": \"none\"});
203 $(\"#brand3\").css({\"display\": \"none\"});
204 }else if( '2' == $(\"select[name='cbrand'] option:selected\").val() ){
205 $(\"#brand1\").css({\"display\": \"none\"});
206 $(\"#brand2\").css({\"display\": \"\"});
207 $(\"#brand3\").css({\"display\": \"none\"});
208 }else if( '3' == $(\"select[name='cbrand'] option:selected\").val() ){
209 $(\"#brand1\").css({\"display\": \"none\"});
210 $(\"#brand2\").css({\"display\": \"none\"});
211 $(\"#brand3\").css({\"display\": \"\"});
212 }else{
213 $(\"#brand1\").css({\"display\": \"none\"});
214 $(\"#brand2\").css({\"display\": \"none\"});
215 $(\"#brand3\").css({\"display\": \"none\"});
216 }
217 });
218 </script>";
219 */
220 if( '' != $message ) {
221 $script .= "
222 <script type=\"text/javascript\">
223 jQuery.event.add( window, 'load', function() {
224 alert('".$message."');
225 });
226 </script>";
227 }
228
229 ob_start();
230 get_header();
231 ?>
232 <?php if( '' != $script ) echo $script; ?>
233 <div id="content" class="two-column">
234 <div class="catbox">
235
236 <?php if( have_posts() ) : usces_remove_filter(); ?>
237
238 <div class="post" id="wc_<?php usces_page_name(); ?>">
239
240 <h1 class="member_page_title"><?php _e('Credit card update', 'usces'); ?></h1>
241 <div class="entry">
242
243 <div id="memberpages">
244
245 <div class="whitebox">
246 <div id="memberinfo">
247
248 <div class="header_explanation">
249 <?php do_action( 'usces_action_member_update_settlement_page_header' ); ?>
250 </div>
251 <p>※有効期限のみ変更する場合は、カード番号は空白にして更新してください。</p>
252
253 <h3><?php _e('Credit card information', 'usces'); ?></h3>
254
255 <div class="error_message"><?php usces_error_message(); ?></div>
256 <form action="<?php echo $update_settlement_url; ?>" method="post" onKeyDown="if(event.keyCode == 13) {return false;}">
257 <?php usces_delivery_secure_form(); ?>
258 <div class="send">
259 <input name="update" type="submit" value="<?php _e('update', 'usces'); ?>" />
260 <input name="back" type="button" value="<?php _e('Back to the member page.', 'usces'); ?>" onclick="location.href='<?php echo USCES_MEMBER_URL; ?>'" />
261 <input name="top" type="button" value="<?php _e('Back to the top page.', 'usces'); ?>" onclick="location.href='<?php echo home_url(); ?>'" />
262 </div>
263 <?php do_action( 'usces_action_member_update_settlement_page_inform' ); ?>
264 </form>
265
266 <div class="footer_explanation">
267 <?php do_action( 'usces_action_member_update_settlement_page_footer' ); ?>
268 </div>
269 </div><!-- end of memberinfo -->
270 </div><!-- end of whitebox -->
271 </div><!-- end of memberpages -->
272
273 </div><!-- end of entry -->
274 </div><!-- end of post -->
275 <?php else: ?>
276 <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
277 <?php endif; ?>
278 </div><!-- end of catbox -->
279 </div><!-- end of content -->
280 <?php
281 get_sidebar( 'cartmember' );
282
283 get_footer();
284 $r = ob_get_contents();
285 ob_end_clean();
286
287 echo $r;
288 }
289
290 function usces_send_update_settlement_mail() {
291 global $usces;
292
293 $member = $usces->get_member();
294 $mail_data = $usces->options['mail_data'];
295
296 $subject = apply_filters( 'usces_filter_send_update_settlement_mail_subject', __('Confirmation of credit card update', 'usces'), $member );
297 $mail_header = __('Your credit card information has been updated.','usces')."\r\n\r\n";
298 $mail_footer = $mail_data['footer']['thankyou'];
299 $name = usces_localized_name( $member['name1'], $member['name2'], 'return' );
300
301 $message = '--------------------------------'."\r\n";
302 $message .= __('Member ID', 'usces').' : '.$member['ID']."\r\n";
303 $message .= __('Name', 'usces').' : '.sprintf( __('Mr/Mrs %s', 'usces'), $name )."\r\n";
304 $message .= __('e-mail adress', 'usces').' : '.$member['mailaddress1']."\r\n";
305 $message .= '--------------------------------'."\r\n\r\n";
306 $message .= __('If you have not requested this email, sorry to trouble you, but please contact us.', 'usces')."\r\n\r\n";
307 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message', $message, $member );
308 $message = apply_filters( 'usces_filter_send_update_settlement_mail_message_head', $mail_header, $member ).$message.apply_filters( 'usces_filter_send_update_settlement_mail_message_foot', $mail_footer, $member )."\n";
309
310 $send_para = array(
311 'to_name' => sprintf( __('Mr/Mrs %s', 'usces'), $name ),
312 'to_address' => $member['mailaddress1'],
313 'from_name' => get_option('blogname'),
314 'from_address' => $usces->options['sender_mail'],
315 'return_path' => $usces->options['sender_mail'],
316 'subject' => $subject,
317 'message' => $message
318 );
319 usces_send_mail( $send_para );
320
321 $admin_para = array(
322 'to_name' => 'Shop Admin',
323 'to_address' => $usces->options['order_mail'],
324 'from_name' => 'Welcart Auto BCC',
325 'from_address' => $usces->options['sender_mail'],
326 'return_path' => $usces->options['sender_mail'],
327 'subject' => $subject,
328 'message' => $message
329 );
330 usces_send_mail( $admin_para );
331 }
332
333 ?>