eway.twig (8275B)
1 {% if error %} 2 <div class="alert alert-danger alert-dismissible">Payment Error: {{ error }}</div> 3 {% else %} 4 <form action="{{ action }}" method="POST" class="form-horizontal" id="eway-payment-form"> 5 <fieldset id="payment"> 6 <legend>{{ text_credit_card }}</legend> 7 <input type="hidden" name="EWAY_ACCESSCODE" value="{{ AccessCode }}" /> 8 {% if text_testing %} 9 <div class="alert alert-warning alert-dismissible">{{ text_testing }}</div> 10 {% endif %} 11 <div class="form-group"> 12 <div class="col-sm-12"> 13 <ul> 14 {% if payment_type.visa == 1 or payment_type.mastercard == 1 or payment_type.diners == 1 or payment_type.jcb == 1 or payment_type.amex == 1 %} 15 <label> 16 <input type="radio" name="EWAY_PAYMENTTYPE" id="eway-radio-cc" value="creditcard" checked="checked" onchange="javascript:select_eWAYPaymentOption('creditcard')" /> 17 {% if payment_type.visa == 1 %} <img src="catalog/view/theme/default/image/eway_creditcard_visa.png" height="30" alt="Visa" /> {% endif %} 18 {% if payment_type.mastercard == 1 %} <img src="catalog/view/theme/default/image/eway_creditcard_master.png" height="30" alt="MasterCard" /> {% endif %} 19 {% if payment_type.diners == 1 %} <img src="catalog/view/theme/default/image/eway_creditcard_diners.png" height="30" alt="Diners Club" /> {% endif %} 20 {% if payment_type.jcb == 1 %} <img src="catalog/view/theme/default/image/eway_creditcard_jcb.png" height="30" alt="JCB" /> {% endif %} 21 {% if payment_type.amex == 1 %} <img src="catalog/view/theme/default/image/eway_creditcard_amex.png" height="30" alt="AMEX" /> {% endif %} </label> 22 {% endif %} 23 {% if payment_type.paypal == 1 %} 24 <label> 25 <input type="radio" name="EWAY_PAYMENTTYPE" value="paypal" onchange="javascript:select_eWAYPaymentOption(paypal)" /> 26 <img src="catalog/view/theme/default/image/eway_paypal.png" height="30" alt="{{ text_card_type_pp }}" /></label> 27 {% endif %} 28 {% if payment_type.masterpass == 1 %} 29 <label> 30 <input type="radio" name="EWAY_PAYMENTTYPE" value="masterpass" onchange="javascript:select_eWAYPaymentOption(masterpass)" /> 31 <img src="catalog/view/theme/default/image/eway_masterpass.png" height="30" alt="{{ text_card_type_mp }}" /></label> 32 {% endif %} 33 </ul> 34 </div> 35 </div> 36 {% if payment_type.paypal == 1 %} 37 <p id="tip-paypal" style="display:none;">{{ text_type_help }}{{ text_card_type_pp }}</p> 38 {% endif %} 39 {% if payment_type.masterpass == 1 %} 40 <p id="tip-masterpass" style="display:none;">{{ text_type_help }}{{ text_card_type_mp }}</p> 41 {% endif %} 42 {% if payment_type.visa == 1 and payment_type.mastercard == 1 and payment_type.diners == 1 or payment_type.jcb == 1 or payment_type.amex == 1 %} 43 <div id="creditcard-info"> 44 <div class="form-group required"> 45 <label class="col-sm-2 control-label" for="eway-cardname">{{ entry_cc_name }}</label> 46 <div class="col-sm-10"> 47 <input name="EWAY_CARDNAME" type="text" value="" id="eway-cardname" placeholder="{{ entry_cc_name }}" autocomplete="off" class="form-control"/> 48 <span id="ewaycard-error" class="text-danger"></span> </div> 49 </div> 50 <div class="form-group required"> 51 <label class="col-sm-2 control-label" for="eway-cardnumber">{{ entry_cc_number }}</label> 52 <div class="col-sm-10"> 53 <input name="EWAY_CARDNUMBER" type="text" maxlength="19" id="eway-cardnumber" value="" placeholder="{{ entry_cc_number }}" autocomplete="off" class="form-control" pattern="\d*" /> 54 <span id="ewaynumber-error" class="text-danger"></span> </div> 55 </div> 56 <div class="form-group required"> 57 <label class="col-sm-2 control-label" for="eway-card-expiry-month">{{ entry_cc_expire_date }}</label> 58 <div class="col-sm-2"> 59 <select name="EWAY_CARDEXPIRYMONTH" id="eway-card-expiry-month" class="form-control"> 60 61 62 % for month in months %} 63 64 65 <option value="{{ month.value }}">{{ month.text }}</option> 66 67 68 {% endfor %} 69 70 71 </select> 72 </div> 73 <div class="col-sm-2"> 74 <select name="EWAY_CARDEXPIRYYEAR" id="eway-card-expiry-year" class="form-control"> 75 76 77 % for year in year_expire %} 78 79 80 <option value="{{ year.value }}">{{ year.text }}</option> 81 82 83 {% endfor %} 84 85 86 </select> 87 <div id="expiry-error" class="text-danger"></div> 88 </div> 89 </div> 90 <div class="form-group required"> 91 <label class="col-sm-2 control-label" for="eway-cardcvn">{{ entry_cc_cvv2 }}</label> 92 <div class="col-sm-10"> 93 <input name="EWAY_CARDCVN" type="text" maxlength="4" value="" placeholder="{{ entry_cc_cvv2 }}" id="eway-cardcvn" autocomplete="off" class="form-control" pattern="\d*" /> 94 <span id="cvn-details" class="help"> {{ help_cvv }} 95 {% if 'amex' in payment_type %}<br /> 96 {{ help_cvv_amex }} 97 {% endif %} </span><br /> 98 <span id="ewaycvn-error" class="text-danger"></span> </div> 99 </div> 100 {% endif %} 101 </fieldset> 102 </form> 103 <div class="buttons"> 104 <div class="pull-right"> 105 <input type="button" value="{{ button_confirm }}" id="button-confirm" data-loading-text="{{ text_loading }}" class="btn btn-primary" /> 106 </div> 107 </div> 108 <script language="JavaScript" type="text/javascript" >//<!-- 109 function select_eWAYPaymentOption(v) { 110 if ($("#creditcard-info").length) { 111 $("#creditcard-info").hide(); 112 } 113 if ($("#tip-paypal").length) { 114 $("#tip-paypal").hide(); 115 } 116 if ($("#tip-masterpass").length) { 117 $("#tip-masterpass").hide(); 118 } 119 if ($("#tip-vme").length) { 120 $("#tip-vme").hide(); 121 } 122 if (v == 'creditcard') { 123 $("#creditcard-info").show(); 124 } else { 125 $("#tip-" + v).show(); 126 } 127 } 128 //--></script> 129 <script type="text/javascript"><!-- 130 $('#button-confirm').bind('click', function () { 131 132 if ($('#eway-radio-cc').is(':checked')) { 133 var eway_error = false; 134 if ($('#eway-cardname').val().length < 1) { 135 eway_error = true; 136 $('#ewaycard-error').html('Card Holder\'s Name must be entered'); 137 } else { 138 $('#ewaycard-error').empty(); 139 } 140 141 var ccnum_regex = new RegExp("^[0-9]{13,19}$"); 142 if (!ccnum_regex.test($('#eway-cardnumber').val().replace(/ /g, '')) || !luhn10($('#eway-cardnumber').val())) { 143 eway_error = true; 144 $('#ewaynumber-error').html('Card Number appears invalid'); 145 } else { 146 $('#ewaynumber-error').empty(); 147 } 148 149 var cc_year = parseInt($('#eway-card-expiry-year').val(), 10); 150 var cc_month = parseInt($('#eway-card-expiry-month').val(), 10); 151 152 var cc_expiry = new Date(cc_year, cc_month, 1); 153 var cc_expired = new Date(cc_expiry - 1); 154 var today = new Date(); 155 156 if (today.getTime() > cc_expired.getTime()) { 157 eway_error = true; 158 $('#expiry-error').html('This expiry date has passed'); 159 } else { 160 $('#expiry-error').empty(); 161 } 162 163 var ccv_regex = new RegExp("^[0-9]{3,4}$"); 164 if (!ccv_regex.test($('#eway-cardcvn').val().replace(/ /g, ''))) { 165 eway_error = true; 166 $('#ewaycvn-error').html('CVV/CSV Number appears invalid'); 167 } else { 168 $('#ewaycvn-error').empty(); 169 } 170 171 if (eway_error) { 172 return false; 173 } 174 } 175 176 $('#eway-payment-form').submit(); 177 $('#button-confirm').button('loading'); 178 $("#button-confirm").prop('disabled', true); 179 180 }); 181 182 var luhn10 = function (a, b, c, d, e) { 183 for (d = +a[b = a.length - 1], e = 0; b--; ) { 184 c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c; 185 } 186 return !(d % 10) 187 }; 188 189 //--></script> 190 {% endif %}