openpay 1.0.10 → 2.0.0b

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.
@@ -2,7 +2,6 @@ require_relative '../spec_helper'
2
2
 
3
3
  describe Transfers do
4
4
 
5
-
6
5
  before(:all) do
7
6
 
8
7
  @merchant_id='mywvupjjs9xdnryxtplq'
@@ -31,26 +30,26 @@ describe Transfers do
31
30
  it 'transfers money from customer to customer' do
32
31
 
33
32
  #create new customer
34
- customer_hash= FactoryGirl.build(:customer)
33
+ customer_hash= FactoryBot.build(:customer)
35
34
  customer=@customers.create(customer_hash)
36
-
37
35
  #create new customer card
38
- card_hash=FactoryGirl.build(:valid_card)
36
+ card_hash=FactoryBot.build(:valid_card)
39
37
  card=@cards.create(card_hash, customer['id'])
40
38
 
41
39
  #create charge
42
- charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id'])
40
+ charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
43
41
  charge=@charges.create(charge_hash,customer['id'])
44
42
 
45
43
  #create customer 2
46
- customer_hash= FactoryGirl.build(:customer,name: 'Alejandro')
44
+ customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
47
45
  customer2=@customers.create(customer_hash)
48
46
 
47
+ sleep(50)
49
48
  #create new transfer
50
- customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id'])
51
-
49
+ customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
52
50
  transfer=@transfers.create(customer_hash,customer['id'])
53
51
  t=@transfers.get(transfer['id'],customer['id'])
52
+
54
53
  expect(t['amount']).to be_within(0.1).of 12.5
55
54
  expect(t['method']).to match 'customer'
56
55
 
@@ -66,23 +65,24 @@ describe Transfers do
66
65
  it 'gets a customer transfer' do
67
66
 
68
67
  #create new customer
69
- customer_hash= FactoryGirl.build(:customer)
68
+ customer_hash= FactoryBot.build(:customer)
70
69
  customer=@customers.create(customer_hash)
71
70
 
72
71
  #create new customer card
73
- card_hash=FactoryGirl.build(:valid_card)
72
+ card_hash=FactoryBot.build(:valid_card)
74
73
  card=@cards.create(card_hash, customer['id'])
75
74
 
76
75
  #create charge
77
- charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id'])
76
+ charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
78
77
  charge=@charges.create(charge_hash,customer['id'])
79
78
 
80
79
  #create customer 2
81
- customer_hash= FactoryGirl.build(:customer,name: 'Alejandro')
80
+ customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
82
81
  customer2=@customers.create(customer_hash)
83
-
82
+
83
+ sleep(50)
84
84
  #create new transfer
85
- customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id'])
85
+ customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
86
86
 
87
87
  transfer=@transfers.create(customer_hash,customer['id'])
88
88
  t=@transfers.get(transfer['id'],customer['id'])
@@ -100,29 +100,29 @@ describe Transfers do
100
100
  end
101
101
 
102
102
  end
103
-
104
103
  describe '.each' do
105
104
 
106
105
  it 'iterates over a given customer transfers' do
107
106
 
108
107
  #create new customer
109
- customer_hash= FactoryGirl.build(:customer)
108
+ customer_hash= FactoryBot.build(:customer)
110
109
  customer=@customers.create(customer_hash)
111
110
 
112
111
  #create new customer card
113
- card_hash=FactoryGirl.build(:valid_card)
112
+ card_hash=FactoryBot.build(:valid_card)
114
113
  card=@cards.create(card_hash, customer['id'])
115
114
 
116
115
  #create charge
117
- charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id'])
116
+ charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
118
117
  charge=@charges.create(charge_hash,customer['id'])
119
118
 
120
119
  #create customer 2
121
- customer_hash= FactoryGirl.build(:customer,name: 'Alejandro')
120
+ customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
122
121
  customer2=@customers.create(customer_hash)
123
122
 
123
+ sleep(50)
124
124
  #create new transfer
125
- customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id'])
125
+ customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
126
126
  transfer=@transfers.create(customer_hash,customer['id'])
127
127
 
128
128
  #iterates over transfers
@@ -143,23 +143,24 @@ describe Transfers do
143
143
 
144
144
 
145
145
  #create new customer
146
- customer_hash= FactoryGirl.build(:customer)
146
+ customer_hash= FactoryBot.build(:customer)
147
147
  customer=@customers.create(customer_hash)
148
148
 
149
149
  #create new customer card
150
- card_hash=FactoryGirl.build(:valid_card)
150
+ card_hash=FactoryBot.build(:valid_card)
151
151
  card=@cards.create(card_hash, customer['id'])
152
152
 
153
153
  #create charge
154
- charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id'])
154
+ charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
155
155
  charge=@charges.create(charge_hash,customer['id'])
156
156
 
157
157
  #create customer 2
158
- customer_hash= FactoryGirl.build(:customer,name: 'Alejandro')
158
+ customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
159
159
  customer2=@customers.create(customer_hash)
160
-
160
+
161
+ sleep(50)
161
162
  #create new transfer
162
- customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id'])
163
+ customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
163
164
  transfer=@transfers.create(customer_hash,customer['id'])
164
165
  transfer=@transfers.create(customer_hash,customer['id'])
165
166
 
@@ -185,24 +186,26 @@ describe Transfers do
185
186
  it 'returns all customer transfers' do
186
187
 
187
188
  #create new customer
188
- customer_hash= FactoryGirl.build(:customer)
189
+ customer_hash= FactoryBot.build(:customer)
189
190
  customer=@customers.create(customer_hash)
190
191
 
191
192
  #create new customer card
192
- card_hash=FactoryGirl.build(:valid_card)
193
+ card_hash=FactoryBot.build(:valid_card)
193
194
  card=@cards.create(card_hash, customer['id'])
194
195
 
195
196
  #create charge
196
- charge_hash=FactoryGirl.build(:card_charge, source_id:card['id'],order_id: card['id'])
197
+ charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
197
198
  charge=@charges.create(charge_hash,customer['id'])
198
199
 
199
200
 
200
201
  #create customer 2
201
- customer_hash= FactoryGirl.build(:customer,name: 'Alejandro')
202
+ customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
202
203
  customer2=@customers.create(customer_hash)
204
+
205
+ sleep(50)
203
206
 
204
207
  #create new transfer
205
- customer_hash= FactoryGirl.build(:transfer,customer_id: customer2['id'])
208
+ customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
206
209
  transfer=@transfers.create(customer_hash,customer['id'])
207
210
 
208
211
 
@@ -216,4 +219,5 @@ describe Transfers do
216
219
  end
217
220
 
218
221
  end
222
+
219
223
  end
@@ -3,14 +3,20 @@ $: << 'lib'
3
3
  $: << 'lib/openpay'
4
4
 
5
5
  require 'openpay'
6
- require 'factory_girl'
6
+ require 'factory_bot'
7
+ #FactoryBot.find_definitions
7
8
  require 'test/Factories'
8
9
  require 'rspec'
9
10
  require 'json_spec'
10
11
 
11
12
  RSpec.configure do |config|
13
+ config.include FactoryBot::Syntax::Methods
14
+
15
+ #config.before(:suite) {FactoryBot.reload}
16
+
12
17
  config.expect_with :rspec do |c|
13
18
  c.syntax = :expect
14
19
  config.include JsonSpec::Helpers
15
20
  end
21
+
16
22
  end
metadata CHANGED
@@ -1,117 +1,118 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 2.0.0b
5
5
  platform: ruby
6
6
  authors:
7
+ - Openpay
7
8
  - ronnie_bermejo
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
12
+ date: 2017-12-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rest-client
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ~>
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: 1.6.7
20
+ version: '2.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ~>
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: 1.6.7
27
+ version: '2.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: json
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - '>='
32
+ - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '0'
34
+ version: '1.8'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - '>='
39
+ - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '0'
41
+ version: '1.8'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: bundler
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ~>
46
+ - - "~>"
46
47
  - !ruby/object:Gem::Version
47
48
  version: '1.3'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - ~>
53
+ - - "~>"
53
54
  - !ruby/object:Gem::Version
54
55
  version: '1.3'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: rake
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
- - - '>='
60
+ - - ">="
60
61
  - !ruby/object:Gem::Version
61
62
  version: '0'
62
63
  type: :development
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - '>='
67
+ - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: json_spec
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
- - - '>='
74
+ - - ">="
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
- description: ruby client for Openpay API services (version 1.0.409)
84
+ description: ruby client for Openpay API services (version 2.0.0)
84
85
  email:
85
- - ronnie.bermejo.mx@gmail.com
86
+ - hola@openpay.mx
86
87
  executables: []
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
90
- - .gitignore
91
- - .idea/.name
92
- - .idea/.rakeTasks
93
- - .idea/OpenPay.iml
94
- - .idea/dictionaries/ronnie.xml
95
- - .idea/encodings.xml
96
- - .idea/misc.xml
97
- - .idea/modules.xml
98
- - .idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml
99
- - .idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml
100
- - .idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml
101
- - .idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml
102
- - .idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml
103
- - .idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml
104
- - .idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml
105
- - .idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml
106
- - .idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml
107
- - .idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml
108
- - .idea/runConfigurations/all_specs.xml
109
- - .idea/runConfigurations/install_open_pay.xml
110
- - .idea/runConfigurations/scrapbook.xml
111
- - .idea/scopes/scope_settings.xml
112
- - .idea/vcs.xml
113
- - .idea/workspace.xml
114
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".idea/.name"
93
+ - ".idea/.rakeTasks"
94
+ - ".idea/OpenPay.iml"
95
+ - ".idea/dictionaries/ronnie.xml"
96
+ - ".idea/encodings.xml"
97
+ - ".idea/misc.xml"
98
+ - ".idea/modules.xml"
99
+ - ".idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml"
100
+ - ".idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml"
101
+ - ".idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml"
102
+ - ".idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml"
103
+ - ".idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml"
104
+ - ".idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml"
105
+ - ".idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml"
106
+ - ".idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml"
107
+ - ".idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml"
108
+ - ".idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml"
109
+ - ".idea/runConfigurations/all_specs.xml"
110
+ - ".idea/runConfigurations/install_open_pay.xml"
111
+ - ".idea/runConfigurations/scrapbook.xml"
112
+ - ".idea/scopes/scope_settings.xml"
113
+ - ".idea/vcs.xml"
114
+ - ".idea/workspace.xml"
115
+ - ".travis.yml"
115
116
  - Gemfile
116
117
  - LICENSE.txt
117
118
  - README.md
@@ -151,11 +152,10 @@ files:
151
152
  - test/spec/subscriptions_spec.rb
152
153
  - test/spec/transfers_spec.rb
153
154
  - test/spec/utils/search_params_spec.rb
154
- - test/spec/webhook_spec.rb
155
155
  - test/spec_helper.rb
156
156
  homepage: http://openpay.mx/
157
157
  licenses:
158
- - Apache
158
+ - Apache-2.0
159
159
  metadata: {}
160
160
  post_install_message: Thanks for installing openpay. Enjoy !
161
161
  rdoc_options: []
@@ -163,20 +163,20 @@ require_paths:
163
163
  - lib
164
164
  - lib/openpay
165
165
  - openpay
166
- - .
166
+ - "."
167
167
  required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - '>='
169
+ - - ">="
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - '>='
174
+ - - ">"
175
175
  - !ruby/object:Gem::Version
176
- version: '0'
176
+ version: 1.3.1
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.0.14
179
+ rubygems_version: 2.6.14
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: ruby api for openpay resources
@@ -195,5 +195,4 @@ test_files:
195
195
  - test/spec/subscriptions_spec.rb
196
196
  - test/spec/transfers_spec.rb
197
197
  - test/spec/utils/search_params_spec.rb
198
- - test/spec/webhook_spec.rb
199
198
  - test/spec_helper.rb
@@ -1,104 +0,0 @@
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