payify 0.1.15 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/payify/payment.rb +2 -0
- data/app/views/payify/payments/_form.html.erb +38 -26
- data/config/routes.rb +1 -1
- data/lib/payify/engine.rb +0 -1
- data/lib/payify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2a72ee40f171a59366aafdae3a4a164350a4f6abce4722eea01d8b81ead5d4d
|
4
|
+
data.tar.gz: b250cfb7c1692d82208d532313a44cded79e43a21d91f0a66c796794e4b742d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
28
|
+
const options = {
|
29
|
+
clientSecret: "<%= payment.stripe_client_secret %>",
|
30
|
+
};
|
19
31
|
|
20
|
-
|
32
|
+
const elements = stripe.elements(options);
|
21
33
|
|
22
|
-
|
23
|
-
|
34
|
+
const paymentElement = elements.create("payment");
|
35
|
+
paymentElement.mount("#payment-element");
|
24
36
|
|
25
|
-
|
37
|
+
const form = document.getElementById("payment-form");
|
26
38
|
|
27
|
-
|
28
|
-
|
39
|
+
form.addEventListener("submit", async (event) => {
|
40
|
+
event.preventDefault();
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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>
|
data/config/routes.rb
CHANGED
data/lib/payify/engine.rb
CHANGED
data/lib/payify/version.rb
CHANGED