iyzipay 1.0.36 → 1.0.39

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.
@@ -5,9 +5,9 @@ require_relative 'spec_helper'
5
5
  RSpec.describe 'Iyzipay' do
6
6
  before :all do
7
7
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
8
+ @options.api_key = SpecOptions::API_KEY
9
+ @options.secret_key = SpecOptions::SECRET_KEY
10
+ @options.base_url = SpecOptions::BASE_URL
11
11
  end
12
12
 
13
13
  it 'should retrieve installment' do
@@ -18,8 +18,23 @@ RSpec.describe 'Iyzipay' do
18
18
  price: '100'
19
19
  }
20
20
  installment_info = Iyzipay::Model::InstallmentInfo.new.retrieve(request, @options)
21
+ installment_info = JSON.parse(installment_info)
22
+ expect(installment_info['status']).to eq('success')
23
+ expect(installment_info['locale']).to eq('tr')
24
+ expect(installment_info['systemTime']).not_to be_nil
25
+ expect(installment_info['conversationId']).to eq('123456789')
26
+ expect(installment_info['installmentDetails']).not_to be_nil
27
+ expect(installment_info['installmentDetails'][0]['binNumber']).to eq('554960')
28
+ expect(installment_info['installmentDetails'][0]['price']).to eq(100)
29
+ expect(installment_info['installmentDetails'][0]['cardType']).to eq('CREDIT_CARD')
30
+ expect(installment_info['installmentDetails'][0]['cardAssociation']).to eq('MASTER_CARD')
31
+ expect(installment_info['installmentDetails'][0]['cardFamilyName']).to eq('Bonus')
32
+ expect(installment_info['installmentDetails'][0]['installmentPrices']).not_to be_nil
33
+ expect(installment_info['installmentDetails'][0]['installmentPrices'][0]['installmentPrice']).not_to be_nil
34
+ expect(installment_info['installmentDetails'][0]['installmentPrices'][0]['totalPrice']).not_to be_nil
35
+ expect(installment_info['installmentDetails'][0]['installmentPrices'][0]['installmentNumber']).not_to be_nil
21
36
  begin
22
- $stderr.puts installment_info.inspect
37
+ $stdout.puts installment_info.inspect
23
38
  rescue
24
39
  $stderr.puts 'oops'
25
40
  raise
@@ -1,16 +1,17 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require_relative 'spec_helper'
4
+ require_relative 'builder'
4
5
 
5
6
  RSpec.describe 'Iyzipay' do
6
7
  before :all do
7
8
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
11
12
  end
12
13
 
13
- it 'should create payment' do
14
+ it 'should create listing payment' do
14
15
  payment_card = {
15
16
  cardHolderName: 'John Doe',
16
17
  cardNumber: '5528790000000008',
@@ -75,7 +76,7 @@ RSpec.describe 'Iyzipay' do
75
76
  installment: 1,
76
77
  basketId: 'B67832',
77
78
  paymentChannel: Iyzipay::Model::PaymentChannel::WEB,
78
- paymentGroup: Iyzipay::Model::PaymentGroup::PRODUCT,
79
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
79
80
  paymentCard: payment_card,
80
81
  buyer: buyer,
81
82
  billingAddress: address,
@@ -84,7 +85,15 @@ RSpec.describe 'Iyzipay' do
84
85
  }
85
86
  payment = Iyzipay::Model::Payment.new.create(request, @options)
86
87
  begin
87
- $stderr.puts payment.inspect
88
+ $stdout.puts payment.inspect
89
+ payment = JSON.parse(payment)
90
+ expect(payment['status']).to eq('success')
91
+ expect(payment['locale']).to eq('tr')
92
+ expect(payment['systemTime']).not_to be_nil
93
+ expect(payment['conversationId']).to eq('123456789')
94
+ expect(payment['price']).to eq(1)
95
+ expect(payment['paidPrice']).to eq(1.1)
96
+ expect(payment['installment']).to eq(1)
88
97
  rescue
89
98
  $stderr.puts 'oops'
90
99
  raise
@@ -92,6 +101,9 @@ RSpec.describe 'Iyzipay' do
92
101
  end
93
102
 
94
103
  it 'should create marketplace payment' do
104
+ # create sub merchant
105
+ sub_merchant = Builder::SubMerchantBuilder.new.create_personal_sub_merchant(@options)
106
+
95
107
  payment_card = {
96
108
  cardHolderName: 'John Doe',
97
109
  cardNumber: '5528790000000008',
@@ -130,7 +142,7 @@ RSpec.describe 'Iyzipay' do
130
142
  category2: 'Accessories',
131
143
  itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
132
144
  price: '0.3',
133
- subMerchantKey: 'sub merchant key',
145
+ subMerchantKey: sub_merchant['subMerchantKey'],
134
146
  subMerchantPrice: '0.27'
135
147
  }
136
148
  item2 = {
@@ -140,7 +152,7 @@ RSpec.describe 'Iyzipay' do
140
152
  category2: 'Online Game Items',
141
153
  itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
142
154
  price: '0.5',
143
- subMerchantKey: 'sub merchant key',
155
+ subMerchantKey: sub_merchant['subMerchantKey'],
144
156
  subMerchantPrice: '0.42'
145
157
  }
146
158
  item3 = {
@@ -150,7 +162,7 @@ RSpec.describe 'Iyzipay' do
150
162
  category2: 'Usb / Cable',
151
163
  itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
152
164
  price: '0.2',
153
- subMerchantKey: 'sub merchant key',
165
+ subMerchantKey: sub_merchant['subMerchantKey'],
154
166
  subMerchantPrice: '0.18'
155
167
  }
156
168
  request = {
@@ -171,7 +183,15 @@ RSpec.describe 'Iyzipay' do
171
183
  }
172
184
  payment = Iyzipay::Model::Payment.new.create(request, @options)
173
185
  begin
174
- $stderr.puts payment.inspect
186
+ $stdout.puts payment.inspect
187
+ payment = JSON.parse(payment)
188
+ expect(payment['status']).to eq('success')
189
+ expect(payment['locale']).to eq('tr')
190
+ expect(payment['systemTime']).not_to be_nil
191
+ expect(payment['conversationId']).to eq('123456789')
192
+ expect(payment['price']).to eq(1)
193
+ expect(payment['paidPrice']).to eq(1.1)
194
+ expect(payment['installment']).to eq(1)
175
195
  rescue
176
196
  $stderr.puts 'oops'
177
197
  raise
@@ -179,9 +199,12 @@ RSpec.describe 'Iyzipay' do
179
199
  end
180
200
 
181
201
  it 'should create payment with registered card' do
202
+ # create card
203
+ card = Builder::CardBuilder.new.create_card(@options)
204
+
182
205
  payment_card = {
183
- cardUserKey: 'card user key',
184
- cardToken: 'card token'
206
+ cardUserKey: card['cardUserKey'],
207
+ cardToken: card['cardToken']
185
208
  }
186
209
  buyer = {
187
210
  id: 'BY789',
@@ -239,7 +262,7 @@ RSpec.describe 'Iyzipay' do
239
262
  installment: 1,
240
263
  basketId: 'B67832',
241
264
  paymentChannel: Iyzipay::Model::PaymentChannel::WEB,
242
- paymentGroup: Iyzipay::Model::PaymentGroup::PRODUCT,
265
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
243
266
  paymentCard: payment_card,
244
267
  buyer: buyer,
245
268
  billingAddress: address,
@@ -248,23 +271,44 @@ RSpec.describe 'Iyzipay' do
248
271
  }
249
272
  payment = Iyzipay::Model::Payment.new.create(request, @options)
250
273
  begin
251
- $stderr.puts payment.inspect
274
+ $stdout.puts payment.inspect
275
+ payment = JSON.parse(payment)
276
+ expect(payment['status']).to eq('success')
277
+ expect(payment['locale']).to eq('tr')
278
+ expect(payment['systemTime']).not_to be_nil
279
+ expect(payment['conversationId']).to eq('123456789')
280
+ expect(payment['price']).to eq(1)
281
+ expect(payment['paidPrice']).to eq(1.1)
282
+ expect(payment['installment']).to eq(1)
252
283
  rescue
253
284
  $stderr.puts 'oops'
254
285
  raise
255
286
  end
256
287
  end
257
288
 
258
- it 'should retrieve payment result' do
289
+ it 'should retrieve payment' do
290
+ # create payment
291
+ payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
292
+
259
293
  request = {
260
294
  locale: Iyzipay::Model::Locale::TR,
261
295
  conversationId: '123456789',
262
- paymentId: '1',
296
+ paymentId: payment['paymentId'],
263
297
  paymentConversationId: '123456789'
264
298
  }
265
- bkm = Iyzipay::Model::Payment.new.retrieve(request, @options)
299
+
300
+ retrieved_payment = Iyzipay::Model::Payment.new.retrieve(request, @options)
266
301
  begin
267
- $stderr.puts bkm.inspect
302
+ $stdout.puts retrieved_payment.inspect
303
+ retrieved_payment = JSON.parse(retrieved_payment)
304
+ expect(retrieved_payment['status']).to eq('success')
305
+ expect(retrieved_payment['locale']).to eq('tr')
306
+ expect(retrieved_payment['systemTime']).not_to be_nil
307
+ expect(retrieved_payment['conversationId']).to eq('123456789')
308
+ expect(retrieved_payment['price']).to eq(1)
309
+ expect(retrieved_payment['paidPrice']).to eq(1.1)
310
+ expect(retrieved_payment['installment']).to eq(1)
311
+ expect(retrieved_payment['paymentId']).to eq(payment['paymentId'])
268
312
  rescue
269
313
  $stderr.puts 'oops'
270
314
  raise
@@ -1,13 +1,14 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require_relative 'spec_helper'
4
+ require_relative 'builder'
4
5
 
5
6
  RSpec.describe 'Iyzipay' do
6
7
  before :all do
7
8
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
11
12
  end
12
13
 
13
14
  it 'should initialize pecco' do
@@ -75,9 +76,14 @@ RSpec.describe 'Iyzipay' do
75
76
  pecco_initialize = Iyzipay::Model::PeccoInitialize.new.create(request, @options)
76
77
  begin
77
78
  $stderr.puts pecco_initialize.inspect
78
- threeds_initialize_dict = JSON.parse(pecco_initialize)
79
- unless threeds_initialize_dict['htmlContent'].nil?
80
- $stderr.puts Base64.decode64(threeds_initialize_dict['htmlContent']).inspect
79
+ pecco_initialize = JSON.parse(pecco_initialize)
80
+ unless pecco_initialize['htmlContent'].nil?
81
+ $stdout.puts Base64.decode64(pecco_initialize['htmlContent']).inspect
82
+ expect(pecco_initialize['status']).to eq('success')
83
+ expect(pecco_initialize['locale']).to eq('tr')
84
+ expect(pecco_initialize['systemTime']).not_to be_nil
85
+ expect(pecco_initialize['conversationId']).to eq('123456789')
86
+ expect(pecco_initialize['htmlContent']).not_to be_nil
81
87
  end
82
88
  rescue
83
89
  $stderr.puts 'oops'
@@ -86,16 +92,21 @@ RSpec.describe 'Iyzipay' do
86
92
  end
87
93
 
88
94
  it 'should create pecco payment' do
95
+
96
+ # This test needs manual payment from Pecco on sandbox environment. So it does not contain any assertions.
97
+ pecco_initialize = Builder::PeccoInitializeBuilder.new.create_pecco_initialize(@options)
98
+
89
99
  request = {
90
100
  locale: Iyzipay::Model::Locale::TR,
91
101
  conversationId: '123456789',
92
- token: 'token'
102
+ token: pecco_initialize['token']
93
103
  }
94
104
  pecco_payment = Iyzipay::Model::PeccoPayment.new.create(request, @options)
105
+
95
106
  begin
96
- $stderr.puts pecco_payment.inspect
107
+ $stdout.puts pecco_payment.inspect
97
108
  rescue
98
- $stderr.puts 'oops'
109
+ $stdout.puts 'oops'
99
110
  raise
100
111
  end
101
112
  end
@@ -1,27 +1,39 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require_relative 'spec_helper'
4
+ require_relative 'builder'
4
5
 
5
6
  RSpec.describe 'Iyzipay' do
6
7
  before :all do
7
8
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
11
12
  end
12
13
 
13
14
  it 'should refund payment' do
15
+ # create payment
16
+ payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
17
+
14
18
  request = {
15
19
  locale: Iyzipay::Model::Locale::TR,
16
20
  conversationId: '123456789',
17
- paymentTransactionId: '1',
18
- price: '0.5',
21
+ paymentTransactionId: payment['itemTransactions'][0]['paymentTransactionId'],
22
+ price: '0.2',
19
23
  currency: Iyzipay::Model::Currency::TRY,
20
24
  ip: '85.34.78.112'
21
25
  }
22
26
  refund = Iyzipay::Model::Refund.new.create(request, @options)
23
27
  begin
24
- $stderr.puts refund.inspect
28
+ $stdout.puts refund.inspect
29
+ refund = JSON.parse(refund)
30
+ expect(refund['status']).to eq('success')
31
+ expect(refund['locale']).to eq('tr')
32
+ expect(refund['systemTime']).not_to be_nil
33
+ expect(refund['conversationId']).to eq('123456789')
34
+ expect(refund['paymentId']).to eq(payment['paymentId'])
35
+ expect(refund['paymentTransactionId']).to eq(payment['itemTransactions'][0]['paymentTransactionId'])
36
+ expect(refund['price']).to eq(0.2)
25
37
  rescue
26
38
  $stderr.puts 'oops'
27
39
  raise
@@ -5,9 +5,9 @@ require_relative 'spec_helper'
5
5
  RSpec.describe 'Iyzipay' do
6
6
  before :all do
7
7
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
8
+ @options.api_key = SpecOptions::API_KEY
9
+ @options.secret_key = SpecOptions::SECRET_KEY
10
+ @options.base_url = SpecOptions::BASE_URL
11
11
  end
12
12
 
13
13
  it 'should retrieve payout completed transactions' do
@@ -16,9 +16,14 @@ RSpec.describe 'Iyzipay' do
16
16
  conversationId: '123456789',
17
17
  date: '2016-01-22 19:13:00'
18
18
  }
19
- refund = Iyzipay::Model::PayoutCompletedTransactionList.new.retrieve(request, @options)
19
+ transaction_list = Iyzipay::Model::PayoutCompletedTransactionList.new.retrieve(request, @options)
20
20
  begin
21
- $stderr.puts refund.inspect
21
+ $stdout.puts transaction_list.inspect
22
+ transaction_list = JSON.parse(transaction_list)
23
+ expect(transaction_list['status']).to eq('success')
24
+ expect(transaction_list['locale']).to eq('tr')
25
+ expect(transaction_list['systemTime']).not_to be_nil
26
+ expect(transaction_list['conversationId']).to eq('123456789')
22
27
  rescue
23
28
  $stderr.puts 'oops'
24
29
  raise
@@ -31,9 +36,14 @@ RSpec.describe 'Iyzipay' do
31
36
  conversationId: '123456789',
32
37
  date: '2016-01-22 19:13:00'
33
38
  }
34
- refund = Iyzipay::Model::BouncedBankTransferList.new.retrieve(request, @options)
39
+ bounced_bank_transfer_list = Iyzipay::Model::BouncedBankTransferList.new.retrieve(request, @options)
35
40
  begin
36
- $stderr.puts refund.inspect
41
+ $stdout.puts bounced_bank_transfer_list.inspect
42
+ bounced_bank_transfer_list = JSON.parse(bounced_bank_transfer_list)
43
+ expect(bounced_bank_transfer_list['status']).to eq('success')
44
+ expect(bounced_bank_transfer_list['locale']).to eq('tr')
45
+ expect(bounced_bank_transfer_list['systemTime']).not_to be_nil
46
+ expect(bounced_bank_transfer_list['conversationId']).to eq('123456789')
37
47
  rescue
38
48
  $stderr.puts 'oops'
39
49
  raise
@@ -1,4 +1,5 @@
1
- require_relative '../lib/Iyzipay.rb'
1
+ require_relative '../lib/iyzipay.rb'
2
+ require_relative 'spec_options'
2
3
 
3
4
  RSpec.configure do |config|
4
5
  # rspec-expectations config goes here. You can use an alternate
@@ -0,0 +1,5 @@
1
+ module SpecOptions
2
+ API_KEY = 'sandbox-afXhZPW0MQlE4dCUUlHcEopnMBgXnAZI'
3
+ SECRET_KEY = 'sandbox-wbwpzKIiplZxI3hh5ALI4FJyAcZKL6kq'
4
+ BASE_URL = 'https://sandbox-api.iyzipay.com'
5
+ end
@@ -1,25 +1,27 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require_relative 'spec_helper'
4
+ require_relative 'builder'
4
5
 
5
6
  RSpec.describe 'Iyzipay' do
6
7
  before :all do
7
8
  @options = Iyzipay::Options.new
8
- @options.api_key = 'your api key'
9
- @options.secret_key = 'your secret key'
10
- @options.base_url = 'https://sandbox-api.iyzipay.com'
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
11
12
  end
12
13
 
13
14
  it 'should create personal sub merchant' do
15
+ random_number = Random.rand(11**11).to_s
14
16
  request = {
15
17
  locale: Iyzipay::Model::Locale::TR,
16
18
  conversationId: '123456789',
17
- subMerchantExternalId: 'B49224',
19
+ subMerchantExternalId: 'B' + random_number,
18
20
  subMerchantType: Iyzipay::Model::SubMerchantType::PERSONAL,
19
21
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
20
22
  contactName: 'John',
21
23
  contactSurname: 'Doe',
22
- email: 'email@submerchantemail.com',
24
+ email: random_number + '@email.com',
23
25
  gsmNumber: '+905350000000',
24
26
  name: 'John\'s market',
25
27
  iban: 'TR180006200119000006672315',
@@ -28,7 +30,12 @@ RSpec.describe 'Iyzipay' do
28
30
  }
29
31
  sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
30
32
  begin
31
- $stderr.puts sub_merchant.inspect
33
+ $stdout.puts sub_merchant.inspect
34
+ sub_merchant = JSON.parse(sub_merchant)
35
+ expect(sub_merchant['status']).to eq('success')
36
+ expect(sub_merchant['locale']).to eq('tr')
37
+ expect(sub_merchant['systemTime']).not_to be_nil
38
+ expect(sub_merchant['conversationId']).to eq('123456789')
32
39
  rescue
33
40
  $stderr.puts 'oops'
34
41
  raise
@@ -36,15 +43,16 @@ RSpec.describe 'Iyzipay' do
36
43
  end
37
44
 
38
45
  it 'should create private sub merchant' do
46
+ random_number = Random.rand(11**11).to_s
39
47
  request = {
40
48
  locale: Iyzipay::Model::Locale::TR,
41
49
  conversationId: '123456789',
42
- subMerchantExternalId: 'S49222',
50
+ subMerchantExternalId: 'B' + random_number,
43
51
  subMerchantType: Iyzipay::Model::SubMerchantType::PRIVATE_COMPANY,
44
52
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
45
53
  taxOffice: 'Tax office',
46
54
  legalCompanyTitle: 'John Doe inc',
47
- email: 'email@submerchantemail.com',
55
+ email: random_number + '@email.com',
48
56
  gsmNumber: '+905350000000',
49
57
  name: 'John\'s market',
50
58
  iban: 'TR180006200119000006672315',
@@ -53,7 +61,11 @@ RSpec.describe 'Iyzipay' do
53
61
  }
54
62
  sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
55
63
  begin
56
- $stderr.puts sub_merchant.inspect
64
+ sub_merchant = JSON.parse(sub_merchant)
65
+ expect(sub_merchant['status']).to eq('success')
66
+ expect(sub_merchant['locale']).to eq('tr')
67
+ expect(sub_merchant['systemTime']).not_to be_nil
68
+ expect(sub_merchant['conversationId']).to eq('123456789')
57
69
  rescue
58
70
  $stderr.puts 'oops'
59
71
  raise
@@ -61,10 +73,11 @@ RSpec.describe 'Iyzipay' do
61
73
  end
62
74
 
63
75
  it 'should create limited company sub merchant' do
76
+ random_number = Random.rand(11**11).to_s
64
77
  request = {
65
78
  locale: Iyzipay::Model::Locale::TR,
66
79
  conversationId: '123456789',
67
- subMerchantExternalId: 'AS49224',
80
+ subMerchantExternalId: 'B' + random_number,
68
81
  subMerchantType: Iyzipay::Model::SubMerchantType::LIMITED_OR_JOINT_STOCK_COMPANY,
69
82
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
70
83
  taxOffice: 'Tax office',
@@ -78,7 +91,11 @@ RSpec.describe 'Iyzipay' do
78
91
  }
79
92
  sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
80
93
  begin
81
- $stderr.puts sub_merchant.inspect
94
+ sub_merchant = JSON.parse(sub_merchant)
95
+ expect(sub_merchant['status']).to eq('success')
96
+ expect(sub_merchant['locale']).to eq('tr')
97
+ expect(sub_merchant['systemTime']).not_to be_nil
98
+ expect(sub_merchant['conversationId']).to eq('123456789')
82
99
  rescue
83
100
  $stderr.puts 'oops'
84
101
  raise
@@ -86,11 +103,14 @@ RSpec.describe 'Iyzipay' do
86
103
  end
87
104
 
88
105
  it 'should update personal sub merchant' do
106
+ # create personal sub merchant
107
+ sub_merchant = Builder::SubMerchantBuilder.new.create_personal_sub_merchant(@options)
108
+
89
109
  request = {
90
110
  locale: Iyzipay::Model::Locale::TR,
91
111
  conversationId: '123456789',
92
- subMerchantExternalId: 'B49224',
93
- subMerchantKey: 'sub merchant key',
112
+ subMerchantExternalId: sub_merchant['subMerchantExternalId'],
113
+ subMerchantKey: sub_merchant['subMerchantKey'],
94
114
  iban: 'TR180006200119000006672315',
95
115
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
96
116
  contactName: 'Jane',
@@ -103,7 +123,12 @@ RSpec.describe 'Iyzipay' do
103
123
  }
104
124
  sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
105
125
  begin
106
- $stderr.puts sub_merchant.inspect
126
+ $stdout.puts sub_merchant.inspect
127
+ sub_merchant = JSON.parse(sub_merchant)
128
+ expect(sub_merchant['status']).to eq('success')
129
+ expect(sub_merchant['locale']).to eq('tr')
130
+ expect(sub_merchant['systemTime']).not_to be_nil
131
+ expect(sub_merchant['conversationId']).to eq('123456789')
107
132
  rescue
108
133
  $stderr.puts 'oops'
109
134
  raise
@@ -111,11 +136,14 @@ RSpec.describe 'Iyzipay' do
111
136
  end
112
137
 
113
138
  it 'should update private sub merchant' do
139
+ # create private sub merchant
140
+ sub_merchant = Builder::SubMerchantBuilder.new.create_private_sub_merchant(@options)
141
+
114
142
  request = {
115
143
  locale: Iyzipay::Model::Locale::TR,
116
144
  conversationId: '123456789',
117
145
  subMerchantExternalId: 'S49222',
118
- subMerchantKey: 'sub merchant key',
146
+ subMerchantKey: sub_merchant['subMerchantKey'],
119
147
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
120
148
  taxOffice: 'Tax office',
121
149
  legalCompanyTitle: 'Jane Doe inc',
@@ -128,7 +156,12 @@ RSpec.describe 'Iyzipay' do
128
156
  }
129
157
  sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
130
158
  begin
131
- $stderr.puts sub_merchant.inspect
159
+ $stdout.puts sub_merchant.inspect
160
+ sub_merchant = JSON.parse(sub_merchant)
161
+ expect(sub_merchant['status']).to eq('success')
162
+ expect(sub_merchant['locale']).to eq('tr')
163
+ expect(sub_merchant['systemTime']).not_to be_nil
164
+ expect(sub_merchant['conversationId']).to eq('123456789')
132
165
  rescue
133
166
  $stderr.puts 'oops'
134
167
  raise
@@ -136,10 +169,12 @@ RSpec.describe 'Iyzipay' do
136
169
  end
137
170
 
138
171
  it 'should update limited company sub merchant' do
172
+ sub_merchant = Builder::SubMerchantBuilder.new.create_limited_sub_merchant(@options)
173
+
139
174
  request = {
140
175
  locale: Iyzipay::Model::Locale::TR,
141
176
  conversationId: '123456789',
142
- subMerchantKey: 'sub merchant key',
177
+ subMerchantKey: sub_merchant['subMerchantKey'],
143
178
  address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
144
179
  taxOffice: 'Tax office',
145
180
  taxNumber: '9261877',
@@ -152,7 +187,12 @@ RSpec.describe 'Iyzipay' do
152
187
  }
153
188
  sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
154
189
  begin
155
- $stderr.puts sub_merchant.inspect
190
+ $stdout.puts sub_merchant.inspect
191
+ sub_merchant = JSON.parse(sub_merchant)
192
+ expect(sub_merchant['status']).to eq('success')
193
+ expect(sub_merchant['locale']).to eq('tr')
194
+ expect(sub_merchant['systemTime']).not_to be_nil
195
+ expect(sub_merchant['conversationId']).to eq('123456789')
156
196
  rescue
157
197
  $stderr.puts 'oops'
158
198
  raise
@@ -160,14 +200,22 @@ RSpec.describe 'Iyzipay' do
160
200
  end
161
201
 
162
202
  it 'should retrieve sub merchant' do
203
+ random_number = Random.rand(11**11).to_s
204
+ Builder::SubMerchantBuilder.new.create_limited_sub_merchant_with_external_key(random_number, @options)
205
+
163
206
  request = {
164
207
  locale: Iyzipay::Model::Locale::TR,
165
208
  conversationId: '123456789',
166
- subMerchantExternalId: 'AS49224'
209
+ subMerchantExternalId: random_number
167
210
  }
168
211
  sub_merchant = Iyzipay::Model::SubMerchant.new.retrieve(request, @options)
169
212
  begin
170
- $stderr.puts sub_merchant.inspect
213
+ $stdout.puts sub_merchant.inspect
214
+ sub_merchant = JSON.parse(sub_merchant)
215
+ expect(sub_merchant['status']).to eq('success')
216
+ expect(sub_merchant['locale']).to eq('tr')
217
+ expect(sub_merchant['systemTime']).not_to be_nil
218
+ expect(sub_merchant['conversationId']).to eq('123456789')
171
219
  rescue
172
220
  $stderr.puts 'oops'
173
221
  raise