iyzipay-subscriptions 1.0.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 (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +17 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +21 -0
  8. data/README.md +183 -0
  9. data/Rakefile +5 -0
  10. data/VERSION +1 -0
  11. data/contributors +2 -0
  12. data/examples/options.rb +4 -0
  13. data/examples/plan.rb +36 -0
  14. data/examples/product.rb +32 -0
  15. data/examples/subscription.rb +33 -0
  16. data/examples/subscription_checkout_form_initialize.rb +39 -0
  17. data/examples/subscription_initialize.rb +47 -0
  18. data/gemfiles/Gemfile.nokogiri-1.6.8.1 +7 -0
  19. data/iyzipay.gemspec +24 -0
  20. data/lib/iyzipay.rb +16 -0
  21. data/lib/iyzipay/http_client.rb +39 -0
  22. data/lib/iyzipay/iyzipay_resource.rb +60 -0
  23. data/lib/iyzipay/iyzipay_resource_v2.rb +39 -0
  24. data/lib/iyzipay/model.rb +63 -0
  25. data/lib/iyzipay/model/address.rb +17 -0
  26. data/lib/iyzipay/model/api_test.rb +10 -0
  27. data/lib/iyzipay/model/approval.rb +17 -0
  28. data/lib/iyzipay/model/basic_bkm.rb +17 -0
  29. data/lib/iyzipay/model/basic_bkm_initialize.rb +24 -0
  30. data/lib/iyzipay/model/basic_payment.rb +27 -0
  31. data/lib/iyzipay/model/basic_payment_post_auth.rb +20 -0
  32. data/lib/iyzipay/model/basic_payment_pre_auth.rb +27 -0
  33. data/lib/iyzipay/model/basic_threeds_initialize.rb +27 -0
  34. data/lib/iyzipay/model/basic_threeds_initialize_pre_auth.rb +27 -0
  35. data/lib/iyzipay/model/basic_threeds_payment.rb +18 -0
  36. data/lib/iyzipay/model/basket.rb +26 -0
  37. data/lib/iyzipay/model/basket_item_type.rb +8 -0
  38. data/lib/iyzipay/model/bin_number.rb +17 -0
  39. data/lib/iyzipay/model/bkm.rb +17 -0
  40. data/lib/iyzipay/model/bkm_initialize.rb +26 -0
  41. data/lib/iyzipay/model/bounced_bank_transfer_list.rb +17 -0
  42. data/lib/iyzipay/model/buyer.rb +25 -0
  43. data/lib/iyzipay/model/cancel.rb +20 -0
  44. data/lib/iyzipay/model/card.rb +36 -0
  45. data/lib/iyzipay/model/card_information.rb +17 -0
  46. data/lib/iyzipay/model/card_list.rb +17 -0
  47. data/lib/iyzipay/model/checkout_form.rb +17 -0
  48. data/lib/iyzipay/model/checkout_form_initialize.rb +31 -0
  49. data/lib/iyzipay/model/checkout_form_initialize_pre_auth.rb +30 -0
  50. data/lib/iyzipay/model/cross_booking_from_sub_merchant.rb +20 -0
  51. data/lib/iyzipay/model/cross_booking_to_sub_merchant.rb +20 -0
  52. data/lib/iyzipay/model/currency.rb +11 -0
  53. data/lib/iyzipay/model/disapproval.rb +17 -0
  54. data/lib/iyzipay/model/installment_details.rb +19 -0
  55. data/lib/iyzipay/model/installment_info.rb +18 -0
  56. data/lib/iyzipay/model/installment_prices.rb +19 -0
  57. data/lib/iyzipay/model/locale.rb +8 -0
  58. data/lib/iyzipay/model/pay_with_iyzico_initialize.rb +31 -0
  59. data/lib/iyzipay/model/pay_with_iyzico_retrieve.rb +17 -0
  60. data/lib/iyzipay/model/payment.rb +47 -0
  61. data/lib/iyzipay/model/payment_card.rb +22 -0
  62. data/lib/iyzipay/model/payment_channel.rb +14 -0
  63. data/lib/iyzipay/model/payment_group.rb +9 -0
  64. data/lib/iyzipay/model/payment_post_auth.rb +20 -0
  65. data/lib/iyzipay/model/payment_pre_auth.rb +47 -0
  66. data/lib/iyzipay/model/payout_completed_transaction_list.rb +17 -0
  67. data/lib/iyzipay/model/pecco_initialize.rb +27 -0
  68. data/lib/iyzipay/model/pecco_payment.rb +17 -0
  69. data/lib/iyzipay/model/refund.rb +22 -0
  70. data/lib/iyzipay/model/refund_charged_from_merchant.rb +20 -0
  71. data/lib/iyzipay/model/refund_reason.rb +10 -0
  72. data/lib/iyzipay/model/refund_to_balance.rb +18 -0
  73. data/lib/iyzipay/model/settlement_to_balance.rb +19 -0
  74. data/lib/iyzipay/model/sub_merchant.rb +72 -0
  75. data/lib/iyzipay/model/sub_merchant_type.rb +9 -0
  76. data/lib/iyzipay/model/threeds_initialize.rb +32 -0
  77. data/lib/iyzipay/model/threeds_initialize_pre_auth.rb +32 -0
  78. data/lib/iyzipay/model/threeds_payment.rb +34 -0
  79. data/lib/iyzipay/model/v2/checkout_form.rb +20 -0
  80. data/lib/iyzipay/model/v2/checkout_form_initialize.rb +21 -0
  81. data/lib/iyzipay/model/v2/plan.rb +33 -0
  82. data/lib/iyzipay/model/v2/product.rb +39 -0
  83. data/lib/iyzipay/model/v2/subscription.rb +60 -0
  84. data/lib/iyzipay/model/v2/subscription_initialize.rb +21 -0
  85. data/lib/iyzipay/options.rb +7 -0
  86. data/lib/iyzipay/pki_builder.rb +101 -0
  87. data/spec/api_test_spec.rb +28 -0
  88. data/spec/approval_spec.rb +41 -0
  89. data/spec/bin_number_spec.rb +42 -0
  90. data/spec/bkm_spec.rb +91 -0
  91. data/spec/builder.rb +9 -0
  92. data/spec/builder/approval_builder.rb +18 -0
  93. data/spec/builder/card_builder.rb +27 -0
  94. data/spec/builder/checkout_form_builder.rb +75 -0
  95. data/spec/builder/payment_builder.rb +167 -0
  96. data/spec/builder/pecco_initialize_builder.rb +74 -0
  97. data/spec/builder/sub_merchant_builder.rb +91 -0
  98. data/spec/cancel_spec.rb +72 -0
  99. data/spec/card_storage_spec.rb +153 -0
  100. data/spec/checkout_form_spec.rb +113 -0
  101. data/spec/disapproval_spec.rb +47 -0
  102. data/spec/installment_spec.rb +46 -0
  103. data/spec/pay_with_iyzico_spec.rb +109 -0
  104. data/spec/payment_spec.rb +320 -0
  105. data/spec/pecco_spec.rb +116 -0
  106. data/spec/refund_spec.rb +76 -0
  107. data/spec/refund_to_balance_spec.rb +37 -0
  108. data/spec/retrieve_transactions_spec.rb +55 -0
  109. data/spec/settlement_to_balance_spec.rb +40 -0
  110. data/spec/spec_helper.rb +81 -0
  111. data/spec/spec_options.rb +5 -0
  112. data/spec/sub_merchant_spec.rb +227 -0
  113. data/spec/threeds_payment_spec.rb +229 -0
  114. metadata +226 -0
@@ -0,0 +1,116 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'spec_helper'
4
+ require_relative 'builder'
5
+
6
+ RSpec.describe 'Iyzipay' do
7
+ before :all do
8
+ @options = Iyzipay::Options.new
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
12
+ end
13
+
14
+ it 'should initialize pecco' do
15
+ buyer = {
16
+ id: 'BY789',
17
+ name: 'John',
18
+ surname: 'Doe',
19
+ identityNumber: '74300864791',
20
+ email: 'email@email.com',
21
+ gsmNumber: '+905350000000',
22
+ registrationDate: '2013-04-21 15:12:09',
23
+ lastLoginDate: '2015-10-05 12:43:35',
24
+ registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
25
+ city: 'Istanbul',
26
+ country: 'Turkey',
27
+ zipCode: '34732',
28
+ ip: '85.34.78.112'
29
+ }
30
+ address = {
31
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
32
+ zipCode: '34732',
33
+ contactName: 'John Doe',
34
+ city: 'Istanbul',
35
+ country: 'Turkey'
36
+ }
37
+
38
+ item1 = {
39
+ id: 'BI101',
40
+ name: 'Binocular',
41
+ category1: 'Collectibles',
42
+ category2: 'Accessories',
43
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
44
+ price: '30000'
45
+ }
46
+ item2 = {
47
+ id: 'BI102',
48
+ name: 'Game code',
49
+ category1: 'Game',
50
+ category2: 'Online Game Items',
51
+ itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
52
+ price: '50000'
53
+ }
54
+ item3 = {
55
+ id: 'BI103',
56
+ name: 'Usb',
57
+ category1: 'Electronics',
58
+ category2: 'Usb / Cable',
59
+ itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
60
+ price: '20000'
61
+ }
62
+ request = {
63
+ locale: Iyzipay::Model::Locale::TR,
64
+ conversationId: '123456789',
65
+ price: '100000',
66
+ paidPrice: '120000',
67
+ basketId: 'B67832',
68
+ paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
69
+ callbackUrl: 'https://www.merchant.com/callback',
70
+ currency: Iyzipay::Model::Currency::IRR,
71
+ buyer: buyer,
72
+ billingAddress: address,
73
+ shippingAddress: address,
74
+ basketItems: [item1, item2, item3]
75
+ }
76
+ pecco_initialize = Iyzipay::Model::PeccoInitialize.new.create(request, @options)
77
+ begin
78
+ $stderr.puts pecco_initialize.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
87
+ end
88
+ rescue
89
+ $stderr.puts 'oops'
90
+ raise
91
+ end
92
+ end
93
+
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
+
99
+ request = {
100
+ locale: Iyzipay::Model::Locale::TR,
101
+ conversationId: '123456789',
102
+ token: pecco_initialize['token']
103
+ }
104
+ pecco_payment = Iyzipay::Model::PeccoPayment.new.create(request, @options)
105
+
106
+ begin
107
+ $stdout.puts pecco_payment.inspect
108
+ rescue
109
+ $stdout.puts 'oops'
110
+ raise
111
+ end
112
+ end
113
+
114
+ after :each do
115
+ end
116
+ end
@@ -0,0 +1,76 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'spec_helper'
4
+ require_relative 'builder'
5
+
6
+ RSpec.describe 'Iyzipay' do
7
+ before :all do
8
+ @options = Iyzipay::Options.new
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
12
+ end
13
+
14
+ it 'should refund payment' do
15
+ # create payment
16
+ payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
17
+
18
+ request = {
19
+ locale: Iyzipay::Model::Locale::TR,
20
+ conversationId: '123456789',
21
+ paymentTransactionId: payment['itemTransactions'][0]['paymentTransactionId'],
22
+ price: '0.2',
23
+ currency: Iyzipay::Model::Currency::TRY,
24
+ ip: '85.34.78.112'
25
+ }
26
+ refund = Iyzipay::Model::Refund.new.create(request, @options)
27
+ begin
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)
37
+ rescue
38
+ $stderr.puts 'oops'
39
+ raise
40
+ end
41
+ end
42
+
43
+ it 'should refund payment with reason and description' do
44
+ # create payment
45
+ payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
46
+
47
+ request = {
48
+ locale: Iyzipay::Model::Locale::TR,
49
+ conversationId: '123456789',
50
+ paymentTransactionId: payment['itemTransactions'][0]['paymentTransactionId'],
51
+ price: '0.2',
52
+ currency: Iyzipay::Model::Currency::TRY,
53
+ ip: '85.34.78.112',
54
+ reason: Iyzipay::Model::RefundReason::OTHER,
55
+ description: 'customer requested for default sample'
56
+ }
57
+ refund = Iyzipay::Model::Refund.new.create(request, @options)
58
+ begin
59
+ $stdout.puts refund.inspect
60
+ refund = JSON.parse(refund)
61
+ expect(refund['status']).to eq('success')
62
+ expect(refund['locale']).to eq('tr')
63
+ expect(refund['systemTime']).not_to be_nil
64
+ expect(refund['conversationId']).to eq('123456789')
65
+ expect(refund['paymentId']).to eq(payment['paymentId'])
66
+ expect(refund['paymentTransactionId']).to eq(payment['itemTransactions'][0]['paymentTransactionId'])
67
+ expect(refund['price']).to eq(0.2)
68
+ rescue
69
+ $stderr.puts 'oops'
70
+ raise
71
+ end
72
+ end
73
+
74
+ after :each do
75
+ end
76
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ require_relative 'spec_helper'
3
+ require_relative 'builder'
4
+
5
+ RSpec.describe 'Iyzipay' do
6
+ before :all do
7
+ @options = Iyzipay::Options.new
8
+ @options.api_key = SpecOptions::API_KEY
9
+ @options.secret_key = SpecOptions::SECRET_KEY
10
+ @options.base_url = SpecOptions::BASE_URL
11
+ end
12
+
13
+ it 'should refund to balance' do
14
+ # create payment
15
+ payment = Builder::PaymentBuilder.new.create_standard_listing_payment(@options)
16
+ request = {
17
+ locale: Iyzipay::Model::Locale::TR,
18
+ conversationId: '123456789',
19
+ paymentId: payment['paymentId'],
20
+ callbackUrl: 'https://merchanturl.com'
21
+ }
22
+ refundToBalance = Iyzipay::Model::RefundToBalance.new.create(request, @options)
23
+ begin
24
+ $stdout.puts refundToBalance.inspect
25
+ refundToBalance = JSON.parse(refundToBalance)
26
+ expect(refundToBalance['status']).not_to be_nil
27
+ expect(refundToBalance['token']).not_to be_nil
28
+ expect(refundToBalance['url']).not_to be_nil
29
+ rescue
30
+ $stderr.puts 'oops'
31
+ raise
32
+ end
33
+ end
34
+
35
+ after :each do
36
+ end
37
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ RSpec.describe 'Iyzipay' do
6
+ before :all do
7
+ @options = Iyzipay::Options.new
8
+ @options.api_key = SpecOptions::API_KEY
9
+ @options.secret_key = SpecOptions::SECRET_KEY
10
+ @options.base_url = SpecOptions::BASE_URL
11
+ end
12
+
13
+ it 'should retrieve payout completed transactions' do
14
+ request = {
15
+ locale: Iyzipay::Model::Locale::TR,
16
+ conversationId: '123456789',
17
+ date: '2016-01-22 19:13:00'
18
+ }
19
+ transaction_list = Iyzipay::Model::PayoutCompletedTransactionList.new.retrieve(request, @options)
20
+ begin
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')
27
+ rescue
28
+ $stderr.puts 'oops'
29
+ raise
30
+ end
31
+ end
32
+
33
+ it 'should retrieve bounced bank transfers' do
34
+ request = {
35
+ locale: Iyzipay::Model::Locale::TR,
36
+ conversationId: '123456789',
37
+ date: '2016-01-22 19:13:00'
38
+ }
39
+ bounced_bank_transfer_list = Iyzipay::Model::BouncedBankTransferList.new.retrieve(request, @options)
40
+ begin
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')
47
+ rescue
48
+ $stderr.puts 'oops'
49
+ raise
50
+ end
51
+ end
52
+
53
+ after :each do
54
+ end
55
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ require_relative 'spec_helper'
3
+ require_relative 'builder'
4
+
5
+ RSpec.describe 'Iyzipay' do
6
+ before :all do
7
+ @options = Iyzipay::Options.new
8
+ @options.api_key = SpecOptions::API_KEY
9
+ @options.secret_key = SpecOptions::SECRET_KEY
10
+ @options.base_url = SpecOptions::BASE_URL
11
+ end
12
+
13
+ it 'should make settlement to balance' do
14
+ sub_merchant = Builder::SubMerchantBuilder.new.create_personal_sub_merchant(@options)
15
+ request = {
16
+ subMerchantKey: sub_merchant['subMerchantKey'],
17
+ callbackUrl: 'https://merchantwebsite.com',
18
+ price: '10',
19
+ locale: 'tr',
20
+ conversationId: '123456'
21
+ }
22
+ settlement_to_balance = Iyzipay::Model::SettlementToBalance.new.create(request, @options)
23
+ begin
24
+ $stdout.puts settlement_to_balance.inspect
25
+ expect(settlement_to_balance['status']).not_to be_nil
26
+ expect(settlement_to_balance['locale']).not_to be_nil
27
+ expect(settlement_to_balance['systemTime']).not_to be_nil
28
+ expect(settlement_to_balance['conversationId']).not_to be_nil
29
+ expect(settlement_to_balance['url']).not_to be_nil
30
+ expect(settlement_to_balance['token']).not_to be_nil
31
+ expect(settlement_to_balance['settingsAllTime']).not_to be_nil
32
+ rescue
33
+ $stderr.puts 'oops'
34
+ raise
35
+ end
36
+ end
37
+
38
+ after :each do
39
+ end
40
+ end
@@ -0,0 +1,81 @@
1
+ require_relative '../lib/iyzipay.rb'
2
+ require_relative 'spec_options'
3
+
4
+ RSpec.configure do |config|
5
+ # rspec-expectations config goes here. You can use an alternate
6
+ # assertion/expectation library such as wrong or the stdlib/minitest
7
+ # assertions if you prefer.
8
+ config.expect_with :rspec do |expectations|
9
+ # This option will default to `true` in RSpec 4. It makes the `description`
10
+ # and `failure_message` of custom matchers include text for helper methods
11
+ # defined using `chain`, e.g.:
12
+ # be_bigger_than(2).and_smaller_than(4).description
13
+ # # => "be bigger than 2 and smaller than 4"
14
+ # ...rather than:
15
+ # # => "be bigger than 2"
16
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
17
+ end
18
+
19
+ # rspec-mocks config goes here. You can use an alternate test double
20
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
21
+ config.mock_with :rspec do |mocks|
22
+ # Prevents you from mocking or stubbing a method that does not exist on
23
+ # a real object. This is generally recommended, and will default to
24
+ # `true` in RSpec 4.
25
+ mocks.verify_partial_doubles = true
26
+ end
27
+
28
+ # The settings below are suggested to provide a good initial experience
29
+ # with RSpec, but feel free to customize to your heart's content.
30
+ =begin
31
+ # These two settings work together to allow you to limit a spec run
32
+ # to individual examples or groups you care about by tagging them with
33
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
34
+ # get run.
35
+ config.filter_run :focus
36
+ config.run_all_when_everything_filtered = true
37
+
38
+ # Allows RSpec to persist some state between runs in order to support
39
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
40
+ # you configure your source control system to ignore this file.
41
+ config.example_status_persistence_file_path = "spec/examples.txt"
42
+
43
+ # Limits the available syntax to the non-monkey patched syntax that is
44
+ # recommended. For more details, see:
45
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
46
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
47
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
48
+ config.disable_monkey_patching!
49
+
50
+ # This setting enables warnings. It's recommended, but in some cases may
51
+ # be too noisy due to issues in dependencies.
52
+ config.warnings = true
53
+
54
+ # Many RSpec users commonly either run the entire suite or an individual
55
+ # file, and it's useful to allow more verbose output when running an
56
+ # individual spec file.
57
+ if config.files_to_run.one?
58
+ # Use the documentation formatter for detailed output,
59
+ # unless a formatter has already been configured
60
+ # (e.g. via a command-line flag).
61
+ config.default_formatter = 'doc'
62
+ end
63
+
64
+ # Print the 10 slowest examples and example groups at the
65
+ # end of the spec run, to help surface which specs are running
66
+ # particularly slow.
67
+ config.profile_examples = 10
68
+
69
+ # Run specs in random order to surface order dependencies. If you find an
70
+ # order dependency and want to debug it, you can fix the order by providing
71
+ # the seed, which is printed after each run.
72
+ # --seed 1234
73
+ config.order = :random
74
+
75
+ # Seed global randomization in this process using the `--seed` CLI option.
76
+ # Setting this allows you to use `--seed` to deterministically reproduce
77
+ # test failures related to randomization by passing the same `--seed` value
78
+ # as the one that triggered the failure.
79
+ Kernel.srand config.seed
80
+ =end
81
+ end
@@ -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
@@ -0,0 +1,227 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'spec_helper'
4
+ require_relative 'builder'
5
+
6
+ RSpec.describe 'Iyzipay' do
7
+ before :all do
8
+ @options = Iyzipay::Options.new
9
+ @options.api_key = SpecOptions::API_KEY
10
+ @options.secret_key = SpecOptions::SECRET_KEY
11
+ @options.base_url = SpecOptions::BASE_URL
12
+ end
13
+
14
+ it 'should create personal sub merchant' do
15
+ random_number = Random.rand(11**11).to_s
16
+ request = {
17
+ locale: Iyzipay::Model::Locale::TR,
18
+ conversationId: '123456789',
19
+ subMerchantExternalId: 'B' + random_number,
20
+ subMerchantType: Iyzipay::Model::SubMerchantType::PERSONAL,
21
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
22
+ contactName: 'John',
23
+ contactSurname: 'Doe',
24
+ email: random_number + '@email.com',
25
+ gsmNumber: '+905350000000',
26
+ name: 'John\'s market',
27
+ iban: 'TR180006200119000006672315',
28
+ identityNumber: '1234567890',
29
+ currency: Iyzipay::Model::Currency::TRY
30
+ }
31
+ sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
32
+ begin
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')
39
+ rescue
40
+ $stderr.puts 'oops'
41
+ raise
42
+ end
43
+ end
44
+
45
+ it 'should create private sub merchant' do
46
+ random_number = Random.rand(11**11).to_s
47
+ request = {
48
+ locale: Iyzipay::Model::Locale::TR,
49
+ conversationId: '123456789',
50
+ subMerchantExternalId: 'B' + random_number,
51
+ subMerchantType: Iyzipay::Model::SubMerchantType::PRIVATE_COMPANY,
52
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
53
+ taxOffice: 'Tax office',
54
+ legalCompanyTitle: 'John Doe inc',
55
+ email: random_number + '@email.com',
56
+ gsmNumber: '+905350000000',
57
+ name: 'John\'s market',
58
+ iban: 'TR180006200119000006672315',
59
+ identityNumber: '31300864726',
60
+ currency: Iyzipay::Model::Currency::TRY
61
+ }
62
+ sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
63
+ begin
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')
69
+ rescue
70
+ $stderr.puts 'oops'
71
+ raise
72
+ end
73
+ end
74
+
75
+ it 'should create limited company sub merchant' do
76
+ random_number = Random.rand(11**11).to_s
77
+ request = {
78
+ locale: Iyzipay::Model::Locale::TR,
79
+ conversationId: '123456789',
80
+ subMerchantExternalId: 'B' + random_number,
81
+ subMerchantType: Iyzipay::Model::SubMerchantType::LIMITED_OR_JOINT_STOCK_COMPANY,
82
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
83
+ taxOffice: 'Tax office',
84
+ taxNumber: '9261877',
85
+ legalCompanyTitle: 'XYZ inc',
86
+ email: 'email@submerchantemail.com',
87
+ gsmNumber: '+905350000000',
88
+ name: 'John\'s market',
89
+ iban: 'TR180006200119000006672315',
90
+ currency: Iyzipay::Model::Currency::TRY
91
+ }
92
+ sub_merchant = Iyzipay::Model::SubMerchant.new.create(request, @options)
93
+ begin
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')
99
+ rescue
100
+ $stderr.puts 'oops'
101
+ raise
102
+ end
103
+ end
104
+
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
+
109
+ request = {
110
+ locale: Iyzipay::Model::Locale::TR,
111
+ conversationId: '123456789',
112
+ subMerchantExternalId: sub_merchant['subMerchantExternalId'],
113
+ subMerchantKey: sub_merchant['subMerchantKey'],
114
+ iban: 'TR180006200119000006672315',
115
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
116
+ contactName: 'Jane',
117
+ contactSurname: 'Doe',
118
+ email: 'email@submerchantemail.com',
119
+ gsmNumber: '+905350000000',
120
+ name: 'Jane\'s market',
121
+ identityNumber: '31300864726',
122
+ currency: Iyzipay::Model::Currency::TRY
123
+ }
124
+ sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
125
+ begin
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')
132
+ rescue
133
+ $stderr.puts 'oops'
134
+ raise
135
+ end
136
+ end
137
+
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
+
142
+ request = {
143
+ locale: Iyzipay::Model::Locale::TR,
144
+ conversationId: '123456789',
145
+ subMerchantExternalId: 'S49222',
146
+ subMerchantKey: sub_merchant['subMerchantKey'],
147
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
148
+ taxOffice: 'Tax office',
149
+ legalCompanyTitle: 'Jane Doe inc',
150
+ email: 'email@submerchantemail.com',
151
+ gsmNumber: '+905350000000',
152
+ name: 'Jane\'s market',
153
+ iban: 'TR180006200119000006672315',
154
+ identityNumber: '31300864726',
155
+ currency: Iyzipay::Model::Currency::TRY
156
+ }
157
+ sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
158
+ begin
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')
165
+ rescue
166
+ $stderr.puts 'oops'
167
+ raise
168
+ end
169
+ end
170
+
171
+ it 'should update limited company sub merchant' do
172
+ sub_merchant = Builder::SubMerchantBuilder.new.create_limited_sub_merchant(@options)
173
+
174
+ request = {
175
+ locale: Iyzipay::Model::Locale::TR,
176
+ conversationId: '123456789',
177
+ subMerchantKey: sub_merchant['subMerchantKey'],
178
+ address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
179
+ taxOffice: 'Tax office',
180
+ taxNumber: '9261877',
181
+ legalCompanyTitle: 'ABC inc',
182
+ email: 'email@submerchantemail.com',
183
+ gsmNumber: '+905350000000',
184
+ name: 'Jane\'s market',
185
+ iban: 'TR180006200119000006672315',
186
+ currency: Iyzipay::Model::Currency::TRY
187
+ }
188
+ sub_merchant = Iyzipay::Model::SubMerchant.new.update(request, @options)
189
+ begin
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')
196
+ rescue
197
+ $stderr.puts 'oops'
198
+ raise
199
+ end
200
+ end
201
+
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
+
206
+ request = {
207
+ locale: Iyzipay::Model::Locale::TR,
208
+ conversationId: '123456789',
209
+ subMerchantExternalId: random_number
210
+ }
211
+ sub_merchant = Iyzipay::Model::SubMerchant.new.retrieve(request, @options)
212
+ begin
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')
219
+ rescue
220
+ $stderr.puts 'oops'
221
+ raise
222
+ end
223
+ end
224
+
225
+ after :each do
226
+ end
227
+ end