payola 1.0.0 → 1.0.2
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 +4 -4
- data/LICENSE +0 -0
- data/Rakefile +1 -1
- data/lib/payola/configuration.rb +1 -1
- data/lib/payola/core_ext/string.rb +6 -2
- data/lib/payola/factories/stripe_payment_token.rb +4 -4
- data/lib/payola/registry.rb +4 -4
- data/lib/payola/version.rb +1 -1
- data/spec/lib/payola/payment_gateways/stripe_payment_gateway_spec.rb +40 -35
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b28190b705d4de86e4aae9082e909f13be0db1a2
|
4
|
+
data.tar.gz: 2555647740e5903f86443c5dd4f759780208f938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fb0dc5f46a9d460895d9b5fc90a2f6b7e8bde75c14454207a51bd5ade6a677cb298498bd9df4af6a300018d10c3a1c0e8436e4f04151f3fae5618673cf5956
|
7
|
+
data.tar.gz: c4c08c4b9a800adad3bde1a7153cf2f66e7abcbac9846c29a01b28344fd27dcdc1ad4a45c770474e54957036d1f66b6d03261cd01fd5f70e90ca4e92a363b0ba
|
data/LICENSE
ADDED
File without changes
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/payola/configuration.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
class String
|
2
2
|
def constantize
|
3
|
-
names =
|
3
|
+
names = split('::')
|
4
4
|
names.shift if names.empty? || names.first.empty?
|
5
5
|
|
6
6
|
constant = Object
|
7
7
|
names.each do |name|
|
8
|
-
constant = constant.const_defined?(name)
|
8
|
+
constant = if constant.const_defined?(name)
|
9
|
+
constant.const_get(name)
|
10
|
+
else
|
11
|
+
constant.const_missing(name)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
constant
|
11
15
|
end
|
@@ -4,10 +4,10 @@ class StripePaymentToken
|
|
4
4
|
def self.create(card: nil)
|
5
5
|
Stripe.api_key = Payola.config.payment_gateway_api_key
|
6
6
|
|
7
|
-
card ||= { number:
|
8
|
-
exp_month:
|
9
|
-
exp_year:
|
10
|
-
cvc:
|
7
|
+
card ||= { number: '4242424242424242',
|
8
|
+
exp_month: 3,
|
9
|
+
exp_year: Time.now.strftime('%Y').to_i + 5,
|
10
|
+
cvc: '314' }
|
11
11
|
|
12
12
|
Stripe::Token.create(card: card).id
|
13
13
|
end
|
data/lib/payola/registry.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Payola
|
2
2
|
class Registry
|
3
|
-
|
4
|
-
payment_gateway_adapter: ::Payola::PaymentGateways::StripePaymentGateway
|
3
|
+
@registry = {
|
4
|
+
payment_gateway_adapter: ::Payola::PaymentGateways::StripePaymentGateway,
|
5
5
|
}
|
6
6
|
|
7
7
|
def self.method_missing(name, *args)
|
8
|
-
return
|
8
|
+
return @registry.public_send(name, *args) if @registry.respond_to? name
|
9
9
|
|
10
10
|
super
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.respond_to_missing?(name)
|
14
|
-
|
14
|
+
@registry.respond_to?(name) || super
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
data/lib/payola/version.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
require 'rspectacular'
|
2
2
|
require 'money'
|
3
|
+
require 'chamber'
|
3
4
|
require 'payola/payment_gateways/stripe_payment_gateway'
|
4
5
|
require 'payola/factories/stripe_payment_token'
|
5
6
|
require 'payola/configuration'
|
6
7
|
|
8
|
+
Chamber.load(basepath: Pathname.new(__dir__) + '../../../../')
|
9
|
+
|
7
10
|
module Payola
|
8
11
|
module PaymentGateways
|
9
12
|
describe StripePaymentGateway, :stripe, :vcr do
|
10
13
|
before(:each) do
|
11
|
-
Payola.config.payment_gateway_api_key =
|
12
|
-
Stripe.api_key =
|
14
|
+
Payola.config.payment_gateway_api_key = Chamber.env.stripe.api_key
|
15
|
+
Stripe.api_key = Chamber.env.stripe.api_key
|
13
16
|
end
|
14
17
|
|
15
18
|
let(:credit_card_token) do
|
16
|
-
Payola::Factories::StripePaymentToken.create(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
Payola::Factories::StripePaymentToken.create(card: {
|
20
|
+
number: '4242424242424242',
|
21
|
+
exp_month: 3,
|
22
|
+
exp_year: 2015,
|
23
|
+
cvc: '314' })
|
21
24
|
end
|
22
25
|
|
23
26
|
it 'can create a subscription using the API key from the configuration' do
|
@@ -46,7 +49,7 @@ describe StripePaymentGateway, :stripe, :vcr do
|
|
46
49
|
payment_token: credit_card_token
|
47
50
|
|
48
51
|
expect(subscription[:plan]).to eql 'my test plan id'
|
49
|
-
expect(subscription[:subscription_id]).to match
|
52
|
+
expect(subscription[:subscription_id]).to match(/\Acus_[A-Za-z0-9]{14}\:sub_[A-Za-z0-9]{14}\z/)
|
50
53
|
expect(subscription[:status]).to eql 'active'
|
51
54
|
expect(subscription[:last_four_of_credit_card]).to eql '4242'
|
52
55
|
end
|
@@ -62,15 +65,15 @@ describe StripePaymentGateway, :stripe, :vcr do
|
|
62
65
|
plan_name: 'my test plan name',
|
63
66
|
payment_token: credit_card_token
|
64
67
|
|
65
|
-
expect(subscription[:subscription_id]).to match
|
68
|
+
expect(subscription[:subscription_id]).to match(/#{customer.id}\:sub_[A-Za-z0-9]{14}/)
|
66
69
|
end
|
67
70
|
|
68
71
|
it 'can create a subscription when a plan already exists but not a customer' do
|
69
|
-
Stripe::Plan.create id:
|
70
|
-
amount:
|
71
|
-
currency:
|
72
|
-
interval:
|
73
|
-
name:
|
72
|
+
Stripe::Plan.create id: 'my other existing test plan id',
|
73
|
+
amount: 200,
|
74
|
+
currency: 'EUR',
|
75
|
+
interval: 'week',
|
76
|
+
name: 'what you talkin bout'
|
74
77
|
|
75
78
|
allow(Stripe::Plan).to receive(:create)
|
76
79
|
|
@@ -85,18 +88,18 @@ describe StripePaymentGateway, :stripe, :vcr do
|
|
85
88
|
|
86
89
|
expect(Stripe::Plan).not_to have_received(:create)
|
87
90
|
expect(subscription[:plan]).to eql 'my other existing test plan id'
|
88
|
-
expect(subscription[:subscription_id]).to match
|
91
|
+
expect(subscription[:subscription_id]).to match(/\Acus_[A-Za-z0-9]{14}\:sub_[A-Za-z0-9]{14}\z/)
|
89
92
|
expect(subscription[:status]).to eql 'active'
|
90
93
|
expect(subscription[:last_four_of_credit_card]).to eql '4242'
|
91
94
|
end
|
92
95
|
|
93
96
|
it 'can update a subscription with a new plan' do
|
94
97
|
customer = Stripe::Customer.create
|
95
|
-
plan = Stripe::Plan.create id:
|
96
|
-
amount:
|
97
|
-
currency:
|
98
|
-
interval:
|
99
|
-
name:
|
98
|
+
plan = Stripe::Plan.create id: 'my existing test plan id',
|
99
|
+
amount: 200,
|
100
|
+
currency: 'USD',
|
101
|
+
interval: 'week',
|
102
|
+
name: 'what you talkin bout'
|
100
103
|
existing_subscription = customer.subscriptions.create(
|
101
104
|
plan: plan.id,
|
102
105
|
card: credit_card_token)
|
@@ -116,18 +119,20 @@ describe StripePaymentGateway, :stripe, :vcr do
|
|
116
119
|
|
117
120
|
it 'wraps all exceptions in Payola errors' do
|
118
121
|
allow(Stripe::Customer).to receive(:create).
|
119
|
-
and_raise(RuntimeError.new
|
122
|
+
and_raise(RuntimeError.new 'error creating customer')
|
120
123
|
|
121
|
-
expect
|
124
|
+
expect do
|
125
|
+
StripePaymentGateway.apply_subscription \
|
122
126
|
subscription_id: nil,
|
123
127
|
plan_id: 'my existing test plan id',
|
124
128
|
amount: Money.new(100, 'USD'),
|
125
129
|
interval: 'month',
|
126
130
|
interval_count: 1,
|
127
131
|
plan_name: 'my test plan name',
|
128
|
-
payment_token: credit_card_token
|
132
|
+
payment_token: credit_card_token
|
133
|
+
end.to \
|
129
134
|
raise_error(Payola::Errors::PaymentGatewayRequestError).
|
130
|
-
with_message(
|
135
|
+
with_message('RuntimeError: error creating customer')
|
131
136
|
end
|
132
137
|
|
133
138
|
it 'allows a free subscription to be created without a previous paid subscription' do
|
@@ -140,27 +145,27 @@ describe StripePaymentGateway, :stripe, :vcr do
|
|
140
145
|
plan_name: 'my test plan name'
|
141
146
|
|
142
147
|
expect(subscription[:plan]).to eql 'my test plan id'
|
143
|
-
expect(subscription[:subscription_id]).to match
|
148
|
+
expect(subscription[:subscription_id]).to match(/\Acus_[A-Za-z0-9]{14}\:sub_[A-Za-z0-9]{14}\z/)
|
144
149
|
expect(subscription[:status]).to eql 'active'
|
145
150
|
expect(subscription[:last_four_of_credit_card]).to eql nil
|
146
151
|
end
|
147
152
|
|
148
153
|
it 'can update a subscription with a new payment token' do
|
149
154
|
customer = Stripe::Customer.create
|
150
|
-
plan = Stripe::Plan.create id:
|
151
|
-
amount:
|
152
|
-
currency:
|
153
|
-
interval:
|
154
|
-
name:
|
155
|
+
plan = Stripe::Plan.create id: 'my other existing test plan id',
|
156
|
+
amount: 200,
|
157
|
+
currency: 'USD',
|
158
|
+
interval: 'week',
|
159
|
+
name: 'what you talkin bout'
|
155
160
|
existing_subscription = customer.subscriptions.create(
|
156
161
|
plan: plan.id,
|
157
162
|
card: credit_card_token)
|
158
163
|
|
159
|
-
new_credit_card_token = Payola::Factories::StripePaymentToken.create(
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
+
new_credit_card_token = Payola::Factories::StripePaymentToken.create(card: {
|
165
|
+
number: '4012888888881881',
|
166
|
+
exp_month: 3,
|
167
|
+
exp_year: 2015,
|
168
|
+
cvc: '314' })
|
164
169
|
|
165
170
|
subscription = StripePaymentGateway.apply_subscription \
|
166
171
|
subscription_id: "#{customer.id}:#{existing_subscription.id}",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payola
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stripe
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspectacular
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: '0.48'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: '0.48'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: money
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,9 +112,9 @@ description: ''
|
|
112
112
|
email: accounts+git@thekompanee.com
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
115
|
-
extra_rdoc_files:
|
116
|
-
- README.md
|
115
|
+
extra_rdoc_files: []
|
117
116
|
files:
|
117
|
+
- LICENSE
|
118
118
|
- README.md
|
119
119
|
- Rakefile
|
120
120
|
- lib/payola.rb
|
@@ -131,11 +131,11 @@ files:
|
|
131
131
|
- lib/payola/version.rb
|
132
132
|
- spec/lib/payola/payment_gateways/stripe_payment_gateway_spec.rb
|
133
133
|
homepage: https://github.com/thekompanee/payola
|
134
|
-
licenses:
|
134
|
+
licenses:
|
135
|
+
- MIT
|
135
136
|
metadata: {}
|
136
137
|
post_install_message:
|
137
|
-
rdoc_options:
|
138
|
-
- "--charset = UTF-8"
|
138
|
+
rdoc_options: []
|
139
139
|
require_paths:
|
140
140
|
- lib
|
141
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -149,11 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.4.6
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Abstraction layer on top of Stripe/Braintree, etc so we can get Payola'ed
|
157
157
|
test_files:
|
158
158
|
- spec/lib/payola/payment_gateways/stripe_payment_gateway_spec.rb
|
159
|
-
has_rdoc:
|