Guest User

Untitled

a guest
May 5th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. Issues With Pop-Up Blocking (this shouldn't be happening?)
  2. /* -- Step 3: Complete Checkout Click -- */
  3.  
  4. $('div.finishGroupOrder').live('click', function() {
  5.  
  6. /* User is Click-Happy? */
  7.  
  8. if ( $('div#billing-contents div#loader').length ) {
  9.  
  10. alert('Your order is processing. We know it's hard, but please be patient.');
  11. return false;
  12.  
  13. }
  14.  
  15. var paymentMethod = $('input[name="method"]:checked').val(); // Payment Method Selected ( Card on File / New / PayPal )
  16.  
  17. var secureSession = $(this).attr('secure'); // Secure Session ID
  18.  
  19. var orderData = { addressSelection: $('input[name="address"]:checked').val(),
  20. price: $('div.price').attr('value') };
  21.  
  22. /* Form Validation */
  23.  
  24. switch( orderData.addressSelection ) {
  25.  
  26. case 'new': // User chose to enter address manually
  27.  
  28. var allInputs = $('div#new-address').find('input:not(#address2), select');
  29. var validInputs = $('div#new-address').find('input[value!=""]:not(#address2), select[value!=""]');
  30.  
  31. if ( allInputs.length === validInputs.length ) { // All inputs are valid, capture their contents
  32.  
  33. allInputs.removeClass('bad-value');
  34.  
  35. var address = { phone: $('input#phone').val(),
  36. address1: $('input#address1').val(),
  37. address2: $('input#address2').val(),
  38. city: $('input#city').val(),
  39. state: $('select#state').val(),
  40. zip: $('input#zipcode').val() };
  41.  
  42. var validatedAddress = validation.validateAddress(address);
  43.  
  44. if (validatedAddress) {
  45.  
  46. address.address1 = validatedAddress.address1;
  47. address.address2 = validatedAddress.address2;
  48. address.city = validatedAddress.city;
  49. address.state = validatedAddress.state;
  50. address.timeOffset = validatedAddress.timeOffset; // Time offset from EST (PST = -3, EST = 0, etc.)
  51.  
  52. $('input#timezone').val(address.timeOffset);
  53.  
  54. } else {
  55.  
  56. allInputs.addClass('bad-value');
  57. return false;
  58.  
  59. }
  60.  
  61. } else { // Some inputs are invalid, prompt the user to fix them
  62.  
  63. allInputs.filter(function() { return ($.inArray( this, validInputs ) > -1) ? false : true; }).addClass('bad-value');
  64. return false;
  65.  
  66. }
  67.  
  68. break;
  69.  
  70. case 'verified': // User chose to ship to verified address
  71.  
  72. var address = { address1: 'verified' };
  73.  
  74. break;
  75.  
  76. default:
  77.  
  78. alert('Please choose an address where you want the flowers to be delivered.');
  79. return false;
  80.  
  81. break;
  82.  
  83. }
  84.  
  85.  
  86. /* Sync Order With Updated Address Information */
  87.  
  88. $.ajax({ type: 'POST',
  89. url: location.protocol + '//' + location.host + '/_ajax/order.ajax.php',
  90. data: 'action=update_order&' + $.param( address ),
  91.  
  92. success: function() {
  93.  
  94. /* Load Selected Payment Method */
  95.  
  96. switch( paymentMethod ) {
  97.  
  98. //case 'paypal': paypal(); break;
  99.  
  100. case 'member':
  101. newGroupOrderDialogActions.payAsMember();
  102. break;
  103.  
  104. case 'newCard':
  105. newGroupOrderDialogActions.payWithCard( secureSession );
  106. //$('div.group-secure-terminal').trigger('click');
  107. break;
  108.  
  109. }
  110.  
  111. }
  112. });
  113.  
  114. /* -- Pay With a New Credit Card -- */
  115.  
  116. payWithCard: function( session ) {
  117.  
  118. var windowHeight = 769; // Terminal Height
  119. var windowWidth = 638; // Terminal Width
  120. var w = screen.availWidth; // Available Screen (W)
  121. var h = screen.availHeight; // Available Screen (H)
  122. var top = (h-windowHeight)/2; // Center Positioning
  123. var left = (w-windowWidth)/2; // Center Positioning
  124.  
  125.  
  126. /* Open Secure Order Terminal */
  127.  
  128. var secureTerminal = window.open('https://secure.mydomain.ly/contribute?id=' + session, 'myCompany: Secure Checkout', 'menubar=0,toolbar=0,location=1,resizable=0,scrollbars=1,height='+windowHeight+',width='+windowWidth+',top='+top+',left='+left);
  129.  
  130.  
  131. /* Check for Secure Order Terminal Close Event */
  132.  
  133. var onFinish = setInterval(function() {
  134.  
  135. try {
  136. if (secureTerminal.closed) { // Window has been unloaded, check the order to see if it has been approved
  137.  
  138. clearTimeout(onFinish);
  139.  
  140. $.ajax({ type: 'POST',
  141. url: location.protocol + '//' + location.host + '/_ajax/redirect.ajax.php',
  142. data: 'action=group_order_status_redirect',
  143. success: function(redirect) { newGroupOrderDialogActions.publishOrder( redirect ) } // If redirect is not null, order was successful. Redirect to order page
  144. });
  145. }
  146. } catch (e) {}
  147.  
  148. }, 200);
  149.  
  150. },
Advertisement
Add Comment
Please, Sign In to add comment