openpay 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +1 -0
- data/.idea/.rakeTasks +2 -2
- data/.idea/OpenPay.iml +30 -20
- data/.idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/all_specs.xml +1 -0
- data/.idea/workspace.xml +484 -268
- data/Gemfile +0 -6
- data/README.md +111 -29
- data/lib/openpay.rb +7 -3
- data/lib/openpay/bankaccounts.rb +10 -11
- data/lib/openpay/cards.rb +12 -14
- data/lib/openpay/charges.rb +38 -14
- data/lib/openpay/customers.rb +73 -67
- data/lib/openpay/errors/openpay_exception_factory.rb +14 -26
- data/lib/openpay/fees.rb +1 -1
- data/lib/openpay/open_pay_resource.rb +77 -77
- data/lib/openpay/open_pay_resource_factory.rb +1 -1
- data/lib/openpay/openpay_api.rb +6 -16
- data/lib/openpay/payouts.rb +13 -17
- data/lib/openpay/plans.rb +1 -7
- data/lib/openpay/subscriptions.rb +21 -29
- data/lib/openpay/transfers.rb +14 -18
- data/lib/openpay/utils/search_params.rb +20 -0
- data/lib/version.rb +1 -2
- data/openpay.gemspec +0 -8
- data/test/Factories.rb +80 -126
- data/test/spec/bankaccounts_spec.rb +55 -61
- data/test/spec/cards_spec.rb +56 -76
- data/test/spec/charges_spec.rb +89 -84
- data/test/spec/customers_spec.rb +37 -47
- data/test/spec/exceptions_spec.rb +4 -21
- data/test/spec/fees_spec.rb +51 -7
- data/test/spec/payouts_spec.rb +102 -65
- data/test/spec/plans_spec.rb +27 -50
- data/test/spec/subscriptions_spec.rb +87 -24
- data/test/spec/transfers_spec.rb +42 -44
- data/test/spec/utils/search_params_spec.rb +36 -0
- data/test/spec_helper.rb +1 -5
- metadata +15 -55
- data/lib/OpenPay/Cards.rb +0 -75
- data/lib/OpenPay/Charges.rb +0 -77
- data/lib/OpenPay/Customers.rb +0 -194
- data/lib/OpenPay/Fees.rb +0 -5
- data/lib/OpenPay/Payouts.rb +0 -59
- data/lib/OpenPay/Plans.rb +0 -23
- data/lib/OpenPay/Subscriptions.rb +0 -58
- data/lib/OpenPay/Transfers.rb +0 -43
- data/lib/OpenPay/bankaccounts.rb +0 -59
- data/lib/OpenPay/errors/openpay_connection_exception.rb +0 -3
- data/lib/OpenPay/errors/openpay_exception.rb +0 -29
- data/lib/OpenPay/errors/openpay_exception_factory.rb +0 -60
- data/lib/OpenPay/errors/openpay_transaction_exception.rb +0 -5
- data/lib/OpenPay/open_pay_resource.rb +0 -242
- data/lib/OpenPay/open_pay_resource_factory.rb +0 -10
- data/lib/OpenPay/openpay_api.rb +0 -58
@@ -1,24 +1,25 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
2
|
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe Bankaccounts do
|
5
5
|
|
6
|
-
|
6
|
+
#bankaccounts for merchant cannot be created using the api
|
7
7
|
#the merchant bank account should be created using the Openpay dashboard
|
8
8
|
before(:all) do
|
9
9
|
|
10
10
|
@merchant_id='mywvupjjs9xdnryxtplq'
|
11
11
|
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
12
12
|
|
13
|
-
@openpay=OpenpayApi.new(@merchant_id
|
13
|
+
@openpay=OpenpayApi.new(@merchant_id, @private_key)
|
14
14
|
@bank_accounts=@openpay.create(:bankaccounts)
|
15
15
|
@customers=@openpay.create(:customers)
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it 'has all required methods' do
|
20
|
+
%w(all each create get list delete).each do |meth|
|
21
|
+
expect(@bank_accounts).to respond_to(meth)
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
describe '.create' do
|
@@ -28,19 +29,18 @@ describe Bankaccounts do
|
|
28
29
|
customer=@customers.create(customer_hash)
|
29
30
|
|
30
31
|
account_hash=FactoryGirl.build(:bank_account)
|
31
|
-
bank=@bank_accounts.create(account_hash,customer['id'])
|
32
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
32
33
|
|
33
|
-
bank_account=@bank_accounts.get(customer['id'],bank['id'])
|
34
|
+
bank_account=@bank_accounts.get(customer['id'], bank['id'])
|
34
35
|
expect(bank_account['alias']).to match 'Cuenta principal'
|
35
36
|
|
36
|
-
@bank_accounts.delete(customer['id'],bank['id'])
|
37
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
38
|
+
@customers.delete(customer['id'])
|
37
39
|
|
38
40
|
end
|
39
41
|
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
44
|
describe '.get' do
|
45
45
|
|
46
46
|
it 'get a given bank account for a given customer' do
|
@@ -49,65 +49,76 @@ describe Bankaccounts do
|
|
49
49
|
customer=@customers.create(customer_hash)
|
50
50
|
|
51
51
|
account_hash=FactoryGirl.build(:bank_account)
|
52
|
-
bank=@bank_accounts.create(account_hash,customer['id'])
|
52
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
53
53
|
|
54
|
-
bank_account=@bank_accounts.get(customer['id'],bank['id'])
|
54
|
+
bank_account=@bank_accounts.get(customer['id'], bank['id'])
|
55
55
|
expect(bank_account['alias']).to match 'Cuenta principal'
|
56
|
-
@bank_accounts.delete(customer['id'],bank['id'])
|
56
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
57
|
+
@customers.delete(customer['id'])
|
57
58
|
|
58
59
|
end
|
59
60
|
|
60
61
|
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
63
|
describe '.each' do
|
65
64
|
|
66
|
-
|
67
65
|
it 'iterator for all given customer bank accounts' do
|
68
66
|
|
69
67
|
customer_hash= FactoryGirl.build(:customer)
|
70
68
|
customer=@customers.create(customer_hash)
|
71
69
|
|
72
70
|
account_hash=FactoryGirl.build(:bank_account)
|
73
|
-
bank=@bank_accounts.create(account_hash,customer['id'])
|
71
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
74
72
|
|
75
73
|
@bank_accounts.each(customer['id']) do |bank_account|
|
76
|
-
|
74
|
+
expect(bank_account['alias']).to match 'Cuenta principal'
|
77
75
|
end
|
78
76
|
|
79
|
-
@bank_accounts.delete(customer['id'],bank['id'])
|
77
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
80
78
|
@customers.delete(customer['id'])
|
81
79
|
|
82
80
|
end
|
83
81
|
|
82
|
+
end
|
84
83
|
|
85
|
-
|
84
|
+
describe '.list' do
|
86
85
|
|
86
|
+
it 'list the bank accounts using a given filter' do
|
87
87
|
|
88
|
-
|
88
|
+
customer_hash= FactoryGirl.build(:customer)
|
89
|
+
customer=@customers.create(customer_hash)
|
90
|
+
expect(@bank_accounts.all(customer['id']).size).to be 0
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
92
|
+
account_hash=FactoryGirl.build(:bank_account)
|
93
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
94
|
+
expect(@bank_accounts.all(customer['id']).size).to be 1
|
94
95
|
|
96
|
+
search_params = OpenpayUtils::SearchParams.new
|
97
|
+
search_params.limit = 1
|
95
98
|
|
99
|
+
expect(@bank_accounts.all(customer['id']).size).to eq 1
|
100
|
+
expect(@bank_accounts.list(search_params , customer['id']).size).to eq 1
|
101
|
+
|
102
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
103
|
+
@customers.delete(customer['id'])
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
96
107
|
|
97
108
|
describe '.all' do
|
98
109
|
|
99
|
-
it '
|
110
|
+
it 'all bank accounts for a given customer' do
|
100
111
|
|
101
|
-
|
102
|
-
|
103
|
-
|
112
|
+
customer_hash= FactoryGirl.build(:customer)
|
113
|
+
customer=@customers.create(customer_hash)
|
114
|
+
expect(@bank_accounts.all(customer['id']).size).to be 0
|
104
115
|
|
105
|
-
|
106
|
-
|
107
|
-
|
116
|
+
account_hash=FactoryGirl.build(:bank_account)
|
117
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
118
|
+
expect(@bank_accounts.all(customer['id']).size).to be 1
|
108
119
|
|
109
|
-
|
110
|
-
|
120
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
121
|
+
@customers.delete(customer['id'])
|
111
122
|
|
112
123
|
end
|
113
124
|
|
@@ -117,33 +128,29 @@ end
|
|
117
128
|
|
118
129
|
end
|
119
130
|
|
120
|
-
|
121
131
|
describe '.delete' do
|
122
132
|
|
123
|
-
it 'deletes
|
133
|
+
it 'deletes a given bank account' do
|
124
134
|
|
125
135
|
customer_hash= FactoryGirl.build(:customer)
|
126
136
|
customer=@customers.create(customer_hash)
|
127
137
|
expect(@bank_accounts.all(customer['id']).size).to be 0
|
128
138
|
|
129
|
-
|
130
139
|
account_hash=FactoryGirl.build(:bank_account)
|
131
|
-
bank=@bank_accounts.create(account_hash,customer['id'])
|
140
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
132
141
|
expect(@bank_accounts.all(customer['id']).size).to be 1
|
133
142
|
|
134
|
-
@bank_accounts.delete(customer['id'],bank['id'])
|
143
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
135
144
|
@customers.delete(customer['id'])
|
136
145
|
|
137
146
|
end
|
138
147
|
|
139
|
-
|
140
|
-
|
141
|
-
expect { @customers.delete('1111') }.to raise_exception OpenpayTransactionException
|
148
|
+
it 'fails to delete a non existing bank accounts' do
|
149
|
+
expect { @customers.delete('1111') }.to raise_exception OpenpayTransactionException
|
142
150
|
end
|
143
151
|
|
144
152
|
end
|
145
153
|
|
146
|
-
|
147
154
|
describe '.delete_all' do
|
148
155
|
|
149
156
|
it 'deletes all bank accounts' do
|
@@ -153,34 +160,21 @@ end
|
|
153
160
|
|
154
161
|
account_hash=FactoryGirl.build(:bank_account)
|
155
162
|
|
156
|
-
@bank_accounts.create(account_hash,customer['id'])
|
163
|
+
@bank_accounts.create(account_hash, customer['id'])
|
157
164
|
expect(@bank_accounts.all(customer['id']).size).to be 1
|
158
165
|
|
159
166
|
@bank_accounts.delete_all(customer['id'])
|
160
167
|
expect(@bank_accounts.all(customer['id']).size).to be 0
|
161
168
|
|
169
|
+
@customers.delete(customer['id'])
|
162
170
|
|
163
171
|
end
|
164
172
|
|
165
173
|
it 'fails to deletes all bank accounts when used on PROD' do
|
166
|
-
|
167
174
|
@openpayprod=OpenpayApi.new(@merchant_id, @private_key, true)
|
168
175
|
bank_accounts=@openpayprod.create(:bankaccounts)
|
169
|
-
|
170
|
-
expect { bank_accounts.delete_all('111111') }.to raise_exception OpenpayException
|
171
|
-
|
172
|
-
|
176
|
+
expect { bank_accounts.delete_all('111111') }.to raise_exception OpenpayException
|
173
177
|
end
|
174
178
|
|
175
179
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
end
|
180
|
+
end
|
data/test/spec/cards_spec.rb
CHANGED
@@ -3,6 +3,8 @@ require_relative '../spec_helper'
|
|
3
3
|
|
4
4
|
describe Cards do
|
5
5
|
|
6
|
+
# %w(create delete get list each all fail).each do |meth|
|
7
|
+
# end
|
6
8
|
|
7
9
|
before(:all) do
|
8
10
|
|
@@ -15,17 +17,21 @@ describe Cards do
|
|
15
17
|
|
16
18
|
@cards.delete_all
|
17
19
|
|
18
|
-
|
19
20
|
end
|
20
21
|
|
21
22
|
after(:all) do
|
22
23
|
#each test should build and clean it's own mess.
|
23
24
|
end
|
24
25
|
|
26
|
+
it 'has all required methods' do
|
27
|
+
%w(all each create get list delete).each do |meth|
|
28
|
+
expect(@cards).to respond_to(meth)
|
29
|
+
end
|
30
|
+
end
|
25
31
|
|
26
32
|
describe '.create' do
|
27
33
|
|
28
|
-
it 'creates
|
34
|
+
it 'creates merchant card' do
|
29
35
|
|
30
36
|
#creates merchant card
|
31
37
|
card_hash = FactoryGirl.build(:valid_card)
|
@@ -40,13 +46,11 @@ describe Cards do
|
|
40
46
|
expect(card['holder_name']).to match(name)
|
41
47
|
expect(card['card_number']).to match('1111')
|
42
48
|
|
43
|
-
|
49
|
+
#cleanup
|
44
50
|
@cards.delete(card['id'])
|
45
51
|
|
46
|
-
|
47
52
|
end
|
48
53
|
|
49
|
-
|
50
54
|
it 'creates a customer card' do
|
51
55
|
|
52
56
|
#creates a customer
|
@@ -61,7 +65,7 @@ describe Cards do
|
|
61
65
|
|
62
66
|
id=cards['id']
|
63
67
|
|
64
|
-
|
68
|
+
#performs check
|
65
69
|
customer_cards=customers.all_cards(customer['id'])
|
66
70
|
expect(customer_cards.size).to be 1
|
67
71
|
expect(cards['holder_name']).to match 'Pepe'
|
@@ -74,10 +78,8 @@ describe Cards do
|
|
74
78
|
@cards.delete(id, customer['id'])
|
75
79
|
@customers.delete(customer['id'])
|
76
80
|
|
77
|
-
|
78
81
|
end
|
79
82
|
|
80
|
-
|
81
83
|
it 'fails when trying to create an existing merchant card' do
|
82
84
|
|
83
85
|
#creates merchant card
|
@@ -92,8 +94,6 @@ describe Cards do
|
|
92
94
|
|
93
95
|
end
|
94
96
|
|
95
|
-
|
96
|
-
|
97
97
|
it 'fails when trying to create an existing customer card' do
|
98
98
|
|
99
99
|
#creates a customer
|
@@ -106,18 +106,15 @@ describe Cards do
|
|
106
106
|
card=@cards.create(card_hash, customer['id'])
|
107
107
|
expect(card).to be_a(Hash)
|
108
108
|
|
109
|
-
|
110
|
-
expect { @cards.create(card_hash,customer['id']) }.to raise_error(OpenpayTransactionException)
|
109
|
+
#performs check
|
110
|
+
expect { @cards.create(card_hash, customer['id']) }.to raise_error(OpenpayTransactionException)
|
111
111
|
|
112
112
|
#cleanup
|
113
|
-
@cards.delete(card['id'],customer['id'])
|
113
|
+
@cards.delete(card['id'], customer['id'])
|
114
114
|
@customers.delete(customer['id'])
|
115
115
|
|
116
|
-
|
117
116
|
end
|
118
117
|
|
119
|
-
|
120
|
-
|
121
118
|
it 'fails when using an expired card' do
|
122
119
|
card_hash = FactoryGirl.build(:expired_card)
|
123
120
|
#check
|
@@ -125,14 +122,13 @@ describe Cards do
|
|
125
122
|
#extended check
|
126
123
|
begin
|
127
124
|
@cards.create(card_hash)
|
128
|
-
rescue OpenpayTransactionException =>
|
125
|
+
rescue OpenpayTransactionException => e
|
129
126
|
expect(e.description).to match 'The card has expired'
|
130
127
|
expect(e.error_code).to be 3002
|
131
128
|
end
|
132
129
|
|
133
130
|
end
|
134
131
|
|
135
|
-
|
136
132
|
it 'fails when using a stolen card' do
|
137
133
|
card_json = FactoryGirl.build(:valid_card, card_number: '4000000000000119')
|
138
134
|
expect { @cards.create(card_json) }.to raise_error(OpenpayTransactionException)
|
@@ -140,7 +136,6 @@ describe Cards do
|
|
140
136
|
|
141
137
|
end
|
142
138
|
|
143
|
-
|
144
139
|
describe '.each' do
|
145
140
|
|
146
141
|
it 'iterates over all existing merchant cards' do
|
@@ -149,11 +144,8 @@ describe Cards do
|
|
149
144
|
end
|
150
145
|
end
|
151
146
|
|
152
|
-
|
153
147
|
it 'iterates over all existing customer cards' do
|
154
148
|
|
155
|
-
|
156
|
-
|
157
149
|
#creates a customer
|
158
150
|
card_hash = FactoryGirl.build(:valid_card, holder_name: 'Pepe')
|
159
151
|
customers=@openpay.create(:customers)
|
@@ -168,26 +160,16 @@ describe Cards do
|
|
168
160
|
expect(c['expiration_year']).to match '14'
|
169
161
|
end
|
170
162
|
|
171
|
-
|
172
163
|
#cleanup
|
173
|
-
@cards.delete(card['id'],customer['id'])
|
164
|
+
@cards.delete(card['id'], customer['id'])
|
174
165
|
@customers.delete(customer['id'])
|
175
166
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
167
|
end
|
180
168
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
169
|
end
|
186
170
|
|
187
|
-
|
188
171
|
describe '.delete' do
|
189
172
|
|
190
|
-
|
191
173
|
it 'deletes a merchant card' do
|
192
174
|
|
193
175
|
#creates merchant card
|
@@ -199,20 +181,15 @@ describe Cards do
|
|
199
181
|
name='Vicente Olmos'
|
200
182
|
|
201
183
|
#perform check
|
202
|
-
|
203
184
|
card=@cards.delete(id)
|
204
185
|
expect { @cards.get(id) }.to raise_exception(OpenpayTransactionException)
|
205
186
|
|
206
|
-
|
207
187
|
end
|
208
188
|
|
209
|
-
|
210
|
-
|
211
|
-
it 'fails to deletes a non existing card' do
|
189
|
+
it 'fails to deletes a non existing card' do
|
212
190
|
expect { @cards.delete('1111111') }.to raise_exception(OpenpayTransactionException)
|
213
191
|
end
|
214
192
|
|
215
|
-
|
216
193
|
it 'deletes a customer card' do
|
217
194
|
|
218
195
|
#create customer
|
@@ -228,22 +205,18 @@ describe Cards do
|
|
228
205
|
@cards.delete(card['id'], customer['id'])
|
229
206
|
|
230
207
|
#perform check
|
231
|
-
|
208
|
+
expect { @cards.get(card['id'], customer['id']) }.to raise_exception(OpenpayTransactionException)
|
232
209
|
|
233
210
|
end
|
234
211
|
|
235
|
-
|
236
212
|
it 'fails to deletes a non existing customer card' do
|
237
213
|
expect { @cards.delete('1111111', '1111') }.to raise_exception(OpenpayTransactionException)
|
238
214
|
end
|
239
215
|
|
240
|
-
|
241
216
|
end
|
242
217
|
|
243
|
-
|
244
218
|
describe '.get' do
|
245
219
|
|
246
|
-
|
247
220
|
it ' gets an existing merchant card' do
|
248
221
|
|
249
222
|
#create merchant card
|
@@ -263,13 +236,11 @@ describe Cards do
|
|
263
236
|
|
264
237
|
end
|
265
238
|
|
266
|
-
|
267
239
|
it 'fails when getting a non existing card' do
|
268
240
|
expect { @cards.get('11111') }.to raise_exception(OpenpayTransactionException)
|
269
241
|
end
|
270
242
|
|
271
|
-
|
272
|
-
it ' gets an existing customer card' do
|
243
|
+
it ' gets an existing customer card' do
|
273
244
|
|
274
245
|
#create customer
|
275
246
|
customer_hash = FactoryGirl.build(:customer)
|
@@ -293,18 +264,15 @@ describe Cards do
|
|
293
264
|
|
294
265
|
end
|
295
266
|
|
296
|
-
|
297
267
|
it 'fails when getting a non existing customer card' do
|
298
268
|
expect { @cards.get('11111', '1111') }.to raise_exception(OpenpayTransactionException)
|
299
269
|
end
|
300
270
|
|
301
|
-
|
302
271
|
end
|
303
272
|
|
304
|
-
|
305
273
|
describe '.all' do
|
306
274
|
|
307
|
-
it '
|
275
|
+
it 'all merchant cards' do
|
308
276
|
|
309
277
|
#check initial state
|
310
278
|
expect(@cards.all.size).to be 0
|
@@ -322,9 +290,7 @@ describe Cards do
|
|
322
290
|
|
323
291
|
end
|
324
292
|
|
325
|
-
|
326
|
-
it 'list all customer cards' do
|
327
|
-
|
293
|
+
it 'all customer cards' do
|
328
294
|
|
329
295
|
#create customer
|
330
296
|
customer_hash = FactoryGirl.build(:customer)
|
@@ -346,34 +312,56 @@ describe Cards do
|
|
346
312
|
|
347
313
|
end
|
348
314
|
|
349
|
-
|
350
|
-
it 'list cards for a non existing customer' do
|
315
|
+
it 'cards for a non existing customer' do
|
351
316
|
expect { @cards.all('111111') }.to raise_exception OpenpayTransactionException
|
352
317
|
end
|
353
318
|
|
354
|
-
|
355
319
|
end
|
356
320
|
|
357
|
-
|
358
321
|
describe '.list' do
|
359
322
|
|
360
323
|
it 'list the merchant cards using a filter' do
|
361
324
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
#offset=0&
|
366
|
-
#limit=10
|
367
|
-
# @cards.list('2000-01-01','2000-01-01',0,10)
|
325
|
+
#create merchant card
|
326
|
+
card_hash = FactoryGirl.build(:valid_card)
|
327
|
+
card1 = @cards.create(card_hash)
|
368
328
|
|
329
|
+
card_hash = FactoryGirl.build(:valid_card2)
|
330
|
+
card2 = @cards.create(card_hash)
|
369
331
|
|
332
|
+
search_params = OpenpayUtils::SearchParams.new
|
333
|
+
search_params.limit = 1
|
334
|
+
expect(@cards.list(search_params).size).to eq 1
|
335
|
+
@cards.delete_all
|
370
336
|
end
|
371
337
|
|
372
|
-
|
373
338
|
it 'list the customer cards using a filter' do
|
374
|
-
pending
|
375
|
-
end
|
376
339
|
|
340
|
+
#create customer
|
341
|
+
customer_hash = FactoryGirl.build(:customer)
|
342
|
+
customer = @customers.create(customer_hash)
|
343
|
+
|
344
|
+
#creates card
|
345
|
+
bank_name ='Banamex'
|
346
|
+
card_hash = FactoryGirl.build(:valid_card)
|
347
|
+
card = @cards.create(card_hash, customer['id'])
|
348
|
+
id = card['id']
|
349
|
+
|
350
|
+
#creates card 2
|
351
|
+
bank_name = 'Bancomer'
|
352
|
+
card_hash = FactoryGirl.build(:valid_card2)
|
353
|
+
card = @cards.create(card_hash, customer['id'])
|
354
|
+
id = card['id']
|
355
|
+
|
356
|
+
search_params = OpenpayUtils::SearchParams.new
|
357
|
+
search_params.limit = 1
|
358
|
+
|
359
|
+
expect(@cards.all(customer['id']).size).to eq 2
|
360
|
+
expect(@cards.list(search_params , customer['id']).size).to eq 1
|
361
|
+
|
362
|
+
@cards.delete_all(customer['id'])
|
363
|
+
|
364
|
+
end
|
377
365
|
|
378
366
|
end
|
379
367
|
|
@@ -388,7 +376,6 @@ describe Cards do
|
|
388
376
|
|
389
377
|
end
|
390
378
|
|
391
|
-
|
392
379
|
it 'deletes all existing merchant cards' do
|
393
380
|
|
394
381
|
#create merchant card
|
@@ -399,7 +386,6 @@ describe Cards do
|
|
399
386
|
card2_json = FactoryGirl.build(:valid_card2).to_json
|
400
387
|
@cards.create(card2_json)
|
401
388
|
|
402
|
-
|
403
389
|
#perform check
|
404
390
|
expect(@cards.all.size).to be 2
|
405
391
|
|
@@ -409,12 +395,10 @@ describe Cards do
|
|
409
395
|
#perform check
|
410
396
|
expect(@cards.all.size).to be 0
|
411
397
|
|
412
|
-
|
413
398
|
end
|
414
399
|
|
415
400
|
it 'deletes all existing cards for a given customer' do
|
416
401
|
|
417
|
-
|
418
402
|
#creates customer
|
419
403
|
customer_hash = FactoryGirl.build(:customer)
|
420
404
|
customer=@customers.create(customer_hash)
|
@@ -435,12 +419,8 @@ describe Cards do
|
|
435
419
|
#check
|
436
420
|
expect(@cards.all(customer['id']).size).to be 0
|
437
421
|
|
438
|
-
|
439
|
-
|
440
422
|
end
|
441
423
|
|
442
|
-
|
443
424
|
end
|
444
425
|
|
445
|
-
|
446
|
-
end
|
426
|
+
end
|