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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf6e609c8c30fbe5d43caa90ef34ca4194f67fcd
4
- data.tar.gz: 24b854ce1597268bf5f0ee9595b0e30b494d2c5d
3
+ metadata.gz: a7da83efe7b119315d9780b9f7a80fe8facffb31
4
+ data.tar.gz: e5e38f3bef8e9dcd40a45fed6e51a535bd07a974
5
5
  SHA512:
6
- metadata.gz: 4c5766cebba13ce00419ed3e8b6ad0aeac55288d1632e81d6b6175c42be6257987547af4b9c157e64923bcb64370a7e2ef5362a337d89395ee3c1f0c62b54919
7
- data.tar.gz: a6d806384cd4968bff65cbbae765eacd386514863a6c7321a7261daee2fef57bbccffc567fb4fda464cab131e9e6224a8ed017bb4345ff252f588b7dad68a82d
6
+ metadata.gz: 06381d9aa36de50d330365f3d922cea4a88ce9cf139e72e002a6d687135306b14280fa3dbb5d1b25b1e3766cc71f8654b869ace9fd9c6138c45225cf1d14d15a
7
+ data.tar.gz: 127ac5d58081bda38c5a4458fcd121ccabb5815a494b9c40c0aca5b91179f673538d38b082a689d76a05144711cb701c3da9f432ea1dfb79ca46475afe0da600
@@ -14,3 +14,4 @@ deploy:
14
14
  tags: true
15
15
  repo: iyzico/iyzipay-ruby
16
16
  skip_cleanup: true
17
+ script: rspec spec
data/Gemfile CHANGED
@@ -6,4 +6,5 @@ gem 'rack', '1.6.4'
6
6
  group :development, :local_development do
7
7
  gem 'rspec'
8
8
  gem 'rspec-rails'
9
+ gem 'nokogiri', '1.6.8.1'
9
10
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.36
1
+ 1.0.39
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ group :development do
6
+ gem 'nokogiri', '1.6.8.1'
7
+ end
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'iyzipay'
6
- s.version = '1.0.36'
6
+ s.version = '1.0.39'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.required_ruby_version = '>= 1.9.3'
9
9
  s.summary = %q{iyzipay api ruby client}
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.license = 'MIT'
17
17
 
18
18
  s.add_runtime_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
19
- s.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
20
- s.add_development_dependency 'rspec-rails', '~> 3.3', '>= 3.3.0'
19
+ s.add_development_dependency 'rspec', '~> 3.3.0'
20
+ s.add_development_dependency 'rspec-rails', '~> 3.3.0'
21
21
 
22
22
  s.require_paths = ['lib']
23
23
  end
File without changes
@@ -15,7 +15,7 @@ module Iyzipay
15
15
  random_header_value = random_string(RANDOM_STRING_SIZE)
16
16
  header[:'Authorization'] = "#{prepare_authorization_string(pki_string, random_header_value, options)}"
17
17
  header[:'x-iyzi-rnd'] = "#{random_header_value}"
18
- header[:'x-iyzi-client-version'] = 'iyzipay-ruby-1.0.36'
18
+ header[:'x-iyzi-client-version'] = 'iyzipay-ruby-1.0.39'
19
19
  end
20
20
 
21
21
  header
@@ -17,6 +17,7 @@ module Iyzipay
17
17
  append(:billingAddress, Address.to_pki_string(request[:billingAddress])).
18
18
  append_array(:basketItems, Basket.to_pki_string(request[:basketItems])).
19
19
  append(:callbackUrl, request[:callbackUrl]).
20
+ append(:paymentSource, request[:paymentSource]).
20
21
  append_array(:enabledInstallments, request[:enabledInstallments]).
21
22
  get_request_string
22
23
  end
@@ -5,15 +5,18 @@ 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 test api' do
14
14
  api_test = Iyzipay::Model::ApiTest.new.retrieve(@options)
15
15
  begin
16
- $stderr.puts api_test.inspect
16
+ api_test = JSON.parse(api_test)
17
+ expect(api_test['status']).to eq('success')
18
+ expect(api_test['locale']).to eq('tr')
19
+ expect(api_test['systemTime']).not_to be_nil
17
20
  rescue
18
21
  $stderr.puts 'oops'
19
22
  raise
@@ -1,27 +1,38 @@
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 approve payment item' do
14
- request = {
15
- locale: Iyzipay::Model::Locale::TR,
16
- conversationId: '123456789',
17
- paymentTransactionId: '1'
18
- }
19
- approval = Iyzipay::Model::Approval.new.create(request, @options)
20
- begin
21
- $stderr.puts approval.inspect
22
- rescue
23
- $stderr.puts 'oops'
24
- raise
14
+ context 'when create a payment for market place and then approve payment' do
15
+ it 'should approve payment item' do
16
+ sub_merchant = Builder::SubMerchantBuilder.new.create_personal_sub_merchant(@options)
17
+ payment = Builder::PaymentBuilder.new.create_marketplace_payment(@options, sub_merchant['subMerchantKey'])
18
+
19
+ request = {
20
+ locale: Iyzipay::Model::Locale::TR,
21
+ conversationId: '123456789',
22
+ paymentTransactionId: payment['itemTransactions'][0]['paymentTransactionId']
23
+ }
24
+ approval = Iyzipay::Model::Approval.new.create(request, @options)
25
+
26
+ begin
27
+ approval = JSON.parse(approval)
28
+ expect(approval['status']).to eq('success')
29
+ expect(approval['locale']).to eq('tr')
30
+ expect(approval['systemTime']).not_to be_nil
31
+ expect(approval['paymentTransactionId']).to eq(payment['itemTransactions'][0]['paymentTransactionId'])
32
+ rescue
33
+ $stderr.puts 'oops'
34
+ raise
35
+ end
25
36
  end
26
37
  end
27
38
 
@@ -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 bin number' do
@@ -18,7 +18,19 @@ RSpec.describe 'Iyzipay' do
18
18
  }
19
19
  bin_number = Iyzipay::Model::BinNumber.new.retrieve(request, @options)
20
20
  begin
21
- $stderr.puts bin_number.inspect
21
+ #$stderr.puts bin_number.inspect
22
+ bin_number = JSON.parse(bin_number)
23
+ expect(bin_number['status']).to eq('success')
24
+ expect(bin_number['locale']).to eq('tr')
25
+ expect(bin_number['systemTime']).not_to be_nil
26
+ expect(bin_number['conversationId']).to eq('123456789')
27
+ expect(bin_number['binNumber']).to eq('554960')
28
+ expect(bin_number['cardType']).to eq('CREDIT_CARD')
29
+ expect(bin_number['cardAssociation']).to eq('MASTER_CARD')
30
+ expect(bin_number['cardFamily']).to eq('Bonus')
31
+ expect(bin_number['bankName']).to eq('Garanti Bankası')
32
+ expect(bin_number['bankCode']).to eq(62)
33
+ expect(bin_number['commercial']).to eq(0)
22
34
  rescue
23
35
  $stderr.puts 'oops'
24
36
  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 initialize bkm' do
@@ -63,7 +63,7 @@ RSpec.describe 'Iyzipay' do
63
63
  conversationId: '123456789',
64
64
  price: '1',
65
65
  basketId: 'B67832',
66
- paymentGroup: Iyzipay::Model::PaymentGroup::PRODUCT,
66
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
67
67
  callbackUrl: 'https://www.merchant.com/callback',
68
68
  enabledInstallments: [2, 3, 6, 9],
69
69
  buyer: buyer,
@@ -74,11 +74,10 @@ RSpec.describe 'Iyzipay' do
74
74
  bkm_initialize = Iyzipay::Model::BkmInitialize.new.create(request, @options)
75
75
 
76
76
  begin
77
- $stderr.puts bkm_initialize.inspect
78
-
79
77
  bkm_initialize_dict = JSON.parse(bkm_initialize)
78
+
80
79
  unless bkm_initialize_dict['htmlContent'].nil?
81
- $stderr.puts Base64.decode64(bkm_initialize_dict['htmlContent']).inspect
80
+ expect(Base64.decode64(bkm_initialize_dict['htmlContent'])).not_to be_nil
82
81
  end
83
82
  rescue
84
83
  $stderr.puts 'oops'
@@ -86,20 +85,6 @@ RSpec.describe 'Iyzipay' do
86
85
  end
87
86
  end
88
87
 
89
- it 'should retrieve bkm result' do
90
- request = {
91
- locale: Iyzipay::Model::Locale::TR,
92
- conversationId: '123456789',
93
- token: 'token'
94
- }
95
- bkm = Iyzipay::Model::Bkm.new.retrieve(request, @options)
96
- begin
97
- $stderr.puts bkm.inspect
98
- rescue
99
- $stderr.puts 'oops'
100
- raise
101
- end
102
- end
103
88
 
104
89
  after :each do
105
90
  end
@@ -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'
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ module Builder
6
+ class ApprovalBuilder
7
+
8
+ def create_approval(options, payment_transaction_id)
9
+ request = {
10
+ locale: Iyzipay::Model::Locale::TR,
11
+ conversationId: '123456789',
12
+ paymentTransactionId: payment_transaction_id
13
+ }
14
+ approval = Iyzipay::Model::Approval.new.create(request, options)
15
+ JSON.parse(approval)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ module Builder
6
+ class CardBuilder
7
+
8
+ def create_card(options)
9
+ card_information = {
10
+ cardAlias: 'card alias',
11
+ cardHolderName: 'John Doe',
12
+ cardNumber: '5528790000000008',
13
+ expireYear: '2030',
14
+ expireMonth: '12'
15
+ }
16
+ request = {
17
+ locale: Iyzipay::Model::Locale::TR,
18
+ conversationId: '123456789',
19
+ email: 'email@email.com',
20
+ externalId: 'external id',
21
+ card: card_information
22
+ }
23
+ card = Iyzipay::Model::Card.new.create(request, options)
24
+ JSON.parse(card)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ module Builder
6
+ class CheckoutFormBuilder
7
+
8
+ def create_checkout_form_initialize(options)
9
+ buyer = {
10
+ id: 'BY789',
11
+ name: 'John',
12
+ surname: 'Doe',
13
+ gsmNumber: '+905350000000',
14
+ email: 'email@email.com',
15
+ identityNumber: '74300864791',
16
+ lastLoginDate: '2015-10-05 12:43:35',
17
+ registrationDate: '2013-04-21 15:12:09',
18
+ registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
19
+ ip: '85.34.78.112',
20
+ city: 'Istanbul',
21
+ country: 'Turkey',
22
+ zipCode: '34732'
23
+ }
24
+ address = {
25
+ contactName: 'Jane Doe',
26
+ city: 'Istanbul',
27
+ country: 'Turkey',
28
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
29
+ zipCode: '34732'
30
+ }
31
+
32
+ item1 = {
33
+ id: 'BI101',
34
+ name: 'Binocular',
35
+ category1: 'Collectibles',
36
+ category2: 'Accessories',
37
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
38
+ price: '0.3'
39
+ }
40
+ item2 = {
41
+ id: 'BI102',
42
+ name: 'Game code',
43
+ category1: 'Game',
44
+ category2: 'Online Game Items',
45
+ itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
46
+ price: '0.5'
47
+ }
48
+ item3 = {
49
+ id: 'BI103',
50
+ name: 'Usb',
51
+ category1: 'Electronics',
52
+ category2: 'Usb / Cable',
53
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
54
+ price: '0.2'
55
+ }
56
+ request = {
57
+ locale: Iyzipay::Model::Locale::TR,
58
+ conversationId: '123456789',
59
+ price: '1',
60
+ paidPrice: '1.2',
61
+ currency: Iyzipay::Model::Currency::TRY,
62
+ basketId: 'B67832',
63
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
64
+ callbackUrl: 'https://www.merchant.com/callback',
65
+ enabledInstallments: [2, 3, 6, 9],
66
+ buyer: buyer,
67
+ billingAddress: address,
68
+ shippingAddress: address,
69
+ basketItems: [item1, item2, item3]
70
+ }
71
+ checkout_form_initialize = Iyzipay::Model::CheckoutFormInitialize.new.create(request, options)
72
+ JSON.parse(checkout_form_initialize)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,167 @@
1
+ # coding: utf-8
2
+
3
+ require_relative '../spec_helper'
4
+
5
+ module Builder
6
+ class PaymentBuilder
7
+
8
+ def create_marketplace_payment(options, sub_merchant_key)
9
+ payment_card = {
10
+ cardHolderName: 'John Doe',
11
+ cardNumber: '5528790000000008',
12
+ expireYear: '2030',
13
+ expireMonth: '12',
14
+ cvc: '123',
15
+ registerCard: 0
16
+ }
17
+ buyer = {
18
+ id: 'BY789',
19
+ name: 'John',
20
+ surname: 'Doe',
21
+ gsmNumber: '+905350000000',
22
+ email: 'email@email.com',
23
+ identityNumber: '74300864791',
24
+ lastLoginDate: '2015-10-05 12:43:35',
25
+ registrationDate: '2013-04-21 15:12:09',
26
+ registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
27
+ ip: '85.34.78.112',
28
+ city: 'Istanbul',
29
+ country: 'Turkey',
30
+ zipCode: '34732'
31
+ }
32
+ address = {
33
+ contactName: 'Jane Doe',
34
+ city: 'Istanbul',
35
+ country: 'Turkey',
36
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
37
+ zipCode: '34732'
38
+ }
39
+
40
+ item1 = {
41
+ id: 'BI101',
42
+ name: 'Binocular',
43
+ category1: 'Collectibles',
44
+ category2: 'Accessories',
45
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
46
+ subMerchantKey: sub_merchant_key,
47
+ subMerchantPrice: '0.27',
48
+ price: '0.3'
49
+ }
50
+ item2 = {
51
+ id: 'BI102',
52
+ name: 'Game code',
53
+ category1: 'Game',
54
+ category2: 'Online Game Items',
55
+ itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
56
+ subMerchantKey: sub_merchant_key,
57
+ subMerchantPrice: '0.42',
58
+ price: '0.5'
59
+ }
60
+ item3 = {
61
+ id: 'BI103',
62
+ name: 'Usb',
63
+ category1: 'Electronics',
64
+ category2: 'Usb / Cable',
65
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
66
+ subMerchantKey: sub_merchant_key,
67
+ subMerchantPrice: '0.18',
68
+ price: '0.2'
69
+ }
70
+ request = {
71
+ locale: Iyzipay::Model::Locale::TR,
72
+ conversationId: '123456789',
73
+ price: '1',
74
+ paidPrice: '1.1',
75
+ currency: Iyzipay::Model::Currency::TRY,
76
+ installment: 1,
77
+ basketId: 'B67832',
78
+ paymentChannel: Iyzipay::Model::PaymentChannel::WEB,
79
+ paymentGroup: Iyzipay::Model::PaymentGroup::PRODUCT,
80
+ paymentCard: payment_card,
81
+ buyer: buyer,
82
+ billingAddress: address,
83
+ shippingAddress: address,
84
+ basketItems: [item1, item2, item3]
85
+ }
86
+ payment = Iyzipay::Model::Payment.new.create(request, options)
87
+ JSON.parse(payment)
88
+ end
89
+
90
+ def create_standard_listing_payment(options)
91
+ payment_card = {
92
+ cardHolderName: 'John Doe',
93
+ cardNumber: '5528790000000008',
94
+ expireYear: '2030',
95
+ expireMonth: '12',
96
+ cvc: '123',
97
+ registerCard: 0
98
+ }
99
+ buyer = {
100
+ id: 'BY789',
101
+ name: 'John',
102
+ surname: 'Doe',
103
+ gsmNumber: '+905350000000',
104
+ email: 'email@email.com',
105
+ identityNumber: '74300864791',
106
+ lastLoginDate: '2015-10-05 12:43:35',
107
+ registrationDate: '2013-04-21 15:12:09',
108
+ registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
109
+ ip: '85.34.78.112',
110
+ city: 'Istanbul',
111
+ country: 'Turkey',
112
+ zipCode: '34732'
113
+ }
114
+ address = {
115
+ contactName: 'Jane Doe',
116
+ city: 'Istanbul',
117
+ country: 'Turkey',
118
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
119
+ zipCode: '34732'
120
+ }
121
+
122
+ item1 = {
123
+ id: 'BI101',
124
+ name: 'Binocular',
125
+ category1: 'Collectibles',
126
+ category2: 'Accessories',
127
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
128
+ price: '0.3'
129
+ }
130
+ item2 = {
131
+ id: 'BI102',
132
+ name: 'Game code',
133
+ category1: 'Game',
134
+ category2: 'Online Game Items',
135
+ itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
136
+ price: '0.5'
137
+ }
138
+ item3 = {
139
+ id: 'BI103',
140
+ name: 'Usb',
141
+ category1: 'Electronics',
142
+ category2: 'Usb / Cable',
143
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
144
+ price: '0.2'
145
+ }
146
+ request = {
147
+ locale: Iyzipay::Model::Locale::TR,
148
+ conversationId: '123456789',
149
+ price: '1',
150
+ paidPrice: '1.1',
151
+ currency: Iyzipay::Model::Currency::TRY,
152
+ installment: 1,
153
+ basketId: 'B67832',
154
+ paymentChannel: Iyzipay::Model::PaymentChannel::WEB,
155
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
156
+ paymentCard: payment_card,
157
+ buyer: buyer,
158
+ billingAddress: address,
159
+ shippingAddress: address,
160
+ basketItems: [item1, item2, item3]
161
+ }
162
+ payment = Iyzipay::Model::Payment.new.create(request, options)
163
+ JSON.parse(payment)
164
+ end
165
+
166
+ end
167
+ end