iyzipay 1.0.36 → 1.0.44
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/.travis.yml +1 -0
- data/Gemfile +2 -1
- data/README.md +4 -0
- data/VERSION +1 -1
- data/gemfiles/Gemfile.nokogiri-1.6.8.1 +7 -0
- data/iyzipay.gemspec +3 -3
- data/lib/iyzipay/iyzipay_resource.rb +1 -1
- data/lib/iyzipay/model/bkm_initialize.rb +1 -0
- data/lib/iyzipay/model/cancel.rb +2 -0
- data/lib/iyzipay/model/refund.rb +2 -0
- data/lib/iyzipay/model/refund_reason.rb +10 -0
- data/lib/iyzipay/model.rb +2 -1
- data/spec/api_test_spec.rb +7 -4
- data/spec/approval_spec.rb +26 -15
- data/spec/bin_number_spec.rb +16 -4
- data/spec/bkm_spec.rb +6 -21
- data/spec/builder/approval_builder.rb +18 -0
- data/spec/builder/card_builder.rb +27 -0
- data/spec/builder/checkout_form_builder.rb +75 -0
- data/spec/builder/payment_builder.rb +167 -0
- data/spec/builder/pecco_initialize_builder.rb +74 -0
- data/spec/builder/sub_merchant_builder.rb +91 -0
- data/spec/builder.rb +9 -0
- data/spec/cancel_spec.rb +46 -5
- data/spec/card_storage_spec.rb +71 -12
- data/spec/checkout_form_spec.rb +18 -8
- data/spec/disapproval_spec.rb +22 -5
- data/spec/installment_spec.rb +19 -4
- data/spec/payment_spec.rb +62 -18
- data/spec/pecco_spec.rb +20 -9
- data/spec/refund_spec.rb +49 -6
- data/spec/retrieve_transactions_spec.rb +17 -7
- data/spec/spec_helper.rb +2 -1
- data/spec/spec_options.rb +5 -0
- data/spec/sub_merchant_spec.rb +68 -20
- data/spec/threeds_payment_spec.rb +22 -19
- data/spec/tls12_test_spec.rb +16 -0
- metadata +15 -17
- data/.ruby-version +0 -1
- /data/lib/{Iyzipay.rb → iyzipay.rb} +0 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
module Builder
|
6
|
+
class SubMerchantBuilder
|
7
|
+
|
8
|
+
def create_personal_sub_merchant(options)
|
9
|
+
random_number = Random.rand(11**11).to_s
|
10
|
+
request = {
|
11
|
+
locale: Iyzipay::Model::Locale::TR,
|
12
|
+
conversationId: '123456789',
|
13
|
+
subMerchantExternalId: 'B' + random_number,
|
14
|
+
subMerchantType: Iyzipay::Model::SubMerchantType::PERSONAL,
|
15
|
+
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
16
|
+
contactName: 'John',
|
17
|
+
contactSurname: 'Doe',
|
18
|
+
email: random_number + '@email.com',
|
19
|
+
gsmNumber: '+905350000000',
|
20
|
+
name: 'John\'s market',
|
21
|
+
iban: 'TR180006200119000006672315',
|
22
|
+
identityNumber: random_number,
|
23
|
+
currency: Iyzipay::Model::Currency::TRY
|
24
|
+
}
|
25
|
+
sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, options)
|
26
|
+
JSON.parse(sub_merchant)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_private_sub_merchant(options)
|
30
|
+
random_number = Random.rand(11**11).to_s
|
31
|
+
request = {
|
32
|
+
locale: Iyzipay::Model::Locale::TR,
|
33
|
+
conversationId: '123456789',
|
34
|
+
subMerchantExternalId: 'B' + random_number,
|
35
|
+
subMerchantType: Iyzipay::Model::SubMerchantType::PRIVATE_COMPANY,
|
36
|
+
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
37
|
+
taxOffice: 'Tax office',
|
38
|
+
legalCompanyTitle: 'John Doe inc',
|
39
|
+
email: random_number + '@email.com',
|
40
|
+
gsmNumber: '+905350000000',
|
41
|
+
name: 'John\'s market',
|
42
|
+
iban: 'TR180006200119000006672315',
|
43
|
+
identityNumber: '31300864726',
|
44
|
+
currency: Iyzipay::Model::Currency::TRY
|
45
|
+
}
|
46
|
+
sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, options)
|
47
|
+
JSON.parse(sub_merchant)
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_limited_sub_merchant(options)
|
51
|
+
random_number = Random.rand(11**11).to_s
|
52
|
+
request = {
|
53
|
+
locale: Iyzipay::Model::Locale::TR,
|
54
|
+
conversationId: '123456789',
|
55
|
+
subMerchantExternalId: 'B' + random_number,
|
56
|
+
subMerchantType: Iyzipay::Model::SubMerchantType::LIMITED_OR_JOINT_STOCK_COMPANY,
|
57
|
+
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
58
|
+
taxOffice: 'Tax office',
|
59
|
+
taxNumber: '9261877',
|
60
|
+
legalCompanyTitle: 'XYZ inc',
|
61
|
+
email: 'email@submerchantemail.com',
|
62
|
+
gsmNumber: '+905350000000',
|
63
|
+
name: 'John\'s market',
|
64
|
+
iban: 'TR180006200119000006672315',
|
65
|
+
currency: Iyzipay::Model::Currency::TRY
|
66
|
+
}
|
67
|
+
sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, options)
|
68
|
+
JSON.parse(sub_merchant)
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_limited_sub_merchant_with_external_key(external_key, options)
|
72
|
+
request = {
|
73
|
+
locale: Iyzipay::Model::Locale::TR,
|
74
|
+
conversationId: '123456789',
|
75
|
+
subMerchantExternalId: external_key,
|
76
|
+
subMerchantType: Iyzipay::Model::SubMerchantType::LIMITED_OR_JOINT_STOCK_COMPANY,
|
77
|
+
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
78
|
+
taxOffice: 'Tax office',
|
79
|
+
taxNumber: '9261877',
|
80
|
+
legalCompanyTitle: 'XYZ inc',
|
81
|
+
email: 'email@submerchantemail.com',
|
82
|
+
gsmNumber: '+905350000000',
|
83
|
+
name: 'John\'s market',
|
84
|
+
iban: 'TR180006200119000006672315',
|
85
|
+
currency: Iyzipay::Model::Currency::TRY
|
86
|
+
}
|
87
|
+
sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, options)
|
88
|
+
JSON.parse(sub_merchant)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/builder.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
module Builder
|
2
|
+
end
|
3
|
+
|
4
|
+
require_relative 'builder/payment_builder'
|
5
|
+
require_relative 'builder/sub_merchant_builder'
|
6
|
+
require_relative 'builder/checkout_form_builder'
|
7
|
+
require_relative 'builder/approval_builder'
|
8
|
+
require_relative 'builder/card_builder'
|
9
|
+
require_relative 'builder/pecco_initialize_builder'
|
data/spec/cancel_spec.rb
CHANGED
@@ -1,25 +1,66 @@
|
|
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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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 cancel payment' do
|
15
|
+
payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
|
16
|
+
|
14
17
|
request = {
|
15
18
|
locale: Iyzipay::Model::Locale::TR,
|
16
19
|
conversationId: '123456789',
|
17
|
-
paymentId: '
|
20
|
+
paymentId: payment['paymentId'],
|
18
21
|
ip: '85.34.78.112'
|
19
22
|
}
|
20
23
|
cancel = Iyzipay::Model::Cancel.new.create(request, @options)
|
21
24
|
begin
|
22
|
-
$
|
25
|
+
$stdout.puts cancel.inspect
|
26
|
+
cancel = JSON.parse(cancel)
|
27
|
+
expect(cancel['status']).to eq('success')
|
28
|
+
expect(cancel['locale']).to eq('tr')
|
29
|
+
expect(cancel['systemTime']).not_to be_nil
|
30
|
+
expect(cancel['conversationId']).to eq('123456789')
|
31
|
+
expect(cancel['paymentId']).to eq(payment['paymentId'])
|
32
|
+
expect(cancel['price']).to eq(1.10000000)
|
33
|
+
expect(cancel['currency']).to eq('TRY')
|
34
|
+
expect(cancel['authCode']).not_to be_nil
|
35
|
+
rescue
|
36
|
+
$stderr.puts 'oops'
|
37
|
+
raise
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should cancel payment with reason and description' do
|
42
|
+
payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
|
43
|
+
|
44
|
+
request = {
|
45
|
+
locale: Iyzipay::Model::Locale::TR,
|
46
|
+
conversationId: '123456789',
|
47
|
+
paymentId: payment['paymentId'],
|
48
|
+
ip: '85.34.78.112',
|
49
|
+
reason: Iyzipay::Model::RefundReason::OTHER,
|
50
|
+
description: 'customer requested for default sample'
|
51
|
+
}
|
52
|
+
cancel = Iyzipay::Model::Cancel.new.create(request, @options)
|
53
|
+
begin
|
54
|
+
$stdout.puts cancel.inspect
|
55
|
+
cancel = JSON.parse(cancel)
|
56
|
+
expect(cancel['status']).to eq('success')
|
57
|
+
expect(cancel['locale']).to eq('tr')
|
58
|
+
expect(cancel['systemTime']).not_to be_nil
|
59
|
+
expect(cancel['conversationId']).to eq('123456789')
|
60
|
+
expect(cancel['paymentId']).to eq(payment['paymentId'])
|
61
|
+
expect(cancel['price']).to eq(1.10000000)
|
62
|
+
expect(cancel['currency']).to eq('TRY')
|
63
|
+
expect(cancel['authCode']).not_to be_nil
|
23
64
|
rescue
|
24
65
|
$stderr.puts 'oops'
|
25
66
|
raise
|
data/spec/card_storage_spec.rb
CHANGED
@@ -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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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 user and add card' do
|
@@ -27,14 +28,33 @@ RSpec.describe 'Iyzipay' do
|
|
27
28
|
}
|
28
29
|
card = Iyzipay::Model::Card.new.create(request, @options)
|
29
30
|
begin
|
30
|
-
$
|
31
|
+
$stdout.puts card.inspect
|
32
|
+
card = JSON.parse(card)
|
33
|
+
expect(card['status']).to eq('success')
|
34
|
+
expect(card['locale']).to eq('tr')
|
35
|
+
expect(card['systemTime']).not_to be_nil
|
36
|
+
expect(card['conversationId']).to eq('123456789')
|
37
|
+
expect(card['externalId']).to eq('external id')
|
38
|
+
expect(card['email']).to eq('email@email.com')
|
39
|
+
expect(card['cardUserKey']).to eq(card['cardUserKey'])
|
40
|
+
expect(card['cardToken']).to eq(card['cardToken'])
|
41
|
+
expect(card['cardAlias']).to eq('card alias')
|
42
|
+
expect(card['binNumber']).to eq('552879')
|
43
|
+
expect(card['cardType']).to eq('CREDIT_CARD')
|
44
|
+
expect(card['cardAssociation']).to eq('MASTER_CARD')
|
45
|
+
expect(card['cardFamily']).to eq('Paraf')
|
46
|
+
expect(card['cardBankCode']).to eq(12)
|
47
|
+
expect(card['cardBankName']).to eq('Halk Bankası')
|
31
48
|
rescue
|
32
49
|
$stderr.puts 'oops'
|
33
50
|
raise
|
34
51
|
end
|
35
52
|
end
|
36
53
|
|
37
|
-
it 'should create card' do
|
54
|
+
it 'should create card and add card to existing user' do
|
55
|
+
# create card user
|
56
|
+
card = Builder::CardBuilder.new.create_card(@options)
|
57
|
+
|
38
58
|
card_information = {
|
39
59
|
cardAlias: 'card alias',
|
40
60
|
cardHolderName: 'John Doe',
|
@@ -46,12 +66,27 @@ RSpec.describe 'Iyzipay' do
|
|
46
66
|
locale: Iyzipay::Model::Locale::TR,
|
47
67
|
conversationId: '123456789',
|
48
68
|
email: 'email@email.com',
|
49
|
-
cardUserKey:
|
69
|
+
cardUserKey: card['cardUserKey'],
|
50
70
|
card: card_information
|
51
71
|
}
|
52
72
|
card = Iyzipay::Model::Card.new.create(request, @options)
|
53
73
|
begin
|
54
|
-
$
|
74
|
+
$stdout.puts card.inspect
|
75
|
+
card = JSON.parse(card)
|
76
|
+
expect(card['status']).to eq('success')
|
77
|
+
expect(card['locale']).to eq('tr')
|
78
|
+
expect(card['systemTime']).not_to be_nil
|
79
|
+
expect(card['conversationId']).to eq('123456789')
|
80
|
+
expect(card['email']).to eq('email@email.com')
|
81
|
+
expect(card['cardUserKey']).to eq(card['cardUserKey'])
|
82
|
+
expect(card['cardToken']).to eq(card['cardToken'])
|
83
|
+
expect(card['cardAlias']).to eq('card alias')
|
84
|
+
expect(card['binNumber']).to eq('552879')
|
85
|
+
expect(card['cardType']).to eq('CREDIT_CARD')
|
86
|
+
expect(card['cardAssociation']).to eq('MASTER_CARD')
|
87
|
+
expect(card['cardFamily']).to eq('Paraf')
|
88
|
+
expect(card['cardBankCode']).to eq(12)
|
89
|
+
expect(card['cardBankName']).to eq('Halk Bankası')
|
55
90
|
rescue
|
56
91
|
$stderr.puts 'oops'
|
57
92
|
raise
|
@@ -59,15 +94,23 @@ RSpec.describe 'Iyzipay' do
|
|
59
94
|
end
|
60
95
|
|
61
96
|
it 'should delete card' do
|
97
|
+
# create card
|
98
|
+
card = Builder::CardBuilder.new.create_card(@options)
|
99
|
+
|
62
100
|
request = {
|
63
101
|
locale: Iyzipay::Model::Locale::TR,
|
64
102
|
conversationId: '123456789',
|
65
|
-
cardToken:
|
66
|
-
cardUserKey:
|
103
|
+
cardToken: card['cardToken'],
|
104
|
+
cardUserKey: card['cardUserKey']
|
67
105
|
}
|
68
106
|
card = Iyzipay::Model::Card.new.delete(request, @options)
|
69
107
|
begin
|
70
|
-
$
|
108
|
+
$stdout.puts card.inspect
|
109
|
+
card = JSON.parse(card)
|
110
|
+
expect(card['status']).to eq('success')
|
111
|
+
expect(card['locale']).to eq('tr')
|
112
|
+
expect(card['systemTime']).not_to be_nil
|
113
|
+
expect(card['conversationId']).to eq('123456789')
|
71
114
|
rescue
|
72
115
|
$stderr.puts 'oops'
|
73
116
|
raise
|
@@ -75,14 +118,30 @@ RSpec.describe 'Iyzipay' do
|
|
75
118
|
end
|
76
119
|
|
77
120
|
it 'should retrieve card' do
|
121
|
+
card = Builder::CardBuilder.new.create_card(@options)
|
122
|
+
|
78
123
|
request = {
|
79
124
|
locale: Iyzipay::Model::Locale::TR,
|
80
125
|
conversationId: '123456789',
|
81
|
-
cardUserKey:
|
126
|
+
cardUserKey: card['cardUserKey']
|
82
127
|
}
|
83
128
|
card_list = Iyzipay::Model::CardList.new.retrieve(request, @options)
|
84
129
|
begin
|
85
|
-
$
|
130
|
+
$stdout.puts card_list.inspect
|
131
|
+
card_list = JSON.parse(card_list)
|
132
|
+
expect(card_list['status']).to eq('success')
|
133
|
+
expect(card_list['locale']).to eq('tr')
|
134
|
+
expect(card_list['systemTime']).not_to be_nil
|
135
|
+
expect(card_list['conversationId']).to eq('123456789')
|
136
|
+
expect(card_list['cardUserKey']).to eq(card['cardUserKey'])
|
137
|
+
expect(card_list['cardDetails'][0]['cardToken']).to eq(card['cardToken'])
|
138
|
+
expect(card_list['cardDetails'][0]['cardAlias']).to eq('card alias')
|
139
|
+
expect(card_list['cardDetails'][0]['binNumber']).to eq('552879')
|
140
|
+
expect(card_list['cardDetails'][0]['cardType']).to eq('CREDIT_CARD')
|
141
|
+
expect(card_list['cardDetails'][0]['cardAssociation']).to eq('MASTER_CARD')
|
142
|
+
expect(card_list['cardDetails'][0]['cardFamily']).to eq('Paraf')
|
143
|
+
expect(card_list['cardDetails'][0]['cardBankCode']).to eq(12)
|
144
|
+
expect(card_list['cardDetails'][0]['cardBankName']).to eq('Halk Bankası')
|
86
145
|
rescue
|
87
146
|
$stderr.puts 'oops'
|
88
147
|
raise
|
data/spec/checkout_form_spec.rb
CHANGED
@@ -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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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 initialize checkout form' do
|
14
|
+
it 'should initialize checkout form for standard merchant' do
|
14
15
|
buyer = {
|
15
16
|
id: 'BY789',
|
16
17
|
name: 'John',
|
@@ -65,7 +66,7 @@ RSpec.describe 'Iyzipay' do
|
|
65
66
|
paidPrice: '1.2',
|
66
67
|
currency: Iyzipay::Model::Currency::TRY,
|
67
68
|
basketId: 'B67832',
|
68
|
-
paymentGroup: Iyzipay::Model::PaymentGroup::
|
69
|
+
paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
|
69
70
|
callbackUrl: 'https://www.merchant.com/callback',
|
70
71
|
enabledInstallments: [2, 3, 6, 9],
|
71
72
|
buyer: buyer,
|
@@ -76,7 +77,13 @@ RSpec.describe 'Iyzipay' do
|
|
76
77
|
checkout_form_initialize = Iyzipay::Model::CheckoutFormInitialize.new.create(request, @options)
|
77
78
|
|
78
79
|
begin
|
79
|
-
$
|
80
|
+
$stdout.puts checkout_form_initialize.inspect
|
81
|
+
checkout_form_initialize = JSON.parse(checkout_form_initialize)
|
82
|
+
expect(checkout_form_initialize['status']).to eq('success')
|
83
|
+
expect(checkout_form_initialize['locale']).to eq('tr')
|
84
|
+
expect(checkout_form_initialize['systemTime']).not_to be_nil
|
85
|
+
expect(checkout_form_initialize['token']).not_to be_nil
|
86
|
+
expect(checkout_form_initialize['checkoutFormContent']).not_to be_nil
|
80
87
|
rescue
|
81
88
|
$stderr.puts 'oops'
|
82
89
|
raise
|
@@ -84,14 +91,17 @@ RSpec.describe 'Iyzipay' do
|
|
84
91
|
end
|
85
92
|
|
86
93
|
it 'should retrieve checkout form result' do
|
94
|
+
# This test needs manual on sandbox environment. So it does not contain any assertions.
|
95
|
+
checkout_form_initialize = Builder::CheckoutFormBuilder.new.create_checkout_form_initialize(@options)
|
96
|
+
|
87
97
|
request = {
|
88
98
|
locale: Iyzipay::Model::Locale::TR,
|
89
99
|
conversationId: '123456789',
|
90
|
-
token: 'token'
|
100
|
+
token: checkout_form_initialize['token']
|
91
101
|
}
|
92
102
|
checkout_form_payment = Iyzipay::Model::CheckoutForm.new.retrieve(request, @options)
|
93
103
|
begin
|
94
|
-
$
|
104
|
+
$stdout.puts checkout_form_payment.inspect
|
95
105
|
rescue
|
96
106
|
$stderr.puts 'oops'
|
97
107
|
raise
|
data/spec/disapproval_spec.rb
CHANGED
@@ -1,24 +1,41 @@
|
|
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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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 disapprove payment item' do
|
15
|
+
# create sub merchant
|
16
|
+
sub_merchant = Builder::SubMerchantBuilder.new.create_personal_sub_merchant(@options)
|
17
|
+
|
18
|
+
# create payment
|
19
|
+
payment = Builder::PaymentBuilder.new.create_marketplace_payment(@options, sub_merchant['subMerchantKey'])
|
20
|
+
|
21
|
+
# approve payment
|
22
|
+
Builder::ApprovalBuilder.new.create_approval(@options, payment['itemTransactions'][0]['paymentTransactionId'])
|
23
|
+
|
24
|
+
# disapprove payment
|
14
25
|
request = {
|
15
26
|
locale: Iyzipay::Model::Locale::TR,
|
16
27
|
conversationId: '123456789',
|
17
|
-
paymentTransactionId: '
|
28
|
+
paymentTransactionId: payment['itemTransactions'][0]['paymentTransactionId']
|
18
29
|
}
|
19
30
|
disapproval = Iyzipay::Model::Disapproval.new.create(request, @options)
|
20
31
|
begin
|
21
|
-
$
|
32
|
+
$stdout.puts disapproval.inspect
|
33
|
+
disapproval = JSON.parse(disapproval)
|
34
|
+
expect(disapproval['status']).to eq('success')
|
35
|
+
expect(disapproval['locale']).to eq('tr')
|
36
|
+
expect(disapproval['systemTime']).not_to be_nil
|
37
|
+
expect(disapproval['conversationId']).to eq('123456789')
|
38
|
+
expect(disapproval['paymentTransactionId']).to eq(payment['itemTransactions'][0]['paymentTransactionId'])
|
22
39
|
rescue
|
23
40
|
$stderr.puts 'oops'
|
24
41
|
raise
|
data/spec/installment_spec.rb
CHANGED
@@ -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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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
|
-
$
|
37
|
+
$stdout.puts installment_info.inspect
|
23
38
|
rescue
|
24
39
|
$stderr.puts 'oops'
|
25
40
|
raise
|
data/spec/payment_spec.rb
CHANGED
@@ -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 =
|
9
|
-
@options.secret_key =
|
10
|
-
@options.base_url =
|
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::
|
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
|
-
$
|
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: '
|
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: '
|
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: '
|
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
|
-
$
|
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:
|
184
|
-
cardToken:
|
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::
|
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
|
-
$
|
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
|
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: '
|
296
|
+
paymentId: payment['paymentId'],
|
263
297
|
paymentConversationId: '123456789'
|
264
298
|
}
|
265
|
-
|
299
|
+
|
300
|
+
retrieved_payment = Iyzipay::Model::Payment.new.retrieve(request, @options)
|
266
301
|
begin
|
267
|
-
$
|
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
|