openpay 1.0.7 → 2.0.1
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +4 -1
- data/Gemfile +2 -2
- data/README.md +25 -25
- data/Rakefile +2 -1
- data/lib/openpay.rb +3 -0
- data/lib/openpay/open_pay_resource.rb +40 -9
- data/lib/openpay/points.rb +10 -0
- data/lib/openpay/tokens.rb +7 -0
- data/lib/openpay/utils/search_params.rb +4 -1
- data/lib/openpay/webhooks.rb +9 -0
- data/lib/version.rb +1 -1
- data/openpay.gemspec +6 -6
- data/test/Factories.rb +30 -16
- data/test/spec/bankaccounts_spec.rb +44 -17
- data/test/spec/cards_spec.rb +52 -39
- data/test/spec/charges_spec.rb +48 -71
- data/test/spec/customers_spec.rb +15 -13
- data/test/spec/exceptions_spec.rb +4 -20
- data/test/spec/fees_spec.rb +24 -18
- data/test/spec/openpayresource_spec.rb +4 -2
- data/test/spec/payouts_spec.rb +41 -44
- data/test/spec/plans_spec.rb +16 -10
- data/test/spec/points_spec.rb +26 -0
- data/test/spec/requesttimeout_spec.rb +2 -0
- data/test/spec/subscriptions_spec.rb +39 -36
- data/test/spec/transfers_spec.rb +37 -31
- data/test/spec/utils/search_params_spec.rb +1 -1
- data/test/spec_helper.rb +10 -2
- metadata +41 -49
data/test/spec/plans_spec.rb
CHANGED
@@ -6,6 +6,8 @@ describe Plans 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)
|
@@ -15,10 +17,14 @@ describe Plans do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
|
20
|
+
=begin
|
21
|
+
|
18
22
|
after(:all) do
|
19
23
|
@plans.delete_all
|
20
24
|
end
|
21
25
|
|
26
|
+
=end
|
27
|
+
|
22
28
|
it 'has all required methods' do
|
23
29
|
%w(all each create get list delete).each do |meth|
|
24
30
|
expect(@plans).to respond_to(meth)
|
@@ -29,7 +35,7 @@ describe Plans do
|
|
29
35
|
|
30
36
|
it 'creates a merchant plan' do
|
31
37
|
|
32
|
-
plan_hash=
|
38
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5)
|
33
39
|
plan=@plans.create(plan_hash)
|
34
40
|
|
35
41
|
#validates
|
@@ -47,7 +53,7 @@ describe Plans do
|
|
47
53
|
it 'gets a merchant plan' do
|
48
54
|
|
49
55
|
#creates a plan
|
50
|
-
plan_hash=
|
56
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
51
57
|
plan=@plans.create(plan_hash)
|
52
58
|
|
53
59
|
#validates
|
@@ -81,7 +87,7 @@ describe Plans do
|
|
81
87
|
describe '.list' do
|
82
88
|
it 'list all plans given the filter' do
|
83
89
|
#creates a plan
|
84
|
-
plan_hash=
|
90
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
85
91
|
plan=@plans.create(plan_hash)
|
86
92
|
|
87
93
|
search_params = OpenpayUtils::SearchParams.new
|
@@ -98,11 +104,11 @@ describe Plans do
|
|
98
104
|
|
99
105
|
it 'updates an existing customer plan' do
|
100
106
|
#creates a plan
|
101
|
-
plan_hash=
|
107
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 10)
|
102
108
|
plan=@plans.create(plan_hash)
|
103
109
|
|
104
110
|
expect(plan['trial_days']).to be 10
|
105
|
-
plan_hash=
|
111
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 100)
|
106
112
|
plan=@plans.update(plan_hash, plan['id'])
|
107
113
|
expect(plan['trial_days']).to be 100
|
108
114
|
|
@@ -112,7 +118,7 @@ describe Plans do
|
|
112
118
|
|
113
119
|
it 'fails to update an non existing customer plan' do
|
114
120
|
|
115
|
-
plan_hash=
|
121
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 100)
|
116
122
|
|
117
123
|
#validates
|
118
124
|
expect { @plans.update(plan_hash, '111111') }.to raise_exception RestClient::ResourceNotFound
|
@@ -120,26 +126,26 @@ describe Plans do
|
|
120
126
|
@plans.update(plan_hash, '111111')
|
121
127
|
rescue RestClient::ResourceNotFound => e
|
122
128
|
expect(e.http_body).to be_a String
|
123
|
-
expect(e.message).to
|
129
|
+
expect(e.message).to include("404")
|
124
130
|
end
|
125
131
|
|
126
132
|
end
|
127
133
|
|
128
134
|
end
|
129
135
|
|
130
|
-
|
136
|
+
skip '.each' do
|
131
137
|
|
132
138
|
it 'iterates over all customer plans' do
|
133
139
|
|
134
140
|
#creates a plan
|
135
|
-
plan_hash=
|
141
|
+
plan_hash= FactoryBot.build(:plan, trial_days: 30)
|
136
142
|
plan=@plans.create(plan_hash)
|
137
143
|
plan1=@plans.create(plan_hash)
|
138
144
|
plan2=@plans.create(plan_hash)
|
139
145
|
|
140
146
|
expect(@plans.all.size).to be_a Integer
|
141
147
|
@plans.each do |plan|
|
142
|
-
expect(plan['name']).to match '
|
148
|
+
expect(plan['name']).to match 'TODO INCLUIDO'
|
143
149
|
@plans.delete(plan['id'])
|
144
150
|
end
|
145
151
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'Points' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
|
7
|
+
@merchant_id='mhbzmkji20dhu9kq3r2i'
|
8
|
+
@private_key='sk_0070ce5a12d948e0a0c9b5b8b7ff51ae'
|
9
|
+
|
10
|
+
@openpay=OpenpayApi.new(@merchant_id,@private_key)
|
11
|
+
@points=@openpay.create(:points)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.get' do
|
20
|
+
it 'Card Points ' do
|
21
|
+
point=@points.getPointsBalance('ka2fi3h6ikppavewn5ne')
|
22
|
+
puts point.to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -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)
|
@@ -6,6 +6,8 @@ describe Subscriptions 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)
|
@@ -29,19 +31,19 @@ describe Subscriptions do
|
|
29
31
|
it 'creates a subscription' do
|
30
32
|
|
31
33
|
#creates a customer
|
32
|
-
customer_hash=
|
34
|
+
customer_hash=FactoryBot.build(:customer)
|
33
35
|
customer=@customers.create(customer_hash)
|
34
36
|
|
35
37
|
#creates a customer card
|
36
|
-
card_hash=
|
38
|
+
card_hash=FactoryBot.build(:valid_card)
|
37
39
|
card=@cards.create(card_hash, customer['id'])
|
38
40
|
|
39
41
|
#creates a plan
|
40
|
-
plan_hash=
|
42
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
41
43
|
plan=@plans.create(plan_hash)
|
42
44
|
|
43
45
|
#creates subscription
|
44
|
-
subscription_hash=
|
46
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
45
47
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
46
48
|
|
47
49
|
#performs check
|
@@ -60,19 +62,19 @@ describe Subscriptions do
|
|
60
62
|
it 'gets customer subscriptions' do
|
61
63
|
|
62
64
|
#creates a customer
|
63
|
-
customer_hash=
|
65
|
+
customer_hash=FactoryBot.build(:customer)
|
64
66
|
customer=@customers.create(customer_hash)
|
65
67
|
|
66
68
|
#creates a customer card
|
67
|
-
card_hash=
|
69
|
+
card_hash=FactoryBot.build(:valid_card)
|
68
70
|
card=@cards.create(card_hash, customer['id'])
|
69
71
|
|
70
72
|
#creates a plan
|
71
|
-
plan_hash=
|
73
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
72
74
|
plan=@plans.create(plan_hash)
|
73
75
|
|
74
76
|
#creates subscription
|
75
|
-
subscription_hash=
|
77
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
76
78
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
77
79
|
|
78
80
|
#get customer subscription
|
@@ -92,20 +94,22 @@ describe Subscriptions do
|
|
92
94
|
|
93
95
|
it 'updates customer subscription' do
|
94
96
|
|
97
|
+
time = Time.now + (60*60*24*2);
|
98
|
+
time = time.strftime("%Y-%m-%d")
|
95
99
|
#creates a customer
|
96
|
-
customer_hash=
|
100
|
+
customer_hash=FactoryBot.build(:customer)
|
97
101
|
customer=@customers.create(customer_hash)
|
98
102
|
|
99
103
|
#creates a customer card
|
100
|
-
card_hash=
|
104
|
+
card_hash=FactoryBot.build(:valid_card)
|
101
105
|
card=@cards.create(card_hash, customer['id'])
|
102
106
|
|
103
107
|
#creates a plan
|
104
|
-
plan_hash=
|
108
|
+
plan_hash=FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
105
109
|
plan=@plans.create(plan_hash)
|
106
110
|
|
107
111
|
#creates subscription
|
108
|
-
subscription_hash=
|
112
|
+
subscription_hash=FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
109
113
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
110
114
|
|
111
115
|
#get customer subscription
|
@@ -113,11 +117,10 @@ describe Subscriptions do
|
|
113
117
|
|
114
118
|
#performs check
|
115
119
|
expect(stored_s['status']).to match 'trial'
|
116
|
-
|
117
|
-
|
118
|
-
|
120
|
+
subscription_update_hash={ trial_end_date: time }
|
121
|
+
sleep(20)
|
119
122
|
stored_s=@subscriptions.update(subscription['id'], customer['id'], subscription_update_hash)
|
120
|
-
expect(stored_s['trial_end_date']).to eq
|
123
|
+
expect(stored_s['trial_end_date']).to eq time
|
121
124
|
|
122
125
|
#cleanup
|
123
126
|
@subscriptions.delete(subscription['id'], customer['id'])
|
@@ -131,19 +134,19 @@ describe Subscriptions do
|
|
131
134
|
it 'returns all subscriptions for a given customer' do
|
132
135
|
|
133
136
|
#creates a customer
|
134
|
-
customer_hash=
|
137
|
+
customer_hash= FactoryBot.build(:customer)
|
135
138
|
customer=@customers.create(customer_hash)
|
136
139
|
|
137
140
|
#creates a customer card
|
138
|
-
card_hash=
|
141
|
+
card_hash= FactoryBot.build(:valid_card)
|
139
142
|
card=@cards.create(card_hash, customer['id'])
|
140
143
|
|
141
144
|
#creates a plan
|
142
|
-
plan_hash=
|
145
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
143
146
|
plan=@plans.create(plan_hash)
|
144
147
|
|
145
148
|
#creates subscription
|
146
|
-
subscription_hash=
|
149
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
147
150
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
148
151
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
149
152
|
|
@@ -161,19 +164,19 @@ describe Subscriptions do
|
|
161
164
|
|
162
165
|
it 'list subscriptions based on given filter' do
|
163
166
|
#creates a customer
|
164
|
-
customer_hash=
|
167
|
+
customer_hash= FactoryBot.build(:customer)
|
165
168
|
customer=@customers.create(customer_hash)
|
166
169
|
|
167
170
|
#creates a customer card
|
168
|
-
card_hash=
|
171
|
+
card_hash= FactoryBot.build(:valid_card)
|
169
172
|
card=@cards.create(card_hash, customer['id'])
|
170
173
|
|
171
174
|
#creates a plan
|
172
|
-
plan_hash=
|
175
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
173
176
|
plan=@plans.create(plan_hash)
|
174
177
|
|
175
178
|
#creates subscription
|
176
|
-
subscription_hash=
|
179
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
177
180
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
178
181
|
subscription1=@subscriptions.create(subscription_hash, customer['id'])
|
179
182
|
subscription2=@subscriptions.create(subscription_hash, customer['id'])
|
@@ -198,19 +201,19 @@ describe Subscriptions do
|
|
198
201
|
it 'iterates over all subscriptions for a given customer' do
|
199
202
|
|
200
203
|
#creates a customer
|
201
|
-
customer_hash=
|
204
|
+
customer_hash= FactoryBot.build(:customer)
|
202
205
|
customer=@customers.create(customer_hash)
|
203
206
|
|
204
207
|
#creates a customer card
|
205
|
-
card_hash=
|
208
|
+
card_hash= FactoryBot.build(:valid_card)
|
206
209
|
card=@cards.create(card_hash, customer['id'])
|
207
210
|
|
208
211
|
#creates a plan
|
209
|
-
plan_hash=
|
212
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
210
213
|
plan=@plans.create(plan_hash)
|
211
214
|
|
212
215
|
#creates subscription
|
213
|
-
subscription_hash=
|
216
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
214
217
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
215
218
|
@subscriptions.create(subscription_hash, customer['id'])
|
216
219
|
|
@@ -231,19 +234,19 @@ describe Subscriptions do
|
|
231
234
|
it 'deletes an existing subscription for a given customer' do
|
232
235
|
|
233
236
|
#creates a customer
|
234
|
-
customer_hash=
|
237
|
+
customer_hash= FactoryBot.build(:customer)
|
235
238
|
customer=@customers.create(customer_hash)
|
236
239
|
|
237
240
|
#creates a customer card
|
238
|
-
card_hash=
|
241
|
+
card_hash= FactoryBot.build(:valid_card)
|
239
242
|
card=@cards.create(card_hash, customer['id'])
|
240
243
|
|
241
244
|
#creates a plan
|
242
|
-
plan_hash=
|
245
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
243
246
|
plan=@plans.create(plan_hash)
|
244
247
|
|
245
248
|
#creates subscription
|
246
|
-
subscription_hash=
|
249
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
247
250
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
248
251
|
subscription=@subscriptions.create(subscription_hash, customer['id'])
|
249
252
|
|
@@ -262,19 +265,19 @@ describe Subscriptions do
|
|
262
265
|
it 'deletes all existing subscription for a given customer' do
|
263
266
|
|
264
267
|
#creates a customer
|
265
|
-
customer_hash=
|
268
|
+
customer_hash= FactoryBot.build(:customer)
|
266
269
|
customer=@customers.create(customer_hash)
|
267
270
|
|
268
271
|
#creates a customer card
|
269
|
-
card_hash=
|
272
|
+
card_hash= FactoryBot.build(:valid_card)
|
270
273
|
card=@cards.create(card_hash, customer['id'])
|
271
274
|
|
272
275
|
#creates a plan
|
273
|
-
plan_hash=
|
276
|
+
plan_hash= FactoryBot.build(:plan, repeat_every: 5, amount: 500)
|
274
277
|
plan=@plans.create(plan_hash)
|
275
278
|
|
276
279
|
#creates subscriptions
|
277
|
-
subscription_hash=
|
280
|
+
subscription_hash= FactoryBot.build(:subscription, plan_id: plan['id'], card_id: card['id'])
|
278
281
|
expect(@subscriptions.all(customer['id']).size).to be 0
|
279
282
|
@subscriptions.create(subscription_hash, customer['id'])
|
280
283
|
@subscriptions.create(subscription_hash, customer['id'])
|
data/test/spec/transfers_spec.rb
CHANGED
@@ -2,11 +2,12 @@ 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'
|
9
8
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
9
|
+
|
10
|
+
#LOG.level=Logger::DEBUG
|
10
11
|
|
11
12
|
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
12
13
|
@customers=@openpay.create(:customers)
|
@@ -29,26 +30,26 @@ describe Transfers do
|
|
29
30
|
it 'transfers money from customer to customer' do
|
30
31
|
|
31
32
|
#create new customer
|
32
|
-
customer_hash=
|
33
|
+
customer_hash= FactoryBot.build(:customer)
|
33
34
|
customer=@customers.create(customer_hash)
|
34
|
-
|
35
35
|
#create new customer card
|
36
|
-
card_hash=
|
36
|
+
card_hash=FactoryBot.build(:valid_card)
|
37
37
|
card=@cards.create(card_hash, customer['id'])
|
38
38
|
|
39
39
|
#create charge
|
40
|
-
charge_hash=
|
40
|
+
charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
|
41
41
|
charge=@charges.create(charge_hash,customer['id'])
|
42
42
|
|
43
43
|
#create customer 2
|
44
|
-
customer_hash=
|
44
|
+
customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
|
45
45
|
customer2=@customers.create(customer_hash)
|
46
46
|
|
47
|
+
sleep(50)
|
47
48
|
#create new transfer
|
48
|
-
customer_hash=
|
49
|
-
|
49
|
+
customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
|
50
50
|
transfer=@transfers.create(customer_hash,customer['id'])
|
51
51
|
t=@transfers.get(transfer['id'],customer['id'])
|
52
|
+
|
52
53
|
expect(t['amount']).to be_within(0.1).of 12.5
|
53
54
|
expect(t['method']).to match 'customer'
|
54
55
|
|
@@ -64,23 +65,24 @@ describe Transfers do
|
|
64
65
|
it 'gets a customer transfer' do
|
65
66
|
|
66
67
|
#create new customer
|
67
|
-
customer_hash=
|
68
|
+
customer_hash= FactoryBot.build(:customer)
|
68
69
|
customer=@customers.create(customer_hash)
|
69
70
|
|
70
71
|
#create new customer card
|
71
|
-
card_hash=
|
72
|
+
card_hash=FactoryBot.build(:valid_card)
|
72
73
|
card=@cards.create(card_hash, customer['id'])
|
73
74
|
|
74
75
|
#create charge
|
75
|
-
charge_hash=
|
76
|
+
charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
|
76
77
|
charge=@charges.create(charge_hash,customer['id'])
|
77
78
|
|
78
79
|
#create customer 2
|
79
|
-
customer_hash=
|
80
|
+
customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
|
80
81
|
customer2=@customers.create(customer_hash)
|
81
|
-
|
82
|
+
|
83
|
+
sleep(50)
|
82
84
|
#create new transfer
|
83
|
-
customer_hash=
|
85
|
+
customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
|
84
86
|
|
85
87
|
transfer=@transfers.create(customer_hash,customer['id'])
|
86
88
|
t=@transfers.get(transfer['id'],customer['id'])
|
@@ -98,29 +100,29 @@ describe Transfers do
|
|
98
100
|
end
|
99
101
|
|
100
102
|
end
|
101
|
-
|
102
103
|
describe '.each' do
|
103
104
|
|
104
105
|
it 'iterates over a given customer transfers' do
|
105
106
|
|
106
107
|
#create new customer
|
107
|
-
customer_hash=
|
108
|
+
customer_hash= FactoryBot.build(:customer)
|
108
109
|
customer=@customers.create(customer_hash)
|
109
110
|
|
110
111
|
#create new customer card
|
111
|
-
card_hash=
|
112
|
+
card_hash=FactoryBot.build(:valid_card)
|
112
113
|
card=@cards.create(card_hash, customer['id'])
|
113
114
|
|
114
115
|
#create charge
|
115
|
-
charge_hash=
|
116
|
+
charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
|
116
117
|
charge=@charges.create(charge_hash,customer['id'])
|
117
118
|
|
118
119
|
#create customer 2
|
119
|
-
customer_hash=
|
120
|
+
customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
|
120
121
|
customer2=@customers.create(customer_hash)
|
121
122
|
|
123
|
+
sleep(50)
|
122
124
|
#create new transfer
|
123
|
-
customer_hash=
|
125
|
+
customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
|
124
126
|
transfer=@transfers.create(customer_hash,customer['id'])
|
125
127
|
|
126
128
|
#iterates over transfers
|
@@ -141,23 +143,24 @@ describe Transfers do
|
|
141
143
|
|
142
144
|
|
143
145
|
#create new customer
|
144
|
-
customer_hash=
|
146
|
+
customer_hash= FactoryBot.build(:customer)
|
145
147
|
customer=@customers.create(customer_hash)
|
146
148
|
|
147
149
|
#create new customer card
|
148
|
-
card_hash=
|
150
|
+
card_hash=FactoryBot.build(:valid_card)
|
149
151
|
card=@cards.create(card_hash, customer['id'])
|
150
152
|
|
151
153
|
#create charge
|
152
|
-
charge_hash=
|
154
|
+
charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
|
153
155
|
charge=@charges.create(charge_hash,customer['id'])
|
154
156
|
|
155
157
|
#create customer 2
|
156
|
-
customer_hash=
|
158
|
+
customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
|
157
159
|
customer2=@customers.create(customer_hash)
|
158
|
-
|
160
|
+
|
161
|
+
sleep(50)
|
159
162
|
#create new transfer
|
160
|
-
customer_hash=
|
163
|
+
customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
|
161
164
|
transfer=@transfers.create(customer_hash,customer['id'])
|
162
165
|
transfer=@transfers.create(customer_hash,customer['id'])
|
163
166
|
|
@@ -183,24 +186,26 @@ describe Transfers do
|
|
183
186
|
it 'returns all customer transfers' do
|
184
187
|
|
185
188
|
#create new customer
|
186
|
-
customer_hash=
|
189
|
+
customer_hash= FactoryBot.build(:customer)
|
187
190
|
customer=@customers.create(customer_hash)
|
188
191
|
|
189
192
|
#create new customer card
|
190
|
-
card_hash=
|
193
|
+
card_hash=FactoryBot.build(:valid_card)
|
191
194
|
card=@cards.create(card_hash, customer['id'])
|
192
195
|
|
193
196
|
#create charge
|
194
|
-
charge_hash=
|
197
|
+
charge_hash=FactoryBot.build(:card_charge, source_id:card['id'],order_id: card['id'])
|
195
198
|
charge=@charges.create(charge_hash,customer['id'])
|
196
199
|
|
197
200
|
|
198
201
|
#create customer 2
|
199
|
-
customer_hash=
|
202
|
+
customer_hash= FactoryBot.build(:customer,name: 'Alejandro')
|
200
203
|
customer2=@customers.create(customer_hash)
|
204
|
+
|
205
|
+
sleep(50)
|
201
206
|
|
202
207
|
#create new transfer
|
203
|
-
customer_hash=
|
208
|
+
customer_hash= FactoryBot.build(:transfer,customer_id: customer2['id'])
|
204
209
|
transfer=@transfers.create(customer_hash,customer['id'])
|
205
210
|
|
206
211
|
|
@@ -214,4 +219,5 @@ describe Transfers do
|
|
214
219
|
end
|
215
220
|
|
216
221
|
end
|
222
|
+
|
217
223
|
end
|