| 1 |
jQuery( document ).ready( function( $ ) { |
| 2 |
|
| 3 |
$( 'body input[type="submit"]' ).each( function( i, elem ) { |
| 4 |
if ( "confirm" == $( this ).attr( "name" ) ) { |
| 5 |
$( this ).parents( "form" ).attr( "id", "delivery-form" ); |
| 6 |
} |
| 7 |
}); |
| 8 |
|
| 9 |
$( document ).on( "click", 'body input[type="submit"]', function( e ) { |
| 10 |
if ( "module" == paygent_params.card_service_type && "confirm" == $( this ).attr( "name" ) && $( "#paygent_card_form" ).css( "display" ) != "none" ) { |
| 11 |
var stock_card = ( 0 < $( "input[name=stock_card]" ).length ) ? $( "input[name=stock_card]:checked" ).val() : "new"; |
| 12 |
if ( "new" == stock_card ) { |
| 13 |
var check = true; |
| 14 |
if ( "" == $( "#card_number" ).val() ) { |
| 15 |
check = false; |
| 16 |
} |
| 17 |
if ( undefined == $( "#expire_year" ).get( 0 ) || undefined == $( "#expire_month" ).get( 0 ) ) { |
| 18 |
check = false; |
| 19 |
} else if ( "" == $( "#expire_year option:selected" ).val() || "" == $( "#expire_month option:selected" ).val() ) { |
| 20 |
check = false; |
| 21 |
} |
| 22 |
if ( "on" == paygent_params.use_card_conf_number ) { |
| 23 |
if ( "" == $( "#cvc" ).val() ) { |
| 24 |
check = false; |
| 25 |
} |
| 26 |
} |
| 27 |
if( !check ) { |
| 28 |
alert( paygent_params.message.error_card_number ); |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
var card_number = $( "#card_number" ).val(); |
| 33 |
var expire_year = $( "#expire_year option:selected" ).val(); |
| 34 |
var expire_month = $( "#expire_month option:selected" ).val(); |
| 35 |
var cvc = ( "on" == paygent_params.use_card_conf_number ) ? $( "#cvc" ).val() : ""; |
| 36 |
|
| 37 |
var paygentToken = new PaygentToken(); |
| 38 |
paygentToken.createToken( |
| 39 |
paygent_params.seq_merchant_id, |
| 40 |
paygent_params.token_key, |
| 41 |
{ |
| 42 |
card_number: card_number, |
| 43 |
expire_year: expire_year, |
| 44 |
expire_month: expire_month, |
| 45 |
cvc: cvc, |
| 46 |
name: "" |
| 47 |
}, execPurchase |
| 48 |
); |
| 49 |
return false; |
| 50 |
} else if ( "stock" == stock_card && "on" == paygent_params.use_card_conf_number ) { |
| 51 |
var message = ""; |
| 52 |
if ( "" == $( "#cvc" ).val() ) { |
| 53 |
message += paygent_params.message.error_card_cvc + "\n"; |
| 54 |
} |
| 55 |
if ( "" != message ) { |
| 56 |
alert( message ); |
| 57 |
return false; |
| 58 |
} |
| 59 |
|
| 60 |
var cvc = $( "#cvc" ).val(); |
| 61 |
|
| 62 |
var paygentToken = new PaygentToken(); |
| 63 |
paygentToken.createCvcToken( |
| 64 |
paygent_params.seq_merchant_id, |
| 65 |
paygent_params.token_key, |
| 66 |
{ |
| 67 |
cvc: cvc |
| 68 |
}, execPurchase |
| 69 |
); |
| 70 |
return false; |
| 71 |
} else { |
| 72 |
$( "delivery-form" ).submit(); |
| 73 |
} |
| 74 |
|
| 75 |
} else if ( "module" == paygent_params.conv_service_type && "confirm" == $( this ).attr( "name" ) && $( "#paygent_conv_form" ).css( "display" ) != "none" ) { |
| 76 |
var message = ''; |
| 77 |
if ( "" == $( "#customer_family_name" ).val() ) { |
| 78 |
message += paygent_params.message.error_customer_family_name + "\n"; |
| 79 |
} |
| 80 |
if ( "" == $( "#customer_name" ).val() ) { |
| 81 |
message += paygent_params.message.error_customer_name + "\n"; |
| 82 |
} |
| 83 |
if ( "" == $( "#customer_tel" ).val() ) { |
| 84 |
message += paygent_params.message.error_customer_tel + "\n"; |
| 85 |
} |
| 86 |
if ( "" != message ) { |
| 87 |
alert( message ); |
| 88 |
return false; |
| 89 |
} |
| 90 |
$( "delivery-form" ).submit(); |
| 91 |
|
| 92 |
} else { |
| 93 |
$( "delivery-form" ).submit(); |
| 94 |
} |
| 95 |
}); |
| 96 |
|
| 97 |
if ( "module" == paygent_params.card_service_type && $( "input[name=stock_card]" ).length ) { |
| 98 |
$( document ).on( "click", ".stock_card", function( e ) { |
| 99 |
if ( "stock" == $( "input[name=stock_card]:checked" ).val() ) { |
| 100 |
$( ".paygent_new_card_area" ).hide(); |
| 101 |
$( "#card_number" ).prop( "disabled", true ); |
| 102 |
if( $( "#cust_manage" ).length ) { |
| 103 |
$( "#cust_manage" ).prop( "disabled", true ); |
| 104 |
$( "#cust_manage_label" ).css( "color", "#848484" ); |
| 105 |
} |
| 106 |
$( "#expire_month" ).prop( "disabled", true ).css( "background-color", "#ebebe4" ); |
| 107 |
$( "#expire_year" ).prop( "disabled", true ).css( "background-color", "#ebebe4" ); |
| 108 |
} else { |
| 109 |
$( ".paygent_new_card_area" ).show(); |
| 110 |
$( "#card_number" ).prop( "disabled", false ); |
| 111 |
if ( $( "#cust_manage" ).length ) { |
| 112 |
$( "#cust_manage" ).prop( "disabled", false ); |
| 113 |
$( "#cust_manage_label" ).css( "color", "#000" ); |
| 114 |
} |
| 115 |
$( "#expire_month" ).prop( "disabled", false ).css( "background-color", "#fff" ); |
| 116 |
$( "#expire_year" ).prop( "disabled", false ).css( "background-color", "#fff" ); |
| 117 |
} |
| 118 |
}); |
| 119 |
$( "#stock_card_use" ).prop( "checked", true ).trigger( "click" ); |
| 120 |
if ( $( "#split_type" ).length ) { |
| 121 |
/* VISA|Master Card|JCB */ |
| 122 |
if ( "4535" == $( "#split_type" ).val() ) { |
| 123 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 124 |
$( "#split_count_4535" ).prop( "disabled", false ).css( "display", "inline" ); |
| 125 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 126 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 127 |
/* Diners Club */ |
| 128 |
} else if ( "36" == $( "#split_type" ).val() ) { |
| 129 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 130 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 131 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 132 |
$( "#split_count_36" ).prop( "disabled", false ).css( "display", "inline" ); |
| 133 |
/* American Express */ |
| 134 |
} else if ( "37" == $( "#split_type" ).val() ) { |
| 135 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 136 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 137 |
$( "#split_count_37" ).prop( "disabled", false ).css( "display", "inline" ); |
| 138 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 139 |
} else { |
| 140 |
$( "#split_count_default" ).prop( "disabled", false ).css( "display", "inline" ); |
| 141 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 142 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 143 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
if ( "module" == paygent_params.card_service_type ) { |
| 149 |
$( document ).on( "change", "#card_number", function( e ) { |
| 150 |
var first_c = $( this ).val().substr( 0, 1 ); |
| 151 |
var second_c = $( this ).val().substr( 1, 1 ); |
| 152 |
/* VISA|Master Card|JCB */ |
| 153 |
if ( '4' == first_c || '5' == first_c || ( '3' == first_c && '5' == second_c ) ) { |
| 154 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 155 |
$( "#split_count_4535" ).prop( "disabled", false ).css( "display", "inline" ); |
| 156 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 157 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 158 |
/* Diners Club */ |
| 159 |
} else if ( '3' == first_c && '6' == second_c ) { |
| 160 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 161 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 162 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 163 |
$( "#split_count_36" ).prop( "disabled", false ).css( "display", "inline" ); |
| 164 |
/* American Express */ |
| 165 |
} else if ( '3' == first_c && '7' == second_c ) { |
| 166 |
$( "#split_count_default" ).prop( "disabled", true ).css( "display", "none" ); |
| 167 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 168 |
$( "#split_count_37" ).prop( "disabled", false ).css( "display", "inline" ); |
| 169 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 170 |
} else { |
| 171 |
$( "#split_count_default" ).prop( "disabled", false ).css( "display", "inline" ); |
| 172 |
$( "#split_count_4535" ).prop( "disabled", true ).css( "display", "none" ); |
| 173 |
$( "#split_count_37" ).prop( "disabled", true ).css( "display", "none" ); |
| 174 |
$( "#split_count_36" ).prop( "disabled", true ).css( "display", "none" ); |
| 175 |
} |
| 176 |
}); |
| 177 |
} |
| 178 |
}); |
| 179 |
|
| 180 |
function execPurchase( response ) { |
| 181 |
if ( response.result == "0000" ) { |
| 182 |
document.getElementById( "token" ).value = response.tokenizedCardObject.token; |
| 183 |
document.getElementById( "masked_card_number" ).value = response.tokenizedCardObject.masked_card_number; |
| 184 |
document.getElementById( "valid_until" ).value = response.tokenizedCardObject.valid_until; |
| 185 |
document.getElementById( "fingerprint" ).value = response.tokenizedCardObject.fingerprint; |
| 186 |
document.getElementById( "hc" ).value = response.hc; |
| 187 |
document.getElementById( "delivery-form" ).submit(); |
| 188 |
} else { |
| 189 |
alert( paygent_params.message.error_token ); |
| 190 |
return false; |
| 191 |
} |
| 192 |
} |
| 193 |
|