| 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 |
|
| 7 |
function usces_filter_update_settlement_form_howpay( $html ) { |
| 8 |
if( isset($_GET['page'] ) and 'member_update_settlement' == $_GET['page'] ) { |
| 9 |
$html = ''; |
| 10 |
} |
| 11 |
return $html; |
| 12 |
} |
| 13 |
|
| 14 |
function usces_action_settlement_memberinfo_page_header() { |
| 15 |
global $usces; |
| 16 |
|
| 17 |
$html = ''; |
| 18 |
$member = $usces->get_member(); |
| 19 |
$pcid = $usces->get_member_meta_value( 'zeus_pcid', $member['ID'] ); |
| 20 |
if( $pcid ) { |
| 21 |
$update_settlement_url = add_query_arg( array( 'page' => 'member_update_settlement', 're-enter' => 1 ), USCES_MEMBER_URL ); |
| 22 |
$html .= ' |
| 23 |
<div class="gotoedit"> |
| 24 |
<a href="'.$update_settlement_url.'">'.__("Change the credit card is here >>", 'usces').'</a> |
| 25 |
</div>'; |
| 26 |
} |
| 27 |
echo $html; |
| 28 |
} |
| 29 |
|
| 30 |
function usces_filter_settlement_template_redirect() { |
| 31 |
global $usces; |
| 32 |
|
| 33 |
if( $usces->is_member_page($_SERVER['REQUEST_URI']) ) { |
| 34 |
if( $usces->options['membersystem_state'] != 'activate' ) return; |
| 35 |
|
| 36 |
if( $usces->is_member_logged_in() and ( isset($_REQUEST['page']) and 'member_update_settlement' == $_REQUEST['page'] ) ) { |
| 37 |
$usces->page = 'member_update_settlement'; |
| 38 |
usces_member_update_settlement_form(); |
| 39 |
exit; |
| 40 |
} |
| 41 |
} |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
function usces_member_update_settlement_form() { |
| 46 |
global $usces; |
| 47 |
|
| 48 |
$member = $usces->get_member(); |
| 49 |
$acting_opts = $usces->options['acting_settings']['zeus']; |
| 50 |
$script = ''; |
| 51 |
$message = ''; |
| 52 |
|
| 53 |
if( isset($_POST['update']) ) { |
| 54 |
$interface = parse_url( $acting_opts['card_url'] ); |
| 55 |
$rand = sprintf( '%010d', mt_rand(1, 9999999999) ); |
| 56 |
|
| 57 |
$vars = 'send=mall'; |
| 58 |
$vars .= '&clientip='.$acting_opts['clientip']; |
| 59 |
$vars .= '&cardnumber='.$_POST['cnum1']; |
| 60 |
if( 1 == $usces->options['acting_settings']['zeus']['security'] ) { |
| 61 |
$vars .= '&seccode='.$_POST['securecode']; |
| 62 |
} |
| 63 |
$vars .= '&expyy='.substr( $_POST['expyy'], 2 ); |
| 64 |
$vars .= '&expmm='.$_POST['expmm']; |
| 65 |
$vars .= '&telno='.str_replace( '-', '', $member['tel'] ); |
| 66 |
$vars .= '&email='.$member['mailaddress1']; |
| 67 |
$vars .= '&sendid='.$member['ID']; |
| 68 |
$vars .= '&username='.$_POST['username']; |
| 69 |
$vars .= '&money=0'; |
| 70 |
$vars .= '&sendpoint='.$rand; |
| 71 |
$vars .= '&printord='; |
| 72 |
$vars .= '&return_value=yes'; |
| 73 |
//if( isset($_POST['howpay']) && WCUtils::is_zero($_POST['howpay']) ) { |
| 74 |
// $vars .= '&div='.$_POST['div']; |
| 75 |
//} |
| 76 |
|
| 77 |
$header = "POST ".$interface['path']." HTTP/1.1\r\n"; |
| 78 |
$header .= "Host: ".$_SERVER['HTTP_HOST']."\r\n"; |
| 79 |
$header .= "User-Agent: PHP Script\r\n"; |
| 80 |
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| 81 |
$header .= "Content-Length: ".strlen( $vars )."\r\n"; |
| 82 |
$header .= "Connection: close\r\n\r\n"; |
| 83 |
$header .= $vars; |
| 84 |
$fp = fsockopen( 'ssl://'.$interface['host'], 443, $errno, $errstr, 30 ); |
| 85 |
|
| 86 |
$err_code = ''; |
| 87 |
$settltment_errmsg = ''; |
| 88 |
|
| 89 |
if( $fp ) { |
| 90 |
$page = ''; |
| 91 |
fwrite( $fp, $header ); |
| 92 |
while( !feof( $fp ) ) { |
| 93 |
$scr = fgets( $fp, 1024 ); |
| 94 |
$page .= $scr; |
| 95 |
} |
| 96 |
fclose( $fp ); |
| 97 |
|
| 98 |
if( false !== strpos( $page, 'Success_order') ) { |
| 99 |
usces_log( 'zeus card : Settlement update', 'acting_transaction.log' ); |
| 100 |
//$usces->error_message = __( 'The update was completed.', 'usces' ); |
| 101 |
$usces->error_message = ''; |
| 102 |
$message = __( 'The update was completed.', 'usces' ); |
| 103 |
$partofcard = substr( $_POST['cnum1'], -4 ); |
| 104 |
$usces->set_member_meta_value( 'zeus_partofcard', $partofcard ); |
| 105 |
} else { |
| 106 |
$err_code = usces_get_err_code( $page ); |
| 107 |
usces_log( 'zeus card : Certification Error : '.$err_code, 'acting_transaction.log' ); |
| 108 |
$usces->error_message = __( 'failure in update', 'usces' ); |
| 109 |
} |
| 110 |
} else { |
| 111 |
usces_log( 'zeus card : Socket Error', 'acting_transaction.log' ); |
| 112 |
$usces->error_message = __( 'failure in update', 'usces' ); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
$partofcard = $usces->get_member_meta_value( 'zeus_partofcard', $member['ID'] ); |
| 117 |
if( 4 == strlen($partofcard) ) $_POST['cnum1'] = '************'.$partofcard; |
| 118 |
|
| 119 |
$update_settlement_url = add_query_arg( array( 'page' => 'member_update_settlement', 'settlement' => 1, 're-enter' => 1 ), USCES_MEMBER_URL ); |
| 120 |
/* |
| 121 |
$script .= " |
| 122 |
<script type=\"text/javascript\"> |
| 123 |
jQuery( function($) { |
| 124 |
$(\"input[name='howpay']\").change(function() { |
| 125 |
if( '' != $(\"select[name='cbrand'] option:selected\").val() ){ |
| 126 |
$(\"#div_zeus\").css({\"display\": \"\"}); |
| 127 |
} |
| 128 |
if( '1' == $(\"input[name='howpay']:checked\").val() ){ |
| 129 |
$(\"#cbrand_zeus\").css({\"display\": \"none\"}); |
| 130 |
$(\"#div_zeus\").css({\"display\": \"none\"}); |
| 131 |
}else{ |
| 132 |
$(\"#cbrand_zeus\").css({\"display\": \"\"}); |
| 133 |
} |
| 134 |
}); |
| 135 |
|
| 136 |
$(\"select[name='cbrand']\").change(function() { |
| 137 |
$(\"#div_zeus\").css({\"display\": \"\"}); |
| 138 |
if( '1' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 139 |
$(\"#brand1\").css({\"display\": \"\"}); |
| 140 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 141 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 142 |
}else if( '2' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 143 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 144 |
$(\"#brand2\").css({\"display\": \"\"}); |
| 145 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 146 |
}else if( '3' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 147 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 148 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 149 |
$(\"#brand3\").css({\"display\": \"\"}); |
| 150 |
}else{ |
| 151 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 152 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 153 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 154 |
} |
| 155 |
}); |
| 156 |
|
| 157 |
if( '1' == $(\"input[name='howpay']:checked\").val() ){ |
| 158 |
$(\"#cbrand_zeus\").css({\"display\": \"none\"}); |
| 159 |
$(\"#div_zeus\").css({\"display\": \"none\"}); |
| 160 |
}else{ |
| 161 |
$(\"#cbrand_zeus\").css({\"display\": \"\"}); |
| 162 |
$(\"#div_zeus\").css({\"display\": \"\"}); |
| 163 |
} |
| 164 |
|
| 165 |
if( '1' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 166 |
$(\"#brand1\").css({\"display\": \"\"}); |
| 167 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 168 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 169 |
}else if( '2' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 170 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 171 |
$(\"#brand2\").css({\"display\": \"\"}); |
| 172 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 173 |
}else if( '3' == $(\"select[name='cbrand'] option:selected\").val() ){ |
| 174 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 175 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 176 |
$(\"#brand3\").css({\"display\": \"\"}); |
| 177 |
}else{ |
| 178 |
$(\"#brand1\").css({\"display\": \"none\"}); |
| 179 |
$(\"#brand2\").css({\"display\": \"none\"}); |
| 180 |
$(\"#brand3\").css({\"display\": \"none\"}); |
| 181 |
} |
| 182 |
}); |
| 183 |
</script>"; |
| 184 |
*/ |
| 185 |
if( '' != $message ) { |
| 186 |
$script .= " |
| 187 |
<script type=\"text/javascript\"> |
| 188 |
jQuery.event.add( window, 'load', function() { |
| 189 |
alert('".$message."'); |
| 190 |
}); |
| 191 |
</script>"; |
| 192 |
} |
| 193 |
|
| 194 |
ob_start(); |
| 195 |
get_header(); |
| 196 |
?> |
| 197 |
<?php if( '' != $script ) echo $script; ?> |
| 198 |
<div id="content" class="two-column"> |
| 199 |
<div class="catbox"> |
| 200 |
|
| 201 |
<?php if( have_posts() ) : usces_remove_filter(); ?> |
| 202 |
|
| 203 |
<div class="post" id="wc_<?php usces_page_name(); ?>"> |
| 204 |
|
| 205 |
<h1 class="member_page_title"><?php _e('Credit card update', 'usces'); ?></h1> |
| 206 |
<div class="entry"> |
| 207 |
|
| 208 |
<div id="memberpages"> |
| 209 |
|
| 210 |
<div class="whitebox"> |
| 211 |
<div id="memberinfo"> |
| 212 |
|
| 213 |
<div class="header_explanation"> |
| 214 |
<?php do_action( 'usces_action_member_update_settlement_page_header' ); ?> |
| 215 |
</div> |
| 216 |
|
| 217 |
<h3><?php _e('Credit card information', 'usces'); ?></h3> |
| 218 |
|
| 219 |
<div class="error_message"><?php usces_error_message(); ?></div> |
| 220 |
<form action="<?php echo $update_settlement_url; ?>" method="post" onKeyDown="if(event.keyCode == 13) {return false;}"> |
| 221 |
<?php usces_delivery_secure_form(); ?> |
| 222 |
<div class="send"> |
| 223 |
<input name="update" type="submit" value="<?php _e('update', 'usces'); ?>" /> |
| 224 |
<input name="back" type="button" value="<?php _e('Back to the member page.', 'usces'); ?>" onclick="location.href='<?php echo USCES_MEMBER_URL; ?>'" /> |
| 225 |
<input name="top" type="button" value="<?php _e('Back to the top page.', 'usces'); ?>" onclick="location.href='<?php echo home_url(); ?>'" /> |
| 226 |
</div> |
| 227 |
<?php do_action( 'usces_action_member_update_settlement_page_inform' ); ?> |
| 228 |
</form> |
| 229 |
|
| 230 |
<div class="footer_explanation"> |
| 231 |
<?php do_action( 'usces_action_member_update_settlement_page_footer' ); ?> |
| 232 |
</div> |
| 233 |
</div><!-- end of memberinfo --> |
| 234 |
</div><!-- end of whitebox --> |
| 235 |
</div><!-- end of memberpages --> |
| 236 |
|
| 237 |
</div><!-- end of entry --> |
| 238 |
</div><!-- end of post --> |
| 239 |
<?php else: ?> |
| 240 |
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p> |
| 241 |
<?php endif; ?> |
| 242 |
</div><!-- end of catbox --> |
| 243 |
</div><!-- end of content --> |
| 244 |
<?php |
| 245 |
get_sidebar( 'cartmember' ); |
| 246 |
|
| 247 |
get_footer(); |
| 248 |
$r = ob_get_contents(); |
| 249 |
ob_end_clean(); |
| 250 |
|
| 251 |
echo $r; |
| 252 |
} |
| 253 |
|
| 254 |
?> |