Advertisement
scriptvscript

Untitled

May 4th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var paymentWindow;
  2. var paymentLoop;
  3. var popupTick;
  4. var addWarning = function(){
  5.     var box = swal.getContent();
  6.     if (box){
  7.         $(box).parent().parent().append('<span style="position:absolute;color:white;width:100%;font-size:2rem;top:15px;display:block;text-align:center">PLEASE DO NOT CLOSE THIS WINDOW<br>YOU MAY LOSE FUNDS IF YOU DO!</span>');
  8.     }
  9. }
  10. var waitForPayment = function(action, invoice, success, error){
  11.     if (paymentLoop){
  12.         $.post(action, {invoice: invoice}, function(response){
  13.             if (response.error){
  14.                 if (paymentWindow){
  15.                     clearInterval(popupTick);
  16.                     paymentWindow.close();
  17.                     delete paymentWindow;
  18.                 }
  19.                 swal('Oops...', response.msg, 'error');
  20.             } else if (response.status == 1){
  21.                 if (paymentWindow){
  22.                     clearInterval(popupTick);
  23.                     paymentWindow.close();
  24.                     delete paymentWindow;
  25.                 }
  26.                 $(swal.getTitle()).html('Waiting for you to join the group<br><a class="" target=_blank href=https://www.roblox.com/groups/group.aspx?gid=' + response.group + '>roblox.com/groups/' + response.group + '</a>');
  27.                 if (response.paid == 1){
  28.                     $(window).unbind('beforeunload');
  29.                     var alertWindow = swal('Success', 'You successfully purchased funds!', 'success');
  30.                     if (success && {}.toString.call(success) === '[object Function]'){
  31.                         alertWindow.then(success);
  32.                     }
  33.                 } else {
  34.                     waitForPayment(action, invoice);
  35.                 }
  36.             } else {
  37.                 waitForPayment(action, invoice);
  38.             }
  39.         }).error(function(){
  40.             swal('Oops...', 'Failed to reach server', 'error');
  41.             if (error && {}.toString.call(error) === '[object Function]'){
  42.                 error();
  43.             }
  44.         });
  45.     }
  46. }
  47. $(document).ready(function(){
  48.     new fp2().get(function(h){$("#funds").append("<input name=h value="+h+" type=hidden>")});
  49.     var button = $('#funds>button');
  50.     $("#funds>input[name=amount]").keyup(function(){
  51.         button.find('.price').html(Math.ceil($(this).val() / 1000 * robuxCostPerThousand * 100) / 100);
  52.     });
  53.     $('form#funds').submit(function(event){
  54.         event.preventDefault();
  55.         var action = $(this).attr('action');
  56.         var form = $(this);
  57.         var username = $(this).find('input[name=username]').val().replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
  58.            return '&#'+i.charCodeAt(0)+';';
  59.         });
  60.         function sanitize(s) {
  61.             return s.replace(/[^\d\w\s_]+/g, '');
  62.         }
  63.         swal({
  64.             title: 'Is this you?',
  65.             html: '<b>' + username + '</b><br><img width=15% src=https://www.roblox.com/Thumbs/Avatar.ashx?x=420&y=420&username=' + sanitize(username) + '>',
  66.             showCancelButton: true,
  67.             confirmButtonColor: '#66bb6a',
  68.             cancelButtonColor: '#bdbdbd',
  69.             confirmButtonText: '<i style=vertical-align:bottom class=material-icons>thumb_up</i> Yes, that\'s me!',
  70.             cancelButtonText: '<i style=vertical-align:bottom class=material-icons>thumb_down</i> Nope'
  71.         }).then(function(){  
  72.             var leftX = (((window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width) / 2) - 500) + (window.screenLeft != undefined ? window.screenLeft : screen.left);  
  73.             var defaultHeight = 700;
  74.             var defaultTopOffset = 300;
  75.             if (window.screen){
  76.                 defaultHeight = window.screen.availHeight * 0.7
  77.                 defaultTopOffset = window.screen.availHeight * 0.4
  78.             }
  79.             var paymentWindow = window.open('https://www.rbx.place/load.html', 'Payment', 'scrollbars=yes, width=1000, height=' + defaultHeight + ', top=' + defaultTopOffset + ', left=' + leftX);  
  80.             paymentWindow.focus();
  81.             swal({
  82.                 title: 'Processing...',
  83.                 input: 'select',
  84.                 allowOutsideClick: false,
  85.                 allowEscapeKey: false,
  86.                 inputOptions: new Promise(function(){
  87.                     setTimeout(addWarning, 100);
  88.                     $.post(action, form.serialize(), function(response){
  89.                         if (response.error){
  90.                             swal('Oops...', response.msg, 'error');
  91.                             paymentWindow.close();
  92.                         } else {
  93.                             paymentWindow.location = response.redirect;
  94.                             popupTick = setInterval(function(){
  95.                                 if (paymentWindow.closed) {
  96.                                     clearInterval(popupTick);
  97.                                     $.post(action, {invoice: response.invoice}, function(response){
  98.                                         if (response.error || response.status == 0){
  99.                                             paymentLoop = false;
  100.                                             swal('Oops...', 'Looks like you clicked out of the payment window', 'error');
  101.                                         }
  102.                                     });
  103.                                 }
  104.                             }, 500);
  105.                             $(window).bind('beforeunload', function(event){
  106.                                 return 'Are you sure you want to leave?';
  107.                             });
  108.                             paymentLoop = true;
  109.                             swal({
  110.                                 title: 'Awaiting payment...',
  111.                                 input: 'select',
  112.                                 allowOutsideClick: false,
  113.                                 allowEscapeKey: false,
  114.                                 inputOptions: new Promise(function(){
  115.                                     setTimeout(addWarning, 100);
  116.                                     waitForPayment(action, response.invoice);
  117.                                 })
  118.                             });
  119.                         }
  120.                     }).error(function(){
  121.                         swal('Oops...', 'Failed to reach server', 'error');
  122.                     });
  123.                 })
  124.             });
  125.         });
  126.     });
  127. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement