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