Sha256: 24b19141ba6db579155f05593466a1e2374d88d283fc22c7922fbd2c2e1bbf6c

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

<div id="paypal-button-container" class="paypal-button-container"></div>
<script src="http://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",
          })
        });
    }
  }).render('#paypal-button-container');
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_paypal_api_checkout-0.0.6 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.0.5 app/views/spree/checkout/payment/_paypal_checkout.html.erb
spree_paypal_api_checkout-0.0.4 app/views/spree/checkout/payment/_paypal_checkout.html.erb