iyzi 0.0.1

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 (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +84 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/examples.md +286 -0
  13. data/iyzi.gemspec +32 -0
  14. data/lib/iyzi.rb +52 -0
  15. data/lib/iyzi/api_error.rb +7 -0
  16. data/lib/iyzi/configuration.rb +38 -0
  17. data/lib/iyzi/endpoints.rb +25 -0
  18. data/lib/iyzi/pki_builder.rb +88 -0
  19. data/lib/iyzi/pki_builders/address.rb +17 -0
  20. data/lib/iyzi/pki_builders/basket_item.rb +25 -0
  21. data/lib/iyzi/pki_builders/basket_items.rb +17 -0
  22. data/lib/iyzi/pki_builders/bin_control.rb +15 -0
  23. data/lib/iyzi/pki_builders/buyer.rb +30 -0
  24. data/lib/iyzi/pki_builders/card_storage.rb +23 -0
  25. data/lib/iyzi/pki_builders/checkout_form.rb +36 -0
  26. data/lib/iyzi/pki_builders/checkout_form_auth.rb +15 -0
  27. data/lib/iyzi/pki_builders/payment_auth.rb +36 -0
  28. data/lib/iyzi/pki_builders/payment_card.rb +23 -0
  29. data/lib/iyzi/pki_builders/store_card.rb +19 -0
  30. data/lib/iyzi/pki_builders/sub_merchant.rb +63 -0
  31. data/lib/iyzi/request.rb +88 -0
  32. data/lib/iyzi/requests/api_test.rb +9 -0
  33. data/lib/iyzi/requests/bin_control.rb +13 -0
  34. data/lib/iyzi/requests/card_storage.rb +30 -0
  35. data/lib/iyzi/requests/checkout_form.rb +13 -0
  36. data/lib/iyzi/requests/checkout_form_auth.rb +13 -0
  37. data/lib/iyzi/requests/payment_auth.rb +13 -0
  38. data/lib/iyzi/requests/sub_merchant.rb +30 -0
  39. data/lib/iyzi/resources.rb +35 -0
  40. data/lib/iyzi/utils.rb +37 -0
  41. data/lib/iyzi/version.rb +3 -0
  42. metadata +210 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf1e310505128560d353de7ef2ce5ba012a5c7e9
4
+ data.tar.gz: b371845099f999768459d033cd2ffcb79edc3081
5
+ SHA512:
6
+ metadata.gz: 584d09f76e2b8bcee08a85ca680ba52e7ac7e01146aa4e5c24b756070aed650aa1e15c284efa162e03cdf25a963c8e102ec82102a0021b49d4639023c5a119cf
7
+ data.tar.gz: 7243d0300d52c75d9370c624b53065a6e00fccc480312850defb8875392f4b1877ebe9087cabfca3011947a4ffc5944100f37b9f4bfe25864fc32c80e8511f46
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ ruby-2.2.3
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iyzi.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Demirhan Aydin
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,84 @@
1
+ # Iyzi
2
+
3
+ [![Build Status](https://travis-ci.org/parasutcom/iyzi.svg?branch=master)](https://travis-ci.org/parasutcom/iyzi)
4
+
5
+ Iyzico ruby client
6
+
7
+ Checkout api documentations
8
+ https://www.iyzico.com/entegrasyon/ozel-yazilim-entegrasyonu/
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'iyzi'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install iyzi
25
+
26
+ ## Setup
27
+
28
+ Before using the library, you must supply your Iyzico API key and secret. There are two ways to configure. You can either put the code below into initializer:
29
+ ```ruby
30
+ Iyzi.configure do |config|
31
+ config.api_key = 'API_KEY'
32
+ config.secret = 'SECRET'
33
+ config.base_url = 'BASE_API_URL' # default 'https://api.iyzipay.com/' if not specified
34
+ end
35
+ ```
36
+ or you could send configuration object as a parameter
37
+ ```ruby
38
+ config = Iyzi::Configuration.new(api_key: 'API_KEY', secret: 'SECRET')
39
+ params = { bin_number: '411111', config: config }
40
+ Iyzi.bin_control(params)
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ Checkout [examples](examples.md)
46
+
47
+ ## Supported Endpoints
48
+ Checked items are supported
49
+
50
+ - [x] Yeni Alt Üye İşyeri Ekleme Servisi /onboarding/submerchant POST
51
+ - [x] Alt Üye İşyeri Güncelleme Servisi /onboarding/submerchant PUT
52
+ - [ ] Ödeme (Auth) Servisi /payment/iyzipos/auth/ecom POST
53
+ - [ ] 3D Secure Ödeme (initialize 3DS) Başlatma Servisi /payment/iyzipos/initialize3ds/ecom POST
54
+ - [ ] 3D Secure Ödeme (Auth 3DS) Servisi /payment/iyzipos/auth3ds/ecom POST
55
+ - [ ] Ön Otorizasyon (PreAuth) Servisi /payment/iyzipos/preauth/ecom POST
56
+ - [ ] Son Otorizasyon (PostAuth=Capture) Servisi /payment/iyzipos/postauth POST
57
+ - [ ] İptal (Cancel) Servisi /payment/iyzipos/cancel POST
58
+ - [ ] İade (Refund) Servisi /payment/iyzipos/refund POST
59
+ - [ ] İade (Refund) Servisi - İadeyi Üye İşyerinin Üstlendiği /payment/iyzipos/refund/merchant/charge POST
60
+ - [ ] Para Transferi İçin Ürüne Onay Verme Servisi /payment/iyzipos/item/approve POST
61
+ - [ ] Para Transferi İçin Ürüne Verilen Onayı Geri Çekme Servisi /payment/iyzipos/item/disapprove POST
62
+ - [ ] Mahsuplaşma - Alt Üye İşyerine Para Gönderme Servisi /crossbooking/send POST
63
+ - [ ] Mahsuplaşma - Alt Üye İşyerinden Para Alma Servisi /crossbooking/receive POST
64
+ - [x] Servis Ayakta mı Testi (Healthcheck) /payment/test GET
65
+ - [x] BIN Kontrol Servisi /payment/bin/check POST
66
+ - [ ] Taksit Matrisi (Installment) Servisi /payment/iyzipos/installment POST
67
+ - [x] Ödemeden Bağımsız Kart Ekleme Servisi /cardstorage/card POST
68
+ - [x] Ödemeden Bağımsız Kart Silme Servisi /cardstorage/card DELETE
69
+ - [x] Ödemeden Bağımsız Kart Bilgilerini Çekme Servisi /cardstorage/cards POST
70
+ - [ ] Parası Transferi Yapılan İşlemler Servisi /reporting/settlement/payoutcompleted POST
71
+ - [ ] Para Transferi Bankadan Geri Dönenler Servisi /reporting/settlement/bounced POST
72
+ - [x] initializeCheckoutForm /payment/iyzipos/checkoutform/initialize/ecom POST
73
+ - [x] Callback & getAuthResponse /payment/iyzipos/checkoutform/auth/ecom/detail POST
74
+
75
+ ## Development
76
+
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+
79
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
80
+
81
+ ## License
82
+
83
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
84
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "iyzi"
5
+ require "ap"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,286 @@
1
+ ### Api Test
2
+ ```ruby
3
+ Iyzi.api_test
4
+ #=> {"status"=>"success", "locale"=>"tr", "system_time"=>1461684700719}
5
+ ```
6
+
7
+ ### Checkout Form
8
+ ```ruby
9
+ params = {
10
+ :locale => "tr",
11
+ :conversation_id => "123456",
12
+ :price => "3.0",
13
+ :paid_price => "3.0",
14
+ :basket_id => "B67832",
15
+ :payment_group => "PRODUCT",
16
+ :callback_url => "https://eda1f961.ngrok.io/callback",
17
+ :buyer => {
18
+ :id => "BY789",
19
+ :name => "John",
20
+ :surname => "Doe",
21
+ :identity_number => "74300864791",
22
+ :email => "email@email.com",
23
+ :gsm_number => "+905350000000",
24
+ :registration_date => "2013-04-21 15:12:09",
25
+ :last_login_date => "2015-10-05 12:43:35",
26
+ :registration_address => "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1",
27
+ :city => "Istanbul",
28
+ :country => "Turkey",
29
+ :zip_code => "34732",
30
+ :ip => "85.34.78.112"
31
+ },
32
+ :billing_address => {
33
+ :address => "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1",
34
+ :zip_code => "34732",
35
+ :contact_name => "Jane Doe",
36
+ :city => "Istanbul",
37
+ :country => "Turkey"
38
+ },
39
+ :basket_items => [
40
+ {
41
+ "id" => "BI102",
42
+ "name" => "Game code",
43
+ "category1" => "Game",
44
+ "category2" => "Online Game Items",
45
+ "itemType" => "VIRTUAL",
46
+ "price" => "1"
47
+ },
48
+ {
49
+ "id" => "I12",
50
+ "name" => "Game code",
51
+ "category1" => "Game",
52
+ "category2" => "Online Game Items",
53
+ "itemType" => "VIRTUAL",
54
+ "price" => "2"
55
+ }
56
+ ]
57
+ }
58
+ Iyzi.checkout_form(options)
59
+ #=> {
60
+ # "status" => "success",
61
+ # "locale" => "tr",
62
+ # "system_time" => 1460588522560,
63
+ # "conversation_id" => "123456",
64
+ # "token" => "TOKEN",
65
+ # "checkout_form_content" => "<script type=\"text/javascript\">\nvar iyziInit = {token:'TOKEN',price:3.00,locale:'tr',baseUrl:'https://api.iyzipay.com',registerCardEnabled:true,userCards:[], \ncreateTag:function(){\nvar iyziCSSTag = document.createElement('link');\niyziCSSTag.setAttribute('rel','stylesheet');\niyziCSSTag.setAttribute('type','text/css');\niyziCSSTag.setAttribute('href','https://static.iyzipay.com/checkoutform/css/main.min.css');\ndocument.head.appendChild(iyziCSSTag);\nvar iyziJSTag = document.createElement('script');\niyziJSTag.setAttribute('src','https://static.iyzipay.com/checkoutform/js/iyziCheckout.min.js');\ndocument.head.appendChild(iyziJSTag);\n}\n}\niyziInit.createTag();\n</script>\n",
66
+ # "token_expire_time" => 1800,
67
+ # "payment_page_url" => "https://cpp.iyzipay.com?token=TOKEN"
68
+ #}
69
+ ```
70
+ ### Checkout Form Auth
71
+ ```ruby
72
+ params = {
73
+ :locale => "tr",
74
+ :conversation_id => "123456",
75
+ :token => "87ed39e6-a125-46ff-81c0-XXXX"
76
+ }
77
+ Iyzi.checkout_form_auth(params)
78
+ #=> {
79
+ # "status" => "success",
80
+ # "locale" => "tr",
81
+ # "system_time" => 1460590653230,
82
+ # "conversation_id" => "123456",
83
+ # "price" => 1.0,
84
+ # "paid_price" => 1.0,
85
+ # "installment" => 1,
86
+ # "payment_id" => "PAYMENT_ID",
87
+ # "fraud_status" => 1,
88
+ # "merchant_commission_rate" => 0.0,
89
+ # "merchant_commission_rate_amount" => 0.0,
90
+ # "iyzi_commission_rate_amount" => 0.0295,
91
+ # "iyzi_commission_fee" => 0.295,
92
+ # "card_type" => "CREDIT_CARD",
93
+ # "card_association" => "VISA",
94
+ # "card_family" => "Maximum",
95
+ # "bin_number" => "411111",
96
+ # "basket_id" => "B67832",
97
+ # "item_transactions" => [
98
+ # {
99
+ # "item_id" => "BI102",
100
+ # "payment_transaction_id" => "PAYMENT_TRANSACTION_ID",
101
+ # "transaction_status" => 2,
102
+ # "price" => 1.0,
103
+ # "paid_price" => 1.0,
104
+ # "merchant_commission_rate" => 0.0,
105
+ # "merchant_commission_rate_amount" => 0.0,
106
+ # "iyzi_commission_rate_amount" => 0.0295,
107
+ # "iyzi_commission_fee" => 0.295,
108
+ # "blockage_rate" => 0.0,
109
+ # "blockage_rate_amount_merchant" => 0.0,
110
+ # "blockage_rate_amount_sub_merchant" => 0.0,
111
+ # "blockage_resolved_date" => "2016-04-14 00:19:47",
112
+ # "sub_merchant_price" => 0.0,
113
+ # "sub_merchant_payout_rate" => 0.0,
114
+ # "sub_merchant_payout_amount" => 0.0,
115
+ # "merchant_payout_amount" => 0.6755
116
+ # }
117
+ # ],
118
+ # "token" => "XXXXXXX-XXXX-XXXX-XXXX-XXXX",
119
+ # "callback_url" => "https://eda1f961.ngrok.io/callback",
120
+ # "payment_status" => "SUCCESS"
121
+ #}
122
+ ```
123
+ ### Payment Auth
124
+ ```ruby
125
+ params = {
126
+ :locale => "tr",
127
+ :conversation_id => "123456",
128
+ :price => 1,
129
+ :paid_price => 1,
130
+ :basket_id => "TEST_BASKET_ID",
131
+ :payment_group => "SUBSCRIPTION",
132
+ :payment_card => {
133
+ :card_token => "CARD_TOKEN",
134
+ :card_user_key => "CARD_USER_KEY"
135
+ },
136
+ :buyer => {
137
+ :id => "BY789",
138
+ :name => "Genc",
139
+ :surname => "Osman",
140
+ :identity_number => "1000001",
141
+ :email => "genc@osman.com",
142
+ :registration_address => "Tomtom Mah. Nur-i Ziya Sok. 16/1 34433 Beyoğlu",
143
+ :city => "Istanbul",
144
+ :country => "Turkey",
145
+ :ip => "localhost"
146
+ },
147
+ :billing_address => {
148
+ :address => "Tomtom Mah. Nur-i Ziya Sok. 16/1 34433 Beyoğlu",
149
+ :contact_name => "Genc Osman",
150
+ :city => "Istanbul",
151
+ :country => "Turkey"
152
+ },
153
+ :basket_items => [
154
+ {
155
+ :id => "PARASUT:1",
156
+ :name => "Test Subscription",
157
+ :category1 => "Finance",
158
+ :category2 => "Online",
159
+ :item_type => "VIRTUAL",
160
+ :price => "1"
161
+ }
162
+ ]
163
+ }
164
+ Iyzi.payment_auth(params)
165
+ #=> {
166
+ # "status" => "success",
167
+ # "locale" => "tr",
168
+ # "system_time" => 1461519398004,
169
+ # "conversation_id" => "123456",
170
+ # "price" => 1,
171
+ # "paid_price" => 1,
172
+ # "installment" => 1,
173
+ # "payment_id" => "3410766",
174
+ # "fraud_status" => 1,
175
+ # "merchant_commission_rate" => 0.0,
176
+ # "merchant_commission_rate_amount" => 0,
177
+ # "iyzi_commission_rate_amount" => 0.0295,
178
+ # "iyzi_commission_fee" => 0.295,
179
+ # "card_type" => "CREDIT_CARD",
180
+ # "card_association" => "VISA",
181
+ # "card_family" => "Maximum",
182
+ # "bin_number" => "418342",
183
+ # "basket_id" => "TEST_BASKET_ID",
184
+ # "item_transactions" => [{
185
+ # "item_id" => "PARASUT:1",
186
+ # "payment_transaction_id" => "2774801",
187
+ # "transaction_status" => 2,
188
+ # "price" => 1,
189
+ # "paid_price" => 1.0,
190
+ # "merchant_commission_rate" => 0.0,
191
+ # "merchant_commission_rate_amount" => 0.0,
192
+ # "iyzi_commission_rate_amount" => 0.0295,
193
+ # "iyzi_commission_fee" => 0.295,
194
+ # "blockage_rate" => 0.0,
195
+ # "blockage_rate_amount_merchant" => 0.0,
196
+ # "blockage_rate_amount_sub_merchant" => 0,
197
+ # "blockage_resolved_date" => "2016-04-24 20:36:37",
198
+ # "sub_merchant_price" => 0,
199
+ # "sub_merchant_payout_rate" => 0.0,
200
+ # "sub_merchant_payout_amount" => 0,
201
+ # "merchant_payout_amount" => 0.6755
202
+ # }]
203
+ #}
204
+ ```
205
+ ### Register Card
206
+ ```ruby
207
+ params = {
208
+ :locale => "tr",
209
+ :conversation_id => "123",
210
+ :email => "email@email.com",
211
+ :external_id => "321",
212
+ :card => {
213
+ :card_alias => "used in pardev",
214
+ :card_holder_name => "John Doe",
215
+ :card_number => "5528790000000008",
216
+ :expire_month => "12",
217
+ :expire_year => "2030"
218
+ }
219
+ }
220
+ Iyzi.register_card(params)
221
+ #=> {
222
+ # "status" => "success",
223
+ # "locale" => "tr",
224
+ # "system_time" => 1461507777282,
225
+ # "conversation_id" => "123",
226
+ # "external_id" => "321",
227
+ # "email" => "email@email.com",
228
+ # "card_user_key" => "CARD_USER_KEY",
229
+ # "card_token" => "CARD_TOKEN",
230
+ # "card_alias" => "used in pardev",
231
+ # "bin_number" => "552879",
232
+ # "card_type" => "CREDIT_CARD",
233
+ # "card_association" => "MASTER_CARD",
234
+ # "card_family" => "Paraf",
235
+ # "card_bank_code" => 12,
236
+ # "card_bank_name" => "Halk Bankası"
237
+ #}
238
+ ```
239
+ ### List Cards
240
+ ```ruby
241
+ params = { card_user_key: "CARD_USER_KEY" }
242
+ Iyzi.list_cards(params)
243
+ #=> {
244
+ # "status" => "success",
245
+ # "locale" => "tr",
246
+ # "system_time" => 1461512570878,
247
+ # "card_user_key" => "CARD_USER_KEY",
248
+ # "card_details" => [
249
+ # {
250
+ # "card_token" => "CARD_TOKEN",
251
+ # "card_alias" => "used in pardev",
252
+ # "bin_number" => "552879",
253
+ # "card_type" => "CREDIT_CARD",
254
+ # "card_association" => "MASTER_CARD",
255
+ # "card_family" => "Paraf",
256
+ # "card_bank_code" => 12,
257
+ # "card_bank_name" => "Halk Bankası"
258
+ # }
259
+ # ]
260
+ #}
261
+ ```
262
+ ### Delete Saved Card
263
+ ```ruby
264
+ params = {
265
+ :card_token => "uYPntt0W4QZ8pFm6afLXCvWKjI8=",
266
+ :card_user_key => "hK13yPTT0DPgs57+Y0lkfuDs1dc="
267
+ }
268
+ Iyzi.delete_card(params)
269
+ #=> { "status" => "success", "locale" => "tr", "system_time" => 1461510776404 }
270
+ ```
271
+ ### Bin Control
272
+ ```ruby
273
+ params = { bin_number: '557023' }
274
+ Iyzi.bin_control(params)
275
+ #=> {
276
+ # "status" => "success",
277
+ # "locale" => "tr",
278
+ # "system_time" => 1461422153162,
279
+ # "bin_number" => "557023",
280
+ # "card_type" => "CREDIT_CARD",
281
+ # "card_association" => "MASTER_CARD",
282
+ # "card_family" => "Bonus",
283
+ # "bank_name" => "Garanti Bankası",
284
+ # "bank_code" => 62
285
+ #}
286
+ ```