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,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
@@ -0,0 +1,8 @@
1
+ module Iyzipay
2
+ module Model
3
+ module BasketItemType
4
+ PHYSICAL = 'PHYSICAL'
5
+ VIRTUAL = 'VIRTUAL'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BinNumber < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/bin/check", 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(:binNumber, request[:binNumber]).
13
+ get_request_string
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Bkm < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/bkm/auth/ecom/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,26 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BkmInitialize < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/bkm/initialize/ecom", 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(:basketId, request[:basketId]).
14
+ append(:paymentGroup, request[:paymentGroup]).
15
+ append(:buyer, Buyer.to_pki_string(request[:buyer])).
16
+ append(:shippingAddress, Address.to_pki_string(request[:shippingAddress])).
17
+ append(:billingAddress, Address.to_pki_string(request[:billingAddress])).
18
+ append_array(:basketItems, Basket.to_pki_string(request[:basketItems])).
19
+ append(:callbackUrl, request[:callbackUrl]).
20
+ append(:paymentSource, request[:paymentSource]).
21
+ append_array(:enabledInstallments, request[:enabledInstallments]).
22
+ get_request_string
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class BouncedBankTransferList < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/reporting/settlement/bounced", 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(:date, request[:date]).
13
+ get_request_string
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Buyer
4
+ def self.to_pki_string(request)
5
+ unless request.nil?
6
+ PkiBuilder.new.
7
+ append(:id, request[:id]).
8
+ append(:name, request[:name]).
9
+ append(:surname, request[:surname]).
10
+ append(:identityNumber, request[:identityNumber]).
11
+ append(:email, request[:email]).
12
+ append(:gsmNumber, request[:gsmNumber]).
13
+ append(:registrationDate, request[:registrationDate]).
14
+ append(:lastLoginDate, request[:lastLoginDate]).
15
+ append(:registrationAddress, request[:registrationAddress]).
16
+ append(:city, request[:city]).
17
+ append(:country, request[:country]).
18
+ append(:zipCode, request[:zipCode]).
19
+ append(:ip, request[:ip]).
20
+ get_request_string
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Cancel < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/cancel", 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(:reason, request[:reason]).
15
+ append(:description, request[:description]).
16
+ get_request_string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Card < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string_create(request)
7
+ HttpClient.post("#{options.base_url}/cardstorage/card", get_http_header(pki_string, options), request.to_json)
8
+ end
9
+
10
+ def delete(request = {}, options)
11
+ pki_string = to_pki_string_delete(request)
12
+ HttpClient.delete("#{options.base_url}/cardstorage/card", get_http_header(pki_string, options), request.to_json)
13
+ end
14
+
15
+ def to_pki_string_create(request)
16
+ PkiBuilder.new.
17
+ append(:locale, request[:locale]).
18
+ append(:conversationId, request[:conversationId]).
19
+ append(:externalId, request[:externalId]).
20
+ append(:email, request[:email]).
21
+ append(:cardUserKey, request[:cardUserKey]).
22
+ append(:card, CardInformation.to_pki_string(request[:card])).
23
+ get_request_string
24
+ end
25
+
26
+ def to_pki_string_delete(request)
27
+ PkiBuilder.new.
28
+ append(:locale, request[:locale]).
29
+ append(:conversationId, request[:conversationId]).
30
+ append(:cardUserKey, request[:cardUserKey]).
31
+ append(:cardToken, request[:cardToken]).
32
+ get_request_string
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CardInformation
4
+ def self.to_pki_string(request)
5
+ unless request.nil?
6
+ PkiBuilder.new.
7
+ append(:cardAlias, request[:cardAlias]).
8
+ append(:cardNumber, request[:cardNumber]).
9
+ append(:expireYear, request[:expireYear]).
10
+ append(:expireMonth, request[:expireMonth]).
11
+ append(:cardHolderName, request[:cardHolderName]).
12
+ get_request_string
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CardList < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/cardstorage/cards", 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(:cardUserKey, request[:cardUserKey]).
13
+ get_request_string
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CheckoutForm < IyzipayResource
4
+
5
+ def retrieve(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/checkoutform/auth/ecom/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,31 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CheckoutFormInitialize < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/checkoutform/initialize/ecom", 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(:basketId, request[:basketId]).
14
+ append(:paymentGroup, request[:paymentGroup]).
15
+ append(:buyer, Buyer.to_pki_string(request[:buyer])).
16
+ append(:shippingAddress, Address.to_pki_string(request[:shippingAddress])).
17
+ append(:billingAddress, Address.to_pki_string(request[:billingAddress])).
18
+ append_array(:basketItems, Basket.to_pki_string(request[:basketItems])).
19
+ append(:callbackUrl, request[:callbackUrl]).
20
+ append(:paymentSource, request[:paymentSource]).
21
+ append(:currency, request[:currency]).
22
+ append(:posOrderId, request[:posOrderId]).
23
+ append_price(:paidPrice, request[:paidPrice]).
24
+ append(:forceThreeDS, request[:forceThreeDS]).
25
+ append(:cardUserKey, request[:cardUserKey]).
26
+ append_array(:enabledInstallments, request[:enabledInstallments]).
27
+ get_request_string
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CheckoutFormInitializePreAuth < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/checkoutform/initialize/preauth/ecom", 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(:basketId, request[:basketId]).
14
+ append(:paymentGroup, request[:paymentGroup]).
15
+ append(:buyer, Buyer.to_pki_string(request[:buyer])).
16
+ append(:shippingAddress, Address.to_pki_string(request[:shippingAddress])).
17
+ append(:billingAddress, Address.to_pki_string(request[:billingAddress])).
18
+ append_array(:basketItems, Basket.to_pki_string(request[:basketItems])).
19
+ append(:callbackUrl, request[:callbackUrl]).
20
+ append(:paymentSource, request[:paymentSource]).
21
+ append(:posOrderId, request[:posOrderId]).
22
+ append_price(:paidPrice, request[:paidPrice]).
23
+ append(:forceThreeDS, request[:forceThreeDS]).
24
+ append(:cardUserKey, request[:cardUserKey]).
25
+ append_array(:enabledInstallments, request[:enabledInstallments]).
26
+ get_request_string
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CrossBookingFromSubMerchant < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/crossbooking/receive", 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(:subMerchantKey, request[:subMerchantKey]).
13
+ append_price(:price, request[:price]).
14
+ append(:reason, request[:reason]).
15
+ append(:currency, request[:currency]).
16
+ get_request_string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Iyzipay
2
+ module Model
3
+ class CrossBookingToSubMerchant < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/crossbooking/send", 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(:subMerchantKey, request[:subMerchantKey]).
13
+ append_price(:price, request[:price]).
14
+ append(:reason, request[:reason]).
15
+ append(:currency, request[:currency]).
16
+ get_request_string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module Iyzipay
2
+ module Model
3
+ module Currency
4
+ TRY = 'TRY'
5
+ EUR = 'EUR'
6
+ USD = 'USD'
7
+ GBP = 'GBP'
8
+ IRR = 'IRR'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ module Iyzipay
2
+ module Model
3
+ class Disapproval < IyzipayResource
4
+
5
+ def create(request = {}, options)
6
+ pki_string = to_pki_string(request)
7
+ HttpClient.post("#{options.base_url}/payment/iyzipos/item/disapprove", 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