checkout_sdk 0.3.0 → 1.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26f117e315cedf6293b15fabeca2736d00a5e59a98257e0f6af6c111e1d4ca7b
4
- data.tar.gz: 17935194ff3650b305c3f2795c6932cb61a2b07e84259683397785367bb4d8fe
3
+ metadata.gz: 02f69890364a27b8824317c2604c3dcc1182ceab269ba237589c7db3529d16a1
4
+ data.tar.gz: fd4d4cdbf183476ae79c4fbf58f517102eb23d3795af8a8d2be5e1e76a44ab2c
5
5
  SHA512:
6
- metadata.gz: e76a36a2f4ffabace3f0911192b63eeda2119ee39bc0b1fad7792afdd81222b6e6a3acc42f85d2209510cb15fbe5893988e88c69c65dc51cf171824f74fbb14c
7
- data.tar.gz: 36767831e67555237bf1f2f8ed28ff861693bd32737c3b7f5d7f0a1579a2ba8c53e7280ad13cfa02937a48f2e5dd80a1fe06a1fdf8986f17736c1c050d94f2c5
6
+ metadata.gz: 627d42ca4a6d47e0336bfbf0df46dca6c703898c17923fbb0356974e0833c3a099e7701ffab5caee7eae83966469849931ca3183b14f52f1afcca0cd1e46047c
7
+ data.tar.gz: ad0c24f31adf78f719a4af8f5e6e889274b08987d038e8b470aa8c1881114242b21462bd1b237f217f79f5c30d4020d94cdb6470037aad1354d5e19035346d8c
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Metrics/AbcSize:
5
+ Enabled: false
6
+
7
+ Lint/MissingSuper:
8
+ Enabled: false
9
+
10
+ Layout/LineLength:
11
+ Max: 120
12
+
13
+ Metrics/ModuleLength:
14
+ Max: 260
15
+
16
+ Metrics/MethodLength:
17
+ Max: 25
18
+
19
+ Metrics/ParameterLists:
20
+ Max: 10
21
+
22
+ Style/Documentation:
23
+ Enabled: false
24
+
25
+ Style/OpenStructUse:
26
+ Enabled: false
27
+
28
+ Naming/MethodName:
29
+ Exclude:
30
+ - "**/google_pay_token_data*"
31
+ - "**/sofort_source*"
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at aibarrakerzon@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gemspec
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in checkout_sdk.gemspec
6
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Checkout.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,150 +1,136 @@
1
- [![GitHub license](https://img.shields.io/github/license/checkout/checkout-sdk-ruby.svg)](https://github.com/checkout/checkout-sdk-ruby/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/checkout/checkout-sdk-ruby.svg)](https://GitHub.com/checkout/checkout-sdk-ruby/releases/)
1
+ # Checkout.com Ruby SDK
2
2
 
3
- <p align="center"><img src="https://i.ibb.co/5Mx7ZsS/Screenshot-2020-07-30-at-17-20-31.png" width="20%"></p>
3
+ ![build-status](https://github.com/checkout/checkout-sdk-ruby/workflows/build-master/badge.svg)
4
+ [![GitHub license](https://img.shields.io/github/license/checkout/checkout-sdk-ruby.svg)](https://github.com/checkout/checkout-sdk-ruby/blob/master/LICENSE)
5
+ [![GitHub release](https://img.shields.io/github/release/checkout/checkout-sdk-ruby.svg)](https://GitHub.com/checkout/checkout-sdk-ruby/releases/)
6
+ [![Gem Version](https://badge.fury.io/rb/checkout_sdk.svg)](https://badge.fury.io/rb/checkout_sdk)
4
7
 
5
- # Checkout.com Ruby SDK
8
+ ## Getting started
9
+
10
+ > **Version 1.0.0 is here!**
11
+ > <br/><br/>
12
+ > We improved the initialization of SDK making it easier to understand the available options. <br/>
13
+ > Now `NAS` accounts are the default instance for the SDK and `ABC` structure was moved to a `previous` prefixes. <br/>
14
+
15
+ ### Gem installer
16
+
17
+ ```sh
18
+ gem install checkout_sdk
19
+ ```
6
20
 
7
- # :rocket: Install
21
+ ### Bundler
8
22
 
9
- Add this line to your application's Gemfile:
23
+ Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that
24
+ you need.
10
25
 
11
26
  ```ruby
27
+ source 'https://rubygems.org'
28
+
12
29
  gem 'checkout_sdk'
13
30
  ```
14
31
 
15
- And then execute:
32
+ ### :rocket: Please check in [GitHub releases](https://github.com/checkout/checkout-sdk-ruby/releases) for all the versions available.
16
33
 
17
- ```bash
18
- $ bundle
19
- ```
34
+ ### :book: Checkout our official documentation.
20
35
 
21
- Or install it yourself as:
36
+ * [Official Docs (Default)](https://docs.checkout.com/)
37
+ * [Official Docs (Previous)](https://docs.checkout.com/previous)
22
38
 
23
- ```bash
24
- $ gem install checkout_sdk
25
- ```
39
+ ### :books: Check out our official API documentation guide, where you can also find more usage examples.
26
40
 
27
- # :wrench: Configure
41
+ * [API Reference (Default)](https://api-reference.checkout.com/)
42
+ * [API Reference (Previous)](https://api-reference.checkout.com/previous)
28
43
 
29
- API keys must be configured in the gem setup. You can do this anywhere in your application before you make API calls using the gem.
44
+ ## How to use the SDK
30
45
 
31
- ```ruby
32
- CheckoutSdk.configure do |config|
33
- config.secret_key = ENV['SECRET_KEY']
34
- config.public_key = ENV['PUBLIC_KEY']
35
- config.base_url = ENV['BASE_URL']
36
- config.persistent = true|false # default: true
37
- end
38
- ```
46
+ This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply
47
+ using specific API features. </br>
48
+ Please find in the table below the types of keys that can be used within this SDK.
39
49
 
40
- # :book: Documentation
50
+ | Account System | Public Key (example) | Secret Key (example) |
51
+ |----------------|-----------------------------------------|-----------------------------------------|
52
+ | Default | pk_pkhpdtvabcf7hdgpwnbhw7r2uic | sk_m73dzypy7cf3gf5d2xr4k7sxo4e |
53
+ | Previous | pk_g650ff27-7c42-4ce1-ae90-5691a188ee7b | sk_gk3517a8-3z01-45fq-b4bd-4282384b0a64 |
41
54
 
42
- You can see the [SDK documentation here](https://checkout.github.io/checkout-sdk-ruby/getting_started/).
55
+ Note: sandbox keys have a `sbox_` or `test_` identifier, for Default and Previous accounts respectively.
43
56
 
44
- # :dash: Quickstart
57
+ If you don't have your own API keys, you can sign up for a test
58
+ account [here](https://www.checkout.com/get-test-account).
45
59
 
46
- #### Source Type: `token`
47
- A card token can be obtained using one of Checkout.com's JavaScript frontend solutions such as [Frames](https://docs.checkout.com/docs/frames "Frames") or any of the [mobile SDKs](https://docs.checkout.com/docs/sdks#section-mobile-sdk-libraries "Mobile SDKs")
60
+ **PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.**
48
61
 
49
- ```ruby
50
- payment_request_source = CheckoutSdk::PaymentRequestSource.new
51
- payment_request_source.type = "token"
52
- payment_request_source.token = "tok_..."
53
- payment_request_source.amount = 2022
54
- payment_request_source.currency = "GBP"
55
-
56
- api_resource = CheckoutSdk::ApiResource.new
57
-
58
- # Send API call
59
- response = api_resource.request_payment(payment_request_source)
60
-
61
- # response parsing
62
- response.data # => {...}
63
- response.body # => "..."
64
- response.headers # => {...}
65
- response.remote_ip # => "..."
66
- response.status # => 200
67
- response.remote_ip # => "..."
68
- response.local_port # => 51601
69
- response.local_address # => "..."
70
- ```
62
+ ### Default
71
63
 
72
- #### Source Type: `id`
64
+ Default keys client instantiation can be done as follows:
73
65
 
74
66
  ```ruby
75
- payment_request_source = CheckoutSdk::PaymentRequestSource.new
76
- payment_request_source.type = "id"
77
- payment_request_source.token = "src_..."
78
- payment_request_source.amount = 2022
79
- payment_request_source.currency = "GBP"
80
-
81
- api_resource = CheckoutSdk::ApiResource.new
82
-
83
- # Send API call
84
- response = api_resource.request_payment(payment_request_source)
85
-
86
- # response parsing
87
- response.data # => {...}
88
- response.body # => "..."
89
- response.headers # => {...}
90
- response.remote_ip # => "..."
91
- response.status # => 200
92
- response.remote_ip # => "..."
93
- response.local_port # => 51601
94
- response.local_address # => "..."
67
+ api = CheckoutSdk.builder
68
+ .static_keys
69
+ .with_secret_key('secret_key')
70
+ .with_public_key('public_key') # optional, only required for operations related with tokens
71
+ .with_environment(CheckoutSdk::Environment.sandbox)
72
+ .build
95
73
  ```
96
74
 
75
+ ### Default OAuth
76
+
77
+ The SDK supports client credentials OAuth, when initialized as follows:
97
78
 
98
- #### Source Type: `card`
99
- [Fully PCI Compliant](https://docs.checkout.com/docs/pci-compliance) merchants only
100
79
  ```ruby
101
- payment_request_source = CheckoutSdk::PaymentRequestSource.new
102
- payment_request_source.type = "card"
103
- payment_request_source.card_number = "4242424242424242"
104
- payment_request_source.card_expiry_month = 6
105
- payment_request_source.card_expiry_year = 2025
106
- payment_request_source.card_name = "Bruce Wayne"
107
- payment_request_source.card_cvv = "100"
108
- payment_request_source.amount = 2022
109
- payment_request_source.currency = "GBP"
110
-
111
- api_resource = CheckoutSdk::ApiResource.new
112
-
113
- # Send API call
114
- response = api_resource.request_payment(payment_request_source)
115
-
116
- # response parsing
117
- response.data # => {...}
118
- response.body # => "..."
119
- response.headers # => {...}
120
- response.remote_ip # => "..."
121
- response.status # => 200
122
- response.remote_ip # => "..."
123
- response.local_port # => 51601
124
- response.local_address # => "..."
80
+ api = CheckoutSdk.builder
81
+ .oauth
82
+ .with_authorization_uri('https://access.sandbox.checkout.com/connect/token') # custom authorization URI, optional
83
+ .with_client_credentials("client_id", "client_secret")
84
+ .with_scopes([CheckoutSdk::OAuthScopes::VAULT, CheckoutSdk::OAuthScopes::GATEWAY]) # array of scopes
85
+ .with_environment(CheckoutSdk::Environment.sandbox)
86
+ .build
125
87
  ```
126
88
 
127
- # :warning: Boolean/falsy values
89
+ ### Previous
128
90
 
129
- "nil" or empty strings will be stripped from API calls
91
+ If your pair of keys matches the previous system type, this is how the SDK should be used:
130
92
 
131
93
  ```ruby
132
- # ignored
133
- payment_request_source.capture = nil
134
- payment_request_source.capture = ""
94
+ api = CheckoutSdk.builder
95
+ .previous
96
+ .static_keys
97
+ .with_secret_key('secret_key')
98
+ .with_public_key('public_key') # optional, only required for operations related with tokens
99
+ .with_environment(CheckoutSdk::Environment.sandbox)
100
+ .build
135
101
  ```
136
102
 
137
- but "false" or 0 are retained and sent in the request
103
+ Then just get any client, and start making requests:
138
104
 
139
105
  ```ruby
140
- # sent
141
- payment_request_source.capture = false
142
- payment_request_source.capture = 0
106
+ request = CheckoutSdk::Payments::PaymentRequest.new
107
+ payment_response = api.payments.request_payment(request)
143
108
  ```
144
- See [api_resource_spec](https://github.com/checkout/checkout-sdk-ruby/blob/master/spec/checkout_sdk/api_resource_spec.rb#L10-L24) for details.
145
109
 
146
- # :rotating_light: Tests
110
+ ## Exception handling
111
+
112
+ All the API responses that do not fall in the 2** status codes will cause a `CheckoutSdk::CheckoutApiException`. The
113
+ exception
114
+ encapsulates the `http_metadata` and a map of `error_details`, if available.
147
115
 
148
- ```bash
149
- $ rspec
116
+ ## Building from source
117
+
118
+ Once you check out the code from GitHub, the project can be built using gem:
119
+
120
+ ```sh
121
+ gem build checkout_sdk.gemspec
150
122
  ```
123
+
124
+ The execution of integration tests require the following environment variables set in your system:
125
+
126
+ * For default account systems (NAS): `CHECKOUT_DEFAULT_PUBLIC_KEY` & `CHECKOUT_DEFAULT_SECRET_KEY`
127
+ * For default account systems (OAuth): `CHECKOUT_DEFAULT_OAUTH_CLIENT_ID` & `CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET`
128
+ * For Previous account systems (ABC): `CHECKOUT_PREVIOUS_PUBLIC_KEY` & `CHECKOUT_PREVIOUS_SECRET_KEY`
129
+
130
+ ## Code of Conduct
131
+
132
+ Please refer to [Code of Conduct](CODE_OF_CONDUCT.md)
133
+
134
+ ## Licensing
135
+
136
+ [MIT](LICENSE.md)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ class AbstractCheckoutSdkBuilder
5
+ # @!attribute environment
6
+ # @return [Environment]
7
+ # @!attribute http_client
8
+ # @return [Object]
9
+ attr_accessor :environment, :http_client
10
+
11
+ # @param [Environment] environment
12
+ def with_environment(environment)
13
+ @environment = environment
14
+ self
15
+ end
16
+
17
+ def with_http_client(http_client)
18
+ @http_client = http_client
19
+ self
20
+ end
21
+
22
+ def build
23
+ with_environment(Environment.sandbox) if environment.nil?
24
+ raise CheckoutArgumentException, 'HttpClient must be an instance of Faraday::Connection' \
25
+ if !http_client.nil? && !@http_client.instance_of?(Faraday::Connection)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ class ApiClient
5
+ # @param [CheckoutConfiguration] _configuration
6
+ # @param [String] uri
7
+ def initialize(_configuration, uri)
8
+ # TODO: expect given http client
9
+ @client = build_default_client(uri)
10
+ @multipart_client = build_multipart_client(uri)
11
+ end
12
+
13
+ # @param [String] path
14
+ # @param [SdkAuthorization] authorization
15
+ # @param [Object] params
16
+ def invoke_get(path,
17
+ authorization,
18
+ params = nil)
19
+ invoke(:get, path, authorization, params: params)
20
+ end
21
+
22
+ def invoke_post(path,
23
+ authorization,
24
+ request = nil,
25
+ idempotency_key = nil)
26
+ invoke(:post, path, authorization, request, idempotency_key)
27
+ end
28
+
29
+ def invoke_put(path,
30
+ authorization,
31
+ request)
32
+ invoke(:put, path, authorization, request)
33
+ end
34
+
35
+ def invoke_patch(path,
36
+ authorization,
37
+ request = nil)
38
+ invoke(:patch, path, authorization, request)
39
+ end
40
+
41
+ def invoke_delete(path,
42
+ authorization)
43
+ invoke(:delete, path, authorization)
44
+ end
45
+
46
+ def submit_file(path,
47
+ authorization,
48
+ request)
49
+ upload_file(path, authorization, request)
50
+ end
51
+
52
+ private
53
+
54
+ def build_multipart_client(uri)
55
+ Faraday.new(uri) do |f|
56
+ f.request :multipart
57
+ f.response :raise_error
58
+ end
59
+ end
60
+
61
+ def build_default_client(uri)
62
+ Faraday.new(uri) do |f|
63
+ f.response :raise_error
64
+ end
65
+ end
66
+
67
+ def invoke(method, path, authorization, body = nil, idempotency_key = nil, params: nil)
68
+ path = append_params(path, params) unless params.nil?
69
+
70
+ headers = get_default_headers authorization
71
+ headers[:'Content-Type'] = 'application/json'
72
+ headers[:'Cko-Idempotency-Key'] = idempotency_key unless idempotency_key.nil?
73
+
74
+ json_body = CheckoutSdk::JsonSerializer.to_custom_hash(body).to_json
75
+
76
+ begin
77
+ response = @client.run_request(method, path, json_body, headers)
78
+ rescue Faraday::ClientError => e
79
+ raise CheckoutApiException, e.response
80
+ end
81
+
82
+ parse_response response
83
+ end
84
+
85
+ def get_default_headers(authorization)
86
+ {
87
+ 'User-Agent': "checkout-sdk-ruby/#{VERSION}",
88
+ Accept: 'application/json',
89
+ Authorization: authorization.authorization_header
90
+ }
91
+ end
92
+
93
+ def append_params(path, input_params)
94
+ # TODO: refactor this into a utils method
95
+ hash = CheckoutSdk::JsonSerializer.to_custom_hash(input_params)
96
+ params = URI.encode_www_form(hash)
97
+ "#{path}?#{params}"
98
+ end
99
+
100
+ def build_multipart_request(file_request, file)
101
+ key = file_request.is_a?(CheckoutSdk::Common::FileRequest) ? :file : :path
102
+ {
103
+ key => Faraday::Multipart::FilePart.new(
104
+ file,
105
+ MIME::Types.type_for(file_request.file).first,
106
+ File.basename(file_request.file)
107
+ ),
108
+ :purpose => file_request.purpose
109
+ }
110
+ end
111
+
112
+ def upload_file(path, authorization, file_request)
113
+ headers = get_default_headers authorization
114
+
115
+ file = File.open(file_request.file)
116
+
117
+ form = build_multipart_request file_request, file
118
+
119
+ begin
120
+ response = @multipart_client.run_request(:post, path, form, headers)
121
+ rescue Faraday::ClientError => e
122
+ raise CheckoutApiException, e.response
123
+ ensure
124
+ file.close
125
+ end
126
+
127
+ parse_response response
128
+ end
129
+
130
+ def parse_response(response)
131
+ # TODO: include http metadata response
132
+ JSON.parse(response.body, object_class: OpenStruct) if !response.body.nil? && response.body != ''
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Klarna
4
+ require 'checkout_sdk/apm/previous/klarna/credit_session_request'
5
+ require 'checkout_sdk/apm/previous/klarna/klarna'
6
+ require 'checkout_sdk/apm/previous/klarna/klarna_product'
7
+ require 'checkout_sdk/apm/previous/klarna/klarna_shipping_info'
8
+ require 'checkout_sdk/apm/previous/klarna/order_capture_request'
9
+
10
+ require 'checkout_sdk/apm/previous/klarna/klarna_client'
11
+ require 'checkout_sdk/apm/previous/sepa/sepa_client'
12
+ require 'checkout_sdk/apm/ideal/ideal_client'
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Apm
5
+ class IdealClient < Client
6
+ IDEAL_EXTERNAL = 'ideal-external'
7
+ ISSUERS = 'issuers'
8
+ private_constant :IDEAL_EXTERNAL, :ISSUERS
9
+
10
+ # @param [ApiClient] api_client
11
+ # @param [CheckoutConfiguration] configuration
12
+ def initialize(api_client, configuration)
13
+ super api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY
14
+ end
15
+
16
+ def info
17
+ api_client.invoke_get(IDEAL_EXTERNAL, sdk_authorization)
18
+ end
19
+
20
+ def issuers
21
+ api_client.invoke_get(build_path(IDEAL_EXTERNAL, ISSUERS), sdk_authorization)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Apm
6
+ module Klarna
7
+ # @!attribute purchase_country
8
+ # @return [String] {CheckoutSdk::Common::Country}
9
+ # @!attribute currency
10
+ # @return [String] {CheckoutSdk::Common::Currency}
11
+ # @!attribute locale
12
+ # @return [String]
13
+ # @!attribute amount
14
+ # @return [Integer]
15
+ # @!attribute tax_amount
16
+ # @return [Integer]
17
+ # @!attribute products
18
+ # @return [Array(KlarnaProduct)]
19
+ class CreditSessionRequest
20
+ attr_accessor :purchase_country,
21
+ :currency,
22
+ :locale,
23
+ :amount,
24
+ :tax_amount,
25
+ :products
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Apm
6
+ module Klarna
7
+ # @!attribute description
8
+ # @return [String]
9
+ # @!attribute products
10
+ # @return [Array(KlarnaProduct)]
11
+ # @!attribute shipping_info
12
+ # @return [KlarnaShippingInfo]
13
+ # @!attribute shipping_delay
14
+ # @return [Integer]
15
+ class Klarna
16
+ attr_accessor :description,
17
+ :products,
18
+ :shipping_info,
19
+ :shipping_delay
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end