iyzipay-subscription-payments 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +183 -0
- data/Rakefile +5 -0
- data/VERSION +1 -0
- data/contributors +2 -0
- data/examples/options.rb +4 -0
- data/examples/plan.rb +36 -0
- data/examples/product.rb +32 -0
- data/examples/subscription.rb +33 -0
- data/examples/subscription_checkout_form_initialize.rb +39 -0
- data/examples/subscription_initialize.rb +47 -0
- data/gemfiles/Gemfile.nokogiri-1.6.8.1 +7 -0
- data/iyzipay.gemspec +24 -0
- data/lib/iyzipay/http_client.rb +39 -0
- data/lib/iyzipay/iyzipay_resource.rb +60 -0
- data/lib/iyzipay/iyzipay_resource_v2.rb +39 -0
- data/lib/iyzipay/model/address.rb +17 -0
- data/lib/iyzipay/model/api_test.rb +10 -0
- data/lib/iyzipay/model/approval.rb +17 -0
- data/lib/iyzipay/model/basic_bkm.rb +17 -0
- data/lib/iyzipay/model/basic_bkm_initialize.rb +24 -0
- data/lib/iyzipay/model/basic_payment.rb +27 -0
- data/lib/iyzipay/model/basic_payment_post_auth.rb +20 -0
- data/lib/iyzipay/model/basic_payment_pre_auth.rb +27 -0
- data/lib/iyzipay/model/basic_threeds_initialize.rb +27 -0
- data/lib/iyzipay/model/basic_threeds_initialize_pre_auth.rb +27 -0
- data/lib/iyzipay/model/basic_threeds_payment.rb +18 -0
- data/lib/iyzipay/model/basket.rb +26 -0
- data/lib/iyzipay/model/basket_item_type.rb +8 -0
- data/lib/iyzipay/model/bin_number.rb +17 -0
- data/lib/iyzipay/model/bkm.rb +17 -0
- data/lib/iyzipay/model/bkm_initialize.rb +26 -0
- data/lib/iyzipay/model/bounced_bank_transfer_list.rb +17 -0
- data/lib/iyzipay/model/buyer.rb +25 -0
- data/lib/iyzipay/model/cancel.rb +20 -0
- data/lib/iyzipay/model/card.rb +36 -0
- data/lib/iyzipay/model/card_information.rb +17 -0
- data/lib/iyzipay/model/card_list.rb +17 -0
- data/lib/iyzipay/model/checkout_form.rb +17 -0
- data/lib/iyzipay/model/checkout_form_initialize.rb +31 -0
- data/lib/iyzipay/model/checkout_form_initialize_pre_auth.rb +30 -0
- data/lib/iyzipay/model/cross_booking_from_sub_merchant.rb +20 -0
- data/lib/iyzipay/model/cross_booking_to_sub_merchant.rb +20 -0
- data/lib/iyzipay/model/currency.rb +11 -0
- data/lib/iyzipay/model/disapproval.rb +17 -0
- data/lib/iyzipay/model/installment_details.rb +19 -0
- data/lib/iyzipay/model/installment_info.rb +18 -0
- data/lib/iyzipay/model/installment_prices.rb +19 -0
- data/lib/iyzipay/model/locale.rb +8 -0
- data/lib/iyzipay/model/pay_with_iyzico_initialize.rb +31 -0
- data/lib/iyzipay/model/pay_with_iyzico_retrieve.rb +17 -0
- data/lib/iyzipay/model/payment.rb +47 -0
- data/lib/iyzipay/model/payment_card.rb +22 -0
- data/lib/iyzipay/model/payment_channel.rb +14 -0
- data/lib/iyzipay/model/payment_group.rb +9 -0
- data/lib/iyzipay/model/payment_post_auth.rb +20 -0
- data/lib/iyzipay/model/payment_pre_auth.rb +47 -0
- data/lib/iyzipay/model/payout_completed_transaction_list.rb +17 -0
- data/lib/iyzipay/model/pecco_initialize.rb +27 -0
- data/lib/iyzipay/model/pecco_payment.rb +17 -0
- data/lib/iyzipay/model/refund.rb +22 -0
- data/lib/iyzipay/model/refund_charged_from_merchant.rb +20 -0
- data/lib/iyzipay/model/refund_reason.rb +10 -0
- data/lib/iyzipay/model/refund_to_balance.rb +18 -0
- data/lib/iyzipay/model/settlement_to_balance.rb +19 -0
- data/lib/iyzipay/model/sub_merchant.rb +72 -0
- data/lib/iyzipay/model/sub_merchant_type.rb +9 -0
- data/lib/iyzipay/model/threeds_initialize.rb +32 -0
- data/lib/iyzipay/model/threeds_initialize_pre_auth.rb +32 -0
- data/lib/iyzipay/model/threeds_payment.rb +34 -0
- data/lib/iyzipay/model/v2/checkout_form.rb +20 -0
- data/lib/iyzipay/model/v2/checkout_form_initialize.rb +21 -0
- data/lib/iyzipay/model/v2/plan.rb +33 -0
- data/lib/iyzipay/model/v2/product.rb +39 -0
- data/lib/iyzipay/model/v2/subscription.rb +60 -0
- data/lib/iyzipay/model/v2/subscription_initialize.rb +21 -0
- data/lib/iyzipay/model.rb +63 -0
- data/lib/iyzipay/options.rb +7 -0
- data/lib/iyzipay/pki_builder.rb +101 -0
- data/lib/iyzipay.rb +16 -0
- data/spec/api_test_spec.rb +28 -0
- data/spec/approval_spec.rb +41 -0
- data/spec/bin_number_spec.rb +42 -0
- data/spec/bkm_spec.rb +91 -0
- 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 +72 -0
- data/spec/card_storage_spec.rb +153 -0
- data/spec/checkout_form_spec.rb +113 -0
- data/spec/disapproval_spec.rb +47 -0
- data/spec/installment_spec.rb +46 -0
- data/spec/pay_with_iyzico_spec.rb +109 -0
- data/spec/payment_spec.rb +320 -0
- data/spec/pecco_spec.rb +116 -0
- data/spec/refund_spec.rb +76 -0
- data/spec/refund_to_balance_spec.rb +37 -0
- data/spec/retrieve_transactions_spec.rb +55 -0
- data/spec/settlement_to_balance_spec.rb +40 -0
- data/spec/spec_helper.rb +81 -0
- data/spec/spec_options.rb +5 -0
- data/spec/sub_merchant_spec.rb +227 -0
- data/spec/threeds_payment_spec.rb +229 -0
- metadata +226 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Iyzipay
|
4
|
+
module Model
|
5
|
+
module V2
|
6
|
+
class Product < IyzipayResourceV2
|
7
|
+
RESOURCE = '/v2/subscription/products'
|
8
|
+
|
9
|
+
def list(options)
|
10
|
+
header = get_http_header(options, RESOURCE)
|
11
|
+
HttpClient.get_even_on_error(base_url(options), header)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(request, options)
|
15
|
+
data = request.to_json
|
16
|
+
header = get_http_header(options, RESOURCE, data)
|
17
|
+
HttpClient.post_even_on_error(base_url(options), header, data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(request, options)
|
21
|
+
data = request.to_json
|
22
|
+
path = path_for_action(request[:productReferenceCode])
|
23
|
+
header = get_http_header(options, path, data)
|
24
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def base_url(options, path = RESOURCE)
|
30
|
+
"#{options.base_url}#{path}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def path_for_action(*path_args)
|
34
|
+
"#{RESOURCE}#{'/' + path_args.join('/')}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Iyzipay
|
2
|
+
module Model
|
3
|
+
module V2
|
4
|
+
class Subscription < IyzipayResourceV2
|
5
|
+
RESOURCE = '/v2/subscription'
|
6
|
+
def activate(request, options)
|
7
|
+
path = path_for_action(request[:subscriptionReferenceCode], 'subscriptions/activate')
|
8
|
+
data = request.to_json
|
9
|
+
header = get_http_header(options, path, data)
|
10
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def retry(request, options)
|
14
|
+
path = path_for_action('operation/retry')
|
15
|
+
data = request.to_json
|
16
|
+
header = get_http_header(options, path, data)
|
17
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def upgrade(request, options)
|
21
|
+
path = path_for_action('subscriptions', request[:subscriptionReferenceCode], 'upgrade')
|
22
|
+
data = request.to_json
|
23
|
+
header = get_http_header(options, path, data)
|
24
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def cancel(request, options)
|
28
|
+
path = path_for_action('subscriptions', request[:subscriptionReferenceCode], 'cancel')
|
29
|
+
data = request.to_json
|
30
|
+
header = get_http_header(options, path, data)
|
31
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
32
|
+
end
|
33
|
+
|
34
|
+
def details(request, options)
|
35
|
+
path = path_for_action('subscriptions', request[:subscriptionReferenceCode])
|
36
|
+
data = request.to_json
|
37
|
+
header = get_http_header(options, path, data)
|
38
|
+
HttpClient.post_even_on_error(base_url(options, path), header, data)
|
39
|
+
end
|
40
|
+
|
41
|
+
def search(request, options)
|
42
|
+
data = request.to_json
|
43
|
+
path = path_for_action('subscriptions')
|
44
|
+
header = get_http_header(options, path, data)
|
45
|
+
HttpClient.get_even_on_error(base_url(options, RESOURCE), header)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def base_url(options, path = nil)
|
51
|
+
"#{options.base_url}#{path}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def path_for_action(*args)
|
55
|
+
"#{RESOURCE}#{'/' + args.join('/')}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Iyzipay
|
2
|
+
module Model
|
3
|
+
module V2
|
4
|
+
class SubscriptionInitialize < IyzipayResourceV2
|
5
|
+
RESOURCE = '/v2/subscription/initialize'
|
6
|
+
|
7
|
+
def create(request, options)
|
8
|
+
data = request.to_json
|
9
|
+
header = get_http_header(options, RESOURCE, data)
|
10
|
+
HttpClient.post_even_on_error(base_url(options), header, data)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def base_url(options)
|
16
|
+
"#{options.base_url}#{RESOURCE}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Model
|
2
|
+
end
|
3
|
+
|
4
|
+
require_relative 'model/address'
|
5
|
+
require_relative 'model/api_test'
|
6
|
+
require_relative 'model/approval'
|
7
|
+
require_relative 'model/basic_bkm'
|
8
|
+
require_relative 'model/basic_bkm_initialize'
|
9
|
+
require_relative 'model/basic_payment'
|
10
|
+
require_relative 'model/basic_payment_post_auth'
|
11
|
+
require_relative 'model/basic_payment_pre_auth'
|
12
|
+
require_relative 'model/basic_threeds_initialize'
|
13
|
+
require_relative 'model/basic_threeds_initialize_pre_auth'
|
14
|
+
require_relative 'model/basic_threeds_payment'
|
15
|
+
require_relative 'model/basket'
|
16
|
+
require_relative 'model/basket_item_type'
|
17
|
+
require_relative 'model/bin_number'
|
18
|
+
require_relative 'model/bkm'
|
19
|
+
require_relative 'model/bkm_initialize'
|
20
|
+
require_relative 'model/bounced_bank_transfer_list'
|
21
|
+
require_relative 'model/buyer'
|
22
|
+
require_relative 'model/card'
|
23
|
+
require_relative 'model/card_information'
|
24
|
+
require_relative 'model/card_list'
|
25
|
+
require_relative 'model/cancel'
|
26
|
+
require_relative 'model/checkout_form'
|
27
|
+
require_relative 'model/checkout_form_initialize'
|
28
|
+
require_relative 'model/checkout_form_initialize_pre_auth'
|
29
|
+
require_relative 'model/cross_booking_from_sub_merchant'
|
30
|
+
require_relative 'model/cross_booking_to_sub_merchant'
|
31
|
+
require_relative 'model/disapproval'
|
32
|
+
require_relative 'model/installment_details'
|
33
|
+
require_relative 'model/installment_info'
|
34
|
+
require_relative 'model/installment_prices'
|
35
|
+
require_relative 'model/locale'
|
36
|
+
require_relative 'model/payment'
|
37
|
+
require_relative 'model/payment_card'
|
38
|
+
require_relative 'model/payment_channel'
|
39
|
+
require_relative 'model/payment_group'
|
40
|
+
require_relative 'model/payment_post_auth'
|
41
|
+
require_relative 'model/payment_pre_auth'
|
42
|
+
require_relative 'model/payout_completed_transaction_list'
|
43
|
+
require_relative 'model/pecco_initialize'
|
44
|
+
require_relative 'model/pecco_payment'
|
45
|
+
require_relative 'model/refund'
|
46
|
+
require_relative 'model/refund_charged_from_merchant'
|
47
|
+
require_relative 'model/sub_merchant'
|
48
|
+
require_relative 'model/sub_merchant_type'
|
49
|
+
require_relative 'model/threeds_initialize'
|
50
|
+
require_relative 'model/threeds_initialize_pre_auth'
|
51
|
+
require_relative 'model/threeds_payment'
|
52
|
+
require_relative 'model/currency'
|
53
|
+
require_relative 'model/refund_reason'
|
54
|
+
require_relative 'model/settlement_to_balance'
|
55
|
+
require_relative 'model/refund_to_balance'
|
56
|
+
require_relative 'model/pay_with_iyzico_initialize'
|
57
|
+
require_relative 'model/pay_with_iyzico_retrieve'
|
58
|
+
require_relative 'model/v2/checkout_form'
|
59
|
+
require_relative 'model/v2/checkout_form_initialize'
|
60
|
+
require_relative 'model/v2/plan'
|
61
|
+
require_relative 'model/v2/product'
|
62
|
+
require_relative 'model/v2/subscription'
|
63
|
+
require_relative 'model/v2/subscription_initialize'
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Iyzipay
|
2
|
+
class PkiBuilder
|
3
|
+
attr_accessor :request_string
|
4
|
+
|
5
|
+
def initialize(request_string = '')
|
6
|
+
@request_string = request_string
|
7
|
+
end
|
8
|
+
|
9
|
+
def append_super(super_request_string)
|
10
|
+
unless super_request_string.nil?
|
11
|
+
|
12
|
+
s = super_request_string[1..-2]
|
13
|
+
if s.length > 0
|
14
|
+
result = @request_string + s
|
15
|
+
result << ','
|
16
|
+
end
|
17
|
+
@request_string = result
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def append(key, value = nil)
|
23
|
+
unless value.nil?
|
24
|
+
append_key_value(key, value)
|
25
|
+
end
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def append_price(key, value = nil)
|
30
|
+
unless value.nil?
|
31
|
+
append_key_value(key, format_price(value))
|
32
|
+
end
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def append_array(key, array = nil)
|
37
|
+
unless array.nil?
|
38
|
+
appended_value = ''
|
39
|
+
array.each do |value|
|
40
|
+
appended_value << value.to_s
|
41
|
+
appended_value << ', '
|
42
|
+
end
|
43
|
+
end
|
44
|
+
append_key_value_array(key, appended_value)
|
45
|
+
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def append_key_value(key, value)
|
50
|
+
@request_string = "#{@request_string}#{key}=#{value}," unless value.nil?
|
51
|
+
end
|
52
|
+
|
53
|
+
def append_key_value_array(key, value)
|
54
|
+
unless value.nil?
|
55
|
+
sub = ', '
|
56
|
+
value = value.gsub(/[#{sub}]+$/, '')
|
57
|
+
@request_string = "#{@request_string}#{key}=[#{value}],"
|
58
|
+
end
|
59
|
+
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def append_prefix
|
64
|
+
@request_string = "[#{@request_string}]"
|
65
|
+
end
|
66
|
+
|
67
|
+
def remove_trailing_comma
|
68
|
+
sub = ','
|
69
|
+
@request_string = @request_string.gsub(/[#{sub}]+$/, '')
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_request_string
|
73
|
+
remove_trailing_comma
|
74
|
+
append_prefix
|
75
|
+
|
76
|
+
@request_string
|
77
|
+
end
|
78
|
+
|
79
|
+
def format_price(price)
|
80
|
+
unless price.include? '.'
|
81
|
+
price = price+'.0'
|
82
|
+
end
|
83
|
+
sub_str_index = 0
|
84
|
+
price_reversed = price.reverse
|
85
|
+
i=0
|
86
|
+
while i < price.size do
|
87
|
+
if price_reversed[i] == '0'
|
88
|
+
sub_str_index = i + 1
|
89
|
+
elsif price_reversed[i] == '.'
|
90
|
+
price_reversed = '0' + price_reversed
|
91
|
+
break
|
92
|
+
else
|
93
|
+
break
|
94
|
+
end
|
95
|
+
i+=1
|
96
|
+
end
|
97
|
+
(price_reversed[sub_str_index..-1]).reverse
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
data/lib/iyzipay.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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/iyzipay_resource_v2'
|
15
|
+
require_relative 'iyzipay/model'
|
16
|
+
require_relative 'iyzipay/options'
|
@@ -0,0 +1,28 @@
|
|
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 test api' do
|
14
|
+
api_test = Iyzipay::Model::ApiTest.new.retrieve(@options)
|
15
|
+
begin
|
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
|
20
|
+
rescue
|
21
|
+
$stderr.puts 'oops'
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
after :each do
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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
|
+
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
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
after :each do
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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 bin number' do
|
14
|
+
request = {
|
15
|
+
locale: Iyzipay::Model::Locale::TR,
|
16
|
+
conversationId: '123456789',
|
17
|
+
binNumber: '554960'
|
18
|
+
}
|
19
|
+
bin_number = Iyzipay::Model::BinNumber.new.retrieve(request, @options)
|
20
|
+
begin
|
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)
|
34
|
+
rescue
|
35
|
+
$stderr.puts 'oops'
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
after :each do
|
41
|
+
end
|
42
|
+
end
|
data/spec/bkm_spec.rb
ADDED
@@ -0,0 +1,91 @@
|
|
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 initialize bkm' do
|
14
|
+
buyer = {
|
15
|
+
id: 'BY789',
|
16
|
+
name: 'John',
|
17
|
+
surname: 'Doe',
|
18
|
+
gsmNumber: '+905350000000',
|
19
|
+
email: 'email@email.com',
|
20
|
+
identityNumber: '74300864791',
|
21
|
+
lastLoginDate: '2015-10-05 12:43:35',
|
22
|
+
registrationDate: '2013-04-21 15:12:09',
|
23
|
+
registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
24
|
+
ip: '85.34.78.112',
|
25
|
+
city: 'Istanbul',
|
26
|
+
country: 'Turkey',
|
27
|
+
zipCode: '34732'
|
28
|
+
}
|
29
|
+
address = {
|
30
|
+
contactName: 'Jane Doe',
|
31
|
+
city: 'Istanbul',
|
32
|
+
country: 'Turkey',
|
33
|
+
address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1',
|
34
|
+
zipCode: '34732'
|
35
|
+
}
|
36
|
+
|
37
|
+
item1 = {
|
38
|
+
id: 'BI101',
|
39
|
+
name: 'Binocular',
|
40
|
+
category1: 'Collectibles',
|
41
|
+
category2: 'Accessories',
|
42
|
+
itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
|
43
|
+
price: '0.3'
|
44
|
+
}
|
45
|
+
item2 = {
|
46
|
+
id: 'BI102',
|
47
|
+
name: 'Game code',
|
48
|
+
category1: 'Game',
|
49
|
+
category2: 'Online Game Items',
|
50
|
+
itemType: Iyzipay::Model::BasketItemType::VIRTUAL,
|
51
|
+
price: '0.5'
|
52
|
+
}
|
53
|
+
item3 = {
|
54
|
+
id: 'BI103',
|
55
|
+
name: 'Usb',
|
56
|
+
category1: 'Electronics',
|
57
|
+
category2: 'Usb / Cable',
|
58
|
+
itemType: Iyzipay::Model::BasketItemType::PHYSICAL,
|
59
|
+
price: '0.2'
|
60
|
+
}
|
61
|
+
request = {
|
62
|
+
locale: Iyzipay::Model::Locale::TR,
|
63
|
+
conversationId: '123456789',
|
64
|
+
price: '1',
|
65
|
+
basketId: 'B67832',
|
66
|
+
paymentGroup: Iyzipay::Model::PaymentGroup::LISTING,
|
67
|
+
callbackUrl: 'https://www.merchant.com/callback',
|
68
|
+
enabledInstallments: [2, 3, 6, 9],
|
69
|
+
buyer: buyer,
|
70
|
+
billingAddress: address,
|
71
|
+
shippingAddress: address,
|
72
|
+
basketItems: [item1, item2, item3]
|
73
|
+
}
|
74
|
+
bkm_initialize = Iyzipay::Model::BkmInitialize.new.create(request, @options)
|
75
|
+
|
76
|
+
begin
|
77
|
+
bkm_initialize_dict = JSON.parse(bkm_initialize)
|
78
|
+
|
79
|
+
unless bkm_initialize_dict['htmlContent'].nil?
|
80
|
+
expect(Base64.decode64(bkm_initialize_dict['htmlContent'])).not_to be_nil
|
81
|
+
end
|
82
|
+
rescue
|
83
|
+
$stderr.puts 'oops'
|
84
|
+
raise
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
after :each do
|
90
|
+
end
|
91
|
+
end
|
@@ -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
|