countries = { "-Please select-": "", "Afghanistan": "AF", "Aland Islands": "AX", "Albania": "AL", "Algeria": "DZ", "American Samoa": "AS", "Andorra": "AD", "Angola": "AO", "Anguilla": "AI", "Antigua and Barbuda": "AG", "Argentina": "AR", "Armenia": "AM", "Aruba": "AW", "Australia": "AU", "Austria": "AT", "Azerbaijan": "AZ", "Bahamas": "BS", "Bahrain": "BH", "Bangladesh": "BD", "Barbados": "BB", "Belarus": "BY", "Belgium": "BE", "Belize": "BZ", "Benin": "BJ", "Bermuda": "BM", "Bhutan": "BT", "Bolivia": "BO", "Bonaire, Sint Eustatius and Saba": "BQ", "Bosnia and Herzegovina": "BA", "Botswana": "BW", "Bouvet Island": "BV", "Brazil": "BR", "Brit. Indian Ocean": "IO", "British Virgin Islands": "VG", "Brunei": "BN", "Bulgaria": "BG", "Burkina Faso": "BF", "Burundi": "BI", "Cambodia": "KH", "Cameroon": "CM", "Canada": "CA", "Cape Verde": "CV", "Cayman Islands": "KY", "Central African Republic": "CF", "Chad": "TD", "Chile": "CL", "China": "CN", "Christmas Island": "CX", "Cocos Islands": "CC", "Colombia": "CO", "Comoros": "KM", "Cook Islands": "CK", "Costa Rica": "CR", "Cote D’Ivoire": "CI", "Croatia": "HR", "Curaçao": "CW", "Cyprus": "CY", "Czech Republic": "CZ", "Denmark": "DK", "Djibouti": "DJ", "Dominica": "DM", "Dominican Republic": "DO", "Ecuador": "EC", "Egypt": "EG", "El Salvador": "SV", "Equatorial Guinea": "GQ", "Eritrea": "ER", "Estonia": "EE", "Ethiopia": "ET", "Falkland Islands": "FK", "Faroe Islands": "FO", "Fiji": "FJ", "Finland": "FI", "France": "FR", "French Guiana": "GF", "French Polynesia": "PF", "French Southern Terr.": "TF", "Gabon": "GA", "Gambia": "GM", "Georgia": "GE", "Germany": "DE", "Ghana": "GH", "Gibraltar": "GI", "Greece": "GR", "Greenland": "GL", "Grenada": "GD", "Guadeloupe": "GP", "Guam": "GU", "Guatemala": "GT", "Guernsey": "GG", "Guinea": "GN", "Guinea-Bissau": "GW", "Guyana": "GY", "Haiti": "HT", "Heard/ Mcdonald Islands": "HM", "Holy See/ Vatican City": "VA", "Honduras": "HN", "Hong Kong": "HK", "Hungary": "HU", "Iceland": "IS", "India": "IN", "Indonesia": "ID", "Iraq": "IQ", "Ireland": "IE", "Isle of Man": "IM", "Israel": "IL", "Italy": "IT", "Jamaica": "JM", "Japan": "JP", "Jersey": "JE", "Jordan": "JO", "Kazakhstan": "KZ", "Kenya": "KE", "Kiribati": "KI", "Kuwait": "KW", "Kyrgyzstan": "KG", "Lao People’s DR": "LA", "Latvia": "LV", "Lebanon": "LB", "Lesotho": "LS", "Liberia": "LR", "Liechtenstein": "LI", "Lithuania": "LT", "Luxembourg": "LU", "Macao": "MO", "Macedonia": "MK", "Madagascar": "MG", "Malawi": "MW", "Malaysia": "MY", "Maldives": "MV", "Mali": "ML", "Malta": "MT", "Marshall Islands": "MH", "Martinique": "MQ", "Mauritania": "MR", "Mauritius": "MU", "Mayotte": "YT", "Mexico": "MX", "Micronesia": "FM", "Moldova": "MD", "Monaco": "MC", "Mongolia": "MN", "Montenegro": "ME", "Montserrat": "MS", "Morocco": "MA", "Mozambique": "MZ", "Myanmar": "MM", "Namibia": "NA", "Nauru": "NR", "Nepal": "NP", "Netherlands": "NL", "Netherlands Antilles": "AN", "New Caledonia": "NC", "New Zealand": "NZ", "Niger": "NE", "Nigeria": "NG", "Niue": "NU", "Norfolk Island": "NF", "Northern Mariana Islands": "MP", "Norway": "NO", "Oman": "OM", "Pakistan": "PK", "Palau": "PW", "Palestinian Territory": "PS", "Panama": "PA", "Papua New Guinea": "PG", "Paraguay": "PY", "Peru": "PE", "Philippines": "PH", "Pitcairn": "PN", "Poland": "PL", "Portugal": "PT", "Puerto Rico": "PR", "Qatar": "QA", "Republic of Congo": "CG", "Republic of Serbia": "RS", "Reunion": "RE", "Romania": "RO", "Russian Federation": "RU", "Rwanda": "RW", "S. Georgia/ Sandwich Islands": "GS", "Saint Helena": "SH", "Saint Kitts and Nevis": "KN", "Saint Lucia": "LC", "Saint Martin": "MF", "Saint Pierre and Miquelon": "PM", "Saint Vincent/ Grenadines": "VC", "Samoa": "WS", "San Marino": "SM", "Sao Tome and Principe": "ST", "Saudi Arabia": "SA", "Senegal": "SN", "Seychelles": "SC", "Sierra Leone": "SL", "Singapore": "SG", "Slovakia": "SK", "Slovenia": "SI", "Solomon Islands": "SB", "South Africa": "ZA", "South Korea": "KR", "Spain": "ES", "Sri Lanka": "LK", "Sudan": "SD", "Suriname": "SR", "Svalbard and Jan Mayen": "SJ", "Swaziland": "SZ", "Sweden": "SE", "Switzerland": "CH", "Taiwan": "TW", "Tajikistan": "TJ", "Tanzania": "TZ", "Thailand": "TH", "Timor-Leste": "TL", "Togo": "TG", "Tokelau": "TK", "Tonga": "TO", "Trinidad and Tobago": "TT", "Tunisia": "TN", "Turkey": "TR", "Turkmenistan": "TM", "Turks and Caicos Islands": "TC", "Tuvalu": "TV", "U.S. Virgin Islands": "VI", "Uganda": "UG", "Ukraine": "UA", "United Arab Emirates": "AE", "United Kingdom": "GB", "United States": "US", "United States (M.O.I.)": "UM", "Uruguay": "UY", "Uzbekistan": "UZ", "Vanuatu": "VU", "Vietnam": "VN", "Wallis and Futuna": "WF", "Western Sahara": "EH", "Zambia": "ZM", "Zimbabwe": "ZW" } var passthroughData, productId, quantity mode = "paddle" // mode = "mycommerce" function validateform() { switch ($("#editionSelect").val()) { case "professional": $('#domainRequired').show(); $('#maxAccountsRequired').show(); break case "enhanced": $('#domainRequired').show(); $('#maxAccountsRequired').hide(); $('#maxAccountsInput').val(''); break case "redteam": $('#domainRequired').hide(); $('#domainInput').val(''); $('#maxAccountsRequired').hide(); $('#maxAccountsInput').val(''); break default: $('#domainRequired').hide(); $('#domainInput').val(''); $('#maxAccountsRequired').hide(); $('#maxAccountsInput').val(''); } switch (mode) { case "paddle": $.ajax({ type: "GET", url: "/shop/purchase-validate", data: $('#purchaseForm').serialize(), success: function (data) { // remove all old feedback data $(".invalid-feedback").remove() $(".is-invalid").removeClass("is-invalid") // update button state $('#payButton').attr('disabled', !data.Success); // reflect prices if (data.Total > 0) { $('#price').html(data.Currency + " " + data.Total.toFixed(2)) if (data.QuantityDiscount > 0) { $('#quantityDiscount').html(data.QuantityDiscount.toFixed(2) + "% quantity discount") } else { $('#quantityDiscount').empty() } if (data.Tax > 0) { $('#priceTax').html("(" + data.Currency + " " + data.Net.toFixed(2) + " plus " + data.Tax.toFixed(2) + " tax)") } if (data.ListTotal != data.Total && data.ListTotal > 0) { $('#listPrice').html("Coupon accepted, regular price: " + data.Currency + " " + data.ListTotal.toFixed(2)) } else { if ($("[name='Coupon'").val() != "") { $("[name='Coupon']").parent().addClass("is-invalid") $("[name='Coupon']").after("
Coupon code not accepted
") } $('#listPrice').empty() } } else { $('#price').empty() $('#quantityDiscount').empty() $('#priceTax').empty() $('#listPrice').empty() } // if (data.Errors.length > 0) { for (fieldWithError in data.Errors) { message = data.Errors[fieldWithError] $("[name='" + fieldWithError + "']").parent().addClass("is-invalid") $("[name='" + fieldWithError + "']").after("
" + message + "
") } // } passthroughData = data.PassthroughData quantity = data.Quantity productId = data.ProductId }, error: function (data, status, error) { console.log(data); }, }); break case "mycommerce": break } } $(function () { Paddle.Setup({ vendor: 149810 }); for (var country in countries) { $("#countrySelect").append(""); }; // when form changes, do auto validation var changetimer; $('#purchaseForm :input').on('input', function () { clearTimeout(changetimer); changetimer = setTimeout(validateform, 2000); }); $('#purchaseForm').submit(function (e) { e.preventDefault(); console.log("Order, please") $.ajax({ type: "GET", url: "/shop/purchase-validate?purchase=true", data: $('#purchaseForm').serialize(), success: function (data) { Paddle.Checkout.open({ override: data.OverrideURL, method: "overlay", }); }, error: function (data, status, error) { console.log("Order trouble :-(") console.log(data); }, }); }); validateform(); });