1 2function FormbaseValidateCard() { 3 var val = $j(FbPayTargetEl).val(); 4 var val = $j(".FpCardNumIn").val(); 5 var nondigits = new RegExp(/[^0-9]+/g); 6 var number = val.replace(nondigits, ''); 7 var pos, digit, i, sub_total, sum = 0; 8 var strlen = number.length; 9 if ((strlen < 13) || isNaN(val)) { 10 alert("Invalid Card Number."); 11 } else { 12 for (i = 0; i < strlen; i++) { 13 pos = strlen - i; 14 digit = parseInt(number.substring(pos - 1, pos)); 15 if (i % 2 == 1) { sub_total = digit * 2; if (sub_total > 9) { sub_total = 1 + (sub_total - 10); } } else { sub_total = digit; } 16 sum += sub_total; 17 } 18 if (sum > 0 && sum % 10 == 0) { if (FbPayVendor == 6) { FormbaseAuthorizeClient(); } else { FormbasePostPayment(); } } else { alert("Invalid Card Number."); } 19 } 20} 21 22 23 24 25function FormbaseAuthorizeClient() { 26 $j.ajax({ 27 type: "POST", contentType: "application/json; charset=utf-8", 28 url: FbPathToAsmx + "/GetAccessBlock", 29 data: '{\'AccessToken\':\'' + FbAccessToken + '\'}', dataType: "json", 30 success: function (data) { 31 var s4obj = JSON.parse(data.d); 32 FormbaseGetToken(s4obj.i4go_accessblock, s4obj.i4go_server); 33 } 34 }); 35} 36 37 38function FormbaseGetToken(accessBlock, serverAddr) { 39 var CardVal = $j('.FpCardNumIn').val().replace(/[^\d]/g, ""); 40 $j.ajax({ 41 type: 'POST', url: serverAddr, 42 dataType: 'jsonp', 43 jsonpCallback: 'FormbaseParseResponse', 44 data: {fuseaction: 'api.jsonpPostCardEntry', i4go_accessblock: accessBlock, i4Go_CardholderName: $j(".FpNameOnCardIn").val(), 45 i4Go_CardType: $j(".FpTypeSel").val(), i4Go_CardNumber: CardVal, i4Go_cvv2Code: $j(".FpCardCvvIn").val(), 46 i4Go_ExpirationMonth: $j(".FpMoSel").val(),i4Go_ExpirationYear: $j(".FpYrSel").val()}, 47 cache: false 48 }); 49} 50 51 52var FbShift4Token = ""; 53function FormbaseParseResponse(data) { 54 FbShift4Token = ""; 55 if (data.i4go_responsecode != null) { 56 if (data.i4go_responsecode == 1) { 57 FbShift4Token = data.i4go_uniqueid; 58 FormbasePostPayment(); 59 } else { 60 alert('Invalid Card Information, please re-enter [' + data.i4go_responsecode + ']'); 61 } 62 } else { 63 alert('Invalid Card Information'); 64 } 65} 66 67 68 69function FormbasePostPayment() { 70 var BillObj = {FirstName: $j(".FpFnameIn").val(), LastName: $j(".FpLnameIn").val(), Address1: $j('.FpAdd1In').val(), 71 City: $j(".FpCityIn").val(), State: $j(".FpStateSel").val(), Zip: $j(".FpZipIn").val(), Country: "" 72 }; 73 74 var CardObj = {CardType: $j(".FpTypeSel").val(), CardHolder: $j(".FpNameOnCardIn").val(), CardNumber: $j('.FpCardNumIn').val().replace(/[^\d]/g, ""), 75 CardCvv: $j(".FpCardCvvIn").val(), ExpMonth: $j(".FpMoSel").val(), ExpYear: $j(".FpYrSel").val(), S4Token: FbShift4Token 76 }; 77 78 var PayObj = { SetupID: FbSetupID, Amount: $j(FbPayTargetEl).val(), Vendor: FbPayVendor, BillInfo: BillObj, CardInfo: CardObj }; 79 var PayStr = JSON.stringify(PayObj).replace(/[\n\r]+\-/g, "\\'"); 80 PayStr = PayStr.replace(/'/g, "\\'"); 81 82 $j.ajax({type: "POST", contentType: "application/json; charset=utf-8", url: FbPathToAsmx + "/PostPayment", 83 data: '{\'PayData\':\'' + PayStr + '\'}', dataType: "json", 84 success: function (data) { 85 var resp = JSON.parse(data.d); 86 if (resp.Status) { 87 document.getElementById(DataIn_ClientID).value = JSON.stringify(resp); 88 document.getElementById(SubBtn_ClientID).click(); 89 } else { 90 alert("There's a problem with your submission. Please try again."); 91 } 92 }, 93 error: function (xhr, ajaxOptions, thrownError) { 94 alert("There's a problem with your submission. Please try again."); 95 } 96 }); 97 98}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.