erdem-iyzipay 1.1.0

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +16 -0
  7. data/Gemfile +9 -0
  8. data/LICENSE +21 -0
  9. data/README.md +180 -0
  10. data/Rakefile +5 -0
  11. data/VERSION +1 -0
  12. data/contributors +2 -0
  13. data/iyzipay.gemspec +23 -0
  14. data/lib/Iyzipay.rb +15 -0
  15. data/lib/iyzipay/http_client.rb +19 -0
  16. data/lib/iyzipay/iyzipay_resource.rb +60 -0
  17. data/lib/iyzipay/model/address.rb +17 -0
  18. data/lib/iyzipay/model/api_test.rb +10 -0
  19. data/lib/iyzipay/model/approval.rb +17 -0
  20. data/lib/iyzipay/model/basic_bkm.rb +17 -0
  21. data/lib/iyzipay/model/basic_bkm_initialize.rb +24 -0
  22. data/lib/iyzipay/model/basic_payment.rb +27 -0
  23. data/lib/iyzipay/model/basic_payment_post_auth.rb +20 -0
  24. data/lib/iyzipay/model/basic_payment_pre_auth.rb +27 -0
  25. data/lib/iyzipay/model/basic_threeds_initialize.rb +27 -0
  26. data/lib/iyzipay/model/basic_threeds_initialize_pre_auth.rb +27 -0
  27. data/lib/iyzipay/model/basic_threeds_payment.rb +18 -0
  28. data/lib/iyzipay/model/basket.rb +26 -0
  29. data/lib/iyzipay/model/basket_item_type.rb +8 -0
  30. data/lib/iyzipay/model/bin_number.rb +17 -0
  31. data/lib/iyzipay/model/bkm.rb +17 -0
  32. data/lib/iyzipay/model/bkm_initialize.rb +26 -0
  33. data/lib/iyzipay/model/bounced_bank_transfer_list.rb +17 -0
  34. data/lib/iyzipay/model/buyer.rb +25 -0
  35. data/lib/iyzipay/model/cancel.rb +18 -0
  36. data/lib/iyzipay/model/card.rb +36 -0
  37. data/lib/iyzipay/model/card_information.rb +17 -0
  38. data/lib/iyzipay/model/card_list.rb +17 -0
  39. data/lib/iyzipay/model/checkout_form.rb +17 -0
  40. data/lib/iyzipay/model/checkout_form_initialize.rb +31 -0
  41. data/lib/iyzipay/model/checkout_form_initialize_pre_auth.rb +30 -0
  42. data/lib/iyzipay/model/cross_booking_from_sub_merchant.rb +20 -0
  43. data/lib/iyzipay/model/cross_booking_to_sub_merchant.rb +20 -0
  44. data/lib/iyzipay/model/currency.rb +11 -0
  45. data/lib/iyzipay/model/disapproval.rb +17 -0
  46. data/lib/iyzipay/model/installment_details.rb +19 -0
  47. data/lib/iyzipay/model/installment_info.rb +18 -0
  48. data/lib/iyzipay/model/installment_prices.rb +19 -0
  49. data/lib/iyzipay/model/locale.rb +8 -0
  50. data/lib/iyzipay/model/payment.rb +47 -0
  51. data/lib/iyzipay/model/payment_card.rb +22 -0
  52. data/lib/iyzipay/model/payment_channel.rb +14 -0
  53. data/lib/iyzipay/model/payment_group.rb +9 -0
  54. data/lib/iyzipay/model/payment_post_auth.rb +20 -0
  55. data/lib/iyzipay/model/payment_pre_auth.rb +47 -0
  56. data/lib/iyzipay/model/payout_completed_transaction_list.rb +17 -0
  57. data/lib/iyzipay/model/pecco_initialize.rb +27 -0
  58. data/lib/iyzipay/model/pecco_payment.rb +17 -0
  59. data/lib/iyzipay/model/refund.rb +20 -0
  60. data/lib/iyzipay/model/refund_charged_from_merchant.rb +20 -0
  61. data/lib/iyzipay/model/sub_merchant.rb +72 -0
  62. data/lib/iyzipay/model/sub_merchant_type.rb +9 -0
  63. data/lib/iyzipay/model/threeds_initialize.rb +32 -0
  64. data/lib/iyzipay/model/threeds_initialize_pre_auth.rb +32 -0
  65. data/lib/iyzipay/model/threeds_payment.rb +34 -0
  66. data/lib/iyzipay/model.rb +52 -0
  67. data/lib/iyzipay/options.rb +7 -0
  68. data/lib/iyzipay/pki_builder.rb +101 -0
  69. data/spec/api_test_spec.rb +25 -0
  70. data/spec/approval_spec.rb +30 -0
  71. data/spec/bin_number_spec.rb +30 -0
  72. data/spec/bkm_spec.rb +106 -0
  73. data/spec/cancel_spec.rb +31 -0
  74. data/spec/card_storage_spec.rb +94 -0
  75. data/spec/checkout_form_spec.rb +103 -0
  76. data/spec/disapproval_spec.rb +30 -0
  77. data/spec/installment_spec.rb +31 -0
  78. data/spec/payment_spec.rb +276 -0
  79. data/spec/pecco_spec.rb +105 -0
  80. data/spec/refund_spec.rb +33 -0
  81. data/spec/retrieve_transactions_spec.rb +45 -0
  82. data/spec/spec_helper.rb +80 -0
  83. data/spec/sub_merchant_spec.rb +179 -0
  84. data/spec/threeds_payment_spec.rb +226 -0
  85. metadata +186 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 38df98704350d4158eca8b5ddc63224f52244dbf
4
+ data.tar.gz: fd9f546eb6e2df57c419b909a15736873f6c7ebb
5
+ SHA512:
6
+ metadata.gz: 488679a53781a92c0b0f53dd87c98f2367ff0f04685e67d9d3d4c589b5393cf3987e7a2e95c2e53f64d24d0c2812e8710b7e967a0dec6d7caff9360224fb0459
7
+ data.tar.gz: 7c93f85a20f3530e251c6b585452173d76429a9b66db912134a02a0796ab89fb703a8bb26087be773d430e30f38993015304d2ff517fada7daad6df8930ebf9f
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .DS_Store
2
+ .lock
3
+ .rvmrc
4
+ .vimrc
5
+ .redcar
6
+ .bundle
7
+ .rbx
8
+ .idea/
9
+ Gemfile.lock
10
+ .Gemfile.lock
11
+ tags
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ iyzipay
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.0
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ ruby:
3
+ - '1.9'
4
+ - '2.0'
5
+ - '2.1'
6
+ - '2.2'
7
+ - '2.3'
8
+ deploy:
9
+ provider: rubygems
10
+ api_key:
11
+ secure: oyTMpNUPMM2ExVpmXHCHrMc04aCgMcp0gJwhcDHlTyy7HpJBHZS3abBUCOxQOtBj7RKir7BkMFH+XoQz2OoIt//2+S9yBDTf1Nt15KkcXvJq9fIXSiHgiqnQnnZTuE5M2LE287lqO3mGXcJvTaosxO6Wh9K6K6pA0nSOt7DE4foG53MfjX4no1aazrlIDGqZYO4Ml8cHqph02Kp2U5N/+f5V3EfhYp9QshGa3AeUx+gIcXaIbh2v9fz1mEYA3qPFL4Yi9c36p9tqwhPe62pEYBmo9pDziSShIoGZiWMAKFS8qJXXHlWFAYmt9tFLmSNyiiWl35JPjU7Wz5wC9xQHP/o3ZsIT23/UrI0xBZxtTA0eqoeNRERAUN5kARqhKM4UMWyp4ss7+gA69B6zO58HGu/8ZPVn7zQ6yhSrMSTU03DOl3z05koS5YDNLBDKv903jeNO54j31OMlNXht7ugLTP+DNO35vTitzUvxzvOCpVAGuqoYABfATweVMYRUYf+3m6ypBlEC3k3Z2WLaez2FFEfIZXikhVzjWrxiaKfMdzc2XRgr8Ea3KxPmOeYN4gULGZXQaZJ37xQKTRyAkCbt0G/xi2L4q5bDP9NuvRjeijKGtyarshIpOdb9nTEVm8C43+H3mq2Y9Dwtv9dl5DoNYcJjJMiJv1hbldthlInPTqo=
12
+ gem: iyzipay
13
+ on:
14
+ tags: true
15
+ repo: iyzico/iyzipay-ruby
16
+ skip_cleanup: true
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rest-client', '~> 2.0.0'
4
+ gem 'rack', '1.6.4'
5
+
6
+ group :development, :local_development do
7
+ gem 'rspec'
8
+ gem 'rspec-rails'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 - iyzico Ödeme Hizmetleri A.Ş. (https://iyzico.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # iyzipay-ruby
2
+
3
+ [![Build Status](https://travis-ci.org/iyzico/iyzipay-ruby.svg?branch=master)](https://travis-ci.org/iyzico/iyzipay-ruby)
4
+
5
+ You can sign up for an iyzico account at https://iyzico.com
6
+
7
+ # Requirements
8
+
9
+ * Ruby 1.9.3 or newer
10
+ * rest-client
11
+
12
+ # Installation
13
+
14
+ gem install iyzipay
15
+
16
+ ## Bundler
17
+
18
+ ``` ruby
19
+ source 'https://rubygems.org'
20
+
21
+ gem 'iyzipay'
22
+
23
+ ```
24
+
25
+ # Usage
26
+
27
+ ```ruby
28
+
29
+ before :all do
30
+ @options = Iyzipay::Options.new
31
+ @options.api_key = 'your api key'
32
+ @options.secret_key = 'your secret key'
33
+ @options.base_url = 'https://sandbox-api.iyzipay.com'
34
+ end
35
+
36
+ it 'should create payment' do
37
+ payment_card = {
38
+ cardHolderName: 'John Doe',
39
+ cardNumber: '5528790000000008',
40
+ expireYear: '2030',
41
+ expireMonth: '12',
42
+ cvc: '123',
43
+ registerCard: 0
44
+ }
45
+ buyer = {
46
+ id: 'BY789',
47
+ name: 'John',
48
+ surname: 'Doe',
49
+ identityNumber: '74300864791',
50
+ email: 'email@email.com',
51
+ gsmNumber: '+905350000000',
52
+ registrationDate: '2013-04-21 15:12:09',
53
+ lastLoginDate: '2015-10-05 12:43:35',
54
+ registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
55
+ city: 'Istanbul',
56
+ country: 'Turkey',
57
+ zipCode: '34732',
58
+ ip: '85.34.78.112'
59
+ }
60
+ address = {
61
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
62
+ zipCode: '34732',
63
+ contactName: 'John Doe',
64
+ city: 'Istanbul',
65
+ country: 'Turkey'
66
+ }
67
+
68
+ item1 = {
69
+ id: 'BI101',
70
+ name: 'Binocular',
71
+ category1: 'Collectibles',
72
+ category2: 'Accessories',
73
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
74
+ price: '0.3'
75
+ }
76
+ item2 = {
77
+ id: 'BI102',
78
+ name: 'Game code',
79
+ category1: 'Game',
80
+ category2: 'Online Game Items',
81
+ itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
82
+ price: '0.5'
83
+ }
84
+ item3 = {
85
+ id: 'BI103',
86
+ name: 'Usb',
87
+ category1: 'Electronics',
88
+ category2: 'Usb / Cable',
89
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
90
+ price: '0.2'
91
+ }
92
+ request = {
93
+ locale: Iyzipay::Model::Locale::TR,
94
+ conversationId: '123456789',
95
+ price: '1.0',
96
+ paidPrice: '1.1',
97
+ installment: 1,
98
+ paymentChannel: Iyzipay::Model::PaymentChannel::WEB,
99
+ basketId: 'B67832',
100
+ paymentGroup: Iyzipay::Model::PaymentGroup::SUBSCRIPTION,
101
+ currency: Iyzipay::Model::Currency::TRY,
102
+ paymentCard: payment_card,
103
+ buyer: buyer,
104
+ billingAddress: address,
105
+ shippingAddress: address,
106
+ basketItems: [item1, item2, item3]
107
+ }
108
+ payment = Iyzipay::Model::Payment.new.create(request, @options)
109
+ begin
110
+ $stderr.puts payment.inspect
111
+ rescue
112
+ $stderr.puts 'oops'
113
+ raise
114
+ end
115
+ end
116
+ ```
117
+ See other samples under iyzipay-ruby/spec module.
118
+
119
+ Testing
120
+ =======
121
+
122
+ You can run specs with RSpec under spec module.
123
+
124
+ ### Mock test cards
125
+
126
+ Test cards that can be used to simulate a *successful* payment:
127
+
128
+ Card Number | Bank | Card Type
129
+ ----------- | ---- | ---------
130
+ 5890040000000016 | Akbank | Master Card (Debit)
131
+ 5526080000000006 | Akbank | Master Card (Credit)
132
+ 4766620000000001 | Denizbank | Visa (Debit)
133
+ 4603450000000000 | Denizbank | Visa (Credit)
134
+ 4729150000000005 | Denizbank Bonus | Visa (Credit)
135
+ 4987490000000002 | Finansbank | Visa (Debit)
136
+ 5311570000000005 | Finansbank | Master Card (Credit)
137
+ 9792020000000001 | Finansbank | Troy (Debit)
138
+ 9792030000000000 | Finansbank | Troy (Credit)
139
+ 5170410000000004 | Garanti Bankası | Master Card (Debit)
140
+ 5400360000000003 | Garanti Bankası | Master Card (Credit)
141
+ 374427000000003 | Garanti Bankası | American Express
142
+ 4475050000000003 | Halkbank | Visa (Debit)
143
+ 5528790000000008 | Halkbank | Master Card (Credit)
144
+ 4059030000000009 | HSBC Bank | Visa (Debit)
145
+ 5504720000000003 | HSBC Bank | Master Card (Credit)
146
+ 5892830000000000 | Türkiye İş Bankası | Master Card (Debit)
147
+ 4543590000000006 | Türkiye İş Bankası | Visa (Credit)
148
+ 4910050000000006 | Vakıfbank | Visa (Debit)
149
+ 4157920000000002 | Vakıfbank | Visa (Credit)
150
+ 5168880000000002 | Yapı ve Kredi Bankası | Master Card (Debit)
151
+ 5451030000000000 | Yapı ve Kredi Bankası | Master Card (Credit)
152
+
153
+ *Cross border* test cards:
154
+
155
+ Card Number | Country
156
+ ----------- | -------
157
+ 4054180000000007 | Non-Turkish (Debit)
158
+ 5400010000000004 | Non-Turkish (Credit)
159
+ 6221060000000004 | Iran
160
+
161
+ Test cards to get specific *error* codes:
162
+
163
+ Card Number | Description
164
+ ----------- | -----------
165
+ 5406670000000009 | Success but cannot be cancelled, refund or post auth
166
+ 4111111111111129 | Not sufficient funds
167
+ 4129111111111111 | Do not honour
168
+ 4128111111111112 | Invalid transaction
169
+ 4127111111111113 | Lost card
170
+ 4126111111111114 | Stolen card
171
+ 4125111111111115 | Expired card
172
+ 4124111111111116 | Invalid cvc2
173
+ 4123111111111117 | Not permitted to card holder
174
+ 4122111111111118 | Not permitted to terminal
175
+ 4121111111111119 | Fraud suspect
176
+ 4120111111111110 | Pickup card
177
+ 4130111111111118 | General error
178
+ 4131111111111117 | Success but mdStatus is 0
179
+ 4141111111111115 | Success but mdStatus is 4
180
+ 4151111111111112 | 3dsecure initialize failed
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ task default: %w[test]
2
+
3
+ task :test do
4
+ puts "@TODO"
5
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
data/contributors ADDED
@@ -0,0 +1,2 @@
1
+ Yalcin Yenigun
2
+ Nurettin Bakkal
data/iyzipay.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'erdem-iyzipay'
6
+ s.version = '1.1.0'
7
+ s.platform = Gem::Platform::RUBY
8
+ s.required_ruby_version = '>= 2.4.0'
9
+ s.summary = %q{iyzipay api ruby client}
10
+ s.description = %q{iyzipay api ruby client. You can sign up for an iyzico account at https://iyzico.com}
11
+ s.authors = ['Erdem Gezer']
12
+ s.email = 'erdemgezer@gmail.com'
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
15
+ s.homepage = 'http://rubygems.org/gems/erdem-iyzipay'
16
+ s.license = 'MIT'
17
+
18
+ s.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.1'
19
+ s.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
20
+ s.add_development_dependency 'rspec-rails', '~> 3.3', '>= 3.3.0'
21
+
22
+ s.require_paths = ['lib']
23
+ end
data/lib/Iyzipay.rb ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'json'
5
+ require 'rest-client'
6
+ require 'base64'
7
+
8
+ module Iyzipay
9
+ end
10
+
11
+ require_relative 'iyzipay/http_client'
12
+ require_relative 'iyzipay/pki_builder'
13
+ require_relative 'iyzipay/iyzipay_resource'
14
+ require_relative 'iyzipay/model'
15
+ require_relative 'iyzipay/options'
@@ -0,0 +1,19 @@
1
+ module Iyzipay
2
+ class HttpClient
3
+ def self.get(url, header={})
4
+ RestClient.get(url, header)
5
+ end
6
+
7
+ def self.post(url, header, content)
8
+ RestClient.post(url, content, header)
9
+ end
10
+
11
+ def self.put(url, header, content)
12
+ RestClient.put(url, content, header)
13
+ end
14
+
15
+ def self.delete(url, headers={}, content, &block)
16
+ RestClient::Request.execute(:method => :delete, :url => url, :payload => content, :headers => headers, &block)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,60 @@
1
+ module Iyzipay
2
+ class IyzipayResource
3
+
4
+ AUTHORIZATION_HEADER_NAME = 'Authorization'
5
+ RANDOM_HEADER_NAME = 'x-iyzi-rnd';
6
+ AUTHORIZATION_HEADER_STRING = 'IYZWS %s:%s'
7
+ RANDOM_STRING_SIZE = 8
8
+ RANDOM_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
9
+
10
+ def get_http_header(pki_string = nil, options = nil, authorize_request = true)
11
+ header = {:accept => 'application/json',
12
+ :'content-type' => 'application/json'}
13
+
14
+ if authorize_request
15
+ random_header_value = random_string(RANDOM_STRING_SIZE)
16
+ header[:'Authorization'] = "#{prepare_authorization_string(pki_string, random_header_value, options)}"
17
+ header[:'x-iyzi-rnd'] = "#{random_header_value}"
18
+ header[:'x-iyzi-client-version'] = 'iyzipay-ruby-1.0.36'
19
+ end
20
+
21
+ header
22
+ end
23
+
24
+ def get_plain_http_header
25
+ get_http_header(nil, false)
26
+ end
27
+
28
+ def prepare_authorization_string(pki_string, random_header_value, options)
29
+ hash_digest = calculate_hash(pki_string, random_header_value, options)
30
+ format_header_string(options.api_key, hash_digest)
31
+ end
32
+
33
+ def json_decode(response, raw_result)
34
+ json_result = JSON::parse(raw_result)
35
+ response.from_json(json_result)
36
+ end
37
+
38
+ def calculate_hash(pki_string, random_header_value, options)
39
+ Digest::SHA1.base64digest("#{options.api_key}#{random_header_value}#{options.secret_key}#{pki_string}")
40
+ end
41
+
42
+ def format_header_string(*args)
43
+ sprintf(AUTHORIZATION_HEADER_STRING, *args)
44
+ end
45
+
46
+ def random_string(string_length)
47
+ random_string = ''
48
+ string_length.times do
49
+ random_string << RANDOM_CHARS.split('').sample
50
+ end
51
+ random_string
52
+ end
53
+
54
+ def to_pki_string(request)
55
+ PkiBuilder.new.append(:locale, request[:locale]).
56
+ append(:conversationId, request[:conversationId]).
57
+ get_request_string
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Address
4
+ def self.to_pki_string(request)
5
+ unless request.nil?
6
+ PkiBuilder.new.
7
+ append(:address, request[:address]).
8
+ append(:zipCode, request[:zipCode]).
9
+ append(:contactName, request[:contactName]).
10
+ append(:city, request[:city]).
11
+ append(:country, request[:country]).
12
+ get_request_string
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module Iyzipay
2
+ module Model
3
+ class ApiTest < IyzipayResource
4
+
5
+ def retrieve(options)
6
+ HttpClient.get("#{options.base_url}/payment/test")
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Approval < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/item/approve", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append(:paymentTransactionId, request[:paymentTransactionId]).
13
+ get_request_string
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicBkm < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/bkm/auth/detail", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append(:token, request[:token]).
13
+ get_request_string
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicBkmInitialize < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/bkm/initialize", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append(:connectorName, request[:connectorName]).
13
+ append_price(:price, request[:price]).
14
+ append(:callbackUrl, request[:callbackUrl]).
15
+ append(:buyerEmail, request[:buyerEmail]).
16
+ append(:buyerId, request[:buyerId]).
17
+ append(:buyerIp, request[:buyerIp]).
18
+ append(:posOrderId, request[:posOrderId]).
19
+ append_array(:installmentDetails, InstallmentDetails.to_pki_string(request[:installmentDetails])).
20
+ get_request_string
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicPayment < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/auth", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append_price(:price, request[:price]).
13
+ append_price(:paidPrice, request[:paidPrice]).
14
+ append(:installment, request[:installment]).
15
+ append(:buyerEmail, request[:buyerEmail]).
16
+ append(:buyerId, request[:buyerId]).
17
+ append(:buyerIp, request[:buyerIp]).
18
+ append(:posOrderId, request[:posOrderId]).
19
+ append(:paymentCard, PaymentCard.to_pki_string(request[:paymentCard])).
20
+ append(:currency, request[:currency]).
21
+ append(:connectorName, request[:connectorName]).
22
+ append(:callbackUrl, request[:callbackUrl]).
23
+ get_request_string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicPaymentPostAuth < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/postauth", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append(:paymentId, request[:paymentId]).
13
+ append(:ip, request[:ip]).
14
+ append_price(:paidPrice, request[:paidPrice]).
15
+ append(:currency, request[:currency]).
16
+ get_request_string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicPaymentPreAuth < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/preauth", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append_price(:price, request[:price]).
13
+ append_price(:paidPrice, request[:paidPrice]).
14
+ append(:installment, request[:installment]).
15
+ append(:buyerEmail, request[:buyerEmail]).
16
+ append(:buyerId, request[:buyerId]).
17
+ append(:buyerIp, request[:buyerIp]).
18
+ append(:posOrderId, request[:posOrderId]).
19
+ append(:paymentCard, PaymentCard.to_pki_string(request[:paymentCard])).
20
+ append(:currency, request[:currency]).
21
+ append(:connectorName, request[:connectorName]).
22
+ append(:callbackUrl, request[:callbackUrl]).
23
+ get_request_string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicThreedsInitialize < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/initialize3ds", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append_price(:price, request[:price]).
13
+ append_price(:paidPrice, request[:paidPrice]).
14
+ append(:installment, request[:installment]).
15
+ append(:buyerEmail, request[:buyerEmail]).
16
+ append(:buyerId, request[:buyerId]).
17
+ append(:buyerIp, request[:buyerIp]).
18
+ append(:posOrderId, request[:posOrderId]).
19
+ append(:paymentCard, PaymentCard.to_pki_string(request[:paymentCard])).
20
+ append(:currency, request[:currency]).
21
+ append(:connectorName, request[:connectorName]).
22
+ append(:callbackUrl, request[:callbackUrl]).
23
+ get_request_string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicThreedsInitializePreAuth < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/initialize3ds/preauth", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append_price(:price, request[:price]).
13
+ append_price(:paidPrice, request[:paidPrice]).
14
+ append(:installment, request[:installment]).
15
+ append(:buyerEmail, request[:buyerEmail]).
16
+ append(:buyerId, request[:buyerId]).
17
+ append(:buyerIp, request[:buyerIp]).
18
+ append(:posOrderId, request[:posOrderId]).
19
+ append(:paymentCard, PaymentCard.to_pki_string(request[:paymentCard])).
20
+ append(:currency, request[:currency]).
21
+ append(:connectorName, request[:connectorName]).
22
+ append(:callbackUrl, request[:callbackUrl]).
23
+ get_request_string
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BasicThreedsPayment < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyziconnect/auth3ds", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def to_pki_string(request)
11
+ PkiBuilder.new.append_super(super).
12
+ append(:paymentId, request[:paymentId]).
13
+ append(:conversationData, request[:conversationData]).
14
+ get_request_string
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Basket
4
+ def self.to_pki_string(request)
5
+ unless request.nil?
6
+ basket_items = Array.new
7
+ request.each do |item|
8
+ item_pki = PkiBuilder.new.
9
+ append(:id, item[:id]).
10
+ append_price(:price, item[:price]).
11
+ append(:name, item[:name]).
12
+ append(:category1, item[:category1]).
13
+ append(:category2, item[:category2]).
14
+ append(:itemType, item[:itemType]).
15
+ append(:subMerchantKey, item[:subMerchantKey]).
16
+ append_price(:subMerchantPrice, item[:subMerchantPrice]).
17
+ append(:ip, item[:ip]).
18
+ get_request_string
19
+ basket_items << item_pki
20
+ end
21
+ basket_items
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end