openpay 1.0.8 → 1.0.10
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/.gitignore +1 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/openpay/open_pay_resource.rb +4 -0
- data/lib/openpay/webhooks.rb +9 -0
- data/lib/version.rb +1 -1
- data/openpay.gemspec +1 -1
- data/test/Factories.rb +6 -6
- data/test/spec/bankaccounts_spec.rb +2 -0
- data/test/spec/cards_spec.rb +4 -2
- data/test/spec/charges_spec.rb +2 -0
- data/test/spec/customers_spec.rb +3 -1
- data/test/spec/exceptions_spec.rb +2 -0
- data/test/spec/fees_spec.rb +2 -0
- data/test/spec/openpayresource_spec.rb +2 -0
- data/test/spec/payouts_spec.rb +2 -0
- data/test/spec/plans_spec.rb +2 -0
- data/test/spec/requesttimeout_spec.rb +2 -0
- data/test/spec/subscriptions_spec.rb +2 -0
- data/test/spec/transfers_spec.rb +2 -0
- data/test/spec/webhook_spec.rb +104 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa1c244bcfa5cfa4349bbf0e9248f55109e1f289
|
4
|
+
data.tar.gz: bce6bbec4c2a95dbde57f507d5d50ee14ff79561
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00feb5e106cf0953189167c11d5be3d4b67a6dd062e3a3ac46c98aaae92213605499d1b13887b7c04b1bf2fba3634a678741a5b6d1810fd79391bbad470aff52
|
7
|
+
data.tar.gz: a9be87c49657dd84ca42395b62da0555187d95a2e8bd60ff20f2cc9e44241f29e2ff94efc0ab0181aeff37c20f4af7e46a0e279471bc9771c01a79d4fa6a9667
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -69,6 +69,7 @@ class OpenPayResource
|
|
69
69
|
:url => url(args, terminated),
|
70
70
|
:user => @private_key,
|
71
71
|
:timeout => @timeout,
|
72
|
+
:ssl_version => :TLSv1_2,
|
72
73
|
:headers => {:accept => :json,
|
73
74
|
:content_type => :json,
|
74
75
|
:user_agent => 'Openpay/v1 Ruby-API',
|
@@ -101,6 +102,7 @@ class OpenPayResource
|
|
101
102
|
:url => url(args),
|
102
103
|
:user => @private_key,
|
103
104
|
:timeout => @timeout,
|
105
|
+
:ssl_version => :TLSv1_2,
|
104
106
|
:headers => {:accept => :json,
|
105
107
|
:content_type => :json,
|
106
108
|
:user_agent => 'Openpay/v1 Ruby-API',
|
@@ -143,6 +145,7 @@ class OpenPayResource
|
|
143
145
|
:url => url(args),
|
144
146
|
:user => @private_key,
|
145
147
|
:timeout => @timeout,
|
148
|
+
:ssl_version => :TLSv1_2,
|
146
149
|
:payload => json,
|
147
150
|
:headers => {:accept => :json,
|
148
151
|
:content_type => :json,
|
@@ -187,6 +190,7 @@ class OpenPayResource
|
|
187
190
|
:url => url(args),
|
188
191
|
:user => @private_key,
|
189
192
|
:timeout => @timeout,
|
193
|
+
:ssl_version => :TLSv1_2,
|
190
194
|
:payload => json,
|
191
195
|
:headers => {:accept => :json,
|
192
196
|
:content_type => :json,
|
data/lib/version.rb
CHANGED
data/openpay.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = Openpay::VERSION
|
10
10
|
spec.authors = ["ronnie_bermejo"]
|
11
11
|
spec.email = ["ronnie.bermejo.mx@gmail.com"]
|
12
|
-
spec.description = %q{ruby client for Openpay API services (version 1.0.
|
12
|
+
spec.description = %q{ruby client for Openpay API services (version 1.0.409)}
|
13
13
|
spec.summary = %q{ruby api for openpay resources}
|
14
14
|
spec.homepage = "http://openpay.mx/"
|
15
15
|
spec.license = "Apache"
|
data/test/Factories.rb
CHANGED
@@ -28,7 +28,7 @@ FactoryGirl.define do
|
|
28
28
|
holder_name 'Vicente Olmos'
|
29
29
|
expiration_month '09'
|
30
30
|
card_number '4111111111111111'
|
31
|
-
expiration_year '
|
31
|
+
expiration_year '20'
|
32
32
|
bank_code 'bmx'
|
33
33
|
cvv2 '111'
|
34
34
|
address { {
|
@@ -51,7 +51,7 @@ FactoryGirl.define do
|
|
51
51
|
holder_name 'Alma Olmos'
|
52
52
|
expiration_month '09'
|
53
53
|
card_number '4242424242424242'
|
54
|
-
expiration_year '
|
54
|
+
expiration_year '20'
|
55
55
|
bank_code 'bmx'
|
56
56
|
cvv2 '111'
|
57
57
|
address { {
|
@@ -74,7 +74,7 @@ FactoryGirl.define do
|
|
74
74
|
holder_name 'Alma Olmos'
|
75
75
|
expiration_month '09'
|
76
76
|
card_number '4444444444444448'
|
77
|
-
expiration_year '
|
77
|
+
expiration_year '20'
|
78
78
|
bank_code 'bmx'
|
79
79
|
cvv2 '111'
|
80
80
|
address { {
|
@@ -97,7 +97,7 @@ FactoryGirl.define do
|
|
97
97
|
holder_name 'Vicente Olmos'
|
98
98
|
expiration_month '09'
|
99
99
|
card_number '4000000000000069'
|
100
|
-
expiration_year '
|
100
|
+
expiration_year '20'
|
101
101
|
bank_code 'bmx'
|
102
102
|
cvv2 '111'
|
103
103
|
address { {
|
@@ -212,13 +212,13 @@ FactoryGirl.define do
|
|
212
212
|
|
213
213
|
|
214
214
|
factory :webhook1, class: Hash do
|
215
|
-
url 'http://requestb.in/
|
215
|
+
url 'http://requestb.in/qozy7dqp'
|
216
216
|
event_types ['charge.succeeded','charge.created','charge.cancelled','charge.failed']
|
217
217
|
initialize_with { attributes }
|
218
218
|
end
|
219
219
|
|
220
220
|
factory :webhook2, class: Hash do
|
221
|
-
url 'http://requestb.in/
|
221
|
+
url 'http://requestb.in/10avuvw1'
|
222
222
|
event_types ['charge.succeeded','charge.created','charge.cancelled','charge.failed']
|
223
223
|
initialize_with { attributes }
|
224
224
|
end
|
@@ -10,6 +10,8 @@ describe Bankaccounts do
|
|
10
10
|
@merchant_id='mywvupjjs9xdnryxtplq'
|
11
11
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
12
12
|
|
13
|
+
#LOG.level=Logger::DEBUG
|
14
|
+
|
13
15
|
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
14
16
|
@bank_accounts=@openpay.create(:bankaccounts)
|
15
17
|
@customers=@openpay.create(:customers)
|
data/test/spec/cards_spec.rb
CHANGED
@@ -10,6 +10,8 @@ describe Cards do
|
|
10
10
|
|
11
11
|
@merchant_id='mywvupjjs9xdnryxtplq'
|
12
12
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
13
|
+
|
14
|
+
#LOG.level=Logger::DEBUG
|
13
15
|
|
14
16
|
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
15
17
|
@cards=@openpay.create(:cards)
|
@@ -140,7 +142,7 @@ describe Cards do
|
|
140
142
|
|
141
143
|
it 'iterates over all existing merchant cards' do
|
142
144
|
@cards.each do |card|
|
143
|
-
expect(card['expiration_year']).to match '
|
145
|
+
expect(card['expiration_year']).to match '20'
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
@@ -157,7 +159,7 @@ describe Cards do
|
|
157
159
|
expect(card).to be_a(Hash)
|
158
160
|
|
159
161
|
@cards.each(customer['id']) do |c|
|
160
|
-
expect(c['expiration_year']).to match '
|
162
|
+
expect(c['expiration_year']).to match '20'
|
161
163
|
end
|
162
164
|
|
163
165
|
#cleanup
|
data/test/spec/charges_spec.rb
CHANGED
data/test/spec/customers_spec.rb
CHANGED
@@ -6,6 +6,8 @@ describe Customers do
|
|
6
6
|
|
7
7
|
@merchant_id='mywvupjjs9xdnryxtplq'
|
8
8
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
9
|
+
|
10
|
+
#LOG.level=Logger::DEBUG
|
9
11
|
|
10
12
|
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
11
13
|
@customers=@openpay.create(:customers)
|
@@ -69,7 +71,7 @@ describe Customers do
|
|
69
71
|
@customers.create(customer_hash)
|
70
72
|
rescue OpenpayTransactionException => e
|
71
73
|
expect(e.http_code).to be 400
|
72
|
-
expect(e.description).to match
|
74
|
+
expect(e.description).to match /\"{value}\" is not a valid email address/
|
73
75
|
end
|
74
76
|
|
75
77
|
expect(@customers.errors?).to eq true
|
data/test/spec/fees_spec.rb
CHANGED
data/test/spec/payouts_spec.rb
CHANGED
data/test/spec/plans_spec.rb
CHANGED
@@ -7,6 +7,8 @@ describe 'Request timeout exception' do
|
|
7
7
|
|
8
8
|
@merchant_id='mywvupjjs9xdnryxtplq'
|
9
9
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
10
|
+
|
11
|
+
#LOG.level=Logger::DEBUG
|
10
12
|
|
11
13
|
@openpay=OpenpayApi.new(@merchant_id, @private_key, false, 0)
|
12
14
|
@charges=@openpay.create(:charges)
|
data/test/spec/transfers_spec.rb
CHANGED
@@ -0,0 +1,104 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Webhooks do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@merchant_id='mywvupjjs9xdnryxtplq'
|
7
|
+
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
8
|
+
|
9
|
+
#LOG.level=Logger::DEBUG
|
10
|
+
|
11
|
+
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
12
|
+
@webhooks=@openpay.create(:webhooks)
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
@webhooks.delete_all
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has all required methods' do
|
20
|
+
%w(all each create get list delete).each do |meth|
|
21
|
+
expect(@webhooks).to respond_to(meth)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.create' do
|
26
|
+
it 'creates a webhook' do
|
27
|
+
webhook_hash= FactoryGirl.build(:webhook1)
|
28
|
+
webhook=@webhooks.create(webhook_hash)
|
29
|
+
#validates
|
30
|
+
expect(@webhooks.get(webhook['id'])['url']).to eq('http://requestb.in/qozy7dqp')
|
31
|
+
#clean
|
32
|
+
@webhooks.delete(webhook['id'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.get' do
|
37
|
+
it 'fails to get a non existing customer plan' do
|
38
|
+
#validates
|
39
|
+
expect { @webhooks.get('111111') }.to raise_exception OpenpayTransactionException
|
40
|
+
begin
|
41
|
+
@webhooks.get('111111')
|
42
|
+
rescue OpenpayTransactionException => e
|
43
|
+
expect(e.description).to match 'The merchant with id \'mywvupjjs9xdnryxtplq\' or the webhook with id \'111111\' does not exists.'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.all' do
|
49
|
+
it 'list all webhooks given the filter' do
|
50
|
+
#creates a webhook
|
51
|
+
webhook_hash1= FactoryGirl.build(:webhook1)
|
52
|
+
webhook_hash2= FactoryGirl.build(:webhook2)
|
53
|
+
webhook1=@webhooks.create(webhook_hash1)
|
54
|
+
webhook2=@webhooks.create(webhook_hash2)
|
55
|
+
expect(@webhooks.all().size).to eq 2
|
56
|
+
#clean
|
57
|
+
@webhooks.delete(webhook1['id'])
|
58
|
+
@webhooks.delete(webhook2['id'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.each' do
|
63
|
+
it 'iterates over all webhooks' do
|
64
|
+
#creates a webhook
|
65
|
+
webhook_hash1= FactoryGirl.build(:webhook1)
|
66
|
+
webhook_hash2= FactoryGirl.build(:webhook2)
|
67
|
+
webhook1=@webhooks.create(webhook_hash1)
|
68
|
+
webhook2=@webhooks.create(webhook_hash2)
|
69
|
+
|
70
|
+
expect(@webhooks.all.size).to be_a Integer
|
71
|
+
@webhooks.each do |webhook|
|
72
|
+
expect(webhook['event_types']).to eq(['charge.succeeded','charge.created','charge.cancelled','charge.failed'])
|
73
|
+
@webhooks.delete(webhook['id'])
|
74
|
+
end
|
75
|
+
expect(@webhooks.all.size).to be_a Integer
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
describe '.verify' do
|
81
|
+
it 'verify webhook and activate' do
|
82
|
+
webhook_hash1= FactoryGirl.build(:webhook1)
|
83
|
+
webhook1=@webhooks.create(webhook_hash1)
|
84
|
+
|
85
|
+
puts webhook_hash1[:url] + '?inspect'
|
86
|
+
res=RestClient::Request.new(
|
87
|
+
:method => :post,
|
88
|
+
:url => webhook_hash1[:url] + '?inspect',
|
89
|
+
:timeout => @timeout,
|
90
|
+
:headers => {:accept => :json,
|
91
|
+
:content_type => :json,
|
92
|
+
:user_agent => 'Openpay/v1 Ruby-API',
|
93
|
+
}
|
94
|
+
).execute
|
95
|
+
|
96
|
+
expect(@webhooks.get(webhook1['id'])['status']).to eq('unverified')
|
97
|
+
verification_code = res[res.index('verification_code') + 28 , 8]
|
98
|
+
request_hash=@webhooks.verify(webhook1['id'], verification_code)
|
99
|
+
expect(@webhooks.get(webhook1['id'])['status']).to eq('verified')
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronnie_bermejo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: ruby client for Openpay API services (version 1.0.
|
83
|
+
description: ruby client for Openpay API services (version 1.0.409)
|
84
84
|
email:
|
85
85
|
- ronnie.bermejo.mx@gmail.com
|
86
86
|
executables: []
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/openpay/subscriptions.rb
|
135
135
|
- lib/openpay/transfers.rb
|
136
136
|
- lib/openpay/utils/search_params.rb
|
137
|
+
- lib/openpay/webhooks.rb
|
137
138
|
- lib/version.rb
|
138
139
|
- openpay.gemspec
|
139
140
|
- test/Factories.rb
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- test/spec/subscriptions_spec.rb
|
151
152
|
- test/spec/transfers_spec.rb
|
152
153
|
- test/spec/utils/search_params_spec.rb
|
154
|
+
- test/spec/webhook_spec.rb
|
153
155
|
- test/spec_helper.rb
|
154
156
|
homepage: http://openpay.mx/
|
155
157
|
licenses:
|
@@ -193,4 +195,5 @@ test_files:
|
|
193
195
|
- test/spec/subscriptions_spec.rb
|
194
196
|
- test/spec/transfers_spec.rb
|
195
197
|
- test/spec/utils/search_params_spec.rb
|
198
|
+
- test/spec/webhook_spec.rb
|
196
199
|
- test/spec_helper.rb
|