univapay-apimatic-sdk 0.0.1

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 (272) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +224 -0
  4. data/bin/console +15 -0
  5. data/lib/univapay_client_sdk/api_helper.rb +10 -0
  6. data/lib/univapay_client_sdk/apis/base_api.rb +67 -0
  7. data/lib/univapay_client_sdk/apis/cancels_api.rb +293 -0
  8. data/lib/univapay_client_sdk/apis/charges_api.rb +903 -0
  9. data/lib/univapay_client_sdk/apis/merchants_api.rb +57 -0
  10. data/lib/univapay_client_sdk/apis/refunds_api.rb +298 -0
  11. data/lib/univapay_client_sdk/apis/stores_api.rb +126 -0
  12. data/lib/univapay_client_sdk/apis/subscriptions_api.rb +1014 -0
  13. data/lib/univapay_client_sdk/apis/transaction_tokens_api.rb +455 -0
  14. data/lib/univapay_client_sdk/apis/webhooks_api.rb +463 -0
  15. data/lib/univapay_client_sdk/client.rb +116 -0
  16. data/lib/univapay_client_sdk/configuration.rb +178 -0
  17. data/lib/univapay_client_sdk/events/unknown_event.rb +32 -0
  18. data/lib/univapay_client_sdk/events/webhooks/bank_transfer_handler.rb +37 -0
  19. data/lib/univapay_client_sdk/events/webhooks/cancel_handler.rb +37 -0
  20. data/lib/univapay_client_sdk/events/webhooks/charge_finished_handler.rb +37 -0
  21. data/lib/univapay_client_sdk/events/webhooks/charge_updated_handler.rb +37 -0
  22. data/lib/univapay_client_sdk/events/webhooks/customs_handler.rb +37 -0
  23. data/lib/univapay_client_sdk/events/webhooks/recurring_token_deleted_handler.rb +37 -0
  24. data/lib/univapay_client_sdk/events/webhooks/refund_handler.rb +37 -0
  25. data/lib/univapay_client_sdk/events/webhooks/subscription_canceled_handler.rb +37 -0
  26. data/lib/univapay_client_sdk/events/webhooks/subscription_completed_handler.rb +37 -0
  27. data/lib/univapay_client_sdk/events/webhooks/subscription_created_handler.rb +37 -0
  28. data/lib/univapay_client_sdk/events/webhooks/subscription_failure_handler.rb +37 -0
  29. data/lib/univapay_client_sdk/events/webhooks/subscription_payment_handler.rb +37 -0
  30. data/lib/univapay_client_sdk/events/webhooks/subscription_suspended_handler.rb +37 -0
  31. data/lib/univapay_client_sdk/events/webhooks/token_created_handler.rb +37 -0
  32. data/lib/univapay_client_sdk/events/webhooks/token_cvv_auth_check_updated_handler.rb +37 -0
  33. data/lib/univapay_client_sdk/events/webhooks/token_cvv_auth_updated_handler.rb +37 -0
  34. data/lib/univapay_client_sdk/events/webhooks/token_replaced_handler.rb +37 -0
  35. data/lib/univapay_client_sdk/events/webhooks/token_three_ds_updated_handler.rb +37 -0
  36. data/lib/univapay_client_sdk/events/webhooks/token_updated_handler.rb +37 -0
  37. data/lib/univapay_client_sdk/exceptions/api_error_exception.rb +199 -0
  38. data/lib/univapay_client_sdk/exceptions/api_exception.rb +21 -0
  39. data/lib/univapay_client_sdk/http/api_response.rb +19 -0
  40. data/lib/univapay_client_sdk/http/auth/oauth_2.rb +53 -0
  41. data/lib/univapay_client_sdk/http/http_call_back.rb +10 -0
  42. data/lib/univapay_client_sdk/http/http_method_enum.rb +10 -0
  43. data/lib/univapay_client_sdk/http/http_request.rb +10 -0
  44. data/lib/univapay_client_sdk/http/http_response.rb +10 -0
  45. data/lib/univapay_client_sdk/http/proxy_settings.rb +22 -0
  46. data/lib/univapay_client_sdk/logging/configuration/api_logging_configuration.rb +186 -0
  47. data/lib/univapay_client_sdk/logging/sdk_logger.rb +17 -0
  48. data/lib/univapay_client_sdk/models/api_error_detail.rb +87 -0
  49. data/lib/univapay_client_sdk/models/api_error_status.rb +26 -0
  50. data/lib/univapay_client_sdk/models/bank_transfer_event.rb +27 -0
  51. data/lib/univapay_client_sdk/models/bank_transfer_ledger.rb +199 -0
  52. data/lib/univapay_client_sdk/models/bank_transfer_ledger_bank_ledger_type.rb +36 -0
  53. data/lib/univapay_client_sdk/models/bank_transfer_ledger_list.rb +104 -0
  54. data/lib/univapay_client_sdk/models/bank_transfer_ledger_mode.rb +36 -0
  55. data/lib/univapay_client_sdk/models/bank_transfer_payment_status.rb +44 -0
  56. data/lib/univapay_client_sdk/models/bank_transfer_status_data.rb +229 -0
  57. data/lib/univapay_client_sdk/models/bank_transfer_status_webhook_callback.rb +134 -0
  58. data/lib/univapay_client_sdk/models/bank_transfer_status_webhook_callback_extension.rb +75 -0
  59. data/lib/univapay_client_sdk/models/base_bank_transfer_data.rb +100 -0
  60. data/lib/univapay_client_sdk/models/base_konbini_data.rb +99 -0
  61. data/lib/univapay_client_sdk/models/base_konbini_data_convenience_store.rb +60 -0
  62. data/lib/univapay_client_sdk/models/base_model.rb +110 -0
  63. data/lib/univapay_client_sdk/models/base_online_data.rb +123 -0
  64. data/lib/univapay_client_sdk/models/base_online_data_brand.rb +48 -0
  65. data/lib/univapay_client_sdk/models/base_online_data_call_method.rb +52 -0
  66. data/lib/univapay_client_sdk/models/base_online_data_os_type.rb +36 -0
  67. data/lib/univapay_client_sdk/models/base_online_data_user_identifier_source.rb +36 -0
  68. data/lib/univapay_client_sdk/models/cancel.rb +183 -0
  69. data/lib/univapay_client_sdk/models/cancel_create_request.rb +77 -0
  70. data/lib/univapay_client_sdk/models/cancel_event.rb +26 -0
  71. data/lib/univapay_client_sdk/models/cancel_list.rb +94 -0
  72. data/lib/univapay_client_sdk/models/cancel_status.rb +44 -0
  73. data/lib/univapay_client_sdk/models/cancel_update_request.rb +76 -0
  74. data/lib/univapay_client_sdk/models/cancel_webhook_callback.rb +132 -0
  75. data/lib/univapay_client_sdk/models/cancel_webhook_callback_extension.rb +74 -0
  76. data/lib/univapay_client_sdk/models/card_processor_installment_config.rb +89 -0
  77. data/lib/univapay_client_sdk/models/charge.rb +411 -0
  78. data/lib/univapay_client_sdk/models/charge_capture_request.rb +84 -0
  79. data/lib/univapay_client_sdk/models/charge_create_request.rb +179 -0
  80. data/lib/univapay_client_sdk/models/charge_create_request_client_metadata.rb +76 -0
  81. data/lib/univapay_client_sdk/models/charge_create_request_redirect.rb +75 -0
  82. data/lib/univapay_client_sdk/models/charge_create_request_three_ds.rb +88 -0
  83. data/lib/univapay_client_sdk/models/charge_create_request_three_ds_mode.rb +44 -0
  84. data/lib/univapay_client_sdk/models/charge_finished_webhook_callback.rb +131 -0
  85. data/lib/univapay_client_sdk/models/charge_list.rb +104 -0
  86. data/lib/univapay_client_sdk/models/charge_mode.rb +36 -0
  87. data/lib/univapay_client_sdk/models/charge_redirect.rb +96 -0
  88. data/lib/univapay_client_sdk/models/charge_status.rb +56 -0
  89. data/lib/univapay_client_sdk/models/charge_three_ds.rb +97 -0
  90. data/lib/univapay_client_sdk/models/charge_transaction_token_type.rb +40 -0
  91. data/lib/univapay_client_sdk/models/charge_update_request.rb +75 -0
  92. data/lib/univapay_client_sdk/models/charge_updated_webhook_callback.rb +131 -0
  93. data/lib/univapay_client_sdk/models/cursor_direction_query.rb +36 -0
  94. data/lib/univapay_client_sdk/models/customs_declaration_create_request.rb +106 -0
  95. data/lib/univapay_client_sdk/models/customs_declaration_event.rb +27 -0
  96. data/lib/univapay_client_sdk/models/customs_declaration_patch_request.rb +77 -0
  97. data/lib/univapay_client_sdk/models/customs_declaration_webhook_callback.rb +135 -0
  98. data/lib/univapay_client_sdk/models/customs_declaration_webhook_callback_extension.rb +76 -0
  99. data/lib/univapay_client_sdk/models/customs_declaration_webhook_data.rb +232 -0
  100. data/lib/univapay_client_sdk/models/customs_declaration_webhook_declaration.rb +121 -0
  101. data/lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb +127 -0
  102. data/lib/univapay_client_sdk/models/customs_declaration_webhook_other_error.rb +120 -0
  103. data/lib/univapay_client_sdk/models/customs_declaration_webhook_result.rb +125 -0
  104. data/lib/univapay_client_sdk/models/customs_declaration_webhook_status.rb +44 -0
  105. data/lib/univapay_client_sdk/models/generic_metadata.rb +111 -0
  106. data/lib/univapay_client_sdk/models/installment_fixed_cycles.rb +70 -0
  107. data/lib/univapay_client_sdk/models/installment_plan_type.rb +36 -0
  108. data/lib/univapay_client_sdk/models/issuer_token.rb +177 -0
  109. data/lib/univapay_client_sdk/models/issuer_token_call_method.rb +51 -0
  110. data/lib/univapay_client_sdk/models/issuer_token_payload.rb +105 -0
  111. data/lib/univapay_client_sdk/models/issuer_token_payment_type.rb +36 -0
  112. data/lib/univapay_client_sdk/models/merchant.rb +179 -0
  113. data/lib/univapay_client_sdk/models/merchant_webhook_bank_transfer_configuration.rb +342 -0
  114. data/lib/univapay_client_sdk/models/merchant_webhook_card_brand_percent_fees.rb +167 -0
  115. data/lib/univapay_client_sdk/models/merchant_webhook_card_configuration.rb +301 -0
  116. data/lib/univapay_client_sdk/models/merchant_webhook_checkout_configuration.rb +87 -0
  117. data/lib/univapay_client_sdk/models/merchant_webhook_checkout_toggle.rb +77 -0
  118. data/lib/univapay_client_sdk/models/merchant_webhook_configuration.rb +505 -0
  119. data/lib/univapay_client_sdk/models/merchant_webhook_convenience_configuration.rb +88 -0
  120. data/lib/univapay_client_sdk/models/merchant_webhook_customer_management_configuration.rb +99 -0
  121. data/lib/univapay_client_sdk/models/merchant_webhook_installment_plan_configuration.rb +139 -0
  122. data/lib/univapay_client_sdk/models/merchant_webhook_limit_charge_by_card_configuration.rb +88 -0
  123. data/lib/univapay_client_sdk/models/merchant_webhook_limit_refund_by_sales_configuration.rb +100 -0
  124. data/lib/univapay_client_sdk/models/merchant_webhook_money_amount.rb +85 -0
  125. data/lib/univapay_client_sdk/models/merchant_webhook_online_configuration.rb +77 -0
  126. data/lib/univapay_client_sdk/models/merchant_webhook_paidy_configuration.rb +77 -0
  127. data/lib/univapay_client_sdk/models/merchant_webhook_qr_merchant_configuration.rb +77 -0
  128. data/lib/univapay_client_sdk/models/merchant_webhook_qr_scan_configuration.rb +93 -0
  129. data/lib/univapay_client_sdk/models/merchant_webhook_recurring_cvv_confirmation_config.rb +97 -0
  130. data/lib/univapay_client_sdk/models/merchant_webhook_recurring_token_configuration.rb +109 -0
  131. data/lib/univapay_client_sdk/models/merchant_webhook_security_configuration.rb +234 -0
  132. data/lib/univapay_client_sdk/models/merchant_webhook_subscription_configuration.rb +138 -0
  133. data/lib/univapay_client_sdk/models/merchant_webhook_subscription_plan_configuration.rb +138 -0
  134. data/lib/univapay_client_sdk/models/merchant_webhook_transfer_schedule_configuration.rb +159 -0
  135. data/lib/univapay_client_sdk/models/merchant_webhook_user_transactions_configuration.rb +349 -0
  136. data/lib/univapay_client_sdk/models/mode_query.rb +36 -0
  137. data/lib/univapay_client_sdk/models/payment_error.rb +178 -0
  138. data/lib/univapay_client_sdk/models/plan_settings_type.rb +36 -0
  139. data/lib/univapay_client_sdk/models/recurring_token_deleted_webhook_callback.rb +132 -0
  140. data/lib/univapay_client_sdk/models/refund.rb +240 -0
  141. data/lib/univapay_client_sdk/models/refund_create_request.rb +118 -0
  142. data/lib/univapay_client_sdk/models/refund_event.rb +26 -0
  143. data/lib/univapay_client_sdk/models/refund_list.rb +104 -0
  144. data/lib/univapay_client_sdk/models/refund_reason_request.rb +42 -0
  145. data/lib/univapay_client_sdk/models/refund_reason_response.rb +62 -0
  146. data/lib/univapay_client_sdk/models/refund_status.rb +47 -0
  147. data/lib/univapay_client_sdk/models/refund_update_request.rb +99 -0
  148. data/lib/univapay_client_sdk/models/refund_webhook_callback.rb +132 -0
  149. data/lib/univapay_client_sdk/models/refund_webhook_callback_extension.rb +74 -0
  150. data/lib/univapay_client_sdk/models/restrict_ip_after_failed_charge_config.rb +99 -0
  151. data/lib/univapay_client_sdk/models/store.rb +119 -0
  152. data/lib/univapay_client_sdk/models/store_list.rb +104 -0
  153. data/lib/univapay_client_sdk/models/store_list_item.rb +114 -0
  154. data/lib/univapay_client_sdk/models/subscription.rb +310 -0
  155. data/lib/univapay_client_sdk/models/subscription_canceled_webhook_callback.rb +132 -0
  156. data/lib/univapay_client_sdk/models/subscription_completed_webhook_callback.rb +132 -0
  157. data/lib/univapay_client_sdk/models/subscription_create_request.rb +216 -0
  158. data/lib/univapay_client_sdk/models/subscription_created_webhook_callback.rb +132 -0
  159. data/lib/univapay_client_sdk/models/subscription_failure_webhook_callback.rb +132 -0
  160. data/lib/univapay_client_sdk/models/subscription_installment_plan.rb +86 -0
  161. data/lib/univapay_client_sdk/models/subscription_list.rb +104 -0
  162. data/lib/univapay_client_sdk/models/subscription_list_item.rb +352 -0
  163. data/lib/univapay_client_sdk/models/subscription_next_payment.rb +222 -0
  164. data/lib/univapay_client_sdk/models/subscription_patch_payment_request.rb +117 -0
  165. data/lib/univapay_client_sdk/models/subscription_patch_token_request.rb +79 -0
  166. data/lib/univapay_client_sdk/models/subscription_payment.rb +185 -0
  167. data/lib/univapay_client_sdk/models/subscription_payment_list.rb +94 -0
  168. data/lib/univapay_client_sdk/models/subscription_payment_webhook_callback.rb +132 -0
  169. data/lib/univapay_client_sdk/models/subscription_period.rb +56 -0
  170. data/lib/univapay_client_sdk/models/subscription_plan_settings.rb +98 -0
  171. data/lib/univapay_client_sdk/models/subscription_schedule_settings.rb +132 -0
  172. data/lib/univapay_client_sdk/models/subscription_status.rb +56 -0
  173. data/lib/univapay_client_sdk/models/subscription_suspend_request.rb +79 -0
  174. data/lib/univapay_client_sdk/models/subscription_suspended_webhook_callback.rb +132 -0
  175. data/lib/univapay_client_sdk/models/subscription_terminate_with_status.rb +36 -0
  176. data/lib/univapay_client_sdk/models/subscription_termination_mode.rb +36 -0
  177. data/lib/univapay_client_sdk/models/subscription_update_next_payment.rb +104 -0
  178. data/lib/univapay_client_sdk/models/subscription_update_request.rb +134 -0
  179. data/lib/univapay_client_sdk/models/subscription_update_schedule_settings.rb +110 -0
  180. data/lib/univapay_client_sdk/models/subscription_update_status.rb +37 -0
  181. data/lib/univapay_client_sdk/models/subscription_user_data.rb +134 -0
  182. data/lib/univapay_client_sdk/models/suspend_schedule_settings.rb +78 -0
  183. data/lib/univapay_client_sdk/models/three_ds_issuer_token.rb +116 -0
  184. data/lib/univapay_client_sdk/models/three_ds_issuer_token_call_method.rb +26 -0
  185. data/lib/univapay_client_sdk/models/three_ds_issuer_token_payment_type.rb +26 -0
  186. data/lib/univapay_client_sdk/models/token_create_bank_transfer_data.rb +122 -0
  187. data/lib/univapay_client_sdk/models/token_create_card_data.rb +231 -0
  188. data/lib/univapay_client_sdk/models/token_create_card_data_cvv_authorize.rb +95 -0
  189. data/lib/univapay_client_sdk/models/token_create_card_data_three_ds.rb +97 -0
  190. data/lib/univapay_client_sdk/models/token_create_konbini_data.rb +147 -0
  191. data/lib/univapay_client_sdk/models/token_create_online_data.rb +142 -0
  192. data/lib/univapay_client_sdk/models/token_create_phone_number.rb +104 -0
  193. data/lib/univapay_client_sdk/models/token_created_webhook_callback.rb +131 -0
  194. data/lib/univapay_client_sdk/models/token_cvv_auth_check_updated_webhook_callback.rb +132 -0
  195. data/lib/univapay_client_sdk/models/token_cvv_auth_updated_webhook_callback.rb +132 -0
  196. data/lib/univapay_client_sdk/models/token_replaced_webhook_callback.rb +131 -0
  197. data/lib/univapay_client_sdk/models/token_response_bank_transfer_data.rb +181 -0
  198. data/lib/univapay_client_sdk/models/token_response_card_data.rb +129 -0
  199. data/lib/univapay_client_sdk/models/token_response_card_data_billing.rb +153 -0
  200. data/lib/univapay_client_sdk/models/token_response_card_data_card.rb +187 -0
  201. data/lib/univapay_client_sdk/models/token_response_card_data_cvv_authorize.rb +132 -0
  202. data/lib/univapay_client_sdk/models/token_response_card_data_cvv_authorize_check.rb +118 -0
  203. data/lib/univapay_client_sdk/models/token_response_card_data_three_ds.rb +142 -0
  204. data/lib/univapay_client_sdk/models/token_response_card_data_three_ds_status.rb +48 -0
  205. data/lib/univapay_client_sdk/models/token_response_konbini_data.rb +135 -0
  206. data/lib/univapay_client_sdk/models/token_response_online_data.rb +158 -0
  207. data/lib/univapay_client_sdk/models/token_response_phone_number.rb +96 -0
  208. data/lib/univapay_client_sdk/models/token_three_ds_updated_webhook_callback.rb +132 -0
  209. data/lib/univapay_client_sdk/models/token_updated_webhook_callback.rb +131 -0
  210. data/lib/univapay_client_sdk/models/transaction_token.rb +250 -0
  211. data/lib/univapay_client_sdk/models/transaction_token_create_request.rb +161 -0
  212. data/lib/univapay_client_sdk/models/transaction_token_create_request_metadata.rb +124 -0
  213. data/lib/univapay_client_sdk/models/transaction_token_create_request_payment_type.rb +44 -0
  214. data/lib/univapay_client_sdk/models/transaction_token_create_request_type.rb +40 -0
  215. data/lib/univapay_client_sdk/models/transaction_token_list.rb +104 -0
  216. data/lib/univapay_client_sdk/models/transaction_token_list_item.rb +204 -0
  217. data/lib/univapay_client_sdk/models/transaction_token_list_item_user_data.rb +96 -0
  218. data/lib/univapay_client_sdk/models/transaction_token_mode.rb +36 -0
  219. data/lib/univapay_client_sdk/models/transaction_token_payment_type.rb +48 -0
  220. data/lib/univapay_client_sdk/models/transaction_token_type.rb +40 -0
  221. data/lib/univapay_client_sdk/models/transaction_token_update_request.rb +95 -0
  222. data/lib/univapay_client_sdk/models/transaction_token_update_request_data.rb +184 -0
  223. data/lib/univapay_client_sdk/models/transaction_token_update_request_data_phone_number.rb +86 -0
  224. data/lib/univapay_client_sdk/models/webhook.rb +191 -0
  225. data/lib/univapay_client_sdk/models/webhook_callback_envelope.rb +98 -0
  226. data/lib/univapay_client_sdk/models/webhook_create_request.rb +97 -0
  227. data/lib/univapay_client_sdk/models/webhook_event.rb +166 -0
  228. data/lib/univapay_client_sdk/models/webhook_event_list.rb +94 -0
  229. data/lib/univapay_client_sdk/models/webhook_list.rb +94 -0
  230. data/lib/univapay_client_sdk/models/webhook_trigger.rb +104 -0
  231. data/lib/univapay_client_sdk/models/webhook_update_request.rb +108 -0
  232. data/lib/univapay_client_sdk/utilities/date_time_helper.rb +11 -0
  233. data/lib/univapay_client_sdk/utilities/file_wrapper.rb +28 -0
  234. data/lib/univapay_client_sdk/utilities/union_type_lookup.rb +242 -0
  235. data/lib/univapay_client_sdk.rb +322 -0
  236. data/test/apis/api_test_base.rb +23 -0
  237. data/test/apis/test_cancels_api.rb +162 -0
  238. data/test/apis/test_charges_api.rb +564 -0
  239. data/test/apis/test_merchants_api.rb +50 -0
  240. data/test/apis/test_refunds_api.rb +172 -0
  241. data/test/apis/test_stores_api.rb +86 -0
  242. data/test/apis/test_subscriptions_api.rb +579 -0
  243. data/test/apis/test_transaction_tokens_api.rb +305 -0
  244. data/test/apis/test_webhooks_api.rb +245 -0
  245. data/test/events/webhooks/test_bank_transfer_handler.rb +95 -0
  246. data/test/events/webhooks/test_cancel_handler.rb +90 -0
  247. data/test/events/webhooks/test_charge_finished_handler.rb +95 -0
  248. data/test/events/webhooks/test_charge_updated_handler.rb +95 -0
  249. data/test/events/webhooks/test_customs_handler.rb +100 -0
  250. data/test/events/webhooks/test_recurring_token_deleted_handler.rb +92 -0
  251. data/test/events/webhooks/test_refund_handler.rb +95 -0
  252. data/test/events/webhooks/test_subscription_canceled_handler.rb +101 -0
  253. data/test/events/webhooks/test_subscription_completed_handler.rb +101 -0
  254. data/test/events/webhooks/test_subscription_created_handler.rb +101 -0
  255. data/test/events/webhooks/test_subscription_failure_handler.rb +101 -0
  256. data/test/events/webhooks/test_subscription_payment_handler.rb +101 -0
  257. data/test/events/webhooks/test_subscription_suspended_handler.rb +101 -0
  258. data/test/events/webhooks/test_token_created_handler.rb +92 -0
  259. data/test/events/webhooks/test_token_cvv_auth_check_updated_handler.rb +92 -0
  260. data/test/events/webhooks/test_token_cvv_auth_updated_handler.rb +92 -0
  261. data/test/events/webhooks/test_token_replaced_handler.rb +92 -0
  262. data/test/events/webhooks/test_token_three_ds_updated_handler.rb +92 -0
  263. data/test/events/webhooks/test_token_updated_handler.rb +92 -0
  264. data/test/framework_integrations/rails_app_test_helper.rb +14 -0
  265. data/test/framework_integrations/webhooks/apps/hanami_charge_updated_app.rb +61 -0
  266. data/test/framework_integrations/webhooks/apps/rails_charge_updated_app.rb +24 -0
  267. data/test/framework_integrations/webhooks/apps/sinatra_charge_updated_app.rb +27 -0
  268. data/test/framework_integrations/webhooks/test/test_hanami_charge_updated_app.rb +57 -0
  269. data/test/framework_integrations/webhooks/test/test_rails_charge_updated_app.rb +57 -0
  270. data/test/framework_integrations/webhooks/test/test_sinatra_charge_updated_app.rb +58 -0
  271. data/test/http_response_catcher.rb +19 -0
  272. metadata +397 -0
@@ -0,0 +1,305 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'api_test_base'
7
+
8
+ class TransactionTokensApiTest < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.transaction_tokens
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Exchange raw payment data for a secure token. **PCI DSS Compliance Required** if sending raw card numbers.
17
+ def test_create_transaction_token
18
+ # Parameters for the API call
19
+ body = TransactionTokenCreateRequest.from_hash(APIHelper.json_deserialize(
20
+ '{"payment_type":"card","type":"recurring","email":"test@univapay.com","'\
21
+ 'metadata":{"univapay-phone-number":"+81 08012341234"},"data":{"cardhold'\
22
+ 'er":"TEST TEST","card_number":"4242424242424242","exp_month":"09","exp_'\
23
+ 'year":"26","cvv":"123","phone_number":{"country_code":"81","local_numbe'\
24
+ 'r":"08012341234"},"three_ds":{"redirect_endpoint":"https://univapay.com'\
25
+ '/redirect/index.html"},"cvv_authorize":{"enabled":false,"currency":"JPY'\
26
+ '"}}}', false))
27
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
28
+
29
+ # Perform the API call through the SDK function
30
+ result = @controller.create_transaction_token(
31
+ body, idempotency_key: idempotency_key
32
+ )
33
+
34
+ # Test response code
35
+ assert_equal(201, @response_catcher.response.status_code)
36
+ # Test headers
37
+ expected_headers = {}
38
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
39
+
40
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
41
+
42
+ # Test whether the captured response is as we expected
43
+ refute_nil(result)
44
+ expected_body = JSON.parse(
45
+ '{"id":"11f11e85-e9e9-b198-b990-c3a715943241","store_id":"11f0e274-1e3b-'\
46
+ '4752-9513-33d3e07ede13","email":"test@test.com","payment_type":"card","'\
47
+ 'active":true,"mode":"live","type":"recurring","usage_limit":null,"confi'\
48
+ 'rmed":null,"metadata":{"univapay-link-id":"11f11e85-1b45-dace-bf3d-cbca'\
49
+ 'e52f65fc","univapay-name":"test","univapay-phone-number":"+81 080123412'\
50
+ '34"},"created_on":"2026-03-13T02:39:52.908468Z","updated_on":"2026-03-1'\
51
+ '3T02:39:52.908468Z","last_used_on":null,"data":{"card":{"cardholder":"T'\
52
+ 'EST TEST","exp_month":9,"exp_year":2026,"card_bin":"424242","last_four"'\
53
+ ':"424242","brand":"visa","card_type":"credit","country":"JP","category"'\
54
+ ':"standard","issuer":"issuer","sub_brand":"none"},"billing":{"line1":nu'\
55
+ 'll,"line2":null,"state":null,"city":null,"country":null,"zip":null,"pho'\
56
+ 'ne_number":{"country_code":81,"local_number":"08012341234"}},"cvv_autho'\
57
+ 'rize":{"enabled":false,"status":null,"charge_id":null,"credentials_id":'\
58
+ 'null,"currency":null},"cvv_authorize_check":{"status":null,"charge_id":'\
59
+ 'null,"date":null},"three_ds":{"enabled":true,"status":"pending","redire'\
60
+ 'ct_endpoint":"https://univapay.com/redirect/index.html","error":null,"e'\
61
+ 'xempted":false}}}'
62
+ )
63
+ received_body = JSON.parse(@response_catcher.response.raw_body)
64
+ assert(ComparisonHelper.match_body(expected_body, received_body))
65
+ end
66
+
67
+ # Lists all transaction tokens across all stores.
68
+ def test_list_all_transaction_tokens
69
+ # Parameters for the API call
70
+ limit = 10
71
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
72
+ cursor_direction = 'desc'
73
+
74
+ # Perform the API call through the SDK function
75
+ result = @controller.list_all_transaction_tokens(
76
+ limit: limit, cursor: cursor, cursor_direction: cursor_direction
77
+ )
78
+
79
+ # Test response code
80
+ assert_equal(200, @response_catcher.response.status_code)
81
+ # Test headers
82
+ expected_headers = {}
83
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
84
+
85
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
86
+
87
+ # Test whether the captured response is as we expected
88
+ refute_nil(result)
89
+ expected_body = JSON.parse(
90
+ '{"items":[{"id":"2fe23e45-f95d-4c95-9963-739070096443","store_id":"79e9'\
91
+ '504e-96d8-46ed-8d22-2e8b36238605","merchant_name":"Test Merchant","stor'\
92
+ 'e_name":"Tokyo Store","email":"taro@example.com","payment_type":"card",'\
93
+ '"active":true,"mode":"live","type":"recurring","created_on":"2026-04-09'\
94
+ 'T07:35:50Z","updated_on":"2026-04-09T07:35:50Z","user_data":{"cardholde'\
95
+ 'r_name":"TARO YAMADA","email":"taro@example.com"}},{"id":"3af34f56-a06e'\
96
+ '-4d06-aa74-84a181107554","store_id":"8bfa615f-a7e9-47fe-9e33-3f9c473497'\
97
+ '16","merchant_name":"Test Merchant","store_name":"Osaka Store","email":'\
98
+ '"hanako@example.com","payment_type":"card","active":true,"mode":"live",'\
99
+ '"type":"one_time","created_on":"2026-04-10T10:20:11Z","updated_on":"202'\
100
+ '6-04-10T10:20:11Z","user_data":{"cardholder_name":"HANAKO SUZUKI","emai'\
101
+ 'l":"hanako@example.com"}},{"id":"4bf45e67-b17f-4e17-bb85-95b292218665",'\
102
+ '"store_id":"79e9504e-96d8-46ed-8d22-2e8b36238605","merchant_name":"Test'\
103
+ ' Merchant","store_name":"Tokyo Store","email":"jiro@example.com","payme'\
104
+ 'nt_type":"card","active":false,"mode":"live","type":"subscription","cre'\
105
+ 'ated_on":"2026-04-11T18:05:42Z","updated_on":"2026-04-12T08:31:09Z","us'\
106
+ 'er_data":{"cardholder_name":"JIRO TANAKA","email":"jiro@example.com"}}]'\
107
+ ',"has_more":false,"total_hits":3}'
108
+ )
109
+ received_body = JSON.parse(@response_catcher.response.raw_body)
110
+ assert(ComparisonHelper.match_body(expected_body, received_body))
111
+ end
112
+
113
+ # Lists all transaction tokens for a specific store.
114
+ def test_list_store_transaction_tokens
115
+ # Parameters for the API call
116
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
117
+ limit = 10
118
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
119
+ cursor_direction = 'desc'
120
+
121
+ # Perform the API call through the SDK function
122
+ result = @controller.list_store_transaction_tokens(
123
+ store_id, limit: limit, cursor: cursor,
124
+ cursor_direction: cursor_direction
125
+ )
126
+
127
+ # Test response code
128
+ assert_equal(200, @response_catcher.response.status_code)
129
+ # Test headers
130
+ expected_headers = {}
131
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
132
+
133
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
134
+
135
+ # Test whether the captured response is as we expected
136
+ refute_nil(result)
137
+ expected_body = JSON.parse(
138
+ '{"items":[{"id":"2fe23e45-f95d-4c95-9963-739070096443","store_id":"79e9'\
139
+ '504e-96d8-46ed-8d22-2e8b36238605","merchant_name":"Test Merchant","stor'\
140
+ 'e_name":"Tokyo Store","email":"taro@example.com","payment_type":"card",'\
141
+ '"active":true,"mode":"live","type":"recurring","created_on":"2026-04-09'\
142
+ 'T07:35:50Z","updated_on":"2026-04-09T07:35:50Z","user_data":{"cardholde'\
143
+ 'r_name":"TARO YAMADA","email":"taro@example.com"}},{"id":"5cf56e78-c28a'\
144
+ '-4f28-cc96-06c303329776","store_id":"79e9504e-96d8-46ed-8d22-2e8b362386'\
145
+ '05","merchant_name":"Test Merchant","store_name":"Tokyo Store","email":'\
146
+ '"saburo@example.com","payment_type":"card","active":true,"mode":"live",'\
147
+ '"type":"one_time","created_on":"2026-04-10T12:14:00Z","updated_on":"202'\
148
+ '6-04-10T12:14:00Z","user_data":{"cardholder_name":"SABURO KATO","email"'\
149
+ ':"saburo@example.com"}},{"id":"6df67e89-d39a-4039-dd07-17d414430887","s'\
150
+ 'tore_id":"79e9504e-96d8-46ed-8d22-2e8b36238605","merchant_name":"Test M'\
151
+ 'erchant","store_name":"Tokyo Store","email":"shiro@example.com","paymen'\
152
+ 't_type":"card","active":true,"mode":"live","type":"subscription","creat'\
153
+ 'ed_on":"2026-04-11T16:48:23Z","updated_on":"2026-04-11T16:48:23Z","user'\
154
+ '_data":{"cardholder_name":"SHIRO ITO","email":"shiro@example.com"}}],"h'\
155
+ 'as_more":false,"total_hits":3}'
156
+ )
157
+ received_body = JSON.parse(@response_catcher.response.raw_body)
158
+ assert(ComparisonHelper.match_body(expected_body, received_body))
159
+ end
160
+
161
+ # Retrieves the details of an existing transaction token.
162
+ def test_get_transaction_token
163
+ # Parameters for the API call
164
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
165
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
166
+
167
+ # Perform the API call through the SDK function
168
+ result = @controller.get_transaction_token(store_id, id)
169
+
170
+ # Test response code
171
+ assert_equal(200, @response_catcher.response.status_code)
172
+ # Test headers
173
+ expected_headers = {}
174
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
175
+
176
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
177
+
178
+ # Test whether the captured response is as we expected
179
+ refute_nil(result)
180
+ expected_body = JSON.parse(
181
+ '{"id":"11f11e85-e9e9-b198-b990-c3a715943241","store_id":"11f0e274-1e3b-'\
182
+ '4752-9513-33d3e07ede13","email":"test@test.com","payment_type":"card","'\
183
+ 'active":true,"mode":"live","type":"recurring","usage_limit":null,"confi'\
184
+ 'rmed":null,"metadata":{"univapay-link-id":"11f11e85-1b45-dace-bf3d-cbca'\
185
+ 'e52f65fc","univapay-name":"test","univapay-phone-number":"+81 080123412'\
186
+ '34"},"created_on":"2026-03-13T02:39:52.908468Z","updated_on":"2026-03-1'\
187
+ '3T02:39:52.908468Z","last_used_on":null,"data":{"card":{"cardholder":"T'\
188
+ 'EST TEST","exp_month":9,"exp_year":2026,"card_bin":"424242","last_four"'\
189
+ ':"424242","brand":"visa","card_type":"credit","country":"JP","category"'\
190
+ ':"standard","issuer":"issuer","sub_brand":"none"},"billing":{"line1":nu'\
191
+ 'll,"line2":null,"state":null,"city":null,"country":null,"zip":null,"pho'\
192
+ 'ne_number":{"country_code":81,"local_number":"08012341234"}},"cvv_autho'\
193
+ 'rize":{"enabled":false,"status":null,"charge_id":null,"credentials_id":'\
194
+ 'null,"currency":null},"cvv_authorize_check":{"status":null,"charge_id":'\
195
+ 'null,"date":null},"three_ds":{"enabled":true,"status":"pending","redire'\
196
+ 'ct_endpoint":"https://univapay.com/redirect/index.html","error":null,"e'\
197
+ 'xempted":false}}}'
198
+ )
199
+ received_body = JSON.parse(@response_catcher.response.raw_body)
200
+ assert(ComparisonHelper.match_body(expected_body, received_body))
201
+ end
202
+
203
+ # ⚠️ **LEGACY WARNING: Discouraged Operation**
204
+ #While it is technically possible to update a transaction token, this practice is highly discouraged and is maintained solely for legacy reasons.
205
+ #**Updating raw card details requires your server environment to be fully PCI DSS compliant.**
206
+ #**Recommended Approach:** Instead of updating an existing token, it is best practice to create an entirely new transaction token using Univapay's frontend integrations (**Link Form**, **Widget**, or **Inline Form**). This allows Univapay to securely handle the customer's payment data without it ever touching your servers.
207
+ #--- **Legacy Usage:** Updates CVV, Address, Email, or Card Details. *Note: If updating only the CVV to resolve a `RECURRING_USAGE_REQUIRES_CVV` error, the application token secret is not required.*
208
+ def test_update_transaction_token
209
+ # Parameters for the API call
210
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
211
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
212
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
213
+ body = TransactionTokenUpdateRequest.from_hash(APIHelper.json_deserialize(
214
+ '{"email":"test.update@test.com","data":{"cardholder":"TARO YAMADA","car'\
215
+ 'd_number":"4000020000000000","exp_month":12,"exp_year":2099,"cvv":"123"'\
216
+ ',"line1":"11111","line2":"222","state":"Tokyo","city":"テスト区一丁目","countr'\
217
+ 'y":"JP","zip":"1234567","phone_number":{"country_code":"81","local_numb'\
218
+ 'er":"08000000000"}}}', false))
219
+
220
+ # Perform the API call through the SDK function
221
+ result = @controller.update_transaction_token(
222
+ store_id, id, idempotency_key: idempotency_key, body: body
223
+ )
224
+
225
+ # Test response code
226
+ assert_equal(200, @response_catcher.response.status_code)
227
+ # Test headers
228
+ expected_headers = {}
229
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
230
+
231
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
232
+
233
+ # Test whether the captured response is as we expected
234
+ refute_nil(result)
235
+ expected_body = JSON.parse(
236
+ '{"id":"11f11e85-e9e9-b198-b990-c3a715943241","store_id":"11f0e274-1e3b-'\
237
+ '4752-9513-33d3e07ede13","email":"test@test.com","payment_type":"card","'\
238
+ 'active":true,"mode":"live","type":"recurring","usage_limit":null,"confi'\
239
+ 'rmed":null,"metadata":{"univapay-link-id":"11f11e85-1b45-dace-bf3d-cbca'\
240
+ 'e52f65fc","univapay-name":"test","univapay-phone-number":"+81 080123412'\
241
+ '34"},"created_on":"2026-03-13T02:39:52.908468Z","updated_on":"2026-03-1'\
242
+ '3T02:39:52.908468Z","last_used_on":null,"data":{"card":{"cardholder":"T'\
243
+ 'EST TEST","exp_month":9,"exp_year":2026,"card_bin":"424242","last_four"'\
244
+ ':"424242","brand":"visa","card_type":"credit","country":"JP","category"'\
245
+ ':"standard","issuer":"issuer","sub_brand":"none"},"billing":{"line1":nu'\
246
+ 'll,"line2":null,"state":null,"city":null,"country":null,"zip":null,"pho'\
247
+ 'ne_number":{"country_code":81,"local_number":"08012341234"}},"cvv_autho'\
248
+ 'rize":{"enabled":false,"status":null,"charge_id":null,"credentials_id":'\
249
+ 'null,"currency":null},"cvv_authorize_check":{"status":null,"charge_id":'\
250
+ 'null,"date":null},"three_ds":{"enabled":true,"status":"pending","redire'\
251
+ 'ct_endpoint":"https://univapay.com/redirect/index.html","error":null,"e'\
252
+ 'xempted":false}}}'
253
+ )
254
+ received_body = JSON.parse(@response_catcher.response.raw_body)
255
+ assert(ComparisonHelper.match_body(expected_body, received_body))
256
+ end
257
+
258
+ # Deletes a specific transaction token.
259
+ #⚠️ **WARNING: Breaks Linked Subscriptions**
260
+ #Please note that deleting a transaction token will immediately prevent any linked recurring charges or subscriptions from being processed. Proceed with caution.
261
+ def test_delete_transaction_token
262
+ # Parameters for the API call
263
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
264
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
265
+
266
+ # Perform the API call through the SDK function
267
+ @controller.delete_transaction_token(store_id, id)
268
+
269
+ # Test response code
270
+ assert_equal(204, @response_catcher.response.status_code)
271
+ end
272
+
273
+ # Retrieves the information required to execute 3-D Secure authentication when creating a recurring transaction token.
274
+ #**⚠️ Important Notes:** 1. **PCI DSS Compliance:** This endpoint is only available to PCI DSS compliant merchants who are authorized to send raw card data directly via the API to create tokens. 2. **Target Tokens:** This only applies to tokens where `type` is `recurring`. For `one_time` or `subscription` tokens, 3-D Secure is requested during charge creation, not token creation. 3. **Execution Flow:**
275
+ # - After creating the token, poll the token object until `data.three_ds.status` becomes `awaiting`.
276
+ # - Once `awaiting`, use this endpoint to fetch the issuer token details.
277
+ # - Format the returned `payload` according to the `content_type` (e.g., URL-encoded) and execute an `http_post` request from the consumer's browser to the `issuer_token` URL.
278
+ def test_get_token_three_ds_issuer_token
279
+ # Parameters for the API call
280
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
281
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
282
+
283
+ # Perform the API call through the SDK function
284
+ result = @controller.get_token_three_ds_issuer_token(store_id, id)
285
+
286
+ # Test response code
287
+ assert_equal(200, @response_catcher.response.status_code)
288
+ # Test headers
289
+ expected_headers = {}
290
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
291
+
292
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
293
+
294
+ # Test whether the captured response is as we expected
295
+ refute_nil(result)
296
+ expected_body = JSON.parse(
297
+ '{"issuer_token":"http://test.com/action","call_method":"http_post","pay'\
298
+ 'load":{"request_data":"example_value"},"payment_type":"card","content_t'\
299
+ 'ype":"application/x-www-form-urlencoded; charset=UTF-8"}'
300
+ )
301
+ received_body = JSON.parse(@response_catcher.response.raw_body)
302
+ assert(ComparisonHelper.match_body(expected_body, received_body))
303
+ end
304
+
305
+ end
@@ -0,0 +1,245 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'api_test_base'
7
+
8
+ class WebhooksApiTest < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.webhooks
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Returns a paginated list of webhooks for the specified store. Requires a secret-bearing token.
17
+ def test_list_webhooks
18
+ # Parameters for the API call
19
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
20
+ limit = 10
21
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
22
+ cursor_direction = 'desc'
23
+ active = true
24
+
25
+ # Perform the API call through the SDK function
26
+ result = @controller.list_webhooks(store_id, limit: limit, cursor: cursor,
27
+ cursor_direction: cursor_direction,
28
+ active: active)
29
+
30
+ # Test response code
31
+ assert_equal(200, @response_catcher.response.status_code)
32
+ # Test headers
33
+ expected_headers = {}
34
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
35
+
36
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
37
+
38
+ # Test whether the captured response is as we expected
39
+ refute_nil(result)
40
+ expected_body = JSON.parse(
41
+ '{"items":[{"id":"d3e4f5a6-b7c8-9012-def0-123456789abc","store_id":"76cf'\
42
+ '4a64-02bc-4cb3-9a28-74622e5928a1","merchant_id":"01234567-89ab-cdef-012'\
43
+ '3-456789abcdef","triggers":["charge_finished","refund_finished"],"url":'\
44
+ '"https://example.com/webhooks/payments","auth_token":"my-secret-token",'\
45
+ '"active":true,"is_integration":false,"created_on":"2026-04-01T00:00:00.'\
46
+ '000000Z","updated_on":"2026-04-02T00:00:00.000000Z"},{"id":"e4f5a6b7-c8'\
47
+ 'd9-0123-ef01-23456789abcd","store_id":"76cf4a64-02bc-4cb3-9a28-74622e59'\
48
+ '28a1","merchant_id":"01234567-89ab-cdef-0123-456789abcdef","triggers":['\
49
+ '"subscription_payment","subscription_failure"],"url":"https://example.c'\
50
+ 'om/webhooks/subscriptions","auth_token":null,"active":true,"is_integrat'\
51
+ 'ion":false,"created_on":"2026-04-03T08:30:00.000000Z","updated_on":"202'\
52
+ '6-04-03T08:30:00.000000Z"},{"id":"f5a6b7c8-d9e0-1234-f012-3456789abcde"'\
53
+ ',"store_id":"76cf4a64-02bc-4cb3-9a28-74622e5928a1","merchant_id":"01234'\
54
+ '567-89ab-cdef-0123-456789abcdef","triggers":["cancel_finished"],"url":"'\
55
+ 'https://example.com/webhooks/cancels","auth_token":"legacy-token","acti'\
56
+ 've":false,"is_integration":false,"created_on":"2026-03-20T12:00:00.0000'\
57
+ '00Z","updated_on":"2026-04-05T09:15:00.000000Z"}],"has_more":false}'
58
+ )
59
+ received_body = JSON.parse(@response_catcher.response.raw_body)
60
+ assert(ComparisonHelper.match_body(expected_body, received_body))
61
+ end
62
+
63
+ # Creates a new webhook subscription for the specified store. Requires a secret-bearing token. Duplicate URLs within the same scope are not allowed. There is a maximum limit on the number of webhooks per store.
64
+ def test_create_webhook
65
+ # Parameters for the API call
66
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
67
+ body = WebhookCreateRequest.from_hash(APIHelper.json_deserialize(
68
+ '{"triggers":["charge_finished"],"url":"https://example.com/webhooks/pay'\
69
+ 'ments","auth_token":"my-secret-token"}', false))
70
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
71
+
72
+ # Perform the API call through the SDK function
73
+ result = @controller.create_webhook(store_id, body,
74
+ idempotency_key: idempotency_key)
75
+
76
+ # Test response code
77
+ assert_equal(201, @response_catcher.response.status_code)
78
+ # Test headers
79
+ expected_headers = {}
80
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
81
+
82
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
83
+
84
+ # Test whether the captured response is as we expected
85
+ refute_nil(result)
86
+ expected_body = JSON.parse(
87
+ '{"id":"d3e4f5a6-b7c8-9012-def0-123456789abc","store_id":"76cf4a64-02bc-'\
88
+ '4cb3-9a28-74622e5928a1","merchant_id":"01234567-89ab-cdef-0123-456789ab'\
89
+ 'cdef","triggers":["charge_finished","refund_finished"],"url":"https://e'\
90
+ 'xample.com/webhooks/payments","auth_token":"my-secret-token","active":t'\
91
+ 'rue,"is_integration":false,"created_on":"2026-04-01T00:00:00.000000Z","'\
92
+ 'updated_on":"2026-04-01T00:00:00.000000Z"}'
93
+ )
94
+ received_body = JSON.parse(@response_catcher.response.raw_body)
95
+ assert(ComparisonHelper.match_body(expected_body, received_body))
96
+ end
97
+
98
+ # Retrieves a specific webhook by ID.
99
+ def test_get_webhook
100
+ # Parameters for the API call
101
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
102
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
103
+
104
+ # Perform the API call through the SDK function
105
+ result = @controller.get_webhook(store_id, id)
106
+
107
+ # Test response code
108
+ assert_equal(200, @response_catcher.response.status_code)
109
+ # Test headers
110
+ expected_headers = {}
111
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
112
+
113
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
114
+
115
+ # Test whether the captured response is as we expected
116
+ refute_nil(result)
117
+ expected_body = JSON.parse(
118
+ '{"id":"d3e4f5a6-b7c8-9012-def0-123456789abc","store_id":"76cf4a64-02bc-'\
119
+ '4cb3-9a28-74622e5928a1","merchant_id":"01234567-89ab-cdef-0123-456789ab'\
120
+ 'cdef","triggers":["charge_finished"],"url":"https://example.com/webhook'\
121
+ 's/payments","active":true}'
122
+ )
123
+ received_body = JSON.parse(@response_catcher.response.raw_body)
124
+ assert(ComparisonHelper.match_body(expected_body, received_body))
125
+ end
126
+
127
+ # Updates an existing webhook. All fields are optional; omitted fields are left unchanged. Duplicate URLs within the same scope are not allowed.
128
+ def test_update_webhook
129
+ # Parameters for the API call
130
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
131
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
132
+ body = WebhookUpdateRequest.from_hash(APIHelper.json_deserialize(
133
+ '{"active":false}', false))
134
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
135
+
136
+ # Perform the API call through the SDK function
137
+ result = @controller.update_webhook(store_id, id, body,
138
+ idempotency_key: idempotency_key)
139
+
140
+ # Test response code
141
+ assert_equal(200, @response_catcher.response.status_code)
142
+ # Test headers
143
+ expected_headers = {}
144
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
145
+
146
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
147
+
148
+ # Test whether the captured response is as we expected
149
+ refute_nil(result)
150
+ expected_body = JSON.parse(
151
+ '{"id":"d3e4f5a6-b7c8-9012-def0-123456789abc","store_id":"76cf4a64-02bc-'\
152
+ '4cb3-9a28-74622e5928a1","merchant_id":"01234567-89ab-cdef-0123-456789ab'\
153
+ 'cdef","triggers":["charge_finished"],"url":"https://example.com/webhook'\
154
+ 's/v2","active":false}'
155
+ )
156
+ received_body = JSON.parse(@response_catcher.response.raw_body)
157
+ assert(ComparisonHelper.match_body(expected_body, received_body))
158
+ end
159
+
160
+ # Deactivates and deletes a webhook subscription.
161
+ def test_delete_webhook
162
+ # Parameters for the API call
163
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
164
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
165
+
166
+ # Perform the API call through the SDK function
167
+ @controller.delete_webhook(store_id, id)
168
+
169
+ # Test response code
170
+ assert_equal(204, @response_catcher.response.status_code)
171
+ end
172
+
173
+ # Returns a paginated list of webhook delivery events for the specified webhook. Each event captures the result of a single webhook delivery attempt.
174
+ def test_list_webhook_events
175
+ # Parameters for the API call
176
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
177
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
178
+ limit = 10
179
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
180
+ cursor_direction = 'desc'
181
+
182
+ # Perform the API call through the SDK function
183
+ result = @controller.list_webhook_events(store_id, id, limit: limit,
184
+ cursor: cursor,
185
+ cursor_direction: cursor_direction)
186
+
187
+ # Test response code
188
+ assert_equal(200, @response_catcher.response.status_code)
189
+ # Test headers
190
+ expected_headers = {}
191
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
192
+
193
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
194
+
195
+ # Test whether the captured response is as we expected
196
+ refute_nil(result)
197
+ expected_body = JSON.parse(
198
+ '{"items":[{"id":"e1f2a3b4-c5d6-7890-efab-123456789cde","webhook_id":"d3'\
199
+ 'e4f5a6-b7c8-9012-def0-123456789abc","event":"charge_finished","successf'\
200
+ 'ul":true,"fired_on":"2026-04-09T07:36:00.000000Z","error_message":null,'\
201
+ '"created_on":"2026-04-09T07:35:50.000000Z"},{"id":"f2a3b4c5-d6e7-8901-f'\
202
+ 'abc-23456789cdef","webhook_id":"d3e4f5a6-b7c8-9012-def0-123456789abc","'\
203
+ 'event":"refund_finished","successful":true,"fired_on":"2026-04-10T11:00'\
204
+ ':05.000000Z","error_message":null,"created_on":"2026-04-10T11:00:00.000'\
205
+ '000Z"},{"id":"a3b4c5d6-e7f8-9012-abcd-3456789cdef0","webhook_id":"d3e4f'\
206
+ '5a6-b7c8-9012-def0-123456789abc","event":"cancel_finished","successful"'\
207
+ ':false,"fired_on":"2026-04-11T15:30:10.000000Z","error_message":"Connec'\
208
+ 'tion timed out after 10s","created_on":"2026-04-11T15:30:00.000000Z"}],'\
209
+ '"has_more":false}'
210
+ )
211
+ received_body = JSON.parse(@response_catcher.response.raw_body)
212
+ assert(ComparisonHelper.match_body(expected_body, received_body))
213
+ end
214
+
215
+ # Re-sends the webhook payload for a previously delivered (or failed) event. Returns 202 Accepted immediately; delivery is asynchronous.
216
+ def test_redeliver_webhook_event
217
+ # Parameters for the API call
218
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
219
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
220
+ event_id = 'e1f2a3b4-c5d6-7890-efab-123456789cde'
221
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
222
+
223
+ # Perform the API call through the SDK function
224
+ result = @controller.redeliver_webhook_event(
225
+ store_id, id, event_id, idempotency_key: idempotency_key
226
+ )
227
+
228
+ # Test response code
229
+ assert_equal(202, @response_catcher.response.status_code)
230
+ # Test headers
231
+ expected_headers = {}
232
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
233
+
234
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
235
+
236
+ # Test whether the captured response is as we expected
237
+ refute_nil(result)
238
+ expected_body = JSON.parse(
239
+ '{}'
240
+ )
241
+ received_body = JSON.parse(@response_catcher.response.raw_body)
242
+ assert(ComparisonHelper.match_body(expected_body, received_body))
243
+ end
244
+
245
+ end
@@ -0,0 +1,95 @@
1
+ # univapay_client_sdk
2
+ #
3
+ # This file was automatically generated for Univapay
4
+ # by APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+
7
+ require 'json'
8
+ require 'rack'
9
+ require 'stringio'
10
+ require 'minitest/autorun'
11
+ require 'minitest/hell'
12
+ require 'minitest/pride'
13
+ require 'minitest/proveit'
14
+ require 'univapay_client_sdk'
15
+ class TestBankTransferHandler < Minitest::Test
16
+ parallelize_me!
17
+ include UnivapayClientSdk
18
+ include CoreLibrary
19
+
20
+ def setup
21
+ @handler = BankTransferHandler.new
22
+ end
23
+
24
+ def json_bytes(obj)
25
+ JSON.generate(obj).encode('utf-8')
26
+ end
27
+
28
+ def make_request(body_obj, add_signature_header: true)
29
+ raw = json_bytes(body_obj)
30
+ env = {
31
+ 'REQUEST_METHOD' => 'POST',
32
+ 'PATH_INFO' => '/webhooks',
33
+ 'rack.input' => StringIO.new(raw),
34
+ 'CONTENT_TYPE' => 'application/json'
35
+ }
36
+ Rack::Request.new(env)
37
+ end
38
+
39
+
40
+ def test_bank_transfer_status_updated_from_bank_transfer_handler
41
+ # Tests the `bankTransferStatusUpdated` event from bank-transferHandler.
42
+ # arrange
43
+ event_payload = {
44
+ :id => "11ef0000-0000-4000-8000-000000000001",
45
+ :event => "bank_transfer_status_updated",
46
+ :data => {
47
+ :id => "11ef0000-0000-4000-8000-000000000002",
48
+ :charge_id => "11ef0000-0000-4000-8000-000000000001",
49
+ :payment_status => "exact",
50
+ :latest_deposit_date => "2026-04-09T07:35:50.000000Z",
51
+ :created_on => "2026-04-09T07:35:50.000000Z",
52
+ :latest_deposit_amount => 1000,
53
+ :balance => 0,
54
+ :currency => "JPY",
55
+ :amount => 1000,
56
+ :amount_difference => 0,
57
+ :token_metadata => {
58
+ :order_id => "12345"
59
+ },
60
+ :charge_metadata => {
61
+ :order_id => "order_12345"
62
+ },
63
+ :exampleAdditionalProperty => {
64
+ :key1 => "val1",
65
+ :key2 => "val2"
66
+ }
67
+ },
68
+ :created_on => "2026-04-09T07:35:50.000000Z",
69
+ :exampleAdditionalProperty => {
70
+ :key1 => "val1",
71
+ :key2 => "val2"
72
+ }
73
+ }
74
+ rack_req = make_request(event_payload)
75
+
76
+ # act
77
+ event = @handler.parse_event(rack_req)
78
+
79
+ # assert
80
+ assert event.is_a?(BankTransferStatusWebhookCallback) && event.event == 'bank_transfer_status_updated'
81
+ end
82
+
83
+ def test_unknown_event
84
+ # arrange
85
+ event_payload = 45.0
86
+ rake_req = make_request(event_payload)
87
+
88
+ # act
89
+ event = @handler.parse_event(rake_req)
90
+
91
+ # assert
92
+ assert event.is_a?(UnknownEvent)
93
+ end
94
+
95
+ end