onlinepayments-sdk-ruby 3.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 (269) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +140 -0
  5. data/Rakefile +34 -0
  6. data/lib/onlinepayments/sdk/api_exception.rb +42 -0
  7. data/lib/onlinepayments/sdk/api_resource.rb +115 -0
  8. data/lib/onlinepayments/sdk/authenticator.rb +16 -0
  9. data/lib/onlinepayments/sdk/authorization_exception.rb +13 -0
  10. data/lib/onlinepayments/sdk/call_context.rb +26 -0
  11. data/lib/onlinepayments/sdk/client.rb +82 -0
  12. data/lib/onlinepayments/sdk/communication_exception.rb +16 -0
  13. data/lib/onlinepayments/sdk/communicator.rb +300 -0
  14. data/lib/onlinepayments/sdk/communicator_configuration.rb +59 -0
  15. data/lib/onlinepayments/sdk/connection.rb +41 -0
  16. data/lib/onlinepayments/sdk/data_object.rb +31 -0
  17. data/lib/onlinepayments/sdk/declined_payment_exception.rb +30 -0
  18. data/lib/onlinepayments/sdk/declined_payout_exception.rb +32 -0
  19. data/lib/onlinepayments/sdk/declined_refund_exception.rb +32 -0
  20. data/lib/onlinepayments/sdk/declined_transaction_exception.rb +16 -0
  21. data/lib/onlinepayments/sdk/defaultimpl/authorization_type.rb +24 -0
  22. data/lib/onlinepayments/sdk/defaultimpl/default_authenticator.rb +108 -0
  23. data/lib/onlinepayments/sdk/defaultimpl/default_connection.rb +295 -0
  24. data/lib/onlinepayments/sdk/defaultimpl/default_marshaller.rb +32 -0
  25. data/lib/onlinepayments/sdk/defaultimpl.rb +6 -0
  26. data/lib/onlinepayments/sdk/domain/account_on_file.rb +49 -0
  27. data/lib/onlinepayments/sdk/domain/account_on_file_attribute.rb +38 -0
  28. data/lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb +37 -0
  29. data/lib/onlinepayments/sdk/domain/additional_order_input.rb +54 -0
  30. data/lib/onlinepayments/sdk/domain/address.rb +50 -0
  31. data/lib/onlinepayments/sdk/domain/address_personal.rb +58 -0
  32. data/lib/onlinepayments/sdk/domain/airline_data.rb +128 -0
  33. data/lib/onlinepayments/sdk/domain/airline_flight_leg.rb +102 -0
  34. data/lib/onlinepayments/sdk/domain/airline_passenger.rb +38 -0
  35. data/lib/onlinepayments/sdk/domain/amount_breakdown.rb +30 -0
  36. data/lib/onlinepayments/sdk/domain/amount_of_money.rb +30 -0
  37. data/lib/onlinepayments/sdk/domain/api_error.rb +46 -0
  38. data/lib/onlinepayments/sdk/domain/bank_account_iban.rb +26 -0
  39. data/lib/onlinepayments/sdk/domain/browser_data.rb +42 -0
  40. data/lib/onlinepayments/sdk/domain/cancel_payment_response.rb +30 -0
  41. data/lib/onlinepayments/sdk/domain/capture.rb +46 -0
  42. data/lib/onlinepayments/sdk/domain/capture_output.rb +82 -0
  43. data/lib/onlinepayments/sdk/domain/capture_payment_request.rb +38 -0
  44. data/lib/onlinepayments/sdk/domain/capture_response.rb +46 -0
  45. data/lib/onlinepayments/sdk/domain/capture_status_output.rb +26 -0
  46. data/lib/onlinepayments/sdk/domain/captures_response.rb +33 -0
  47. data/lib/onlinepayments/sdk/domain/card.rb +38 -0
  48. data/lib/onlinepayments/sdk/domain/card_essentials.rb +34 -0
  49. data/lib/onlinepayments/sdk/domain/card_fraud_results.rb +34 -0
  50. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input.rb +98 -0
  51. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_base.rb +86 -0
  52. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_for_hosted_checkout.rb +26 -0
  53. data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output.rb +78 -0
  54. data/lib/onlinepayments/sdk/domain/card_payout_method_specific_input.rb +38 -0
  55. data/lib/onlinepayments/sdk/domain/card_recurrence_details.rb +26 -0
  56. data/lib/onlinepayments/sdk/domain/card_without_cvv.rb +34 -0
  57. data/lib/onlinepayments/sdk/domain/company_information.rb +26 -0
  58. data/lib/onlinepayments/sdk/domain/complete_payment_card_payment_method_specific_input.rb +30 -0
  59. data/lib/onlinepayments/sdk/domain/complete_payment_request.rb +38 -0
  60. data/lib/onlinepayments/sdk/domain/complete_payment_response.rb +46 -0
  61. data/lib/onlinepayments/sdk/domain/contact_details.rb +42 -0
  62. data/lib/onlinepayments/sdk/domain/create_hosted_checkout_request.rb +78 -0
  63. data/lib/onlinepayments/sdk/domain/create_hosted_checkout_response.rb +48 -0
  64. data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +38 -0
  65. data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_response.rb +50 -0
  66. data/lib/onlinepayments/sdk/domain/create_mandate_request.rb +58 -0
  67. data/lib/onlinepayments/sdk/domain/create_mandate_response.rb +38 -0
  68. data/lib/onlinepayments/sdk/domain/create_mandate_with_return_url.rb +58 -0
  69. data/lib/onlinepayments/sdk/domain/create_payment_request.rb +74 -0
  70. data/lib/onlinepayments/sdk/domain/create_payment_response.rb +46 -0
  71. data/lib/onlinepayments/sdk/domain/create_payout_request.rb +46 -0
  72. data/lib/onlinepayments/sdk/domain/create_token_request.rb +34 -0
  73. data/lib/onlinepayments/sdk/domain/created_payment_output.rb +34 -0
  74. data/lib/onlinepayments/sdk/domain/created_token_response.rb +50 -0
  75. data/lib/onlinepayments/sdk/domain/customer.rb +86 -0
  76. data/lib/onlinepayments/sdk/domain/customer_account.rb +70 -0
  77. data/lib/onlinepayments/sdk/domain/customer_account_authentication.rb +30 -0
  78. data/lib/onlinepayments/sdk/domain/customer_device.rb +50 -0
  79. data/lib/onlinepayments/sdk/domain/customer_payment_activity.rb +34 -0
  80. data/lib/onlinepayments/sdk/domain/customer_token.rb +46 -0
  81. data/lib/onlinepayments/sdk/domain/decrypted_payment_data.rb +42 -0
  82. data/lib/onlinepayments/sdk/domain/directory_entry.rb +34 -0
  83. data/lib/onlinepayments/sdk/domain/empty_validator.rb +12 -0
  84. data/lib/onlinepayments/sdk/domain/error_response.rb +37 -0
  85. data/lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb +58 -0
  86. data/lib/onlinepayments/sdk/domain/external_token_linked.rb +34 -0
  87. data/lib/onlinepayments/sdk/domain/fixed_list_validator.rb +32 -0
  88. data/lib/onlinepayments/sdk/domain/fraud_fields.rb +30 -0
  89. data/lib/onlinepayments/sdk/domain/fraud_results.rb +26 -0
  90. data/lib/onlinepayments/sdk/domain/g_pay_three_d_secure.rb +46 -0
  91. data/lib/onlinepayments/sdk/domain/get_hosted_checkout_response.rb +34 -0
  92. data/lib/onlinepayments/sdk/domain/get_hosted_tokenization_response.rb +34 -0
  93. data/lib/onlinepayments/sdk/domain/get_iin_details_request.rb +34 -0
  94. data/lib/onlinepayments/sdk/domain/get_iin_details_response.rb +45 -0
  95. data/lib/onlinepayments/sdk/domain/get_mandate_response.rb +30 -0
  96. data/lib/onlinepayments/sdk/domain/get_payment_product_groups_response.rb +33 -0
  97. data/lib/onlinepayments/sdk/domain/get_payment_products_response.rb +33 -0
  98. data/lib/onlinepayments/sdk/domain/gift_card_purchase.rb +34 -0
  99. data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_input.rb +66 -0
  100. data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_output.rb +30 -0
  101. data/lib/onlinepayments/sdk/domain/iin_detail.rb +30 -0
  102. data/lib/onlinepayments/sdk/domain/label_template_element.rb +30 -0
  103. data/lib/onlinepayments/sdk/domain/length_validator.rb +30 -0
  104. data/lib/onlinepayments/sdk/domain/line_item.rb +46 -0
  105. data/lib/onlinepayments/sdk/domain/line_item_invoice_data.rb +26 -0
  106. data/lib/onlinepayments/sdk/domain/loan_recipient.rb +42 -0
  107. data/lib/onlinepayments/sdk/domain/lodging_data.rb +26 -0
  108. data/lib/onlinepayments/sdk/domain/mandate_address.rb +42 -0
  109. data/lib/onlinepayments/sdk/domain/mandate_contact_details.rb +26 -0
  110. data/lib/onlinepayments/sdk/domain/mandate_customer.rb +58 -0
  111. data/lib/onlinepayments/sdk/domain/mandate_merchant_action.rb +34 -0
  112. data/lib/onlinepayments/sdk/domain/mandate_personal_information.rb +34 -0
  113. data/lib/onlinepayments/sdk/domain/mandate_personal_name.rb +30 -0
  114. data/lib/onlinepayments/sdk/domain/mandate_redirect_data.rb +30 -0
  115. data/lib/onlinepayments/sdk/domain/mandate_response.rb +50 -0
  116. data/lib/onlinepayments/sdk/domain/merchant_action.rb +34 -0
  117. data/lib/onlinepayments/sdk/domain/mobile_payment_data.rb +30 -0
  118. data/lib/onlinepayments/sdk/domain/mobile_payment_method_hosted_checkout_specific_input.rb +30 -0
  119. data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_input.rb +62 -0
  120. data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_output.rb +58 -0
  121. data/lib/onlinepayments/sdk/domain/mobile_payment_product320_specific_input.rb +30 -0
  122. data/lib/onlinepayments/sdk/domain/operation_output.rb +58 -0
  123. data/lib/onlinepayments/sdk/domain/order.rb +70 -0
  124. data/lib/onlinepayments/sdk/domain/order_line_details.rb +54 -0
  125. data/lib/onlinepayments/sdk/domain/order_references.rb +34 -0
  126. data/lib/onlinepayments/sdk/domain/order_status_output.rb +49 -0
  127. data/lib/onlinepayments/sdk/domain/order_type_information.rb +30 -0
  128. data/lib/onlinepayments/sdk/domain/payment_account_on_file.rb +30 -0
  129. data/lib/onlinepayments/sdk/domain/payment_context.rb +38 -0
  130. data/lib/onlinepayments/sdk/domain/payment_creation_output.rb +38 -0
  131. data/lib/onlinepayments/sdk/domain/payment_details_response.rb +65 -0
  132. data/lib/onlinepayments/sdk/domain/payment_error_response.rb +45 -0
  133. data/lib/onlinepayments/sdk/domain/payment_output.rb +82 -0
  134. data/lib/onlinepayments/sdk/domain/payment_product.rb +102 -0
  135. data/lib/onlinepayments/sdk/domain/payment_product130_specific_input.rb +30 -0
  136. data/lib/onlinepayments/sdk/domain/payment_product130_specific_three_d_secure.rb +38 -0
  137. data/lib/onlinepayments/sdk/domain/payment_product302_specific_data.rb +32 -0
  138. data/lib/onlinepayments/sdk/domain/payment_product320_specific_data.rb +36 -0
  139. data/lib/onlinepayments/sdk/domain/payment_product5100_specific_input.rb +26 -0
  140. data/lib/onlinepayments/sdk/domain/payment_product5402_specific_output.rb +26 -0
  141. data/lib/onlinepayments/sdk/domain/payment_product5500_specific_output.rb +34 -0
  142. data/lib/onlinepayments/sdk/domain/payment_product771_specific_output.rb +26 -0
  143. data/lib/onlinepayments/sdk/domain/payment_product840_customer_account.rb +54 -0
  144. data/lib/onlinepayments/sdk/domain/payment_product840_specific_output.rb +53 -0
  145. data/lib/onlinepayments/sdk/domain/payment_product_display_hints.rb +34 -0
  146. data/lib/onlinepayments/sdk/domain/payment_product_field.rb +46 -0
  147. data/lib/onlinepayments/sdk/domain/payment_product_field_data_restrictions.rb +34 -0
  148. data/lib/onlinepayments/sdk/domain/payment_product_field_display_element.rb +38 -0
  149. data/lib/onlinepayments/sdk/domain/payment_product_field_display_hints.rb +70 -0
  150. data/lib/onlinepayments/sdk/domain/payment_product_field_form_element.rb +37 -0
  151. data/lib/onlinepayments/sdk/domain/payment_product_field_tooltip.rb +30 -0
  152. data/lib/onlinepayments/sdk/domain/payment_product_field_validators.rb +90 -0
  153. data/lib/onlinepayments/sdk/domain/payment_product_filter.rb +42 -0
  154. data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_checkout.rb +37 -0
  155. data/lib/onlinepayments/sdk/domain/payment_product_group.rb +52 -0
  156. data/lib/onlinepayments/sdk/domain/payment_product_networks_response.rb +32 -0
  157. data/lib/onlinepayments/sdk/domain/payment_references.rb +30 -0
  158. data/lib/onlinepayments/sdk/domain/payment_response.rb +54 -0
  159. data/lib/onlinepayments/sdk/domain/payment_status_output.rb +57 -0
  160. data/lib/onlinepayments/sdk/domain/payout_error_response.rb +45 -0
  161. data/lib/onlinepayments/sdk/domain/payout_output.rb +30 -0
  162. data/lib/onlinepayments/sdk/domain/payout_response.rb +46 -0
  163. data/lib/onlinepayments/sdk/domain/payout_result.rb +46 -0
  164. data/lib/onlinepayments/sdk/domain/payout_status_output.rb +34 -0
  165. data/lib/onlinepayments/sdk/domain/personal_information.rb +38 -0
  166. data/lib/onlinepayments/sdk/domain/personal_information_token.rb +30 -0
  167. data/lib/onlinepayments/sdk/domain/personal_name.rb +34 -0
  168. data/lib/onlinepayments/sdk/domain/personal_name_token.rb +30 -0
  169. data/lib/onlinepayments/sdk/domain/product_directory.rb +33 -0
  170. data/lib/onlinepayments/sdk/domain/protection_eligibility.rb +30 -0
  171. data/lib/onlinepayments/sdk/domain/range_validator.rb +30 -0
  172. data/lib/onlinepayments/sdk/domain/redirect_data.rb +30 -0
  173. data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +66 -0
  174. data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_output.rb +66 -0
  175. data/lib/onlinepayments/sdk/domain/redirect_payment_product809_specific_input.rb +26 -0
  176. data/lib/onlinepayments/sdk/domain/redirect_payment_product840_specific_input.rb +26 -0
  177. data/lib/onlinepayments/sdk/domain/redirection_data.rb +26 -0
  178. data/lib/onlinepayments/sdk/domain/refund_card_method_specific_output.rb +30 -0
  179. data/lib/onlinepayments/sdk/domain/refund_e_wallet_method_specific_output.rb +38 -0
  180. data/lib/onlinepayments/sdk/domain/refund_error_response.rb +45 -0
  181. data/lib/onlinepayments/sdk/domain/refund_mobile_method_specific_output.rb +34 -0
  182. data/lib/onlinepayments/sdk/domain/refund_output.rb +82 -0
  183. data/lib/onlinepayments/sdk/domain/refund_payment_product840_customer_account.rb +34 -0
  184. data/lib/onlinepayments/sdk/domain/refund_payment_product840_specific_output.rb +30 -0
  185. data/lib/onlinepayments/sdk/domain/refund_redirect_method_specific_output.rb +30 -0
  186. data/lib/onlinepayments/sdk/domain/refund_request.rb +38 -0
  187. data/lib/onlinepayments/sdk/domain/refund_response.rb +46 -0
  188. data/lib/onlinepayments/sdk/domain/refunds_response.rb +33 -0
  189. data/lib/onlinepayments/sdk/domain/regular_expression_validator.rb +26 -0
  190. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input.rb +34 -0
  191. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input_base.rb +34 -0
  192. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +42 -0
  193. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input.rb +34 -0
  194. data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input_base.rb +34 -0
  195. data/lib/onlinepayments/sdk/domain/session_request.rb +32 -0
  196. data/lib/onlinepayments/sdk/domain/session_response.rb +48 -0
  197. data/lib/onlinepayments/sdk/domain/shipping.rb +58 -0
  198. data/lib/onlinepayments/sdk/domain/shopping_cart.rb +64 -0
  199. data/lib/onlinepayments/sdk/domain/shopping_cart_extension.rb +52 -0
  200. data/lib/onlinepayments/sdk/domain/test_connection.rb +26 -0
  201. data/lib/onlinepayments/sdk/domain/three_d_secure.rb +78 -0
  202. data/lib/onlinepayments/sdk/domain/three_d_secure_base.rb +58 -0
  203. data/lib/onlinepayments/sdk/domain/three_d_secure_data.rb +34 -0
  204. data/lib/onlinepayments/sdk/domain/three_d_secure_results.rb +30 -0
  205. data/lib/onlinepayments/sdk/domain/token_card.rb +34 -0
  206. data/lib/onlinepayments/sdk/domain/token_card_data.rb +30 -0
  207. data/lib/onlinepayments/sdk/domain/token_card_specific_input.rb +30 -0
  208. data/lib/onlinepayments/sdk/domain/token_data.rb +30 -0
  209. data/lib/onlinepayments/sdk/domain/token_e_wallet.rb +34 -0
  210. data/lib/onlinepayments/sdk/domain/token_response.rb +58 -0
  211. data/lib/onlinepayments/sdk/domain/value_mapping_element.rb +37 -0
  212. data/lib/onlinepayments/sdk/endpoint_configuration.rb +127 -0
  213. data/lib/onlinepayments/sdk/exceptions.rb +8 -0
  214. data/lib/onlinepayments/sdk/factory.rb +136 -0
  215. data/lib/onlinepayments/sdk/idempotence_exception.rb +24 -0
  216. data/lib/onlinepayments/sdk/logging/communicator_logger.rb +22 -0
  217. data/lib/onlinepayments/sdk/logging/log_message_builder.rb +56 -0
  218. data/lib/onlinepayments/sdk/logging/logging_capable.rb +17 -0
  219. data/lib/onlinepayments/sdk/logging/logging_util.rb +286 -0
  220. data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +39 -0
  221. data/lib/onlinepayments/sdk/logging/response_log_message_builder.rb +34 -0
  222. data/lib/onlinepayments/sdk/logging/ruby_communicator_logger.rb +57 -0
  223. data/lib/onlinepayments/sdk/logging/stdout_communicator_logger.rb +34 -0
  224. data/lib/onlinepayments/sdk/logging.rb +10 -0
  225. data/lib/onlinepayments/sdk/marshaller.rb +24 -0
  226. data/lib/onlinepayments/sdk/marshaller_syntax_exception.rb +6 -0
  227. data/lib/onlinepayments/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +86 -0
  228. data/lib/onlinepayments/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +86 -0
  229. data/lib/onlinepayments/sdk/merchant/mandates/mandates_client.rb +182 -0
  230. data/lib/onlinepayments/sdk/merchant/merchant_client.rb +89 -0
  231. data/lib/onlinepayments/sdk/merchant/payments/payments_client.rb +322 -0
  232. data/lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb +86 -0
  233. data/lib/onlinepayments/sdk/merchant/productgroups/get_product_group_params.rb +57 -0
  234. data/lib/onlinepayments/sdk/merchant/productgroups/get_product_groups_params.rb +57 -0
  235. data/lib/onlinepayments/sdk/merchant/productgroups/product_groups_client.rb +87 -0
  236. data/lib/onlinepayments/sdk/merchant/products/get_payment_product_networks_params.rb +38 -0
  237. data/lib/onlinepayments/sdk/merchant/products/get_payment_product_params.rb +57 -0
  238. data/lib/onlinepayments/sdk/merchant/products/get_payment_products_params.rb +57 -0
  239. data/lib/onlinepayments/sdk/merchant/products/get_product_directory_params.rb +30 -0
  240. data/lib/onlinepayments/sdk/merchant/products/products_client.rb +155 -0
  241. data/lib/onlinepayments/sdk/merchant/services/services_client.rb +82 -0
  242. data/lib/onlinepayments/sdk/merchant/sessions/sessions_client.rb +54 -0
  243. data/lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb +116 -0
  244. data/lib/onlinepayments/sdk/meta_data_provider.rb +150 -0
  245. data/lib/onlinepayments/sdk/modules.rb +62 -0
  246. data/lib/onlinepayments/sdk/not_found_exception.rb +16 -0
  247. data/lib/onlinepayments/sdk/param_request.rb +11 -0
  248. data/lib/onlinepayments/sdk/payment_platform_exception.rb +15 -0
  249. data/lib/onlinepayments/sdk/pooled_connection.rb +21 -0
  250. data/lib/onlinepayments/sdk/proxy_configuration.rb +74 -0
  251. data/lib/onlinepayments/sdk/reference_exception.rb +14 -0
  252. data/lib/onlinepayments/sdk/request_header.rb +50 -0
  253. data/lib/onlinepayments/sdk/request_param.rb +23 -0
  254. data/lib/onlinepayments/sdk/response_exception.rb +47 -0
  255. data/lib/onlinepayments/sdk/response_header.rb +42 -0
  256. data/lib/onlinepayments/sdk/validation_exception.rb +14 -0
  257. data/lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb +20 -0
  258. data/lib/onlinepayments/sdk/webhooks/in_memory_secret_key_store.rb +56 -0
  259. data/lib/onlinepayments/sdk/webhooks/secret_key_not_available_exception.rb +17 -0
  260. data/lib/onlinepayments/sdk/webhooks/secret_key_store.rb +16 -0
  261. data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +19 -0
  262. data/lib/onlinepayments/sdk/webhooks/webhooks.rb +22 -0
  263. data/lib/onlinepayments/sdk/webhooks/webhooks_event.rb +58 -0
  264. data/lib/onlinepayments/sdk/webhooks/webhooks_helper.rb +100 -0
  265. data/lib/onlinepayments/sdk/webhooks/webhooks_helper_builder.rb +25 -0
  266. data/lib/onlinepayments/sdk/webhooks.rb +11 -0
  267. data/lib/onlinepayments/sdk.rb +26 -0
  268. data/onlinepayments-sdk-ruby.gemspec +28 -0
  269. metadata +416 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b972879b30e86122019cb9683a9c0f9bb22e930f3cdb70202dcd71d9b5b3fb48
4
+ data.tar.gz: 85d3c34d68492ea5b77e641d3a1283d312a054105e7421ec19c9c048b3eb3d42
5
+ SHA512:
6
+ metadata.gz: 1d2c66697f92e16a30dff1e09199261b8208acbe58162a2d92f1a48cc1751adf58559d2227b1b27af30be5d77f77a9bb6090983b6bb9d49edbfc2d9a53530f3c
7
+ data.tar.gz: 979d0f48a0d1be1b16d392d0178dd562896fd31095892ee032d646cf43c8b0506f7af5171454cabdf95d2f8354f0bd8998c7425fccd5d40cf78214b4b3b57c2f
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Global Collect Services B.V.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Online Payments Ruby SDK
2
+
3
+ ## Introduction
4
+
5
+ The Ruby SDK helps you to communicate with the payment platform server API. Its primary features are:
6
+
7
+ * convenient Ruby library for the API calls and responses
8
+ * marshalls Ruby request objects to HTTP requests
9
+ * unmarshalls HTTP responses to Ruby response objects or Ruby exceptions
10
+ * handling of all the details concerning authentication
11
+ * handling of required meta data
12
+
13
+ Its use is demonstrated by an example for each possible call. The examples execute a call using the provided API keys.
14
+
15
+ ## Structure of this repository
16
+
17
+ This repository consists out of three main components:
18
+
19
+ 1. The source code of the SDK itself: `/lib/onlinepayments/sdk/`
20
+ 2. The source code of the SDK unit tests: `/spec/lib/`
21
+ 3. The source code of the SDK integration tests: `/spec/integration/`
22
+
23
+ Note that the source code of the unit tests and integration tests can only be found on GitHub.
24
+
25
+ ## Requirements
26
+
27
+ Ruby 2.3 or higher is required.
28
+ As for JRuby, version 9.0.0.0 and higher are supported.
29
+ In addition, the following packages are required:
30
+
31
+ * [httpclient](https://github.com/nahi/httpclient) 2.8 or higher
32
+ * [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) 1.0 or higher
33
+
34
+ ## Installation
35
+
36
+ ### Using RubyGems
37
+
38
+ To install the SDK using `gem`, execute the following command:
39
+
40
+ gem install onlinepayments-sdk-ruby
41
+
42
+ ### Using a pre-built gem
43
+
44
+ 1. Download the latest version of the Ruby SDK from GitHub. Choose the `onlinepayments-sdk-ruby-x.y.z.gem` file from the [releases](https://github.com/wl-online-payments-direct/sdk-ruby/releases) page, where `x.y.z` is the version number.
45
+ 2. Navigate into the folder where the gem file is downloaded to, and execute the following command:
46
+
47
+ ```
48
+ gem install onlinepayments-sdk-ruby-x.y.z.gem
49
+ ```
50
+ 3. Feel free to delete the gem file at this point, it is no longer required.
51
+
52
+ ### From source
53
+
54
+ 1. Download the latest version of the Ruby SDK from GitHub. Choose the `onlinepayments-sdk-ruby-x.y.z.zip` file from the [releases](https://github.com/wl-online-payments-direct/sdk-ruby/releases) page, where `x.y.z` is the version number.
55
+ 1. Download the latest version of the Ruby SDK from GitHub. Choose the `onlinepayments-sdk-ruby-x.y.z.zip` file from the releases page of the Github repository, where `x.y.z` is the version number.
56
+ 2. Unzip the file, navigate into the folder where the file is unzipped to, and execute the following commands:
57
+
58
+ ```
59
+ gem build onlinepayments-sdk-ruby.gemspec
60
+ gem install onlinepayments-sdk-ruby-x.y.z.gem
61
+ ```
62
+ 3. Feel free to delete the unzipped archive, the zip file, and the gem file at this point; they are no longer required.
63
+
64
+ ## Uninstalling
65
+
66
+ After the Ruby SDK has been installed, it can be uninstalled using the
67
+ following command:
68
+
69
+ gem uninstall onlinepayments-sdk-ruby
70
+
71
+ The required packages can be uninstalled in the same way.
72
+
73
+ ## Usage
74
+
75
+ After the Ruby SDK has been installed, it can be required in Ruby program as follows:
76
+
77
+ require 'onlinepayments/sdk'
78
+
79
+ ## Running tests
80
+
81
+ There are two types of tests: unit tests and integration tests. The unit tests will work out-of-the-box; for the integration tests some configuration is required.
82
+ First, some environment variables need to be set:
83
+
84
+ * `onlinePayments_api_apiKeyId` for the API key id to use. This can be retrieved from the Configuration Center.
85
+ * `onlinePayments_api_secretApiKey` for the secret API key to use. This can be retrieved from the Configuration Center.
86
+ * `onlinePayments_api_merchantId` for your merchant ID.
87
+
88
+ In addition, to run the proxy integration tests, the proxy URI, username and password should be set in the `spec/fixtures/resources/properties.proxy.yml` file.
89
+
90
+ In order to run the unit and integration tests, some additional dependencies are required:
91
+
92
+ * [rake](https://ruby.github.io/rake/) 12.3.3 or higher
93
+ * [rspec](https://github.com/rspec/rspec) 3.5 or higher
94
+ * [webmock](https://github.com/bblimke/webmock) 2.1 or higher
95
+ * [sinatra](https://github.com/sinatra/sinatra) 1.4 or higher
96
+
97
+ They can be installed using the following command:
98
+
99
+ gem install rake rspec webmock sinatra
100
+
101
+ *Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.*
102
+
103
+ The following commands can now be executed from the root directory of the SDK folder (/) to execute the tests:
104
+
105
+ * Unit tests:
106
+
107
+ ```
108
+ rake unit
109
+ ```
110
+
111
+ * Integration tests:
112
+
113
+ ```
114
+ rake integration
115
+ ```
116
+
117
+ * Both unit and integration tests:
118
+
119
+ ```
120
+ rake spec
121
+ ```
122
+
123
+ ## Generating documentation
124
+
125
+ Documentation can be generated with YARD. YARD can be installed as a gem. The gems required to generate documentation are:
126
+
127
+ * [rake](https://ruby.github.io/rake/) 12.3.3 or higher
128
+ * [yard](https://github.com/lsegal/yard) 0.9.5 or higher
129
+
130
+ They can be installed using the following command:
131
+
132
+ gem install rake yard
133
+
134
+ *Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.*
135
+
136
+ Once YARD and rake are installed, documentation can be generated with the following command (ran from the root folder):
137
+
138
+ rake yard
139
+
140
+ Documentation will be generated in the `/doc` folder. The file `/doc/index.html` is the main documentation file.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t| # supports automated testing using the command *rake* *spec*
5
+ t.rspec_opts = '--color --format documentation'
6
+ end
7
+
8
+ RSpec::Core::RakeTask.new(:unit) do |t| # supports automated testing using unit tests using the command *rake* *unit*
9
+ t.rspec_opts = '--color --format documentation'
10
+ t.exclude_pattern = 'spec/integration/**'
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(:integration) do |t| # supports automated testing of integration using the command *rake* *integration*
14
+ t.rspec_opts = '--color --format documentation'
15
+ t.pattern = 'spec/integration/**_spec.rb'
16
+ end
17
+
18
+ task :default => :spec
19
+ rescue LoadError
20
+ puts '[*] error -- development dependency is not installed'
21
+ end
22
+
23
+ begin
24
+ require 'yard'
25
+
26
+ YARD::Rake::YardocTask.new(:yard) do |t| # supports generating documentation using the command *rake* *yard*
27
+ # t.files = ['lib/**/*.rb', OTHER_PATHS] # optional
28
+ t.options = ['--no-private']
29
+ end
30
+
31
+ task :doc => :yard # alternative alias to generate documentation
32
+ rescue LoadError
33
+ puts '[*] error -- development dependency is not installed'
34
+ end
@@ -0,0 +1,42 @@
1
+ module OnlinePayments::SDK
2
+
3
+ # Base class for many exceptions raised by the SDK.
4
+ # It is raised when an error response is received from the Online Payments platform.
5
+ # It contains data about the returned response.
6
+ #
7
+ # @attr_reader [Integer] status_code HTTP status code of the returned response.
8
+ # @attr_reader [String] response_body Message body of the returned response.
9
+ # @attr_reader [String] error_id An error id corresponding to the error that occurred, if available.
10
+ # @attr_reader [Array<OnlinePayments::SDK::Domain::APIError>] errors A list of errors received from the Online Payments platform;
11
+ # may be empty but never _nil_
12
+ class ApiException < RuntimeError
13
+
14
+ # Creates a new ApiException that reports an error response from the Online Payments platform.
15
+ #
16
+ # @param status_code (Integer) HTTP status code the response
17
+ # @param response_body (String) HTTP response body
18
+ # @param error_id (String) error id of the error, may be _nil_
19
+ # @param errors (Array<OnlinePayments::SDK::Domain::APIError>) a list of errors that occurred, may be empty
20
+ # @param message (String) error message to include
21
+ def initialize(status_code, response_body, error_id, errors,
22
+ message = 'the Online Payments platform returned an error response')
23
+ super(message)
24
+ @status_code = status_code
25
+ @response_body = response_body
26
+ @error_id = error_id
27
+ @errors = errors || [].freeze
28
+ end
29
+
30
+ attr_reader :status_code
31
+ attr_reader :response_body
32
+ attr_reader :error_id
33
+ attr_reader :errors
34
+
35
+ def to_s
36
+ str = super.to_s
37
+ str += "; status_code=#{@status_code}" if @status_code.positive?
38
+ str += "; response_body='#{@response_body}'" if @response_body&.length&.positive?
39
+ str.to_s
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,115 @@
1
+ require 'onlinepayments/sdk/domain/error_response'
2
+
3
+ module OnlinePayments::SDK
4
+
5
+ # Base class of all Online Payments platform API resources.
6
+ # Provides shared functionality to facilitate communication with the Online Payments platform.
7
+ #
8
+ # @attr_reader [OnlinePayments::SDK::Communicator] communicator Communicator instance that provides communication with the Online Payments platform.
9
+ # @attr_reader [String] client_meta_info JSON string containing client info specific to the current client.
10
+ class ApiResource
11
+
12
+ # Creates a new ApiResource.
13
+ #
14
+ # @param arg [OnlinePayments::SDK::ApiResource, OnlinePayments::SDK::Communicator] parent class or Communicator instance.
15
+ # If a parent class is given its communicator will be used for communication.
16
+ # @param path_context [Hash, nil] hash that contains substitutions for generic locations in the URL path.
17
+ # This hash will be used to instantiate a concrete URL used to access specific resources.
18
+ # For example in the URL https://payment.preprod.online-payments.com/!{version}/!{merchantId}/payments
19
+ # !{version} and !{merchantId} can be instantiated using the hash
20
+ # !{'version' => 'v2', 'merchantId' => '1'}. The final URL in this case will be
21
+ # https://payment.preprod.online-payments.com/v2/1/payments.
22
+ # @param client_meta_info [String, nil] JSON string containing the meta data for the client.
23
+ def initialize(arg, path_context = nil, client_meta_info = false)
24
+ if client_meta_info == false
25
+ raise ArgumentError, 'parent is required' unless arg
26
+
27
+ @parent = arg
28
+ @communicator = arg.communicator
29
+ @client_meta_info = arg.client_meta_info
30
+ else
31
+ raise ArgumentError, 'communicator is required' unless arg
32
+
33
+ @parent = nil
34
+ @communicator = arg
35
+ @client_meta_info = client_meta_info
36
+ end
37
+ @path_context = path_context
38
+ end
39
+
40
+ attr_reader :communicator
41
+ attr_reader :client_meta_info
42
+
43
+ protected
44
+
45
+ # @return [Array<OnlinePayments::SDK::RequestHeader>, nil] the X-GCS-ClientMetaInfo header.
46
+ def client_headers
47
+ @client_meta_info ?
48
+ [RequestHeader.new('X-GCS-ClientMetaInfo', @client_meta_info)] :
49
+ nil
50
+ end
51
+
52
+ def instantiate_uri(uri, path_context = nil)
53
+ uri = replace_all(uri, path_context) if path_context
54
+ uri = replace_all(uri, @path_context)
55
+ @parent ? @parent.instantiate_uri(uri) : uri
56
+ end
57
+
58
+ def create_exception(status_code, response_body, error_object, context)
59
+ if error_object.nil?
60
+ error_id = nil
61
+ errors = []
62
+ elsif error_object.is_a?(OnlinePayments::SDK::Domain::PaymentErrorResponse) && error_object.payment_result
63
+ return DeclinedPaymentException.new(status_code, response_body, error_object)
64
+ elsif error_object.is_a?(OnlinePayments::SDK::Domain::PayoutErrorResponse) && error_object.payout_result
65
+ return DeclinedPayoutException.new(status_code, response_body, error_object)
66
+ elsif error_object.is_a?(OnlinePayments::SDK::Domain::RefundErrorResponse) && error_object.refund_result
67
+ return DeclinedRefundException.new(status_code, response_body, error_object)
68
+ elsif error_object.is_a?(OnlinePayments::SDK::Domain::PaymentErrorResponse) ||
69
+ error_object.is_a?(OnlinePayments::SDK::Domain::PayoutErrorResponse) ||
70
+ error_object.is_a?(OnlinePayments::SDK::Domain::RefundErrorResponse) ||
71
+ error_object.is_a?(OnlinePayments::SDK::Domain::ErrorResponse)
72
+ error_id = error_object.error_id
73
+ errors = error_object.errors
74
+ else
75
+ raise ArgumentError, "unsupported error object type: #{error_object.class.name}"
76
+ end
77
+
78
+ case status_code
79
+ when 400
80
+ return ValidationException.new(status_code, response_body, error_id, errors)
81
+ when 403
82
+ return AuthorizationException.new(status_code, response_body, error_id, errors)
83
+ when 404, 410
84
+ return ReferenceException.new(status_code, response_body, error_id, errors)
85
+ when 409
86
+ if is_idempotence_error(errors, context)
87
+ idempotence_key = context.idempotence_key
88
+ idempotence_request_timestamp = context.idempotence_request_timestamp
89
+ return IdempotenceException.new(status_code, response_body, error_id,
90
+ errors, idempotence_key,
91
+ idempotence_request_timestamp)
92
+ else
93
+ return ReferenceException.new(status_code, response_body, error_id, errors)
94
+ end
95
+ when 500, 502, 503
96
+ return PaymentPlatformException.new(status_code, response_body, error_id, errors)
97
+ else
98
+ return ApiException.new(status_code, response_body, error_id, errors)
99
+ end
100
+ end
101
+
102
+ private
103
+
104
+ def replace_all(uri, path_context)
105
+ path_context&.each do |key, value|
106
+ uri = uri.gsub("{#{key}}", value)
107
+ end
108
+ uri
109
+ end
110
+
111
+ def is_idempotence_error(errors, context)
112
+ context&.idempotence_key && errors.length == 1 && errors[0].code == '1409'
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,16 @@
1
+ module OnlinePayments::SDK
2
+
3
+ # Abstract class that is responsible for authenticating requests sent to the Online Payments platform.
4
+ class Authenticator
5
+
6
+ # Creates a signature to authenticate a request.
7
+ #
8
+ # @param http_method [String] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
9
+ # @param resource_uri [URI::HTTP] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
10
+ # @param request_headers [Array<OnlinePayments::SDK::RequestHeader>] all headers used by the request
11
+ # @return [String] the created signature
12
+ def create_simple_authentication_signature(http_method, resource_uri, request_headers)
13
+ raise NotImplementedError
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module OnlinePayments::SDK
2
+
3
+ # This exception is thrown when a request sent to the Online Payments platform is not correctly authenticated.
4
+ # Corresponds to a HTTP status code of 403.
5
+ # @see ApiException#initialize
6
+ class AuthorizationException < ApiException
7
+
8
+ def initialize(status_code, response_body, error_id, errors,
9
+ message = 'the Online Payments platform returned an authorization error response')
10
+ super(status_code, response_body, error_id, errors, message)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ module OnlinePayments::SDK
2
+
3
+ # A CallContext is used to identify requests and manage idempotent requests.
4
+ # A CallContext contains the following:
5
+ #
6
+ # idempotence_key:: A randomly generated key used to identify requests
7
+ # idempotence_request_timestamp:: If a previous request arrived with the same idempotence key,
8
+ # this value will be set to a timestamp of that request.
9
+ #
10
+ # @attr_reader [String] idempotence_key The idempotence key used to identify this request.
11
+ # If two requests share the same _idempotence_key_, they are considered to be the same request
12
+ # and only the first request will be processed.
13
+ # @attr [Integer] idempotence_request_timestamp If two or more requests arrive at the Online Payments platform with the same _idempotence_key_,
14
+ # the _idempotence_request_timestamp_ will be set to the arrival time of the first of these requests.
15
+ class CallContext
16
+ @idempotence_request_timestamp = nil
17
+ @idempotence_key = nil
18
+
19
+ def initialize(idempotence_key = nil)
20
+ @idempotence_key = idempotence_key
21
+ end
22
+
23
+ attr_reader :idempotence_key
24
+ attr_accessor :idempotence_request_timestamp
25
+ end
26
+ end
@@ -0,0 +1,82 @@
1
+ #
2
+ # This class was auto-generated.
3
+ #
4
+ require 'onlinepayments/sdk/api_resource'
5
+ require 'onlinepayments/sdk/data_object'
6
+ require 'onlinepayments/sdk/logging/logging_capable'
7
+ require 'onlinepayments/sdk/merchant/merchant_client'
8
+ require 'base64'
9
+
10
+ module OnlinePayments
11
+ module SDK
12
+ # payment platform client.
13
+ #
14
+ # This client and all its child clients are bound to one specific value for the X-GCS-ClientMetaInfo header.
15
+ #
16
+ # To get a new client with a different header value, use with_client_meta_info.
17
+ #
18
+ # Thread safe.
19
+ class Client < ApiResource
20
+ include Logging::LoggingCapable
21
+
22
+ # @return [String]
23
+ def self.API_VERSION
24
+ 'v2'
25
+ end
26
+
27
+ # @param communicator [OnlinePayments::SDK::Communicator]
28
+ # @param client_meta_info [String, nil]
29
+ def initialize(communicator, client_meta_info = nil)
30
+ super(communicator, nil, client_meta_info)
31
+ end
32
+
33
+ # @param client_meta_info [String, nil] JSON string containing the meta data for the client
34
+ # @return [OnlinePayments::SDK::Client] a Client which uses the passed meta data for the X-GCS-ClientMetaInfo header.
35
+ # @raise [OnlinePayments::SDK::MarshallerSyntaxException] if the given clientMetaInfo is not a valid JSON string
36
+ def with_client_meta_info(client_meta_info)
37
+ if client_meta_info
38
+ # Checking to see if this is valid JSON (no JSON parse exceptions)
39
+ @communicator.marshaller.unmarshal(client_meta_info, DataObject)
40
+ client_meta_info = Base64.strict_encode64(client_meta_info)
41
+ return @client_meta_info == client_meta_info ? self : Client.new(@communicator, client_meta_info)
42
+ end
43
+ @client_meta_info ? Client.new(@communicator) : self
44
+ end
45
+
46
+ # Utility method that delegates the call to this client's communicator.
47
+ def close_idle_connections(idle_time)
48
+ @communicator.close_idle_connections(idle_time)
49
+ end
50
+
51
+ # Utility method that delegates the call to this client's communicator.
52
+ def close_expired_connections
53
+ @communicator.close_expired_connections
54
+ end
55
+
56
+ # Turns on logging using the given communicator logger.
57
+ # @param communicator_logger [OnlinePayments::SDK::Logging::CommunicatorLogger]
58
+ def enable_logging(communicator_logger)
59
+ @communicator.enable_logging(communicator_logger)
60
+ end
61
+
62
+ # Turns off logging.
63
+ def disable_logging
64
+ @communicator.disable_logging
65
+ end
66
+
67
+ # Releases any system resources associated with this object.
68
+ def close
69
+ @communicator.close
70
+ end
71
+
72
+ # Resource /v2/!{merchantId}
73
+ # @param merchant_id [String]
74
+ # @return [OnlinePayments::SDK::Merchant::MerchantClient]
75
+ def merchant(merchant_id)
76
+ OnlinePayments::SDK::Merchant::MerchantClient.new(self, {
77
+ 'merchantId'.freeze => merchant_id
78
+ })
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,16 @@
1
+ module OnlinePayments::SDK
2
+
3
+ # This exception is used when an error occurs during network communication with the Online Payments platform.
4
+ # A common cause is a timeout while connecting or when receiving or sending data.
5
+ #
6
+ # @attr [Exception] cause The error that is the cause of this error.
7
+ class CommunicationException < RuntimeError
8
+
9
+ def initialize(cause)
10
+ super()
11
+ @cause = cause
12
+ end
13
+
14
+ attr_accessor :cause
15
+ end
16
+ end