Sha256: be2d3796da39db09178ae5d4a7f11c45811de777650a89cbb4d50d234e977027

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

<div id="paypal-button-container" class="paypal-button-container"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.paypal.com/sdk/js?client-id=<%= payment_method.preferred_api_key %>&currency=<%= @order.currency %>"></script>

<script type="text/javascript">
  paypal.Buttons({
    style: {
      layout: 'horizontal',
      color:  'gold',
      shape:  'rect',
      label:  'pay',
      tagline: 'true'
    },
    createOrder: function(data, actions) {
      return fetch(`/paypal_checkout?payment_method_id=<%= payment_method.id %>`, {
        method: "post"
      })
      .then((response) => response.json())
      .then((data) => data['id']);
    },
    onApprove: function(data, actions) {
      return fetch(`/paypal_checkout/confirm?number=${data.orderID}&payment_method_id=<%= payment_method.id %>`, {
        method: "post",
      })
        .then((response) => response.json())
        .then((orderData) => {
          var transaction = orderData.purchase_units[0].payments.captures[0];
          fetch(`/paypal_checkout/proceed?number=${data.orderID}&status=${transaction.status}&transaction_id=${transaction.id}`, {
            method: "get",
          }).then((response) => response.json())
            .then((orderData2) => {
              window.location.href = `${window.location.origin}${orderData2.redirect_to}`
            });
        });
    }
  }).render('#paypal-button-container');
</script>

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree_paypal_checkout-0.0.2 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.1.5 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.1.4 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.1.3 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.1.2 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.1.1 app/views/spree/checkout/payment/_paypal_checkout.html.erb