Sha256: fe6fe9173f20b6994c9f934d64cd15310f082e955083c9be198f094c1ac0bfd4

Contents?: true

Size: 1.1 KB

Versions: 32

Compression:

Stored size: 1.1 KB

Contents

// https://developer.deluxe.com/s/article-hosted-payment-form

function initializeDeluxe() {
  let $deluxe = $('form[data-deluxe-checkout]:not(.initialized)');
  if($deluxe.length == 0) return;

  let options = $deluxe.data('deluxe-checkout');

  HostedForm.init(options, {
    onFailure: (data) => { $('#deluxe-checkout-errors').text(JSON.stringify(data)); },
    onInvalid: (data) => { $('#deluxe-checkout-errors').text(JSON.stringify(data)); },

    onSuccess: (data) => { 
      let value = btoa(JSON.stringify(data)); // A base64 encoded JSON object

      $form = $('form[data-deluxe-checkout]').first();
      $form.find('input[name="deluxe[payment_intent]"]').val(value);
      $form.submit();

      $('#deluxeCheckout').fadeOut('slow');
      $('#deluxe-checkout-loading').text('Thank you! Processing payment information. Please wait...');
    },
  }).then((instance) => {
    $('#deluxe-checkout-loading').text('');
    instance.renderHpf();
  });

  $deluxe.addClass('initialized');
};

$(document).ready(function() { initializeDeluxe() });
$(document).on('turbolinks:load', function() { initializeDeluxe() });

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
effective_orders-6.14.2 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.14.1 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.14.0 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.13.3 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.13.2 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.13.1 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.13.0 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.12.4 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.12.3 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.12.2 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.12.1 app/assets/javascripts/effective_orders/providers/deluxe.js
effective_orders-6.12.0 app/assets/javascripts/effective_orders/providers/deluxe.js