checkout_sdk 0.3.2 → 1.0.0.beta.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 (257) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +31 -0
  3. data/CODE_OF_CONDUCT.md +84 -0
  4. data/Gemfile +5 -2
  5. data/LICENSE.md +9 -0
  6. data/README.md +96 -110
  7. data/Rakefile +3 -1
  8. data/lib/checkout_sdk/abstract_checkout_sdk_builder.rb +28 -0
  9. data/lib/checkout_sdk/api_client.rb +135 -0
  10. data/lib/checkout_sdk/apm/apm.rb +12 -0
  11. data/lib/checkout_sdk/apm/ideal/ideal_client.rb +25 -0
  12. data/lib/checkout_sdk/apm/previous/klarna/credit_session_request.rb +30 -0
  13. data/lib/checkout_sdk/apm/previous/klarna/klarna.rb +24 -0
  14. data/lib/checkout_sdk/apm/previous/klarna/klarna_client.rb +55 -0
  15. data/lib/checkout_sdk/apm/previous/klarna/klarna_product.rb +30 -0
  16. data/lib/checkout_sdk/apm/previous/klarna/klarna_shipping_info.rb +33 -0
  17. data/lib/checkout_sdk/apm/previous/klarna/order_capture_request.rb +37 -0
  18. data/lib/checkout_sdk/apm/previous/sepa/sepa_client.rb +42 -0
  19. data/lib/checkout_sdk/authorization_type.rb +12 -0
  20. data/lib/checkout_sdk/checkout_api.rb +51 -0
  21. data/lib/checkout_sdk/checkout_configuration.rb +22 -0
  22. data/lib/checkout_sdk/checkout_oauth_sdk_builder.rb +52 -0
  23. data/lib/checkout_sdk/checkout_sdk_builder.rb +20 -0
  24. data/lib/checkout_sdk/checkout_static_keys_sdk_builder.rb +23 -0
  25. data/lib/checkout_sdk/checkout_utils.rb +15 -0
  26. data/lib/checkout_sdk/client.rb +46 -0
  27. data/lib/checkout_sdk/common/abstract_file_request.rb +11 -0
  28. data/lib/checkout_sdk/common/account_holder.rb +44 -0
  29. data/lib/checkout_sdk/common/account_holder_identification.rb +20 -0
  30. data/lib/checkout_sdk/common/account_holder_identification_type.rb +13 -0
  31. data/lib/checkout_sdk/common/account_holder_type.rb +11 -0
  32. data/lib/checkout_sdk/common/account_type.rb +11 -0
  33. data/lib/checkout_sdk/common/address.rb +26 -0
  34. data/lib/checkout_sdk/common/amount_allocations.rb +20 -0
  35. data/lib/checkout_sdk/common/bank_details.rb +17 -0
  36. data/lib/checkout_sdk/common/challenge_indicator.rb +12 -0
  37. data/lib/checkout_sdk/common/commission.rb +14 -0
  38. data/lib/checkout_sdk/common/common.rb +22 -0
  39. data/lib/checkout_sdk/common/country.rb +260 -0
  40. data/lib/checkout_sdk/common/currency.rb +168 -0
  41. data/lib/checkout_sdk/common/customer_request.rb +26 -0
  42. data/lib/checkout_sdk/common/file_purpose.rb +9 -0
  43. data/lib/checkout_sdk/common/file_request.rb +11 -0
  44. data/lib/checkout_sdk/common/instrument_type.rb +11 -0
  45. data/lib/checkout_sdk/common/payment_source_type.rb +52 -0
  46. data/lib/checkout_sdk/common/phone.rb +14 -0
  47. data/lib/checkout_sdk/common/update_customer_request.rb +14 -0
  48. data/lib/checkout_sdk/customers/customer_request.rb +26 -0
  49. data/lib/checkout_sdk/customers/customers.rb +4 -0
  50. data/lib/checkout_sdk/customers/customers_client.rb +37 -0
  51. data/lib/checkout_sdk/disputes/dispute_evidence_request.rb +60 -0
  52. data/lib/checkout_sdk/disputes/dispute_status.rb +19 -0
  53. data/lib/checkout_sdk/disputes/disputes.rb +6 -0
  54. data/lib/checkout_sdk/disputes/disputes_client.rb +55 -0
  55. data/lib/checkout_sdk/disputes/disputes_query_filter.rb +47 -0
  56. data/lib/checkout_sdk/environment.rb +59 -0
  57. data/lib/checkout_sdk/error.rb +30 -0
  58. data/lib/checkout_sdk/forex/forex.rb +4 -0
  59. data/lib/checkout_sdk/forex/forex_client.rb +21 -0
  60. data/lib/checkout_sdk/forex/quote_request.rb +23 -0
  61. data/lib/checkout_sdk/http_metadata.rb +9 -0
  62. data/lib/checkout_sdk/instruments/create/instrument_bank_account_request.rb +51 -0
  63. data/lib/checkout_sdk/instruments/create/instrument_request.rb +17 -0
  64. data/lib/checkout_sdk/instruments/create/instrument_token_request.rb +21 -0
  65. data/lib/checkout_sdk/instruments/get/bank_account_field_query.rb +14 -0
  66. data/lib/checkout_sdk/instruments/get/payment_network.rb +14 -0
  67. data/lib/checkout_sdk/instruments/instruments.rb +15 -0
  68. data/lib/checkout_sdk/instruments/instruments_client.rb +49 -0
  69. data/lib/checkout_sdk/instruments/update/update_instrument_bank_account_request.rb +51 -0
  70. data/lib/checkout_sdk/instruments/update/update_instrument_card_request.rb +27 -0
  71. data/lib/checkout_sdk/instruments/update/update_instrument_request.rb +17 -0
  72. data/lib/checkout_sdk/instruments/update/update_instrument_token_request.rb +15 -0
  73. data/lib/checkout_sdk/json_serializer.rb +54 -0
  74. data/lib/checkout_sdk/oauth_access_token.rb +27 -0
  75. data/lib/checkout_sdk/oauth_scopes.rb +41 -0
  76. data/lib/checkout_sdk/oauth_sdk_credentials.rb +112 -0
  77. data/lib/checkout_sdk/payments/airline_data.rb +17 -0
  78. data/lib/checkout_sdk/payments/authorization_request.rb +17 -0
  79. data/lib/checkout_sdk/payments/authorization_type.rb +11 -0
  80. data/lib/checkout_sdk/payments/billing_descriptor.rb +17 -0
  81. data/lib/checkout_sdk/payments/capture_request.rb +41 -0
  82. data/lib/checkout_sdk/payments/capture_type.rb +10 -0
  83. data/lib/checkout_sdk/payments/charge_bearer.rb +10 -0
  84. data/lib/checkout_sdk/payments/d_local_installments.rb +11 -0
  85. data/lib/checkout_sdk/payments/d_local_processing_settings.rb +17 -0
  86. data/lib/checkout_sdk/payments/destination/bank_account_destination.rb +42 -0
  87. data/lib/checkout_sdk/payments/destination/card_destination.rb +24 -0
  88. data/lib/checkout_sdk/payments/destination/destination.rb +19 -0
  89. data/lib/checkout_sdk/payments/destination/destination_type.rb +12 -0
  90. data/lib/checkout_sdk/payments/destination/id_destination.rb +18 -0
  91. data/lib/checkout_sdk/payments/destination/token_destination.rb +18 -0
  92. data/lib/checkout_sdk/payments/exemption.rb +17 -0
  93. data/lib/checkout_sdk/payments/flight_leg_details.rb +35 -0
  94. data/lib/checkout_sdk/payments/instruction_scheme.rb +11 -0
  95. data/lib/checkout_sdk/payments/merchant_initiated_reason.rb +12 -0
  96. data/lib/checkout_sdk/payments/network_token_type.rb +12 -0
  97. data/lib/checkout_sdk/payments/os_type.rb +10 -0
  98. data/lib/checkout_sdk/payments/passenger.rb +17 -0
  99. data/lib/checkout_sdk/payments/passenger_name.rb +11 -0
  100. data/lib/checkout_sdk/payments/payer.rb +17 -0
  101. data/lib/checkout_sdk/payments/payment_instruction.rb +32 -0
  102. data/lib/checkout_sdk/payments/payment_recipient.rb +20 -0
  103. data/lib/checkout_sdk/payments/payment_request.rb +86 -0
  104. data/lib/checkout_sdk/payments/payment_type.rb +13 -0
  105. data/lib/checkout_sdk/payments/payments.rb +82 -0
  106. data/lib/checkout_sdk/payments/payments_client.rb +86 -0
  107. data/lib/checkout_sdk/payments/payout_billing_descriptor.rb +11 -0
  108. data/lib/checkout_sdk/payments/payout_request.rb +38 -0
  109. data/lib/checkout_sdk/payments/preferred_schema.rb +11 -0
  110. data/lib/checkout_sdk/payments/processing_settings.rb +80 -0
  111. data/lib/checkout_sdk/payments/product.rb +47 -0
  112. data/lib/checkout_sdk/payments/product_type.rb +12 -0
  113. data/lib/checkout_sdk/payments/refund_request.rb +17 -0
  114. data/lib/checkout_sdk/payments/risk_request.rb +11 -0
  115. data/lib/checkout_sdk/payments/sender/corporate_sender.rb +27 -0
  116. data/lib/checkout_sdk/payments/sender/government_sender.rb +27 -0
  117. data/lib/checkout_sdk/payments/sender/individual_sender.rb +42 -0
  118. data/lib/checkout_sdk/payments/sender/instrument_sender.rb +11 -0
  119. data/lib/checkout_sdk/payments/sender/sender.rb +22 -0
  120. data/lib/checkout_sdk/payments/sender/sender_type.rb +12 -0
  121. data/lib/checkout_sdk/payments/sender/source_of_funds.rb +14 -0
  122. data/lib/checkout_sdk/payments/sender/ticket.rb +23 -0
  123. data/lib/checkout_sdk/payments/shipping_details.rb +17 -0
  124. data/lib/checkout_sdk/payments/shipping_preference.rb +11 -0
  125. data/lib/checkout_sdk/payments/source/apm/after_pay_source.rb +15 -0
  126. data/lib/checkout_sdk/payments/source/apm/alipay_plus_source.rb +47 -0
  127. data/lib/checkout_sdk/payments/source/apm/bancontact_source.rb +24 -0
  128. data/lib/checkout_sdk/payments/source/apm/benefit_source.rb +11 -0
  129. data/lib/checkout_sdk/payments/source/apm/eps_source.rb +15 -0
  130. data/lib/checkout_sdk/payments/source/apm/giropay_source.rb +27 -0
  131. data/lib/checkout_sdk/payments/source/apm/ideal_source.rb +21 -0
  132. data/lib/checkout_sdk/payments/source/apm/knet_source.rb +36 -0
  133. data/lib/checkout_sdk/payments/source/apm/mbway_source.rb +11 -0
  134. data/lib/checkout_sdk/payments/source/apm/multi_banco_source.rb +21 -0
  135. data/lib/checkout_sdk/payments/source/apm/p24_source.rb +24 -0
  136. data/lib/checkout_sdk/payments/source/apm/paypal_source.rb +11 -0
  137. data/lib/checkout_sdk/payments/source/apm/post_finance_source.rb +21 -0
  138. data/lib/checkout_sdk/payments/source/apm/qpay_source.rb +24 -0
  139. data/lib/checkout_sdk/payments/source/apm/sofort_source.rb +18 -0
  140. data/lib/checkout_sdk/payments/source/apm/stcpay_source.rb +11 -0
  141. data/lib/checkout_sdk/payments/source/apm/tamara_source.rb +15 -0
  142. data/lib/checkout_sdk/payments/source/apm/we_chat_pay_source.rb +15 -0
  143. data/lib/checkout_sdk/payments/source/bank_account_source.rb +30 -0
  144. data/lib/checkout_sdk/payments/source/card_source.rb +39 -0
  145. data/lib/checkout_sdk/payments/source/currency_account_source.rb +15 -0
  146. data/lib/checkout_sdk/payments/source/id_source.rb +21 -0
  147. data/lib/checkout_sdk/payments/source/network_token_source.rb +45 -0
  148. data/lib/checkout_sdk/payments/source/payment_request_source.rb +18 -0
  149. data/lib/checkout_sdk/payments/source/payout_request_source.rb +22 -0
  150. data/lib/checkout_sdk/payments/source/payout_source_type.rb +9 -0
  151. data/lib/checkout_sdk/payments/source/provider_token_source.rb +21 -0
  152. data/lib/checkout_sdk/payments/source/token_source.rb +24 -0
  153. data/lib/checkout_sdk/payments/terminal_type.rb +11 -0
  154. data/lib/checkout_sdk/payments/three_ds_flow_type.rb +11 -0
  155. data/lib/checkout_sdk/payments/three_ds_request.rb +56 -0
  156. data/lib/checkout_sdk/payments/user_action.rb +10 -0
  157. data/lib/checkout_sdk/payments/void_request.rb +14 -0
  158. data/lib/checkout_sdk/platform_type.rb +10 -0
  159. data/lib/checkout_sdk/previous/checkout_api.rb +29 -0
  160. data/lib/checkout_sdk/previous/checkout_previous_sdk_builder.rb +11 -0
  161. data/lib/checkout_sdk/previous/checkout_previous_static_keys_sdk_builder.rb +24 -0
  162. data/lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb +38 -0
  163. data/lib/checkout_sdk/sdk_authorization.rb +25 -0
  164. data/lib/checkout_sdk/sdk_credentials.rb +12 -0
  165. data/lib/checkout_sdk/sessions/authentication_method.rb +14 -0
  166. data/lib/checkout_sdk/sessions/authentication_type.rb +10 -0
  167. data/lib/checkout_sdk/sessions/card_holder_account_info.rb +32 -0
  168. data/lib/checkout_sdk/sessions/category.rb +10 -0
  169. data/lib/checkout_sdk/sessions/channel/app_session.rb +36 -0
  170. data/lib/checkout_sdk/sessions/channel/browser_session.rb +42 -0
  171. data/lib/checkout_sdk/sessions/channel/channel_data.rb +19 -0
  172. data/lib/checkout_sdk/sessions/channel/channel_data_type.rb +10 -0
  173. data/lib/checkout_sdk/sessions/channel/sdk_ephemeral_public_key.rb +19 -0
  174. data/lib/checkout_sdk/sessions/channel/sdk_interface_type.rb +11 -0
  175. data/lib/checkout_sdk/sessions/channel/three_ds_method_completion.rb +11 -0
  176. data/lib/checkout_sdk/sessions/channel/uie_elements.rb +13 -0
  177. data/lib/checkout_sdk/sessions/completion/completion_info.rb +19 -0
  178. data/lib/checkout_sdk/sessions/completion/completion_info_type.rb +10 -0
  179. data/lib/checkout_sdk/sessions/completion/hosted_completion_info.rb +21 -0
  180. data/lib/checkout_sdk/sessions/completion/non_hosted_completion_info.rb +15 -0
  181. data/lib/checkout_sdk/sessions/delivery_timeframe.rb +12 -0
  182. data/lib/checkout_sdk/sessions/installment.rb +17 -0
  183. data/lib/checkout_sdk/sessions/merchant_risk_info.rb +23 -0
  184. data/lib/checkout_sdk/sessions/recurring.rb +14 -0
  185. data/lib/checkout_sdk/sessions/session_address.rb +11 -0
  186. data/lib/checkout_sdk/sessions/session_marketplace_data.rb +11 -0
  187. data/lib/checkout_sdk/sessions/session_request.rb +68 -0
  188. data/lib/checkout_sdk/sessions/session_secret_credentials.rb +28 -0
  189. data/lib/checkout_sdk/sessions/session_source_type.rb +12 -0
  190. data/lib/checkout_sdk/sessions/sessions.rb +47 -0
  191. data/lib/checkout_sdk/sessions/sessions_billing_descriptor.rb +11 -0
  192. data/lib/checkout_sdk/sessions/sessions_client.rb +64 -0
  193. data/lib/checkout_sdk/sessions/shipping_indicator.rb +9 -0
  194. data/lib/checkout_sdk/sessions/source/card_source.rb +30 -0
  195. data/lib/checkout_sdk/sessions/source/id_source.rb +15 -0
  196. data/lib/checkout_sdk/sessions/source/network_token_source.rb +27 -0
  197. data/lib/checkout_sdk/sessions/source/session_scheme.rb +14 -0
  198. data/lib/checkout_sdk/sessions/source/session_source.rb +37 -0
  199. data/lib/checkout_sdk/sessions/source/token_source.rb +18 -0
  200. data/lib/checkout_sdk/sessions/three_ds_method_completion_request.rb +11 -0
  201. data/lib/checkout_sdk/sessions/transaction_type.rb +13 -0
  202. data/lib/checkout_sdk/static_keys_builder.rb +35 -0
  203. data/lib/checkout_sdk/static_keys_sdk_credentials.rb +35 -0
  204. data/lib/checkout_sdk/tokens/apple_pay_token_data.rb +20 -0
  205. data/lib/checkout_sdk/tokens/apple_pay_token_request.rb +15 -0
  206. data/lib/checkout_sdk/tokens/card_token_request.rb +36 -0
  207. data/lib/checkout_sdk/tokens/google_pay_token_data.rb +17 -0
  208. data/lib/checkout_sdk/tokens/google_pay_token_request.rb +15 -0
  209. data/lib/checkout_sdk/tokens/token_type.rb +11 -0
  210. data/lib/checkout_sdk/tokens/tokens.rb +10 -0
  211. data/lib/checkout_sdk/tokens/tokens_client.rb +21 -0
  212. data/lib/checkout_sdk/tokens/wallet_token_request.rb +19 -0
  213. data/lib/checkout_sdk/version.rb +3 -1
  214. data/lib/checkout_sdk.rb +59 -21
  215. data/sig/checkout_sdk.rbs +4 -0
  216. metadata +254 -81
  217. data/.gitignore +0 -11
  218. data/.travis.yml +0 -7
  219. data/Gemfile.lock +0 -45
  220. data/LICENSE +0 -21
  221. data/bin/console +0 -14
  222. data/bin/setup +0 -8
  223. data/checkout_sdk.gemspec +0 -24
  224. data/documentation/.gitignore +0 -20
  225. data/documentation/docs/environment.md +0 -26
  226. data/documentation/docs/getting_started.md +0 -48
  227. data/documentation/docs/initialize.md +0 -19
  228. data/documentation/docs/install.md +0 -21
  229. data/documentation/docs/payments.md +0 -200
  230. data/documentation/docs/sources.md +0 -53
  231. data/documentation/docs/tokens.md +0 -88
  232. data/documentation/docusaurus.config.js +0 -60
  233. data/documentation/package-lock.json +0 -13511
  234. data/documentation/package.json +0 -32
  235. data/documentation/sidebars.js +0 -10
  236. data/documentation/src/css/custom.css +0 -103
  237. data/documentation/src/pages/index.js +0 -10
  238. data/documentation/src/pages/styles.module.css +0 -37
  239. data/documentation/static/img/favicon.png +0 -0
  240. data/documentation/static/img/logo.png +0 -0
  241. data/documentation/static/img/undraw_docusaurus_mountain.svg +0 -170
  242. data/documentation/static/img/undraw_docusaurus_react.svg +0 -169
  243. data/documentation/static/img/undraw_docusaurus_tree.svg +0 -1
  244. data/documentation/yarn.lock +0 -9369
  245. data/lib/checkout_sdk/api_resource.rb +0 -77
  246. data/lib/checkout_sdk/configuration.rb +0 -10
  247. data/lib/checkout_sdk/data/capture_payment.rb +0 -11
  248. data/lib/checkout_sdk/data/payment_request_source.rb +0 -145
  249. data/lib/checkout_sdk/data/payment_source.rb +0 -40
  250. data/lib/checkout_sdk/data/refund_payment.rb +0 -11
  251. data/lib/checkout_sdk/data/request_token.rb +0 -67
  252. data/lib/checkout_sdk/data/void_payment.rb +0 -10
  253. data/spec/checkout_sdk/api_resource_spec.rb +0 -126
  254. data/spec/checkout_sdk/data/payment_request_source_spec.rb +0 -126
  255. data/spec/checkout_sdk/data/request_token_spec.rb +0 -107
  256. data/spec/checkout_sdk_spec.rb +0 -21
  257. data/spec/spec_helper.rb +0 -32
@@ -1,77 +0,0 @@
1
- require "excon"
2
- require "multi_json"
3
-
4
- class CheckoutSdk::ApiResource
5
- attr_reader :checkout_connection
6
-
7
- def initialize
8
- @checkout_connection = Excon.new(
9
- "#{CheckoutSdk.configuration.base_url}",
10
- persistent: CheckoutSdk.configuration.persistent
11
- )
12
- end
13
-
14
- def request_payment(data_object)
15
- post_request("/payments", data_object.data)
16
- end
17
-
18
- def capture_payment(data_object)
19
- post_request("/payments/#{data_object.id}/captures", data_object.data)
20
- end
21
-
22
- def refund_payment(data_object)
23
- post_request("/payments/#{data_object.id}/refunds", data_object.data)
24
- end
25
-
26
- def void_payment(data_object)
27
- post_request("/payments/#{data_object.id}/voids", data_object.data)
28
- end
29
-
30
- def add_payment_source(data_object)
31
- post_request("/sources", data_object.data)
32
- end
33
-
34
- def request_token(data_object)
35
- post_request("/tokens", data_object.data)
36
- end
37
-
38
- def get_payment_details(id)
39
- get("/payments/#{id}")
40
- end
41
-
42
- def get_payment_actions(id)
43
- get("/payments/#{id}/actions")
44
- end
45
-
46
- private
47
-
48
- def post_request(path, data)
49
- checkout_connection.post(
50
- path: path,
51
- body: MultiJson.dump(delete_blank(data)),
52
- headers: { "Content-Type" => "application/json",
53
- "Authorization" => key(path) }
54
- )
55
- end
56
-
57
- def get(path)
58
- checkout_connection.get(
59
- path: path,
60
- headers: { "Authorization" => CheckoutSdk.configuration.secret_key }
61
- )
62
- end
63
-
64
- def key(path)
65
- if path == "/tokens"
66
- CheckoutSdk.configuration.public_key
67
- else
68
- CheckoutSdk.configuration.secret_key
69
- end
70
- end
71
-
72
- def delete_blank(data_hash)
73
- data_hash.delete_if do |k, v|
74
- (v.respond_to?(:empty?) ? v.empty? : v.nil?) or v.instance_of?(Hash) && delete_blank(v).empty?
75
- end
76
- end
77
- end
@@ -1,10 +0,0 @@
1
- class CheckoutSdk::Configuration
2
- attr_accessor :secret_key, :public_key, :base_url, :persistent
3
-
4
- def initialize
5
- @secret_key = nil
6
- @public_key = nil
7
- @base_url = nil
8
- @persistent = true
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- class CheckoutSdk::CapturePayment
2
- attr_accessor :id, :amount, :reference, :metadata
3
-
4
- def data
5
- {
6
- amount: amount,
7
- reference: reference,
8
- metadata: metadata
9
- }
10
- end
11
- end
@@ -1,145 +0,0 @@
1
- class CheckoutSdk::PaymentRequestSource
2
- attr_accessor :type, :token, :billing_address_line1, :billing_address_line2, :billing_city, :billing_state,
3
- :billing_zip, :billing_country, :phone_country_code, :phone_number, :amount,
4
- :currency, :payment_type, :reference, :description, :capture, :capture_on, :customer_id,
5
- :customer_email, :customer_name, :billing_descriptor, :billing_descriptor_name,
6
- :billing_descriptor_city, :shipping_address_line1, :shipping_address_line2, :shipping_city,
7
- :shipping_state, :shipping_zip, :shipping_country, :shipping_phone_country_code,
8
- :shipping_phone_number, :threeds_enabled, :threeds_attempt_n3d, :threeds_eci,
9
- :threeds_cryptogram, :threeds_xid, :threeds_version, :previous_payment_id, :risk_enabled,
10
- :success_url, :failure_url, :payment_ip, :recipient_dob, :recipient_account_number,
11
- :recipient_zip, :recipient_last_name, :processing_mid, :metadata, :cvv, :id, :card_number,
12
- :card_expiry_month, :card_expiry_year, :card_name, :card_cvv, :card_stored, :customer_id,
13
- :customer_email, :merchant_initiated
14
-
15
- def data
16
- { source: source(type),
17
- amount: amount,
18
- currency: currency,
19
- payment_type: payment_type,
20
- merchant_initiated: merchant_initiated,
21
- reference: reference,
22
- description: description,
23
- capture: capture,
24
- capture_on: capture_on,
25
- customer: {
26
- id: customer_id,
27
- email: customer_email,
28
- name: customer_name
29
- },
30
- billing_descriptor: {
31
- name: billing_descriptor_name,
32
- city: billing_descriptor_city
33
- },
34
- shipping: {
35
- address: {
36
- address_line1: shipping_address_line1,
37
- address_line2: shipping_address_line2,
38
- city: shipping_city,
39
- state: shipping_state,
40
- zip: shipping_zip,
41
- country: shipping_country
42
- },
43
- phone: {
44
- country_code: shipping_phone_country_code,
45
- number: shipping_phone_number
46
- }
47
- },
48
- "3ds" => {
49
- enabled: threeds_enabled,
50
- attempt_n3d: threeds_attempt_n3d,
51
- eci: threeds_eci,
52
- cryptogram: threeds_cryptogram,
53
- xid: threeds_xid,
54
- version: threeds_version
55
- },
56
- previous_payment_id: previous_payment_id,
57
- risk: {
58
- enabled: risk_enabled
59
- },
60
- success_url: success_url,
61
- failure_url: failure_url,
62
- payment_ip: payment_ip,
63
- recipient: {
64
- dob: recipient_dob,
65
- account_number: recipient_account_number,
66
- zip: recipient_zip,
67
- last_name: recipient_last_name
68
- },
69
- processing: {
70
- mid: processing_mid
71
- },
72
- metadata: metadata
73
- }
74
- end
75
-
76
- private
77
-
78
- def source(type)
79
- case type
80
- when "id" then id_type
81
- when "token" then token_type
82
- when "card" then card_type
83
- when "customer" then customer_type
84
- end
85
- end
86
-
87
- def token_type
88
- {
89
- type: type,
90
- token: token,
91
- billing_address: {
92
- address_line1: billing_address_line1,
93
- address_line2: billing_address_line2,
94
- city: billing_city,
95
- state: billing_state,
96
- zip: billing_zip,
97
- country: billing_country
98
- },
99
- phone: {
100
- country_code: phone_country_code,
101
- number: phone_number
102
- },
103
- }
104
- end
105
-
106
- def card_type
107
- {
108
- type: type,
109
- number: card_number,
110
- expiry_month: card_expiry_month,
111
- expiry_year: card_expiry_year,
112
- name: card_name,
113
- cvv: card_cvv,
114
- stored: card_stored,
115
- billing_address: {
116
- address_line1: billing_address_line1,
117
- address_line2: billing_address_line2,
118
- city: billing_city,
119
- state: billing_state,
120
- zip: billing_zip,
121
- country: billing_country
122
- },
123
- phone: {
124
- country_code: phone_country_code,
125
- number: phone_number
126
- },
127
- }
128
- end
129
-
130
- def id_type
131
- {
132
- type: type,
133
- id: id,
134
- cvv: cvv
135
- }
136
- end
137
-
138
- def customer_type
139
- {
140
- type: type,
141
- id: customer_id,
142
- email: customer_email
143
- }
144
- end
145
- end
@@ -1,40 +0,0 @@
1
- class CheckoutSdk::PaymentSource
2
- attr_accessor :type, :reference, :billing_address_line1, :billing_address_line2,
3
- :billing_city, :billing_state, :billing_zip, :billing_country,
4
- :phone_country_code, :phone_number, :customer_id,
5
- :customer_email, :customer_name, :source_data_first_name,
6
- :source_data_last_name, :source_data_account_iban, :source_data_bic,
7
- :source_data_billing_descriptor, :source_data_mandate_type
8
-
9
- def data
10
- {
11
- type: type,
12
- reference: reference,
13
- billing_address: {
14
- address_line1: billing_address_line1,
15
- address_line2: billing_address_line2,
16
- city: billing_city,
17
- state: billing_state,
18
- zip: billing_zip,
19
- country: billing_country
20
- },
21
- phone: {
22
- country_code: phone_country_code,
23
- number: phone_number
24
- },
25
- customer: {
26
- id: customer_id,
27
- email: customer_email,
28
- name: customer_name
29
- },
30
- source_data: {
31
- first_name: source_data_first_name,
32
- last_name: source_data_last_name,
33
- account_iban: source_data_account_iban,
34
- bic: source_data_bic,
35
- billing_descriptor: source_data_billing_descriptor,
36
- mandate_type: source_data_mandate_type
37
- }
38
- }
39
- end
40
- end
@@ -1,11 +0,0 @@
1
- class CheckoutSdk::RefundPayment
2
- attr_accessor :id, :amount, :reference, :metadata
3
-
4
- def data
5
- {
6
- amount: amount,
7
- reference: reference,
8
- metadata: metadata
9
- }
10
- end
11
- end
@@ -1,67 +0,0 @@
1
- class CheckoutSdk::RequestToken
2
- attr_accessor :type, :token_data_version, :token_data_data, :token_data_signature,
3
- :token_data_header, :token_data_signature, :token_data_protocolVersion,
4
- :token_data_signedMessage, :card_number, :card_expiry_month, :card_expiry_year,
5
- :card_name, :card_cvv, :billing_address_line1, :billing_address_line2, :billing_city,
6
- :billing_state, :billing_zip, :billing_country, :phone_country_code, :phone_number
7
-
8
- def data
9
- if type == "card"
10
- card_type
11
- else
12
- {
13
- type: type,
14
- token_data: token_data(type)
15
- }
16
- end
17
- end
18
-
19
- private
20
-
21
- def token_data(type)
22
- case type
23
- when "applepay" then applepay_type
24
- when "googlepay" then googlepay_type
25
- end
26
- end
27
-
28
- def applepay_type
29
- {
30
- version: token_data_version,
31
- data: token_data_data,
32
- signature: token_data_signature,
33
- header: token_data_header
34
- }
35
- end
36
-
37
- def googlepay_type
38
- {
39
- signature: token_data_signature,
40
- protocolVersion: token_data_protocolVersion,
41
- signedMessage: token_data_signedMessage
42
- }
43
- end
44
-
45
- def card_type
46
- {
47
- type: type,
48
- number: card_number,
49
- expiry_month: card_expiry_month,
50
- expiry_year: card_expiry_year,
51
- name: card_name,
52
- cvv: card_cvv,
53
- billing_address: {
54
- address_line1: billing_address_line1,
55
- address_line2: billing_address_line2,
56
- city: billing_city,
57
- state: billing_state,
58
- zip: billing_zip,
59
- country: billing_country
60
- },
61
- phone: {
62
- country_code: phone_country_code,
63
- number: phone_number
64
- }
65
- }
66
- end
67
- end
@@ -1,10 +0,0 @@
1
- class CheckoutSdk::VoidPayment
2
- attr_accessor :id, :reference, :metadata
3
-
4
- def data
5
- {
6
- reference: reference,
7
- metadata: metadata
8
- }
9
- end
10
- end
@@ -1,126 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe CheckoutSdk::ApiResource do
4
- let(:api_resource) { CheckoutSdk::ApiResource.new }
5
-
6
- it "has the expected connection configuration" do
7
- expect(api_resource.checkout_connection.data[:host]).to eql("test.com")
8
- end
9
-
10
- describe "#request_payment" do
11
- let(:payment_request_source) { CheckoutSdk::PaymentRequestSource.new }
12
- let(:data) { { mock: true, mockfalse: false, mockzero: 0, mocknil: nil, mockempty: "" } }
13
-
14
- it "sends a POST request with correct params" do
15
- allow(payment_request_source).to receive(:data).and_return(data)
16
-
17
- expect(api_resource.checkout_connection).to receive(:post)
18
- .with({ body:"{\"mock\":true,\"mockfalse\":false,\"mockzero\":0}",
19
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
20
- path:"/payments" })
21
-
22
- api_resource.request_payment(payment_request_source)
23
- end
24
- end
25
-
26
- describe "#capture_payment" do
27
- let(:capture_payment) { CheckoutSdk::CapturePayment.new }
28
-
29
- it "sends a POST request with correct params" do
30
- capture_payment.id = 1
31
-
32
- expect(api_resource.checkout_connection).to receive(:post)
33
- .with({ body:"{}",
34
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
35
- path:"/payments/1/captures" })
36
-
37
- api_resource.capture_payment(capture_payment)
38
- end
39
- end
40
-
41
- describe "#refund_payment" do
42
- let(:refund_payment) { CheckoutSdk::RefundPayment.new }
43
-
44
- it "sends a POST request with correct params" do
45
- refund_payment.id = 1
46
-
47
- expect(api_resource.checkout_connection).to receive(:post)
48
- .with({ body:"{}",
49
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
50
- path:"/payments/1/refunds" })
51
-
52
- api_resource.refund_payment(refund_payment)
53
- end
54
- end
55
-
56
- describe "#void_payment" do
57
- let(:void_payment) { CheckoutSdk::VoidPayment.new }
58
-
59
- it "sends a POST request with correct params" do
60
- void_payment.id = 1
61
-
62
- expect(api_resource.checkout_connection).to receive(:post)
63
- .with({ body:"{}",
64
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
65
- path:"/payments/1/voids" })
66
-
67
- api_resource.void_payment(void_payment)
68
- end
69
- end
70
-
71
- describe "#add_payment_source" do
72
- let(:payment_source) { CheckoutSdk::PaymentSource.new }
73
- let(:data) { { mock: true } }
74
-
75
- it "sends a POST request with correct params" do
76
- allow(payment_source).to receive(:data).and_return(data)
77
-
78
- expect(api_resource.checkout_connection).to receive(:post)
79
- .with({ body:"{\"mock\":true}",
80
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
81
- path:"/sources" })
82
-
83
- api_resource.add_payment_source(payment_source)
84
- end
85
- end
86
-
87
- describe "#request_token" do
88
- let(:request_token) { CheckoutSdk::RequestToken.new }
89
- let(:data) { { mock: true } }
90
-
91
- it "sends a POST request with correct params" do
92
- allow(request_token).to receive(:data).and_return(data)
93
-
94
- expect(api_resource.checkout_connection).to receive(:post)
95
- .with({ body:"{\"mock\":true}",
96
- headers:{"Authorization"=>"pk_test", "Content-Type"=>"application/json"},
97
- path:"/tokens" })
98
-
99
- api_resource.request_token(request_token)
100
- end
101
- end
102
-
103
- describe "#get_payment_details" do
104
- let(:payment_id) { "pay_id" }
105
-
106
- it "sends a Get request with correct params" do
107
- expect(api_resource.checkout_connection).to receive(:get)
108
- .with({headers: {"Authorization"=>"sk_test"},
109
- path: "/payments/#{payment_id}"})
110
-
111
- api_resource.get_payment_details(payment_id)
112
- end
113
- end
114
-
115
- describe "#get_payment_actions" do
116
- let(:payment_id) { "pay_id" }
117
-
118
- it "sends a Get request with correct params" do
119
- expect(api_resource.checkout_connection).to receive(:get)
120
- .with({headers: {"Authorization"=>"sk_test"},
121
- path: "/payments/#{payment_id}/actions"})
122
-
123
- api_resource.get_payment_actions(payment_id)
124
- end
125
- end
126
- end
@@ -1,126 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe CheckoutSdk::PaymentRequestSource do
4
- let(:payment_request_source) { CheckoutSdk::PaymentRequestSource.new }
5
- let(:type) { "card" }
6
- let(:card_number) { "4242424242424242" }
7
- let(:card_expiry_month) { 6 }
8
- let(:card_expiry_year) { 25 }
9
- let(:card_name) { "Elmo and Friends" }
10
- let(:card_cvv) { "123" }
11
- let(:card_stored) { false }
12
- let(:billing_address_line1) { "Sesame street 1" }
13
- let(:billing_address_line2) { "" }
14
- let(:billing_city) { "Sesame city" }
15
- let(:billing_state) { "Sesame state" }
16
- let(:billing_zip) { "12345" }
17
- let(:billing_country) { "Sesame country" }
18
- let(:phone_country_code) { "+1" }
19
- let(:phone_number) { "415 555 2671" }
20
- let(:id) { "12345678" }
21
- let(:cvv) { "123" }
22
- let(:token) { "tok_4gzeau5o2uqubbk6fufs3m7p54" }
23
- let(:customer_id) { "12345678" }
24
- let(:customer_email) { "elmo@friends.sesame" }
25
- let(:expected_card_source) {
26
- {
27
- type: type,
28
- number: card_number,
29
- expiry_month: card_expiry_month,
30
- expiry_year: card_expiry_year,
31
- name: card_name,
32
- cvv: card_cvv,
33
- stored: card_stored,
34
- billing_address: {
35
- address_line1: billing_address_line1,
36
- address_line2: billing_address_line2,
37
- city: billing_city,
38
- state: billing_state,
39
- zip: billing_zip,
40
- country: billing_country
41
- },
42
- phone: {
43
- country_code: phone_country_code,
44
- number: phone_number
45
- },
46
- }
47
- }
48
- let(:expected_id_source) {
49
- {
50
- type: type,
51
- id: id,
52
- cvv: cvv
53
- }
54
- }
55
- let(:expected_token_source) {
56
- {
57
- type: type,
58
- token: token,
59
- billing_address: {
60
- address_line1: billing_address_line1,
61
- address_line2: billing_address_line2,
62
- city: billing_city,
63
- state: billing_state,
64
- zip: billing_zip,
65
- country: billing_country
66
- },
67
- phone: {
68
- country_code: phone_country_code,
69
- number: phone_number
70
- },
71
- }
72
- }
73
- let(:expected_customer_source) {
74
- {
75
- type: type,
76
- id: customer_id,
77
- email: customer_email
78
- }
79
- }
80
-
81
- def get_keys(hash)
82
- hash.map do |k, v|
83
- v = v.first if v.is_a?(Array);
84
-
85
- if v.is_a?(Hash)
86
- [k, get_keys(v)]
87
- else
88
- k
89
- end
90
- end
91
- end
92
-
93
- describe "#data" do
94
- context "card" do
95
- it "uses card settings" do
96
- payment_request_source.type = "card"
97
-
98
- expect(get_keys(payment_request_source.data[:source])).to eql(get_keys(expected_card_source))
99
- end
100
- end
101
-
102
- context "id" do
103
- it "uses id settings" do
104
- payment_request_source.type = "id"
105
-
106
- expect(get_keys(payment_request_source.data[:source])).to eql(get_keys(expected_id_source))
107
- end
108
- end
109
-
110
- context "token" do
111
- it "uses token settings" do
112
- payment_request_source.type = "token"
113
-
114
- expect(get_keys(payment_request_source.data[:source])).to eql(get_keys(expected_token_source))
115
- end
116
- end
117
-
118
- context "token" do
119
- it "uses customer settings" do
120
- payment_request_source.type = "customer"
121
-
122
- expect(get_keys(payment_request_source.data[:source])).to eql(get_keys(expected_customer_source))
123
- end
124
- end
125
- end
126
- end