payola-payments 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/payola/checkout_button.js +11 -14
- data/app/views/payola/transactions/_checkout.html.erb +4 -2
- data/lib/generators/payola/install_generator.rb +1 -1
- data/lib/payola/version.rb +1 -1
- data/lib/payola/worker/active_job.rb +21 -0
- data/lib/payola/worker/base.rb +9 -0
- data/lib/payola/worker/sidekiq.rb +20 -0
- data/lib/payola/worker/sucker_punch.rb +20 -0
- data/lib/payola/worker.rb +12 -41
- data/lib/payola.rb +6 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +2 -8460
- data/spec/dummy/log/test.log +1428 -12240
- data/spec/payola_spec.rb +7 -0
- data/spec/worker_spec.rb +24 -0
- metadata +16 -57
- data/spec/dummy/tmp/cache/assets/development/sprockets/0e585aeb88c1555ae8f5292f7c7a9068 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0f0c99469c51f1b2d76b08f481781d09 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1b54952339cbc96811097cee5f8923b4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1cbc4f4790f2067a2c161c1eb480f276 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5afa4bc970e0bc781b3500c696ba25ff +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/664efeb51d1b486dcfc30d142db56f3c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/68a3bbdc64a0729b5896fa1e33fce4b1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/aea159adbc0944b120d91d5b578612ba +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b83da90cb58011313e13a97a4a41cb6e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c0b954b40f2881a6d286061bc069643e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c5b3877d49b39932a7557611cefca9a6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ca491e325ff6948be9292f701aa4ce64 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d9856638a3c7b9cfd9d1b884e3b33982 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ddba6e841f28d3005e828fbfffd18b74 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/df935e399019055729aa968bd7062096 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ef82c31948061751bb026663b54484e1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f0b5d4bea0c6cdd1904e1e9a0a45532f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f8018075b7aca72974f4014bbbc75ab5 +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Nzc3ZTZjYjM5M2I0MGZlMDMxYjI0Mzc2ZjU2ZjM1NjU0ZDVmZDA3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTY0MzBlYTM1NjNlYmU3OGFiMTQyN2ZiNjZjYmQzYzc3ZTI0YzEwNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODcxYzEwYmYzYjJhMjUyMjhiYjk2ODdiMzM4NTNiZjY1M2JiMjNmNTE5YjE5
|
10
|
+
YzRjZWRmNjAwZThhZTgxNGE5ZDQ4ZTFmNTQwZmYwMDg1ZjhmYzBmMzdkYWYz
|
11
|
+
ZjNjZTk2MjRkYTZlN2E5NzlkNmFiYTVjZTRiMzg3YTdjYjgwNTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2VjMjFkMmI2YjAyYzgxNTBhZTYxOGI0ZTE1NzY2Y2M1OWFiMWM4ZTIxN2Ey
|
14
|
+
NDUwYWIwY2UxNzY0ODFjNTYwOGQzNDQ3NmY5MjUxMjMwMjRiYzhlMTQ3ZDI2
|
15
|
+
NjQ2YjJkMGFjNTJiMmFmY2FhNTlmN2IyNGU4NDBjN2U0MmZjNDc=
|
@@ -30,17 +30,15 @@ var Payola = {
|
|
30
30
|
$(".payola-checkout-button-spinner").show();
|
31
31
|
$.ajax({
|
32
32
|
type: "POST",
|
33
|
-
url: "/
|
33
|
+
url: options.base_path + "/buy/" + options.product_class + "/" + options.product_permalink,
|
34
34
|
data: form.serialize(),
|
35
|
-
success: function(data) { Payola.poll(data.guid, 60, options
|
36
|
-
error: function(data) { Payola.showError(data.responseJSON.error, options
|
35
|
+
success: function(data) { Payola.poll(data.guid, 60, options) },
|
36
|
+
error: function(data) { Payola.showError(data.responseJSON.error, options) }
|
37
37
|
});
|
38
38
|
},
|
39
39
|
|
40
|
-
showError: function(error,
|
41
|
-
|
42
|
-
console.log(error_div_id);
|
43
|
-
var error_div = $("#" + error_div_id);
|
40
|
+
showError: function(error, options) {
|
41
|
+
var error_div = $("#" + options.error_div_id);
|
44
42
|
error_div.html(error);
|
45
43
|
error_div.show();
|
46
44
|
$(".payola-checkout-button").prop("disabled", false);
|
@@ -48,20 +46,19 @@ var Payola = {
|
|
48
46
|
$(".payola-checkout-button-text").show();
|
49
47
|
},
|
50
48
|
|
51
|
-
poll: function(guid, num_retries_left,
|
52
|
-
console.log(error_div_id);
|
49
|
+
poll: function(guid, num_retries_left, options) {
|
53
50
|
if (num_retries_left == 0) {
|
54
|
-
Payola.showError("This seems to be taking too long. Please contact support and give them transaction ID: " + guid,
|
51
|
+
Payola.showError("This seems to be taking too long. Please contact support and give them transaction ID: " + guid, options);
|
55
52
|
return;
|
56
53
|
}
|
57
54
|
|
58
|
-
$.get("/
|
55
|
+
$.get(options.base_path + "/status/" + guid, function(data) {
|
59
56
|
if (data.status === "finished") {
|
60
|
-
window.location = "/
|
57
|
+
window.location = options.base_path + "/confirm/" + guid;
|
61
58
|
} else if (data.status === "errored") {
|
62
|
-
Payola.showError(data.error,
|
59
|
+
Payola.showError(data.error, options);
|
63
60
|
} else {
|
64
|
-
setTimeout(function() { Payola.poll(guid, num_retries_left - 1,
|
61
|
+
setTimeout(function() { Payola.poll(guid, num_retries_left - 1, options) }, 500);
|
65
62
|
}
|
66
63
|
});
|
67
64
|
}
|
@@ -9,7 +9,8 @@
|
|
9
9
|
allow_remember_me = local_assigns.fetch :allow_remember_me, true
|
10
10
|
email = local_assigns.fetch :email, ''
|
11
11
|
verify_zip_code = local_assigns.fetch :verify_zip_code, false
|
12
|
-
|
12
|
+
|
13
|
+
sale = Payola::Sale.new(product: sellable)
|
13
14
|
|
14
15
|
button_id = "payola-button-#{sellable.product_class}-#{sellable.permalink}"
|
15
16
|
|
@@ -38,6 +39,7 @@
|
|
38
39
|
<% end %>
|
39
40
|
<script type="text/javascript">
|
40
41
|
Payola.setUpStripeCheckoutButton({
|
42
|
+
base_path: "<%= main_app.payola_path %>",
|
41
43
|
form_id: "<%= form_id %>",
|
42
44
|
button_id: "<%= button_id %>",
|
43
45
|
error_div_id: "<%= error_div_id %>",
|
@@ -47,7 +49,7 @@
|
|
47
49
|
name: "<%= name %>",
|
48
50
|
description: "<%= description %>",
|
49
51
|
product_image_path: "<%= product_image_path %>",
|
50
|
-
publishable_key: "<%= Payola.
|
52
|
+
publishable_key: "<%= Payola.publishable_key_for_sale(sale) %>",
|
51
53
|
panel_label: "<%= panel_label %>",
|
52
54
|
allow_remember_me: <%= allow_remember_me %>,
|
53
55
|
email: "<%= email %>",
|
data/lib/payola/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module ::ActiveJob
|
2
|
+
class Base; end
|
3
|
+
end
|
4
|
+
|
5
|
+
module Payola
|
6
|
+
module Worker
|
7
|
+
class ActiveJob < ::ActiveJob::Base
|
8
|
+
def self.can_run?
|
9
|
+
defined?(::ActiveJob::Core)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.call(sale)
|
13
|
+
perform_later(sale.guid)
|
14
|
+
end
|
15
|
+
|
16
|
+
def perform(guid)
|
17
|
+
Sale.where(guid: guid).first.process!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require 'sidekiq'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
module Payola
|
7
|
+
module Worker
|
8
|
+
class Sidekiq < BaseWorker
|
9
|
+
include ::Sidekiq::Worker if defined? ::Sidekiq::Worker
|
10
|
+
|
11
|
+
def self.can_run?
|
12
|
+
defined?(::Sidekiq::Worker)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.call(sale)
|
16
|
+
perform_async(sale.guid)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require 'sucker_punch'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
module Payola
|
7
|
+
module Worker
|
8
|
+
class SuckerPunch < BaseWorker
|
9
|
+
include ::SuckerPunch::Job if defined? ::SuckerPunch::Job
|
10
|
+
|
11
|
+
def self.can_run?
|
12
|
+
defined?(::SuckerPunch::Job)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.call(sale)
|
16
|
+
new.async.perform(sale.guid)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/payola/worker.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'sucker_punch'
|
8
|
-
rescue LoadError
|
9
|
-
end
|
1
|
+
require 'payola/worker/base'
|
2
|
+
require 'payola/worker/active_job'
|
3
|
+
require 'payola/worker/sidekiq'
|
4
|
+
require 'payola/worker/sucker_punch'
|
10
5
|
|
11
6
|
module Payola
|
12
7
|
module Worker
|
@@ -22,6 +17,11 @@ module Payola
|
|
22
17
|
end
|
23
18
|
|
24
19
|
def autofind
|
20
|
+
# prefer ActiveJob over the other workers
|
21
|
+
if Payola::Worker::ActiveJob.can_run?
|
22
|
+
return Payola::Worker::ActiveJob
|
23
|
+
end
|
24
|
+
|
25
25
|
registry.values.each do |worker|
|
26
26
|
if worker.can_run?
|
27
27
|
return worker
|
@@ -32,39 +32,10 @@ module Payola
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
class BaseWorker
|
36
|
-
def perform(guid)
|
37
|
-
Sale.where(guid: guid).first.process!
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class Sidekiq < BaseWorker
|
42
|
-
include ::Sidekiq::Worker if defined? ::Sidekiq::Worker
|
43
|
-
|
44
|
-
def self.can_run?
|
45
|
-
defined?(::Sidekiq::Worker)
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.call(sale)
|
49
|
-
perform_async(sale.guid)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class SuckerPunch < BaseWorker
|
54
|
-
include ::SuckerPunch::Job if defined? ::SuckerPunch::Job
|
55
|
-
|
56
|
-
def self.can_run?
|
57
|
-
defined?(::SuckerPunch::Job)
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.call(sale)
|
61
|
-
new.async.perform(sale.guid)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
35
|
self.registry = {
|
66
|
-
sidekiq:
|
67
|
-
sucker_punch: Payola::Worker::SuckerPunch
|
36
|
+
sidekiq: Payola::Worker::Sidekiq,
|
37
|
+
sucker_punch: Payola::Worker::SuckerPunch,
|
38
|
+
active_job: Payola::Worker::ActiveJob
|
68
39
|
}
|
69
40
|
end
|
70
41
|
end
|
data/lib/payola.rb
CHANGED
@@ -6,6 +6,7 @@ require 'jquery-rails'
|
|
6
6
|
module Payola
|
7
7
|
class << self
|
8
8
|
attr_accessor :publishable_key,
|
9
|
+
:publishable_key_retriever,
|
9
10
|
:secret_key,
|
10
11
|
:secret_key_retriever,
|
11
12
|
:background_worker,
|
@@ -23,6 +24,10 @@ module Payola
|
|
23
24
|
return secret_key_retriever.call(sale)
|
24
25
|
end
|
25
26
|
|
27
|
+
def publishable_key_for_sale(sale)
|
28
|
+
return publishable_key_retriever.call(sale)
|
29
|
+
end
|
30
|
+
|
26
31
|
def subscribe(name, callable = Proc.new)
|
27
32
|
StripeEvent.subscribe(name, callable)
|
28
33
|
end
|
@@ -54,6 +59,7 @@ module Payola
|
|
54
59
|
self.publishable_key = ENV['STRIPE_PUBLISHABLE_KEY']
|
55
60
|
self.secret_key = ENV['STRIPE_SECRET_KEY']
|
56
61
|
self.secret_key_retriever = lambda { |sale| Payola.secret_key }
|
62
|
+
self.publishable_key_retriever = lambda { |sale| Payola.publishable_key }
|
57
63
|
self.support_email = 'sales@example.com'
|
58
64
|
self.sellables = {}
|
59
65
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
Binary file
|