Sha256: f96c021a702f776304bb4a4f447035e1a1f24360777727fe66eb62a03c20ebc3

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

SpreeCoinbase = {
  doOnSiteCheckout: function() {
    
    $('#checkout_form_payment input.continue').hide();
    $('div[data-hook="checkout_payment_step"]').html("<iframe src=\"" + SpreeCoinbase.checkoutUrl + "\" style=\"width: 500px; height: 160px; border: none; overflow: hidden;\" scrolling=\"no\" allowtransparency=\"true\" frameborder=\"0\"></iframe>" + 
      "<p><a href=\"" + SpreeCoinbase.cancelUrl + "\">Cancel and choose another payment method</a></p>");
  }
}

$(document).ready(function() {
  $('#checkout_form_payment input.continue').click(function (e) {
    checkedPaymentMethod = $('div[data-hook="checkout_payment_step"] input[type="radio"]:checked');
    
    if (checkedPaymentMethod.val() == SpreeCoinbase.paymentMethodId && !SpreeCoinbase.useOffSite) {
      // On-site checkout!
      SpreeCoinbase.doOnSiteCheckout();
      return false;
    } else {
      return true;
    }
  });
})

window.addEventListener('message', receiveMessage, false);

// Listen for messages from the on-site payment iframe
function receiveMessage(event) {

  if (event.origin == 'https://coinbase.com') {
    var event_type = event.data.split('|')[0];
    if (event_type == 'coinbase_payment_complete') {

      // Redirect to success url (wait 1 second for callback to arrive)
      setTimeout(function() {
        window.location = SpreeCoinbase.successUrl;
      }, 1000);
    }
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_coinbase-2.2.0.1 app/assets/javascripts/spree/frontend/spree_coinbase.js