Sha256: d2d6ca5c6a8786f2fd4d26a4445ec33d34b1c323459db5cefce9488d24cecde8
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 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 %>¤cy=<%= @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
4 entries across 4 versions & 1 rubygems