pagarme 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pagarme/resources/billing.rb +4 -0
- data/lib/pagarme/resources/company.rb +2 -2
- data/lib/pagarme/resources/item.rb +4 -0
- data/lib/pagarme/resources/shipping.rb +4 -0
- data/lib/pagarme/version.rb +1 -1
- data/pagarme.gemspec +1 -1
- data/test/fixtures.rb +75 -6
- data/test/pagarme/resources/postback_test.rb +2 -2
- data/test/pagarme/resources/transaction_test.rb +18 -1
- data/test/test_helper.rb +18 -8
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c801545dfac8dc1716c6832638cf741d58867cd
|
4
|
+
data.tar.gz: c2f90875b21d789837bb7ee268215978b22d3fb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a19a1948aaa48237314574e1e8f7a420106e53a35e23163a7d227a16f8ef302c7a38e4a29a15326ba1a68951a456269fc6fc8d7d0b15d306defd83dd84cd69eb
|
7
|
+
data.tar.gz: 67cffc1d0dd3ecbf74141d83e58a7ae32c0ea6f62d2a7d72f9033ec7ac068018cee7dbdf11bb0f39193f9a97bc354c5a8e5bc247f48945ff422e0208bb209dd5
|
@@ -21,8 +21,8 @@ module PagarMe
|
|
21
21
|
PagarMe::Request.get('/company').call
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.temporary
|
25
|
-
PagarMe::Request.post('/companies/temporary').call
|
24
|
+
def self.temporary(params = Hash.new)
|
25
|
+
PagarMe::Request.post('/companies/temporary', params: params).call
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/pagarme/version.rb
CHANGED
data/pagarme.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
21
21
|
spec.add_development_dependency 'shoulda', '~> 3.4.0'
|
22
22
|
spec.add_development_dependency 'activesupport', '~> 3.0'
|
23
|
+
spec.add_development_dependency 'webmock', '~> 2.3'
|
23
24
|
spec.add_development_dependency 'pry'
|
24
25
|
spec.add_development_dependency 'vcr'
|
25
26
|
spec.add_development_dependency 'rake'
|
26
|
-
spec.add_development_dependency 'webmock'
|
27
27
|
spec.add_development_dependency 'test-unit'
|
28
28
|
spec.add_development_dependency 'clipboard'
|
29
29
|
|
data/test/fixtures.rb
CHANGED
@@ -83,6 +83,60 @@ class Fixtures
|
|
83
83
|
}
|
84
84
|
end
|
85
85
|
|
86
|
+
def address
|
87
|
+
{
|
88
|
+
street: 'Av. Brigadeiro Faria Lima',
|
89
|
+
street_number: '2941',
|
90
|
+
neighborhood: 'Itaim bibi',
|
91
|
+
zipcode: '01452000',
|
92
|
+
city: 'São Paulo',
|
93
|
+
state: 'sp',
|
94
|
+
country: 'br'
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
def billing
|
99
|
+
{
|
100
|
+
billing: {
|
101
|
+
name: 'Jon Snow',
|
102
|
+
address: address
|
103
|
+
}
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def shipping
|
108
|
+
{
|
109
|
+
shipping: {
|
110
|
+
name: 'Daenerys Targeryen',
|
111
|
+
fee: 100,
|
112
|
+
delivery_date: "2000-12-21",
|
113
|
+
expedited: "true",
|
114
|
+
address: address
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
def item
|
120
|
+
{
|
121
|
+
items: [
|
122
|
+
{
|
123
|
+
id: "r123",
|
124
|
+
title: "Red pill",
|
125
|
+
unit_price: 10000,
|
126
|
+
quantity: 1,
|
127
|
+
tangible: true
|
128
|
+
},
|
129
|
+
{
|
130
|
+
id: "b123",
|
131
|
+
title: "Blue pill",
|
132
|
+
unit_price: 10000,
|
133
|
+
quantity: 1,
|
134
|
+
tangible: true
|
135
|
+
}
|
136
|
+
]
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
86
140
|
def bank_account
|
87
141
|
{
|
88
142
|
bank_code: '237',
|
@@ -144,12 +198,27 @@ class Fixtures
|
|
144
198
|
gender: 'M',
|
145
199
|
born_at: '1970-10-11',
|
146
200
|
phone: { ddd: '21', number: '922334455' },
|
147
|
-
address:
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
201
|
+
address: address
|
202
|
+
}
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
def external_id_customer
|
207
|
+
{
|
208
|
+
customer: {
|
209
|
+
external_id: "#3311",
|
210
|
+
name: "Morpheus Fishburne",
|
211
|
+
type: "individual",
|
212
|
+
country: "br",
|
213
|
+
email: "mopheus@nabucodonozor.com",
|
214
|
+
documents: [
|
215
|
+
{
|
216
|
+
type: "cpf",
|
217
|
+
number: "00000000000"
|
218
|
+
}
|
219
|
+
],
|
220
|
+
phone_numbers: ["+5511999998888", "+5511888889999"],
|
221
|
+
birthday: "1965-01-01"
|
153
222
|
}
|
154
223
|
}
|
155
224
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
2
|
|
3
3
|
module PagarMe
|
4
|
-
class
|
4
|
+
class PostbackTest < PagarMeTestCase
|
5
5
|
should 'be valid when has valid signature' do
|
6
6
|
fixed_api_key do
|
7
7
|
postback = PagarMe::Postback.new postback_response_params
|
@@ -9,7 +9,7 @@ module PagarMe
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
should 'be valid when has invalid signature' do
|
12
|
+
should 'not be valid when has invalid signature' do
|
13
13
|
postback = PagarMe::Postback.new postback_response_params(signature: 'sha1=invalid signature')
|
14
14
|
assert !postback.valid?
|
15
15
|
end
|
@@ -48,7 +48,7 @@ module PagarMe
|
|
48
48
|
assert_equal transaction.status, 'refunded'
|
49
49
|
end
|
50
50
|
|
51
|
-
should 'be able to create
|
51
|
+
should 'be able to create transaction with boleto' do
|
52
52
|
transaction = PagarMe::Transaction.charge transaction_with_boleto_params
|
53
53
|
assert_transaction_with_bolelo_on_waiting_payment transaction
|
54
54
|
end
|
@@ -137,6 +137,23 @@ module PagarMe
|
|
137
137
|
assert_equal transaction.refunded_amount, 0
|
138
138
|
end
|
139
139
|
|
140
|
+
should 'be able to create a transaction with billing shipping and items' do
|
141
|
+
change_company(api_version: { test: '2017-08-28', live: '2017-08-28'}) do
|
142
|
+
transaction = PagarMe::Transaction.create transaction_with_external_id_customer_with_billing_with_shipping_with_item_with_card_params
|
143
|
+
found_transaction = PagarMe::Transaction.find_by_id transaction.id
|
144
|
+
|
145
|
+
assert_equal found_transaction.billing, transaction.billing
|
146
|
+
assert_equal found_transaction.shipping, transaction.shipping
|
147
|
+
assert_equal found_transaction.items, transaction.items
|
148
|
+
|
149
|
+
assert found_transaction.billing
|
150
|
+
assert found_transaction.shipping
|
151
|
+
assert found_transaction.items
|
152
|
+
|
153
|
+
assert_transaction_successfully_paid transaction
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
140
157
|
should 'validate transaction with invalid card_number' do
|
141
158
|
transaction = PagarMe::Transaction.new transaction_with_customer_with_invalid_card_number_params
|
142
159
|
transaction.charge
|
data/test/test_helper.rb
CHANGED
@@ -55,18 +55,28 @@ class PagarMeTestCase < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
58
|
+
def change_company(api_version: nil, &block)
|
59
|
+
company = temporary_company api_version: api_version
|
60
|
+
change_api_and_encryption_keys api_key: company.api_key.test, encryption_key: company.encryption_key.test, &block
|
61
|
+
end
|
62
|
+
|
63
|
+
def change_api_and_encryption_keys(api_key: FIXED_API_KEY, encryption_key: FIXED_ENCRYPTION_KEY)
|
64
|
+
previous_encryption_key = PagarMe.encryption_key
|
65
|
+
previous_api_key = PagarMe.api_key
|
66
|
+
|
67
|
+
PagarMe.encryption_key = encryption_key
|
68
|
+
PagarMe.api_key = api_key
|
61
69
|
yield
|
62
|
-
|
63
|
-
PagarMe.
|
70
|
+
|
71
|
+
PagarMe.encryption_key = previous_encryption_key
|
72
|
+
PagarMe.api_key = previous_api_key
|
64
73
|
end
|
74
|
+
alias :fixed_api_key :change_api_and_encryption_keys
|
65
75
|
|
66
|
-
def temporary_company
|
67
|
-
VCR.use_cassette
|
76
|
+
def temporary_company(api_version: nil)
|
77
|
+
VCR.use_cassette "TestCase/tmp_company/api_key/#{api_version}" do
|
68
78
|
PagarMe.api_key = FIXED_API_KEY
|
69
|
-
PagarMe::Company.temporary
|
79
|
+
PagarMe::Company.temporary api_version: api_version
|
70
80
|
end
|
71
81
|
end
|
72
82
|
|
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: 2.2.
|
4
|
+
version: 2.2.2
|
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: 2017-
|
12
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -54,21 +54,21 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: webmock
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '2.3'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '2.3'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: pry
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: vcr
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: rake
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
@@ -192,17 +192,20 @@ files:
|
|
192
192
|
- lib/pagarme/resources/balance.rb
|
193
193
|
- lib/pagarme/resources/balance_operation.rb
|
194
194
|
- lib/pagarme/resources/bank_account.rb
|
195
|
+
- lib/pagarme/resources/billing.rb
|
195
196
|
- lib/pagarme/resources/bulk_anticipation.rb
|
196
197
|
- lib/pagarme/resources/card.rb
|
197
198
|
- lib/pagarme/resources/company.rb
|
198
199
|
- lib/pagarme/resources/customer.rb
|
199
200
|
- lib/pagarme/resources/fee_collection.rb
|
201
|
+
- lib/pagarme/resources/item.rb
|
200
202
|
- lib/pagarme/resources/payable.rb
|
201
203
|
- lib/pagarme/resources/phone.rb
|
202
204
|
- lib/pagarme/resources/plan.rb
|
203
205
|
- lib/pagarme/resources/postal_code.rb
|
204
206
|
- lib/pagarme/resources/postback.rb
|
205
207
|
- lib/pagarme/resources/recipient.rb
|
208
|
+
- lib/pagarme/resources/shipping.rb
|
206
209
|
- lib/pagarme/resources/split_rule.rb
|
207
210
|
- lib/pagarme/resources/subscription.rb
|
208
211
|
- lib/pagarme/resources/transaction.rb
|