JAVASCRIPT   13

paypal.js

Guest on 26th July 2021 04:04:40 PM

  1.  
  2. function hb_paypal_payment_process( $form, callback_func ) {
  3.         $form.addClass( 'submitted' );
  4.         $form.find( 'input[type="submit"]' ).blur().prop( 'disabled', true );
  5.         $form.find( '.hb-saving-resa' ).slideDown();
  6.         $form.find( '.hb-confirm-error' ).slideUp();
  7.         $form.append( jQuery( '<input type="hidden" name="hb-current-url" value="' + document.URL + '" />' ) );
  8.         $form.append( jQuery( '<input type="hidden" name="check-in-formatted" value="' + $form.parents( '.hbook-wrapper' ).find( '.hb-check-in-date' ).val() + '" />' ) );
  9.         $form.append( jQuery( '<input type="hidden" name="check-out-formatted" value="' + $form.parents( '.hbook-wrapper' ).find( '.hb-check-out-date' ).val() + '" />' ) );
  10.         callback_func( $form );
  11.         return true;
  12. }
  13.  
  14. function hb_paypal_payment_redirection( $form, response ) {
  15.         var current_url = document.URL,
  16.                 back_url = '',
  17.                 pattern;
  18.  
  19.         pattern = /&payment_gateway(\=[^&]*)?(?=&|$)|payment_gateway(\=[^&]*)?(&|$)/;
  20.         current_url = current_url.replace( pattern, '' );
  21.         pattern = /&payment_confirm(\=[^&]*)?(?=&|$)|payment_confirm(\=[^&]*)?(&|$)/;
  22.         current_url = current_url.replace( pattern, '' );
  23.         pattern = /&payment_cancel(\=[^&]*)?(?=&|$)|payment_cancel(\=[^&]*)?(&|$)/;
  24.         current_url = current_url.replace( pattern, '' );
  25.         pattern = /&token(\=[^&]*)?(?=&|$)|token(\=[^&]*)?(&|$)/;
  26.         current_url = current_url.replace( pattern, '' );
  27.         pattern = /&PayerID(\=[^&]*)?(?=&|$)|PayerID(\=[^&]*)?(&|$)/;
  28.         current_url = current_url.replace( pattern, '' );
  29.  
  30.         if ( current_url.indexOf( '#' ) > 0 ) {
  31.                 current_url = current_url.substr( 0, current_url.indexOf( '#' ) );
  32.         }
  33.  
  34.         if ( current_url.slice(-1) != '?' ) {
  35.                 if ( current_url.indexOf( '?' ) > 0 ) {
  36.                         current_url += '&';
  37.                 } else {
  38.                         current_url += '?';
  39.                 }
  40.         }
  41.         back_url = current_url + 'payment_gateway=paypal&payment_cancel=1&token=' + response['payment_token'];
  42.         try {
  43.                 history.pushState( {}, '', back_url );
  44.         } catch ( e ) {}
  45.         window.location = hb_paypal_url + '&useraction=commit&token=' + response['payment_token'];
  46. }

Raw Paste


Login or Register to edit or fork this paste. It's free.