payify 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a9d1ca2475c701c3c4c52cf336fe15f4c4af67bd0bda8881f3e46c6138d4e4b
4
- data.tar.gz: 5b860f6d917cdf5d8b5c488ff178b4543fe944abafc2678a373a93af2004e9ea
3
+ metadata.gz: d2a72ee40f171a59366aafdae3a4a164350a4f6abce4722eea01d8b81ead5d4d
4
+ data.tar.gz: b250cfb7c1692d82208d532313a44cded79e43a21d91f0a66c796794e4b742d9
5
5
  SHA512:
6
- metadata.gz: ad029b4c099016f6d332d1174323f8a7a2dc68e43173690651959d20e80310a8feb8d6794b88149608861035d61f1b9decfc1ebd059a2eca97b4fcff797f3a99
7
- data.tar.gz: 1378445bd65037c4b0593387d25efb9cce4ee738d4546da5f4f8a08105317dbd174deb512b7cb636dc10354df239c072872dd82be4475452548a629512d7c3ff
6
+ metadata.gz: fb80e767f463c6ea8967b980ae76ac23b5d3f89d084cc2f4bc216ca387498bdeac5b6a09cf5d243177583d11a3d012439ac78704dfaac281bf375bdf3ee9f98f
7
+ data.tar.gz: e830d91f014df3ad9c143be2127a4ec52f9a435db3969e0b9cf9eba228d34941d39709c7c28189a7989120cce901c42070a051f888ee51cb76ca875ad7e88f9e
@@ -1,5 +1,3 @@
1
- <script src="https://js.stripe.com/v3/"></script>
2
-
3
1
  <%= form_with(id: "payment-form", url: payify.complete_payment_path, method: "post") do |form| %>
4
2
  <div id="payment-element">
5
3
  </div>
@@ -11,36 +9,50 @@
11
9
  <% end %>
12
10
 
13
11
  <script>
14
- const stripe = Stripe("<%= Payify.stripe_publishable_key %>");
12
+ function loadStripeAndExecuteCode() {
13
+ if (typeof Stripe === "undefined") {
14
+ var script = document.createElement("script");
15
+ script.src = "https://js.stripe.com/v3/";
16
+ script.onload = function() {
17
+ executeCode();
18
+ };
19
+ document.head.appendChild(script);
20
+ } else {
21
+ executeCode();
22
+ }
23
+ }
24
+
25
+ function executeCode() {
26
+ const stripe = Stripe("<%= Payify.stripe_publishable_key %>");
15
27
 
16
- const options = {
17
- clientSecret: "<%= payment.stripe_client_secret %>",
18
- };
28
+ const options = {
29
+ clientSecret: "<%= payment.stripe_client_secret %>",
30
+ };
19
31
 
20
- const elements = stripe.elements(options);
32
+ const elements = stripe.elements(options);
21
33
 
22
- const paymentElement = elements.create("payment");
23
- paymentElement.mount("#payment-element");
34
+ const paymentElement = elements.create("payment");
35
+ paymentElement.mount("#payment-element");
24
36
 
25
- const form = document.getElementById("payment-form");
37
+ const form = document.getElementById("payment-form");
26
38
 
27
- form.addEventListener("submit", async (event) => {
28
- event.preventDefault();
39
+ form.addEventListener("submit", async (event) => {
40
+ event.preventDefault();
29
41
 
30
- const {error} = await stripe.confirmPayment({
31
- elements,
32
- confirmParams: {
33
- return_url: "<%= request.base_url %>/payify/payments/<%= payment.id %>/complete",
34
- },
42
+ const {error} = await stripe.confirmPayment({
43
+ elements,
44
+ confirmParams: {
45
+ return_url: "<%= request.base_url %>/payify/payments/<%= payment.id %>/complete",
46
+ },
47
+ });
48
+
49
+ if (error) {
50
+ const messageContainer = document.querySelector("#error-message");
51
+ messageContainer.textContent = error.message;
52
+ } else {
53
+ }
35
54
  });
55
+ }
36
56
 
37
- if (error) {
38
- const messageContainer = document.querySelector("#error-message");
39
- messageContainer.textContent = error.message;
40
- } else {
41
- // Your customer will be redirected to your `return_url`. For some payment
42
- // methods like iDEAL, your customer will be redirected to an intermediate
43
- // site first to authorize the payment, then redirected to the `return_url`.
44
- }
45
- });
57
+ loadStripeAndExecuteCode();
46
58
  </script>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Payify
4
- VERSION = "0.1.16"
4
+ VERSION = "0.1.17"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lopez