pagarme 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/pagarme/model.rb +0 -1
- data/lib/pagarme/subscription.rb +6 -0
- data/pagarme.gemspec +1 -1
- data/test/pagarme/subscription.rb +46 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWU1ZGY0YjVkOGYwNjJmZGZmZjdlYzYxYjBiYzI4MjEwM2FjMGI0MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTFlNjZkOGI0MTM2MGM1YmM1ZGZiZDkwODg3NDZkNTA3ZjFlMTVjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWIwNWEyN2ZhMjM4ODFmM2E3N2E0Yzk1MTU4YjlkZDFlMDYxMWUyZmRjNDIy
|
10
|
+
N2FlYWYwNzljNDkxZjM1NjZiZGZlYzYyZWJjMzRhZTU5Njk2YzRkNDIxYjc5
|
11
|
+
MTc4OGIzMDc3MDVkZDgwMjA5NWQ0MDA0OWY1YzVkODk0ZGYyZmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDQ1NjhkOWQ2MDZiMWM5NmU3MzE5NmVhYTg5OWVhNTAxNDc5ZTBjZmQxZjA0
|
14
|
+
MGMyMTQ5MjEwYmFiNDkxMDJkNTBlYzNjZTY3MmYyMDhjMjY2NDA4Yjk4OGQ0
|
15
|
+
MzEyMWYyOWNlNTMzYzI1YjYwM2M0Y2FkYjM1YjNhYWI3YTgyOWQ=
|
data/Gemfile.lock
CHANGED
data/lib/pagarme/model.rb
CHANGED
data/lib/pagarme/subscription.rb
CHANGED
@@ -23,6 +23,12 @@ module PagarMe
|
|
23
23
|
super
|
24
24
|
end
|
25
25
|
|
26
|
+
def cancel
|
27
|
+
request = PagarMe::Request.new(self.url + '/cancel', 'POST')
|
28
|
+
response = request.run
|
29
|
+
update(response)
|
30
|
+
end
|
31
|
+
|
26
32
|
def charge(amount)
|
27
33
|
request = PagarMe::Request.new(self.url, 'POST')
|
28
34
|
request.parameters = {
|
data/pagarme.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "pagarme"
|
7
|
-
spec.version = 1.
|
7
|
+
spec.version = 1.4
|
8
8
|
spec.authors = ["Pedro Franceschi", "Henrique Dubugras"]
|
9
9
|
spec.email = ["pedrohfranceschi@gmail.com", "henrique@pagar.me"]
|
10
10
|
spec.description = %q{Pagar.me's ruby gem}
|
@@ -2,70 +2,62 @@
|
|
2
2
|
require_relative '../test_helper'
|
3
3
|
|
4
4
|
module PagarMe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
class SubscriptionTest < Test::Unit::TestCase
|
6
|
+
should 'be able to create subscription with plan' do
|
7
|
+
plan = test_plan
|
8
|
+
plan.create
|
9
|
+
subscription = test_subscription
|
10
|
+
subscription.plan = plan
|
11
|
+
subscription.create
|
12
|
+
test_plan_response(subscription.plan)
|
13
|
+
test_transaction_with_customer(subscription)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
16
|
+
should 'be able to create subscription without plan' do
|
17
|
+
subscription = test_subscription({:amount => 2000})
|
18
|
+
subscription.create
|
19
|
+
assert subscription.transactions.length == 1
|
20
|
+
subscription.charge(2000)
|
21
|
+
assert subscription.transactions.length == 2
|
22
|
+
assert subscription.transactions.first.kind_of?(PagarMe::Transaction)
|
23
|
+
subscription.transactions.each do |t|
|
24
|
+
test_subscription_transaction_response(t)
|
26
25
|
end
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
plan2 = PagarMe::Plan.new({
|
34
|
-
:name => "Plano Silver",
|
35
|
-
:days => 30,
|
36
|
-
:amount => 3000
|
37
|
-
});
|
38
|
-
plan2.create
|
39
|
-
|
40
|
-
subscription.plan = plan
|
41
|
-
subscription.create
|
28
|
+
should 'be able to change plans' do
|
29
|
+
subscription = test_subscription
|
30
|
+
plan = test_plan
|
31
|
+
plan.create
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
plan2 = PagarMe::Plan.new({
|
34
|
+
:name => "Plano Silver",
|
35
|
+
:days => 30,
|
36
|
+
:amount => 3000
|
37
|
+
});
|
38
|
+
plan2.create
|
46
39
|
|
47
|
-
|
48
|
-
|
40
|
+
subscription.plan = plan
|
41
|
+
subscription.create
|
49
42
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# plan.create
|
43
|
+
assert subscription.plan.id == plan.id
|
44
|
+
subscription.plan = plan2
|
45
|
+
subscription.save
|
54
46
|
|
55
|
-
|
56
|
-
|
47
|
+
assert subscription.plan.id == plan2.id
|
48
|
+
end
|
57
49
|
|
58
|
-
|
59
|
-
|
50
|
+
should 'be able to cancel a subscription' do
|
51
|
+
subscription = test_subscription
|
52
|
+
plan = test_plan
|
53
|
+
plan.create
|
60
54
|
|
61
|
-
|
55
|
+
subscription.plan = plan
|
56
|
+
subscription.create
|
62
57
|
|
63
|
-
|
64
|
-
# subscription.save
|
58
|
+
subscription.cancel
|
65
59
|
|
66
|
-
|
67
|
-
# p = PagarMe::Plan.find_by_id(subscription.plan_id)
|
68
|
-
# assert p.trial_days == nil
|
69
|
-
# end
|
60
|
+
assert subscription.status == 'canceled'
|
70
61
|
end
|
62
|
+
end
|
71
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagarme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Franceschi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|