connect-sdk-ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (377) 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/connect-sdk-ruby.gemspec +28 -0
  7. data/examples/merchant/example_configuration.yml +6 -0
  8. data/examples/merchant/hostedcheckouts/create_hosted_checkout_example.rb +53 -0
  9. data/examples/merchant/hostedcheckouts/get_hosted_checkout_example.rb +22 -0
  10. data/examples/merchant/payments/approve_payment_example.rb +42 -0
  11. data/examples/merchant/payments/cancel_approval_payment_example.rb +22 -0
  12. data/examples/merchant/payments/cancel_payment_example.rb +22 -0
  13. data/examples/merchant/payments/create_payment_example.rb +177 -0
  14. data/examples/merchant/payments/get_payment_example.rb +22 -0
  15. data/examples/merchant/payments/process_challenged_payment_example.rb +22 -0
  16. data/examples/merchant/payments/refund_payment_example.rb +85 -0
  17. data/examples/merchant/payments/tokenize_payment_example.rb +27 -0
  18. data/examples/merchant/payouts/approve_payout_example.rb +27 -0
  19. data/examples/merchant/payouts/cancel_approval_payout_example.rb +22 -0
  20. data/examples/merchant/payouts/cancel_payout_example.rb +22 -0
  21. data/examples/merchant/payouts/create_payout_example.rb +96 -0
  22. data/examples/merchant/payouts/get_payout_example.rb +22 -0
  23. data/examples/merchant/productgroups/get_payment_product_group_example.rb +32 -0
  24. data/examples/merchant/productgroups/get_payment_product_groups_example.rb +32 -0
  25. data/examples/merchant/products/get_directory_example.rb +28 -0
  26. data/examples/merchant/products/get_payment_product_example.rb +32 -0
  27. data/examples/merchant/products/get_payment_products_example.rb +32 -0
  28. data/examples/merchant/refunds/approve_refund_example.rb +27 -0
  29. data/examples/merchant/refunds/cancel_approval_refund_example.rb +22 -0
  30. data/examples/merchant/refunds/cancel_refund_example.rb +22 -0
  31. data/examples/merchant/refunds/get_refund_example.rb +22 -0
  32. data/examples/merchant/riskassessments/risk_assessment_bank_account_example.rb +54 -0
  33. data/examples/merchant/riskassessments/risk_assessment_cards_example.rb +114 -0
  34. data/examples/merchant/services/convert_amount_example.rb +29 -0
  35. data/examples/merchant/services/convert_bank_account_example.rb +34 -0
  36. data/examples/merchant/services/iin_details_example.rb +27 -0
  37. data/examples/merchant/services/test_connection_example.rb +22 -0
  38. data/examples/merchant/sessions/create_session_example.rb +34 -0
  39. data/examples/merchant/tokens/approve_sepa_direct_debit_token_example.rb +29 -0
  40. data/examples/merchant/tokens/create_token_example.rb +82 -0
  41. data/examples/merchant/tokens/delete_token_example.rb +27 -0
  42. data/examples/merchant/tokens/get_token_example.rb +22 -0
  43. data/examples/merchant/tokens/update_token_example.rb +76 -0
  44. data/lib/ingenico/connect/sdk.rb +27 -0
  45. data/lib/ingenico/connect/sdk/api_exception.rb +52 -0
  46. data/lib/ingenico/connect/sdk/api_resource.rb +126 -0
  47. data/lib/ingenico/connect/sdk/authenticator.rb +15 -0
  48. data/lib/ingenico/connect/sdk/authorization_exception.rb +13 -0
  49. data/lib/ingenico/connect/sdk/call_context.rb +26 -0
  50. data/lib/ingenico/connect/sdk/client.rb +92 -0
  51. data/lib/ingenico/connect/sdk/communication_exception.rb +15 -0
  52. data/lib/ingenico/connect/sdk/communicator.rb +277 -0
  53. data/lib/ingenico/connect/sdk/communicator_configuration.rb +98 -0
  54. data/lib/ingenico/connect/sdk/connection.rb +31 -0
  55. data/lib/ingenico/connect/sdk/data_object.rb +43 -0
  56. data/lib/ingenico/connect/sdk/declined_payment_exception.rb +44 -0
  57. data/lib/ingenico/connect/sdk/declined_payout_exception.rb +44 -0
  58. data/lib/ingenico/connect/sdk/declined_refund_exception.rb +46 -0
  59. data/lib/ingenico/connect/sdk/declined_transaction_exception.rb +16 -0
  60. data/lib/ingenico/connect/sdk/defaultimpl.rb +6 -0
  61. data/lib/ingenico/connect/sdk/defaultimpl/authorization_type.rb +18 -0
  62. data/lib/ingenico/connect/sdk/defaultimpl/default_authenticator.rb +106 -0
  63. data/lib/ingenico/connect/sdk/defaultimpl/default_connection.rb +242 -0
  64. data/lib/ingenico/connect/sdk/defaultimpl/default_marshaller.rb +35 -0
  65. data/lib/ingenico/connect/sdk/domain/definitions/abstract_order_status.rb +32 -0
  66. data/lib/ingenico/connect/sdk/domain/definitions/abstract_payment_method_specific_input.rb +32 -0
  67. data/lib/ingenico/connect/sdk/domain/definitions/additional_order_input_airline_data.rb +36 -0
  68. data/lib/ingenico/connect/sdk/domain/definitions/address.rb +81 -0
  69. data/lib/ingenico/connect/sdk/domain/definitions/airline_data.rb +165 -0
  70. data/lib/ingenico/connect/sdk/domain/definitions/airline_flight_leg.rb +102 -0
  71. data/lib/ingenico/connect/sdk/domain/definitions/amount_of_money.rb +39 -0
  72. data/lib/ingenico/connect/sdk/domain/definitions/bank_account.rb +32 -0
  73. data/lib/ingenico/connect/sdk/domain/definitions/bank_account_bban.rb +67 -0
  74. data/lib/ingenico/connect/sdk/domain/definitions/bank_account_iban.rb +32 -0
  75. data/lib/ingenico/connect/sdk/domain/definitions/card.rb +32 -0
  76. data/lib/ingenico/connect/sdk/domain/definitions/card_essentials.rb +39 -0
  77. data/lib/ingenico/connect/sdk/domain/definitions/card_fraud_results.rb +50 -0
  78. data/lib/ingenico/connect/sdk/domain/definitions/card_without_cvv.rb +39 -0
  79. data/lib/ingenico/connect/sdk/domain/definitions/company_information.rb +32 -0
  80. data/lib/ingenico/connect/sdk/domain/definitions/contact_details_base.rb +39 -0
  81. data/lib/ingenico/connect/sdk/domain/definitions/customer_base.rb +50 -0
  82. data/lib/ingenico/connect/sdk/domain/definitions/fraud_fields.rb +115 -0
  83. data/lib/ingenico/connect/sdk/domain/definitions/fraud_results.rb +32 -0
  84. data/lib/ingenico/connect/sdk/domain/definitions/fraud_results_retail_decisions.rb +46 -0
  85. data/lib/ingenico/connect/sdk/domain/definitions/key_value_pair.rb +39 -0
  86. data/lib/ingenico/connect/sdk/domain/definitions/order_status_output.rb +67 -0
  87. data/lib/ingenico/connect/sdk/domain/definitions/payment_product_filter.rb +51 -0
  88. data/lib/ingenico/connect/sdk/domain/definitions/personal_name_base.rb +46 -0
  89. data/lib/ingenico/connect/sdk/domain/definitions/result_do_risk_assessment.rb +61 -0
  90. data/lib/ingenico/connect/sdk/domain/definitions/retail_decisions_cc_fraud_check_output.rb +46 -0
  91. data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_check.rb +46 -0
  92. data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_output.rb +67 -0
  93. data/lib/ingenico/connect/sdk/domain/errors/api_error.rb +60 -0
  94. data/lib/ingenico/connect/sdk/domain/errors/error_response.rb +46 -0
  95. data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_request.rb +102 -0
  96. data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_response.rb +59 -0
  97. data/lib/ingenico/connect/sdk/domain/hostedcheckout/created_payment_output.rb +72 -0
  98. data/lib/ingenico/connect/sdk/domain/hostedcheckout/displayed_data.rb +53 -0
  99. data/lib/ingenico/connect/sdk/domain/hostedcheckout/get_hosted_checkout_response.rb +43 -0
  100. data/lib/ingenico/connect/sdk/domain/hostedcheckout/hosted_checkout_specific_input.rb +78 -0
  101. data/lib/ingenico/connect/sdk/domain/hostedcheckout/payment_product_filters_hosted_checkout.rb +53 -0
  102. data/lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb +48 -0
  103. data/lib/ingenico/connect/sdk/domain/payment/abstract_payment_method_specific_output.rb +32 -0
  104. data/lib/ingenico/connect/sdk/domain/payment/additional_order_input.rb +72 -0
  105. data/lib/ingenico/connect/sdk/domain/payment/address_personal.rb +36 -0
  106. data/lib/ingenico/connect/sdk/domain/payment/approve_payment_card_payment_method_specific_output.rb +32 -0
  107. data/lib/ingenico/connect/sdk/domain/payment/approve_payment_non_sepa_direct_debit_payment_method_specific_input.rb +16 -0
  108. data/lib/ingenico/connect/sdk/domain/payment/approve_payment_payment_method_specific_input.rb +39 -0
  109. data/lib/ingenico/connect/sdk/domain/payment/approve_payment_request.rb +65 -0
  110. data/lib/ingenico/connect/sdk/domain/payment/approve_payment_sepa_direct_debit_payment_method_specific_input.rb +16 -0
  111. data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input.rb +16 -0
  112. data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input_base.rb +32 -0
  113. data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_output.rb +16 -0
  114. data/lib/ingenico/connect/sdk/domain/payment/cancel_approval_payment_response.rb +36 -0
  115. data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_card_payment_method_specific_output.rb +32 -0
  116. data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_response.rb +47 -0
  117. data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input.rb +61 -0
  118. data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input_base.rb +60 -0
  119. data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_output.rb +65 -0
  120. data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input.rb +47 -0
  121. data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input_base.rb +16 -0
  122. data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_output.rb +16 -0
  123. data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1503_specific_input.rb +32 -0
  124. data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1504_specific_input.rb +32 -0
  125. data/lib/ingenico/connect/sdk/domain/payment/contact_details.rb +39 -0
  126. data/lib/ingenico/connect/sdk/domain/payment/create_payment_request.rb +131 -0
  127. data/lib/ingenico/connect/sdk/domain/payment/create_payment_response.rb +16 -0
  128. data/lib/ingenico/connect/sdk/domain/payment/create_payment_result.rb +58 -0
  129. data/lib/ingenico/connect/sdk/domain/payment/customer.rb +83 -0
  130. data/lib/ingenico/connect/sdk/domain/payment/external_cardholder_authentication_data.rb +60 -0
  131. data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_input.rb +32 -0
  132. data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_output.rb +16 -0
  133. data/lib/ingenico/connect/sdk/domain/payment/level3_summary_data.rb +46 -0
  134. data/lib/ingenico/connect/sdk/domain/payment/line_item.rb +58 -0
  135. data/lib/ingenico/connect/sdk/domain/payment/line_item_invoice_data.rb +60 -0
  136. data/lib/ingenico/connect/sdk/domain/payment/line_item_level3_interchange_information.rb +81 -0
  137. data/lib/ingenico/connect/sdk/domain/payment/merchant_action.rb +64 -0
  138. data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_input.rb +71 -0
  139. data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_output.rb +36 -0
  140. data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_product705_specific_input.rb +50 -0
  141. data/lib/ingenico/connect/sdk/domain/payment/order.rb +83 -0
  142. data/lib/ingenico/connect/sdk/domain/payment/order_approve_payment.rb +47 -0
  143. data/lib/ingenico/connect/sdk/domain/payment/order_invoice_data.rb +59 -0
  144. data/lib/ingenico/connect/sdk/domain/payment/order_output.rb +47 -0
  145. data/lib/ingenico/connect/sdk/domain/payment/order_references.rb +57 -0
  146. data/lib/ingenico/connect/sdk/domain/payment/order_references_approve_payment.rb +32 -0
  147. data/lib/ingenico/connect/sdk/domain/payment/order_type_information.rb +39 -0
  148. data/lib/ingenico/connect/sdk/domain/payment/payment.rb +54 -0
  149. data/lib/ingenico/connect/sdk/domain/payment/payment_approval_response.rb +47 -0
  150. data/lib/ingenico/connect/sdk/domain/payment/payment_creation_output.rb +39 -0
  151. data/lib/ingenico/connect/sdk/domain/payment/payment_creation_references.rb +39 -0
  152. data/lib/ingenico/connect/sdk/domain/payment/payment_error_response.rb +57 -0
  153. data/lib/ingenico/connect/sdk/domain/payment/payment_output.rb +116 -0
  154. data/lib/ingenico/connect/sdk/domain/payment/payment_product836_specific_output.rb +32 -0
  155. data/lib/ingenico/connect/sdk/domain/payment/payment_product840_customer_account.rb +88 -0
  156. data/lib/ingenico/connect/sdk/domain/payment/payment_product840_specific_output.rb +47 -0
  157. data/lib/ingenico/connect/sdk/domain/payment/payment_references.rb +67 -0
  158. data/lib/ingenico/connect/sdk/domain/payment/payment_response.rb +16 -0
  159. data/lib/ingenico/connect/sdk/domain/payment/payment_status_output.rb +39 -0
  160. data/lib/ingenico/connect/sdk/domain/payment/personal_information.rb +50 -0
  161. data/lib/ingenico/connect/sdk/domain/payment/personal_name.rb +32 -0
  162. data/lib/ingenico/connect/sdk/domain/payment/redirect_data.rb +39 -0
  163. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input.rb +72 -0
  164. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input_base.rb +39 -0
  165. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_output.rb +58 -0
  166. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product809_specific_input.rb +39 -0
  167. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product816_specific_input.rb +36 -0
  168. data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product882_specific_input.rb +32 -0
  169. data/lib/ingenico/connect/sdk/domain/payment/refund_bank_method_specific_output.rb +16 -0
  170. data/lib/ingenico/connect/sdk/domain/payment/refund_card_method_specific_output.rb +16 -0
  171. data/lib/ingenico/connect/sdk/domain/payment/refund_e_wallet_method_specific_output.rb +36 -0
  172. data/lib/ingenico/connect/sdk/domain/payment/refund_method_specific_output.rb +39 -0
  173. data/lib/ingenico/connect/sdk/domain/payment/refund_output.rb +72 -0
  174. data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_customer_account.rb +46 -0
  175. data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_specific_output.rb +36 -0
  176. data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_input.rb +60 -0
  177. data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_output.rb +36 -0
  178. data/lib/ingenico/connect/sdk/domain/payment/three_d_secure_results.rb +46 -0
  179. data/lib/ingenico/connect/sdk/domain/payment/tokenize_payment_request.rb +32 -0
  180. data/lib/ingenico/connect/sdk/domain/payout/approve_payout_request.rb +32 -0
  181. data/lib/ingenico/connect/sdk/domain/payout/create_payout_request.rb +101 -0
  182. data/lib/ingenico/connect/sdk/domain/payout/payout_customer.rb +76 -0
  183. data/lib/ingenico/connect/sdk/domain/payout/payout_error_response.rb +57 -0
  184. data/lib/ingenico/connect/sdk/domain/payout/payout_references.rb +46 -0
  185. data/lib/ingenico/connect/sdk/domain/payout/payout_response.rb +16 -0
  186. data/lib/ingenico/connect/sdk/domain/payout/payout_result.rb +54 -0
  187. data/lib/ingenico/connect/sdk/domain/product/account_on_file.rb +64 -0
  188. data/lib/ingenico/connect/sdk/domain/product/account_on_file_attribute.rb +39 -0
  189. data/lib/ingenico/connect/sdk/domain/product/account_on_file_display_hints.rb +46 -0
  190. data/lib/ingenico/connect/sdk/domain/product/directory.rb +39 -0
  191. data/lib/ingenico/connect/sdk/domain/product/directory_entry.rb +59 -0
  192. data/lib/ingenico/connect/sdk/domain/product/empty_validator.rb +16 -0
  193. data/lib/ingenico/connect/sdk/domain/product/fixed_list_validator.rb +38 -0
  194. data/lib/ingenico/connect/sdk/domain/product/label_template_element.rb +39 -0
  195. data/lib/ingenico/connect/sdk/domain/product/length_validator.rb +39 -0
  196. data/lib/ingenico/connect/sdk/domain/product/payment_product.rb +134 -0
  197. data/lib/ingenico/connect/sdk/domain/product/payment_product_display_hints.rb +46 -0
  198. data/lib/ingenico/connect/sdk/domain/product/payment_product_field.rb +61 -0
  199. data/lib/ingenico/connect/sdk/domain/product/payment_product_field_data_restrictions.rb +43 -0
  200. data/lib/ingenico/connect/sdk/domain/product/payment_product_field_display_hints.rb +96 -0
  201. data/lib/ingenico/connect/sdk/domain/product/payment_product_field_form_element.rb +46 -0
  202. data/lib/ingenico/connect/sdk/domain/product/payment_product_field_tooltip.rb +39 -0
  203. data/lib/ingenico/connect/sdk/domain/product/payment_product_field_validators.rb +100 -0
  204. data/lib/ingenico/connect/sdk/domain/product/payment_product_group.rb +71 -0
  205. data/lib/ingenico/connect/sdk/domain/product/payment_product_group_response.rb +16 -0
  206. data/lib/ingenico/connect/sdk/domain/product/payment_product_groups.rb +39 -0
  207. data/lib/ingenico/connect/sdk/domain/product/payment_product_response.rb +16 -0
  208. data/lib/ingenico/connect/sdk/domain/product/payment_products.rb +39 -0
  209. data/lib/ingenico/connect/sdk/domain/product/range_validator.rb +39 -0
  210. data/lib/ingenico/connect/sdk/domain/product/regular_expression_validator.rb +32 -0
  211. data/lib/ingenico/connect/sdk/domain/product/value_mapping_element.rb +39 -0
  212. data/lib/ingenico/connect/sdk/domain/refund/approve_refund_request.rb +32 -0
  213. data/lib/ingenico/connect/sdk/domain/refund/bank_account_bban_refund.rb +39 -0
  214. data/lib/ingenico/connect/sdk/domain/refund/bank_refund_method_specific_input.rb +54 -0
  215. data/lib/ingenico/connect/sdk/domain/refund/refund_customer.rb +58 -0
  216. data/lib/ingenico/connect/sdk/domain/refund/refund_error_response.rb +57 -0
  217. data/lib/ingenico/connect/sdk/domain/refund/refund_references.rb +32 -0
  218. data/lib/ingenico/connect/sdk/domain/refund/refund_request.rb +76 -0
  219. data/lib/ingenico/connect/sdk/domain/refund/refund_response.rb +16 -0
  220. data/lib/ingenico/connect/sdk/domain/refund/refund_result.rb +54 -0
  221. data/lib/ingenico/connect/sdk/domain/riskassessments/customer_risk_assessment.rb +65 -0
  222. data/lib/ingenico/connect/sdk/domain/riskassessments/order_risk_assessment.rb +58 -0
  223. data/lib/ingenico/connect/sdk/domain/riskassessments/personal_information_risk_assessment.rb +36 -0
  224. data/lib/ingenico/connect/sdk/domain/riskassessments/personal_name_risk_assessment.rb +16 -0
  225. data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment.rb +54 -0
  226. data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_bank_account.rb +47 -0
  227. data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_card.rb +36 -0
  228. data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_response.rb +39 -0
  229. data/lib/ingenico/connect/sdk/domain/services/bank_data.rb +53 -0
  230. data/lib/ingenico/connect/sdk/domain/services/bank_details.rb +47 -0
  231. data/lib/ingenico/connect/sdk/domain/services/bank_details_request.rb +16 -0
  232. data/lib/ingenico/connect/sdk/domain/services/bank_details_response.rb +69 -0
  233. data/lib/ingenico/connect/sdk/domain/services/convert_amount.rb +32 -0
  234. data/lib/ingenico/connect/sdk/domain/services/get_iin_details_request.rb +43 -0
  235. data/lib/ingenico/connect/sdk/domain/services/get_iin_details_response.rb +60 -0
  236. data/lib/ingenico/connect/sdk/domain/services/iin_detail.rb +39 -0
  237. data/lib/ingenico/connect/sdk/domain/services/payment_context.rb +50 -0
  238. data/lib/ingenico/connect/sdk/domain/services/swift.rb +95 -0
  239. data/lib/ingenico/connect/sdk/domain/services/test_connection.rb +32 -0
  240. data/lib/ingenico/connect/sdk/domain/sessions/payment_product_filters_client_session.rb +46 -0
  241. data/lib/ingenico/connect/sdk/domain/sessions/session_request.rb +49 -0
  242. data/lib/ingenico/connect/sdk/domain/sessions/session_response.rb +59 -0
  243. data/lib/ingenico/connect/sdk/domain/token/abstract_token.rb +32 -0
  244. data/lib/ingenico/connect/sdk/domain/token/approve_token_request.rb +16 -0
  245. data/lib/ingenico/connect/sdk/domain/token/contact_details_token.rb +16 -0
  246. data/lib/ingenico/connect/sdk/domain/token/create_token_request.rb +76 -0
  247. data/lib/ingenico/connect/sdk/domain/token/create_token_response.rb +39 -0
  248. data/lib/ingenico/connect/sdk/domain/token/creditor.rb +102 -0
  249. data/lib/ingenico/connect/sdk/domain/token/customer_token.rb +47 -0
  250. data/lib/ingenico/connect/sdk/domain/token/customer_token_with_contact_details.rb +36 -0
  251. data/lib/ingenico/connect/sdk/domain/token/debtor.rb +102 -0
  252. data/lib/ingenico/connect/sdk/domain/token/mandate_approval.rb +46 -0
  253. data/lib/ingenico/connect/sdk/domain/token/mandate_non_sepa_direct_debit.rb +36 -0
  254. data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit.rb +36 -0
  255. data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_with_mandate_id.rb +32 -0
  256. data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_without_creditor.rb +79 -0
  257. data/lib/ingenico/connect/sdk/domain/token/personal_information_token.rb +36 -0
  258. data/lib/ingenico/connect/sdk/domain/token/personal_name_token.rb +16 -0
  259. data/lib/ingenico/connect/sdk/domain/token/token_card.rb +47 -0
  260. data/lib/ingenico/connect/sdk/domain/token/token_card_data.rb +50 -0
  261. data/lib/ingenico/connect/sdk/domain/token/token_e_wallet.rb +47 -0
  262. data/lib/ingenico/connect/sdk/domain/token/token_e_wallet_data.rb +32 -0
  263. data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit.rb +47 -0
  264. data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit_payment_product705_specific_data.rb +43 -0
  265. data/lib/ingenico/connect/sdk/domain/token/token_response.rb +83 -0
  266. data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit.rb +47 -0
  267. data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit_without_creditor.rb +47 -0
  268. data/lib/ingenico/connect/sdk/domain/token/update_token_request.rb +76 -0
  269. data/lib/ingenico/connect/sdk/endpoint_configuration.rb +139 -0
  270. data/lib/ingenico/connect/sdk/exceptions.rb +8 -0
  271. data/lib/ingenico/connect/sdk/factory.rb +200 -0
  272. data/lib/ingenico/connect/sdk/global_collect_exception.rb +15 -0
  273. data/lib/ingenico/connect/sdk/idempotence_exception.rb +24 -0
  274. data/lib/ingenico/connect/sdk/logging.rb +10 -0
  275. data/lib/ingenico/connect/sdk/logging/communicator_logger.rb +19 -0
  276. data/lib/ingenico/connect/sdk/logging/log_message_builder.rb +61 -0
  277. data/lib/ingenico/connect/sdk/logging/logging_capable.rb +19 -0
  278. data/lib/ingenico/connect/sdk/logging/logging_util.rb +298 -0
  279. data/lib/ingenico/connect/sdk/logging/request_log_message_builder.rb +42 -0
  280. data/lib/ingenico/connect/sdk/logging/response_log_message_builder.rb +34 -0
  281. data/lib/ingenico/connect/sdk/logging/ruby_communicator_logger.rb +58 -0
  282. data/lib/ingenico/connect/sdk/logging/stdout_communicator_logger.rb +36 -0
  283. data/lib/ingenico/connect/sdk/marshaller.rb +19 -0
  284. data/lib/ingenico/connect/sdk/marshaller_syntax_exception.rb +6 -0
  285. data/lib/ingenico/connect/sdk/merchant/hostedcheckouts/hostedcheckouts_client.rb +88 -0
  286. data/lib/ingenico/connect/sdk/merchant/merchant_client.rb +110 -0
  287. data/lib/ingenico/connect/sdk/merchant/payments/payments_client.rb +319 -0
  288. data/lib/ingenico/connect/sdk/merchant/payouts/payouts_client.rb +197 -0
  289. data/lib/ingenico/connect/sdk/merchant/productgroups/find_productgroups_params.rb +55 -0
  290. data/lib/ingenico/connect/sdk/merchant/productgroups/get_productgroup_params.rb +55 -0
  291. data/lib/ingenico/connect/sdk/merchant/productgroups/productgroups_client.rb +90 -0
  292. data/lib/ingenico/connect/sdk/merchant/products/directory_params.rb +31 -0
  293. data/lib/ingenico/connect/sdk/merchant/products/find_products_params.rb +55 -0
  294. data/lib/ingenico/connect/sdk/merchant/products/get_product_params.rb +55 -0
  295. data/lib/ingenico/connect/sdk/merchant/products/products_client.rb +124 -0
  296. data/lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb +154 -0
  297. data/lib/ingenico/connect/sdk/merchant/riskassessments/riskassessments_client.rb +85 -0
  298. data/lib/ingenico/connect/sdk/merchant/services/convert_amount_params.rb +35 -0
  299. data/lib/ingenico/connect/sdk/merchant/services/services_client.rb +149 -0
  300. data/lib/ingenico/connect/sdk/merchant/sessions/sessions_client.rb +55 -0
  301. data/lib/ingenico/connect/sdk/merchant/tokens/delete_token_params.rb +27 -0
  302. data/lib/ingenico/connect/sdk/merchant/tokens/tokens_client.rb +192 -0
  303. data/lib/ingenico/connect/sdk/meta_data_provider.rb +152 -0
  304. data/lib/ingenico/connect/sdk/modules.rb +130 -0
  305. data/lib/ingenico/connect/sdk/not_found_exception.rb +19 -0
  306. data/lib/ingenico/connect/sdk/param_request.rb +33 -0
  307. data/lib/ingenico/connect/sdk/pooled_connection.rb +21 -0
  308. data/lib/ingenico/connect/sdk/proxy_configuration.rb +75 -0
  309. data/lib/ingenico/connect/sdk/reference_exception.rb +14 -0
  310. data/lib/ingenico/connect/sdk/request_header.rb +25 -0
  311. data/lib/ingenico/connect/sdk/request_param.rb +24 -0
  312. data/lib/ingenico/connect/sdk/response.rb +62 -0
  313. data/lib/ingenico/connect/sdk/response_exception.rb +54 -0
  314. data/lib/ingenico/connect/sdk/response_header.rb +25 -0
  315. data/lib/ingenico/connect/sdk/session.rb +39 -0
  316. data/lib/ingenico/connect/sdk/validation_exception.rb +14 -0
  317. data/spec/comparable_extension.rb +29 -0
  318. data/spec/fixtures/resources/defaultimpl/convertAmount.json +3 -0
  319. data/spec/fixtures/resources/defaultimpl/createPayment.failure.invalidCardNumber.json +11 -0
  320. data/spec/fixtures/resources/defaultimpl/createPayment.failure.rejected.json +48 -0
  321. data/spec/fixtures/resources/defaultimpl/createPayment.json +40 -0
  322. data/spec/fixtures/resources/defaultimpl/idempotence_duplicate_failure.json +8 -0
  323. data/spec/fixtures/resources/defaultimpl/idempotence_rejected.json +46 -0
  324. data/spec/fixtures/resources/defaultimpl/idempotence_success.json +39 -0
  325. data/spec/fixtures/resources/defaultimpl/notFound.html +1 -0
  326. data/spec/fixtures/resources/defaultimpl/testConnection.json +3 -0
  327. data/spec/fixtures/resources/defaultimpl/unknownServerError.json +10 -0
  328. data/spec/fixtures/resources/logging/bodyNoObfuscation.json +17 -0
  329. data/spec/fixtures/resources/logging/bodyWithBinObfuscated.json +3 -0
  330. data/spec/fixtures/resources/logging/bodyWithBinOriginal.json +3 -0
  331. data/spec/fixtures/resources/logging/bodyWithCardObfuscated.json +21 -0
  332. data/spec/fixtures/resources/logging/bodyWithCardOriginal.json +21 -0
  333. data/spec/fixtures/resources/logging/bodyWithIbanObfuscated.json +19 -0
  334. data/spec/fixtures/resources/logging/bodyWithIbanOriginal.json +19 -0
  335. data/spec/fixtures/resources/payment/duplicate_request.json +8 -0
  336. data/spec/fixtures/resources/payment/invalid_authorization.json +9 -0
  337. data/spec/fixtures/resources/payment/invalid_request.json +11 -0
  338. data/spec/fixtures/resources/payment/method_not_allowed.html +1 -0
  339. data/spec/fixtures/resources/payment/not_found.html +1 -0
  340. data/spec/fixtures/resources/payment/pending_approval.json +39 -0
  341. data/spec/fixtures/resources/payment/rejected.json +46 -0
  342. data/spec/fixtures/resources/properties.proxy.yml +13 -0
  343. data/spec/fixtures/resources/properties.yml +7 -0
  344. data/spec/integration/connection_pooling_spec.rb +78 -0
  345. data/spec/integration/convert_amount_spec.rb +25 -0
  346. data/spec/integration/idempotence_spec.rb +59 -0
  347. data/spec/integration/multiline_header_spec.rb +30 -0
  348. data/spec/integration/payment_product_groups_spec.rb +23 -0
  349. data/spec/integration/payment_products_spec.rb +22 -0
  350. data/spec/integration/risk_assessments_spec.rb +37 -0
  351. data/spec/integration/sdk_proxy_spec.rb +89 -0
  352. data/spec/integration/token_spec.rb +42 -0
  353. data/spec/integration_setup.rb +50 -0
  354. data/spec/lib/client_spec.rb +69 -0
  355. data/spec/lib/communicator_configuration_spec.rb +179 -0
  356. data/spec/lib/communicator_spec.rb +31 -0
  357. data/spec/lib/defaultimpl/default_authenticator_spec.rb +74 -0
  358. data/spec/lib/defaultimpl/default_connection_idempotence_spec.rb +142 -0
  359. data/spec/lib/defaultimpl/default_connection_logger_spec.rb +526 -0
  360. data/spec/lib/defaultimpl/default_connection_spec.rb +334 -0
  361. data/spec/lib/defaultimpl/default_marshaller_spec.rb +36 -0
  362. data/spec/lib/factory_spec.rb +41 -0
  363. data/spec/lib/logging/header_obfuscator_spec.rb +51 -0
  364. data/spec/lib/logging/logging_util_spec.rb +143 -0
  365. data/spec/lib/logging/obfuscator_spec.rb +52 -0
  366. data/spec/lib/logging/ruby_communicator_logger_spec.rb +84 -0
  367. data/spec/lib/logging/stdout_communicator_logger_spec.rb +64 -0
  368. data/spec/lib/logging/value_obfuscator_spec.rb +95 -0
  369. data/spec/lib/meta_data_provider_spec.rb +71 -0
  370. data/spec/lib/payments_client_spec.rb +157 -0
  371. data/spec/lib/requestparams/delete_params_spec.rb +21 -0
  372. data/spec/lib/requestparams/directory_params_spec.rb +27 -0
  373. data/spec/lib/requestparams/find_params_spec.rb +58 -0
  374. data/spec/lib/requestparams/get_params_spec.rb +59 -0
  375. data/spec/lib/requestparams/param_request_spec.rb +57 -0
  376. data/spec/spec_helper.rb +23 -0
  377. metadata +565 -0
@@ -0,0 +1,34 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+ require 'ingenico/connect/sdk/domain/sessions/session_request'
7
+
8
+ Sessions = Ingenico::Connect::SDK::Domain::Sessions
9
+
10
+ def example
11
+ get_client do |client|
12
+ tokens = []
13
+ tokens << '126166b16ed04b3ab85fb06da1d7a167'
14
+ tokens << '226166b16ed04b3ab85fb06da1d7a167'
15
+ tokens << '122c5b4d-dd40-49f0-b7c9-3594212167a9'
16
+ tokens << '326166b16ed04b3ab85fb06da1d7a167'
17
+ tokens << '426166b16ed04b3ab85fb06da1d7a167'
18
+
19
+ body = Sessions::SessionRequest.new
20
+ body.tokens = tokens
21
+
22
+ response = client.merchant('merchantId').sessions().create(body)
23
+ end
24
+ end
25
+
26
+ def get_client
27
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
28
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
29
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
30
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
31
+ ensure
32
+ # Free networking resources when done
33
+ client.close unless client.nil?
34
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+ require 'ingenico/connect/sdk/domain/token/approve_token_request'
7
+
8
+ Token = Ingenico::Connect::SDK::Domain::Token
9
+
10
+ def example
11
+ get_client do |client|
12
+ body = Token::ApproveTokenRequest.new
13
+ body.mandate_signature_date = '20150201'
14
+ body.mandate_signature_place = 'Monument Valley'
15
+ body.mandate_signed = true
16
+
17
+ client.merchant('merchantId').tokens().approvesepadirectdebit('tokenId', body)
18
+ end
19
+ end
20
+
21
+ def get_client
22
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
23
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
24
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
25
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
26
+ ensure
27
+ # Free networking resources when done
28
+ client.close unless client.nil?
29
+ end
@@ -0,0 +1,82 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+ require 'ingenico/connect/sdk/domain/definitions/address'
7
+ require 'ingenico/connect/sdk/domain/definitions/bank_account_bban'
8
+ require 'ingenico/connect/sdk/domain/definitions/company_information'
9
+ require 'ingenico/connect/sdk/domain/token/create_token_request'
10
+ require 'ingenico/connect/sdk/domain/token/customer_token'
11
+ require 'ingenico/connect/sdk/domain/token/mandate_non_sepa_direct_debit'
12
+ require 'ingenico/connect/sdk/domain/token/personal_information_token'
13
+ require 'ingenico/connect/sdk/domain/token/personal_name_token'
14
+ require 'ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit'
15
+ require 'ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit_payment_product705_specific_data'
16
+
17
+ Definitions = Ingenico::Connect::SDK::Domain::Definitions
18
+ Token = Ingenico::Connect::SDK::Domain::Token
19
+
20
+ def example
21
+ get_client do |client|
22
+ billing_address = Definitions::Address.new
23
+ billing_address.additional_info = 'Suite II'
24
+ billing_address.city = 'Monument Valley'
25
+ billing_address.country_code = 'US'
26
+ billing_address.house_number = '1'
27
+ billing_address.state = 'Utah'
28
+ billing_address.street = 'Desertroad'
29
+ billing_address.zip = '84536'
30
+
31
+ company_information = Definitions::CompanyInformation.new
32
+ company_information.name = 'Acme Labs'
33
+
34
+ name = Token::PersonalNameToken.new
35
+ name.first_name = 'Wile'
36
+ name.surname = 'Coyote'
37
+ name.surname_prefix = 'E.'
38
+
39
+ personal_information = Token::PersonalInformationToken.new
40
+ personal_information.name = name
41
+
42
+ customer = Token::CustomerToken.new
43
+ customer.billing_address = billing_address
44
+ customer.company_information = company_information
45
+ customer.merchant_customer_id = '1234'
46
+ customer.personal_information = personal_information
47
+
48
+ bank_account_bban = Definitions::BankAccountBban.new
49
+ bank_account_bban.account_number = '000000123456'
50
+ bank_account_bban.bank_code = '05428'
51
+ bank_account_bban.branch_code = '11101'
52
+ bank_account_bban.check_digit = 'X'
53
+ bank_account_bban.country_code = 'IT'
54
+
55
+ payment_product705_specific_data = Token::TokenNonSepaDirectDebitPaymentProduct705SpecificData.new
56
+ payment_product705_specific_data.authorisation_id = '123456'
57
+ payment_product705_specific_data.bank_account_bban = bank_account_bban
58
+
59
+ mandate = Token::MandateNonSepaDirectDebit.new
60
+ mandate.payment_product705_specific_data = payment_product705_specific_data
61
+
62
+ non_sepa_direct_debit = Token::TokenNonSepaDirectDebit.new
63
+ non_sepa_direct_debit.customer = customer
64
+ non_sepa_direct_debit.mandate = mandate
65
+
66
+ body = Token::CreateTokenRequest.new
67
+ body.non_sepa_direct_debit = non_sepa_direct_debit
68
+ body.payment_product_id = 705
69
+
70
+ response = client.merchant('merchantId').tokens().create(body)
71
+ end
72
+ end
73
+
74
+ def get_client
75
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
76
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
77
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
78
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
79
+ ensure
80
+ # Free networking resources when done
81
+ client.close unless client.nil?
82
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+ require 'ingenico/connect/sdk/merchant/tokens/delete_token_params'
7
+
8
+ Tokens = Ingenico::Connect::SDK::Merchant::Tokens
9
+
10
+ def example
11
+ get_client do |client|
12
+ query = Tokens::DeleteTokenParams.new
13
+ query.mandate_cancel_date = '20150102'
14
+
15
+ client.merchant('merchantId').tokens().delete('tokenId', query)
16
+ end
17
+ end
18
+
19
+ def get_client
20
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
21
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
22
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
23
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
24
+ ensure
25
+ # Free networking resources when done
26
+ client.close unless client.nil?
27
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+
7
+
8
+ def example
9
+ get_client do |client|
10
+ response = client.merchant('merchantId').tokens().get('tokenId')
11
+ end
12
+ end
13
+
14
+ def get_client
15
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
16
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
17
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
18
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
19
+ ensure
20
+ # Free networking resources when done
21
+ client.close unless client.nil?
22
+ end
@@ -0,0 +1,76 @@
1
+ #
2
+ # This class was auto-generated from the API references found at
3
+ # https://developer.globalcollect.com/documentation/api/server/
4
+ #
5
+ require 'ingenico/connect/sdk/factory'
6
+ require 'ingenico/connect/sdk/domain/definitions/address'
7
+ require 'ingenico/connect/sdk/domain/definitions/card_without_cvv'
8
+ require 'ingenico/connect/sdk/domain/definitions/company_information'
9
+ require 'ingenico/connect/sdk/domain/token/update_token_request'
10
+ require 'ingenico/connect/sdk/domain/token/customer_token'
11
+ require 'ingenico/connect/sdk/domain/token/personal_information_token'
12
+ require 'ingenico/connect/sdk/domain/token/personal_name_token'
13
+ require 'ingenico/connect/sdk/domain/token/token_card'
14
+ require 'ingenico/connect/sdk/domain/token/token_card_data'
15
+
16
+ Definitions = Ingenico::Connect::SDK::Domain::Definitions
17
+ Token = Ingenico::Connect::SDK::Domain::Token
18
+
19
+ def example
20
+ get_client do |client|
21
+ billing_address = Definitions::Address.new
22
+ billing_address.additional_info = 'b'
23
+ billing_address.city = 'Monument Valley'
24
+ billing_address.country_code = 'US'
25
+ billing_address.house_number = '13'
26
+ billing_address.state = 'Utah'
27
+ billing_address.street = 'Desertroad'
28
+ billing_address.zip = '84536'
29
+
30
+ company_information = Definitions::CompanyInformation.new
31
+ company_information.name = 'Acme Labs'
32
+
33
+ name = Token::PersonalNameToken.new
34
+ name.first_name = 'Wile'
35
+ name.surname = 'Coyote'
36
+ name.surname_prefix = 'E.'
37
+
38
+ personal_information = Token::PersonalInformationToken.new
39
+ personal_information.name = name
40
+
41
+ customer = Token::CustomerToken.new
42
+ customer.billing_address = billing_address
43
+ customer.company_information = company_information
44
+ customer.merchant_customer_id = '1234'
45
+ customer.personal_information = personal_information
46
+
47
+ card_without_cvv = Definitions::CardWithoutCvv.new
48
+ card_without_cvv.card_number = '4567350000427977'
49
+ card_without_cvv.cardholder_name = 'Wile E. Coyote'
50
+ card_without_cvv.expiry_date = '0820'
51
+ card_without_cvv.issue_number = '12'
52
+
53
+ data = Token::TokenCardData.new
54
+ data.card_without_cvv = card_without_cvv
55
+
56
+ card = Token::TokenCard.new
57
+ card.customer = customer
58
+ card.data = data
59
+
60
+ body = Token::UpdateTokenRequest.new
61
+ body.card = card
62
+ body.payment_product_id = 1
63
+
64
+ client.merchant('merchantId').tokens().update('tokenId', body)
65
+ end
66
+ end
67
+
68
+ def get_client
69
+ api_key_id = ENV.fetch('connect.api.apiKeyId', 'someKey')
70
+ secret_api_key = ENV.fetch('connect.api.secretApiKey', 'someSecret')
71
+ configuration_file_name = File.join(__FILE__, '..', '..', 'example_configuration.yml')
72
+ yield client = Ingenico::Connect::SDK::Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key)
73
+ ensure
74
+ # Free networking resources when done
75
+ client.close unless client.nil?
76
+ end
@@ -0,0 +1,27 @@
1
+ prefix = 'ingenico/connect/sdk/'
2
+
3
+ require prefix + 'logging'
4
+ require prefix + 'exceptions'
5
+
6
+ require prefix + 'marshaller'
7
+ require prefix + 'response_header'
8
+ require prefix + 'authenticator'
9
+ require prefix + 'data_object'
10
+ require prefix + 'proxy_configuration'
11
+ require prefix + 'connection'
12
+ require prefix + 'pooled_connection'
13
+ require prefix + 'communicator'
14
+ require prefix + 'endpoint_configuration'
15
+ require prefix + 'communicator_configuration'
16
+ require prefix + 'client'
17
+ require prefix + 'call_context'
18
+ require prefix + 'api_resource'
19
+ require prefix + 'session'
20
+ require prefix + 'response'
21
+ require prefix + 'request_param'
22
+ require prefix + 'request_header'
23
+ require prefix + 'param_request'
24
+ require prefix + 'meta_data_provider'
25
+ require prefix + 'factory'
26
+
27
+ require prefix + 'defaultimpl'
@@ -0,0 +1,52 @@
1
+ module Ingenico::Connect::SDK
2
+
3
+ # Base class for many exceptions raised by the SDK.
4
+ # It is raised when an error response is received from the GlobalCollect platform.
5
+ # It contains data about the returned response.
6
+ class ApiException < RuntimeError
7
+
8
+ # Creates a new ApiException that reports an error response from the GlobalCollect platform.
9
+ # It reports the following:
10
+ # status_code:: HTTP status code the response
11
+ # response_body:: HTTP response body
12
+ # error_id:: Error id of the error, may be _nil_
13
+ # errors:: A list of errors that occurred, may be empty
14
+ # message:: Error message to include
15
+ def initialize(status_code, response_body, error_id, errors,
16
+ message='the GlobalCollect platform returned an error response')
17
+ super(message)
18
+ @status_code = status_code
19
+ @response_body = response_body
20
+ @error_id = error_id
21
+ if errors.nil?
22
+ @errors = [].freeze
23
+ else
24
+ @errors = errors
25
+ end
26
+ end
27
+
28
+ # HTTP status code of the returned response.
29
+ attr_reader :status_code
30
+
31
+ # Message body of the returned response.
32
+ attr_reader :response_body
33
+
34
+ # An error id corresponding to the error that occurred, if available.
35
+ attr_reader :error_id
36
+
37
+ # A list of errors received from the GlobalCollect platform;
38
+ # may be empty but never _nil_
39
+ attr_reader :errors
40
+
41
+ def to_s
42
+ str = super.to_s
43
+ if @status_code > 0
44
+ str += '; status_code=' + @status_code.to_s
45
+ end
46
+ if !@response_body.nil? && @response_body.length > 0
47
+ str += "; response_body='" + @response_body + "'"
48
+ end
49
+ str.to_s
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,126 @@
1
+ require 'ingenico/connect/sdk/domain/errors/error_response'
2
+
3
+ module Ingenico::Connect::SDK
4
+
5
+ # Base class of all GlobalCollect platform API resources.
6
+ # Provides shared functionality to facilitate communication with the GlobalCollect platform.
7
+ class ApiResource
8
+
9
+ # Creates a new ApiResource.
10
+ # arg:: Parent class or {Ingenico::Connect::SDK::Communicator} instance.
11
+ # If a parent class is given its communicator will be used for communication.
12
+ # path_context:: Hash that contains substitutions for generic locations in the url path.
13
+ # This hash will be used to instantiate a concrete url used to access specific resources.
14
+ # For example in the url https://api-sandbox.globalcollect.com/!{version}/!{merchantId}/payments
15
+ # !{version} and !{merchantId} can be instantiated using the hash
16
+ # !{'version' => 'v1', 'merchantId' => '1234'}. The final url in this case will be
17
+ # https://api-sandbox.globalcollect.com/v1/1234/payments.
18
+ # client_meta_info:: JSON string containing the meta data for the client.
19
+ def initialize(arg, path_context, client_meta_info=FALSE)
20
+ if client_meta_info == FALSE
21
+ if arg.nil?
22
+ raise ArgumentError.new('parent is required')
23
+ end
24
+ @parent = arg
25
+ @communicator = arg.communicator
26
+ @path_context = path_context
27
+ @client_meta_info = arg.client_meta_info
28
+ else
29
+ if arg.nil?
30
+ raise ArgumentError.new('communicator is required')
31
+ end
32
+ @parent = nil
33
+ @communicator = arg
34
+ @path_context = path_context
35
+ @client_meta_info = client_meta_info
36
+ end
37
+ end
38
+
39
+ # {Ingenico::Connect::SDK::Communicator} instance that provides communication with the GlobalCollect platform.
40
+ attr_reader :communicator
41
+
42
+ # JSON string containing client info specific to the current client.
43
+ attr_reader :client_meta_info
44
+
45
+ protected
46
+
47
+ # Returns the X-GCS-ClientMetaInfo header as a {Ingenico::Connect::SDK::RequestHeader}
48
+ def client_headers
49
+ if @client_meta_info.nil?
50
+ nil
51
+ else
52
+ [RequestHeader.new('X-GCS-ClientMetaInfo', @client_meta_info)]
53
+ end
54
+ end
55
+
56
+ def instantiate_uri(uri, path_context=FALSE)
57
+ if path_context == FALSE
58
+ uri = replace_all(uri, @path_context)
59
+ unless @parent.nil?
60
+ uri = @parent.instantiate_uri(uri)
61
+ end
62
+ uri
63
+ else
64
+ uri = replace_all(uri, path_context)
65
+ instantiate_uri(uri)
66
+ end
67
+ end
68
+
69
+ def create_exception(status_code, response_body, error_object, context)
70
+ if error_object.is_a?(Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse) && !error_object.payment_result.nil?
71
+ return DeclinedPaymentException.new(status_code, response_body, error_object)
72
+ elsif error_object.is_a?(Ingenico::Connect::SDK::Domain::Payout::PayoutErrorResponse) && !error_object.payout_result.nil?
73
+ return DeclinedPayoutException.new(status_code, response_body, error_object)
74
+ elsif error_object.is_a?(Ingenico::Connect::SDK::Domain::Refund::RefundErrorResponse) && !error_object.refund_result.nil?
75
+ return DeclinedRefundException.new(status_code, response_body, error_object)
76
+ end
77
+ if !(error_object.is_a?(Ingenico::Connect::SDK::Domain::Payment::PaymentErrorResponse) ||
78
+ error_object.is_a?(Ingenico::Connect::SDK::Domain::Payout::PayoutErrorResponse) ||
79
+ error_object.is_a?(Ingenico::Connect::SDK::Domain::Refund::RefundErrorResponse) ||
80
+ error_object.is_a?(Ingenico::Connect::SDK::Domain::Errors::ErrorResponse))
81
+ raise ArgumentError.new("unsupported error object type: " + error_object.class.name)
82
+ else
83
+ error_id = error_object.error_id
84
+ errors = error_object.errors
85
+ end
86
+ case status_code
87
+ when 400
88
+ return ValidationException.new(status_code, response_body, error_id, errors)
89
+ when 403
90
+ return AuthorizationException.new(status_code, response_body, error_id, errors)
91
+ when 404, 410
92
+ return ReferenceException.new(status_code, response_body, error_id, errors)
93
+ when 409
94
+ if is_idempotence_error(errors, context)
95
+ idempotence_key = context.idempotence_key
96
+ idempotence_request_timestamp = context.idempotence_request_timestamp
97
+ return IdempotenceException.new(status_code, response_body, error_id,
98
+ errors, idempotence_key,
99
+ idempotence_request_timestamp)
100
+ else
101
+ return ReferenceException.new(status_code, response_body, error_id, errors)
102
+ end
103
+ when 500, 502, 503
104
+ return GlobalCollectException.new(status_code, response_body, error_id, errors)
105
+ else
106
+ return ApiException.new(status_code, response_body, error_id, errors)
107
+ end
108
+ end
109
+
110
+ private
111
+
112
+ def replace_all(uri, path_context)
113
+ unless path_context.nil?
114
+ path_context.each do |key, value|
115
+ uri = uri.gsub('{' + key + '}', value)
116
+ end
117
+ end
118
+ uri
119
+ end
120
+
121
+ def is_idempotence_error(errors, context)
122
+ !context.nil? && !context.idempotence_key.nil? && errors.length == 1 &&
123
+ errors[0].code == '1409'
124
+ end
125
+ end
126
+ end