|
| 1 | + /** |
| 2 | + * @package GoUrl Bitcoin/Altcoin Payment Box - show iFrame Payment Box |
| 3 | + * @copyright 2014-2020 Delta Consultants |
| 4 | + * @category Javascript |
| 5 | + * @website https://gourl.io |
| 6 | + * @api https://gourl.io/api.html |
| 7 | + * @version 2.2.1 |
| 8 | + */ |
| 9 | + |
| 10 | + /** |
| 11 | + * Display iFrame payment box |
| 12 | + * Full Instruction - https://gourl.io/bitcoin-payment-gateway-api.html |
| 13 | + */ |
| 14 | + |
| 15 | + function cryptobox_show(boxID, coinName, public_key, amount, amountUSD, period, language, iframeID, userID, userFormat, orderID, cookieName, webdev_key, ver, hash, width, height) |
| 16 | + { |
| 17 | + if (typeof width !== 'number') width = 0; |
| 18 | + if (typeof height !== 'number') height = 0; |
| 19 | + |
| 20 | + var id = public_key.substr(0, public_key.indexOf("AA")); |
| 21 | + if (id == '' || boxID != id || public_key.indexOf("PUB") == -1) alert('Invalid payment box public_key'); |
| 22 | + else if ((amount <= 0 && amountUSD <= 0) || (amount > 0 && amountUSD > 0)) alert('You can use in payment box options one of variable only: amount or amountUSD. You cannot place values in that two variables together'); |
| 23 | + else if (amount != 0 && ((amount - 0) != amount || amount < 0.0001)) alert('Invalid payment box amount'); |
| 24 | + else if (amountUSD != 0 && ((amountUSD - 0) != amountUSD || amountUSD < 0.01)) alert('Invalid payment box amountUSD'); |
| 25 | + else if (userFormat != 'COOKIE' && userFormat != 'SESSION' && userFormat != 'IPADDRESS' && userFormat != 'MANUAL') alert('Invalid payment box userFormat value'); |
| 26 | + else if (userFormat == 'COOKIE' && cookieName == '') alert('Invalid payment box cookie name'); |
| 27 | + else if (userFormat == 'COOKIE' && cryptobox_cookie(cookieName) == '') { if (document.getElementById(iframeID).src != null) document.getElementById(iframeID).src = 'https://gourl.io/images/crypto_cookies.png'; alert('Please enable Cookies in your Browser !'); } |
| 28 | + else if (userFormat == 'COOKIE' && cryptobox_cookie(cookieName) != userID) alert('Invalid cookie value. It may be you are viewing an older copy of the page that is stored in the website cache. Please contact with website owner, need to disable/turn-off caching for current page'); |
| 29 | + else if (orderID == '') alert('Invalid orderID'); |
| 30 | + else if (period == '') alert('Invalid period'); |
| 31 | + else if (public_key.length != 50) alert('Invalid public key'); |
| 32 | + else if (webdev_key != '' && (webdev_key.indexOf("DEV") == -1 || webdev_key.length < 20)) alert('Invalid webdev_key, leave it empty'); |
| 33 | + else if (ver == '') alert('Invalid ver value'); |
| 34 | + else if (hash == '') alert('Invalid payment box hash'); |
| 35 | + else |
| 36 | + { |
| 37 | + var url = 'https://coins.gourl.io' + |
| 38 | + '/b/'+encodeURIComponent(boxID)+'/c/'+encodeURIComponent(coinName)+ |
| 39 | + '/p/'+encodeURIComponent(public_key)+ |
| 40 | + '/a/'+encodeURIComponent(amount)+'/au/'+encodeURIComponent(amountUSD)+ |
| 41 | + '/pe/'+encodeURIComponent(period.replace(' ', '_'))+'/l/'+encodeURIComponent(language)+ |
| 42 | + '/i/'+encodeURIComponent(iframeID)+'/u/'+encodeURIComponent(userID)+ |
| 43 | + '/us/'+encodeURIComponent(userFormat)+'/o/'+encodeURIComponent(orderID)+ |
| 44 | + '/t/'+encodeURIComponent(ver)+ |
| 45 | + (webdev_key?'/w/'+encodeURIComponent(webdev_key):'')+ |
| 46 | + (width>0?'/ws/'+encodeURIComponent(width):'')+ |
| 47 | + (height>0?'/hs/'+encodeURIComponent(height):'')+ |
| 48 | + '/h/'+encodeURIComponent(hash)+ |
| 49 | + '/z/'+Math.random(); |
| 50 | + |
| 51 | + var html = document.getElementById(iframeID); |
| 52 | + if (html == null) alert('Cryptobox iframeID HTML with id "' + iframeID + '" not exist!'); |
| 53 | + else html.src = url; |
| 54 | + } |
| 55 | + |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + function cryptobox_cookie(name) |
| 63 | + { |
| 64 | + var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { |
| 65 | + var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) |
| 66 | + return c.substring(nameEQ.length,c.length); } return ''; |
| 67 | + } |
| 68 | + |
| 69 | + |
| 70 | + function cryptobox_msghide (id) |
| 71 | + { |
| 72 | + setTimeout(function(){ document.getElementById(id).style.display='none';}, 15000 ); |
| 73 | + } |
| 74 | + |
0 commit comments