payify 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56393fe8599705be8631aa24680881d1616eff58126f505c3e8063a70045b2cc
4
- data.tar.gz: cc9b67d908c7d8161c511b95293b4e1597a9b082883a814811af9ce1cc3b4304
3
+ metadata.gz: d2a72ee40f171a59366aafdae3a4a164350a4f6abce4722eea01d8b81ead5d4d
4
+ data.tar.gz: b250cfb7c1692d82208d532313a44cded79e43a21d91f0a66c796794e4b742d9
5
5
  SHA512:
6
- metadata.gz: c26af2fe3d5005bce70b1e2d886faa159b63a536dfe17d229beb9027e9feda17e0e49610c56987350a0b485d4a128d805c01219f5ea622961a6fde7045d56b3d
7
- data.tar.gz: 1a27db9b14f7d0e90fa9df15270dd77d1a0eb23570f9640c0ff230c512c5ee1e909677abb53bc4f27410a44057f9a2033fecdaa140fab5b5cf66024be763aee7
6
+ metadata.gz: fb80e767f463c6ea8967b980ae76ac23b5d3f89d084cc2f4bc216ca387498bdeac5b6a09cf5d243177583d11a3d012439ac78704dfaac281bf375bdf3ee9f98f
7
+ data.tar.gz: e830d91f014df3ad9c143be2127a4ec52f9a435db3969e0b9cf9eba228d34941d39709c7c28189a7989120cce901c42070a051f888ee51cb76ca875ad7e88f9e
@@ -1,5 +1,7 @@
1
1
  module Payify
2
2
  class Payment < ApplicationRecord
3
+ self.table_name = "payify_payments"
4
+
3
5
  include ::Payify::StripePaymentConcern
4
6
 
5
7
  enum status: { pending: 0, paid: 1, failed: 2 }
@@ -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>
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ::Payify::Engine.routes.draw do
2
- resources :payments do
2
+ resources :payments, controller: 'payify/payments' do
3
3
  member do
4
4
  get "new"
5
5
  get "complete", as: "complete"
data/lib/payify/engine.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  module Payify
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace Payify
4
3
  end
5
4
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Payify
4
- VERSION = "0.1.15"
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.15
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lopez