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,579 @@
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 SubscriptionsApiTest < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.subscriptions
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Creates a new subscription.
17
+ def test_create_subscription
18
+ # Parameters for the API call
19
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
20
+ body = SubscriptionCreateRequest.from_hash(APIHelper.json_deserialize(
21
+ '{"transaction_token_id":"11ef32a7-3a71-8662-803f-1bc27702eeec","amount"'\
22
+ ':1000,"currency":"JPY","period":"monthly"}', false))
23
+
24
+ # Perform the API call through the SDK function
25
+ result = @controller.create_subscription(idempotency_key: idempotency_key,
26
+ body: body)
27
+
28
+ # Test response code
29
+ assert_equal(201, @response_catcher.response.status_code)
30
+ # Test headers
31
+ expected_headers = {}
32
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
33
+
34
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
35
+
36
+ # Test whether the captured response is as we expected
37
+ refute_nil(result)
38
+ expected_body = JSON.parse(
39
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
40
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71-8662-803f'\
41
+ '-1bc27702eeec","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
42
+ 'initial_amount":1000,"initial_amount_formatted":10.0,"subsequent_cycles'\
43
+ '_start":null,"only_direct_currency":false,"first_charge_authorization_o'\
44
+ 'nly":false,"status":"current","metadata":{"order_id":"ORD-987"},"mode":'\
45
+ '"live","created_on":"2024-06-26T01:51:28.627023Z","period":"monthly","n'\
46
+ 'ext_payment":{"id":"11ef3360-1f9a-c54a-8313-7f9847da313b","due_date":"2'\
47
+ '024-07-26","zone_id":"Asia/Tokyo","amount":1250,"currency":"USD","amoun'\
48
+ 't_formatted":12.5,"is_paid":false}}'
49
+ )
50
+ received_body = JSON.parse(@response_catcher.response.raw_body)
51
+ assert(ComparisonHelper.match_body(expected_body, received_body))
52
+ end
53
+
54
+ # Lists all subscriptions across all stores.
55
+ def test_list_all_subscriptions
56
+ # Parameters for the API call
57
+ limit = 10
58
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
59
+ cursor_direction = 'desc'
60
+
61
+ # Perform the API call through the SDK function
62
+ result = @controller.list_all_subscriptions(
63
+ limit: limit, cursor: cursor, cursor_direction: cursor_direction
64
+ )
65
+
66
+ # Test response code
67
+ assert_equal(200, @response_catcher.response.status_code)
68
+ # Test headers
69
+ expected_headers = {}
70
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
71
+
72
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
73
+
74
+ # Test whether the captured response is as we expected
75
+ refute_nil(result)
76
+ expected_body = JSON.parse(
77
+ '{"items":[{"id":"11ef3410-aaaa-4bcd-8e1f-1a2b3c4d5e60","store_id":"11ed'\
78
+ 'f541-c42d-653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef3413-dddd'\
79
+ '-4ef0-b142-4d5e6f809193","amount":1250,"currency":"USD","amount_formatt'\
80
+ 'ed":12.5,"status":"current","merchant_name":"管理画面ガイド","store_name":"管理画'\
81
+ '面ガイド_TEST店舗","payment_type":"card","next_payment_date":"2024-07-26","us'\
82
+ 'er_data":{"type":"charge","cardholder_name":"taro yamada","email":"taro'\
83
+ '@test.com","brand":"visa"}},{"id":"11ef3411-bbbb-4cde-9f20-2b3c4d5e6f71'\
84
+ '","store_id":"22af6520-d53e-764d-9d4e-ef01b66fa6d1","transaction_token_'\
85
+ 'id":"11ef3414-eeee-4f01-c253-5e6f80919204","amount":3000,"currency":"JP'\
86
+ 'Y","amount_formatted":3000,"status":"current","merchant_name":"管理画面ガイド"'\
87
+ ',"store_name":"管理画面ガイド_Online店舗","payment_type":"card","next_payment_da'\
88
+ 'te":"2024-08-10","user_data":{"type":"charge","cardholder_name":"hanako'\
89
+ ' suzuki","email":"hanako@test.com","brand":"mastercard"}},{"id":"11ef34'\
90
+ '12-cccc-4def-a031-3c4d5e6f8082","store_id":"33af7631-e64f-875e-ae5f-f01'\
91
+ '2c77fb7e2","transaction_token_id":"11ef3415-ffff-4012-d364-6f8091920315'\
92
+ '","amount":9800,"currency":"JPY","amount_formatted":9800,"status":"susp'\
93
+ 'ended","merchant_name":"管理画面ガイド","store_name":"管理画面ガイド_Osaka店舗","paymen'\
94
+ 't_type":"card","next_payment_date":"2024-09-15","user_data":{"type":"ch'\
95
+ 'arge","cardholder_name":"jiro tanaka","email":"jiro@test.com","brand":"'\
96
+ 'jcb"}}],"has_more":false,"total_hits":3}'
97
+ )
98
+ received_body = JSON.parse(@response_catcher.response.raw_body)
99
+ assert(ComparisonHelper.match_body(expected_body, received_body))
100
+ end
101
+
102
+ # Lists all subscriptions for a specific store.
103
+ def test_list_store_subscriptions
104
+ # Parameters for the API call
105
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
106
+ search = 'order_id:12345'
107
+ status = 'current'
108
+ mode = 'live'
109
+ limit = 10
110
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
111
+ cursor_direction = 'desc'
112
+
113
+ # Perform the API call through the SDK function
114
+ result = @controller.list_store_subscriptions(
115
+ store_id, search: search, status: status, mode: mode, limit: limit,
116
+ cursor: cursor, cursor_direction: cursor_direction
117
+ )
118
+
119
+ # Test response code
120
+ assert_equal(200, @response_catcher.response.status_code)
121
+ # Test headers
122
+ expected_headers = {}
123
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
124
+
125
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
126
+
127
+ # Test whether the captured response is as we expected
128
+ refute_nil(result)
129
+ expected_body = JSON.parse(
130
+ '{"items":[{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11ed'\
131
+ 'f541-c42d-653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71'\
132
+ '-8662-803f-1bc27702eeec","amount":1250,"currency":"USD","amount_formatt'\
133
+ 'ed":12.5,"status":"current","merchant_name":"管理画面ガイド","store_name":"管理画'\
134
+ '面ガイド_TEST店舗","payment_type":"card","next_payment_date":"2024-07-26","us'\
135
+ 'er_data":{"type":"charge","cardholder_name":"taro yamada","email":"test'\
136
+ '@test.com","brand":"visa"}},{"id":"11ef3401-1a2b-4c3d-8e4f-5a6b7c8d9e0f'\
137
+ '","store_id":"11edf541-c42d-653c-8c3d-dfe0a55f95c0","transaction_token_'\
138
+ 'id":"11ef3402-2b3c-4d5e-9f60-6b7c8d9e0f11","amount":5000,"currency":"JP'\
139
+ 'Y","amount_formatted":5000,"status":"current","merchant_name":"管理画面ガイド"'\
140
+ ',"store_name":"管理画面ガイド_TEST店舗","payment_type":"card","next_payment_date'\
141
+ '":"2024-08-01","user_data":{"type":"charge","cardholder_name":"hanako s'\
142
+ 'uzuki","email":"hanako@test.com","brand":"mastercard"}},{"id":"11ef3403'\
143
+ '-3c4d-5e6f-a071-7c8d9e0f1122","store_id":"11edf541-c42d-653c-8c3d-dfe0a'\
144
+ '55f95c0","transaction_token_id":"11ef3404-4d5e-6f70-b182-8d9e0f112233",'\
145
+ '"amount":9800,"currency":"JPY","amount_formatted":9800,"status":"suspen'\
146
+ 'ded","merchant_name":"管理画面ガイド","store_name":"管理画面ガイド_TEST店舗","payment_t'\
147
+ 'ype":"card","next_payment_date":"2024-09-15","user_data":{"type":"charg'\
148
+ 'e","cardholder_name":"jiro tanaka","email":"jiro@test.com","brand":"jcb'\
149
+ '"}}],"has_more":false,"total_hits":3}'
150
+ )
151
+ received_body = JSON.parse(@response_catcher.response.raw_body)
152
+ assert(ComparisonHelper.match_body(expected_body, received_body))
153
+ end
154
+
155
+ # Retrieves the details of an existing subscription. Supports internal polling to wait for status changes.
156
+ def test_get_subscription
157
+ # Parameters for the API call
158
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
159
+ id = '11ef335e-9aa5-c54a-8313-7f9847da313a'
160
+ polling = true
161
+
162
+ # Perform the API call through the SDK function
163
+ result = @controller.get_subscription(store_id, id, polling: polling)
164
+
165
+ # Test response code
166
+ assert_equal(200, @response_catcher.response.status_code)
167
+ # Test headers
168
+ expected_headers = {}
169
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
170
+
171
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
172
+
173
+ # Test whether the captured response is as we expected
174
+ refute_nil(result)
175
+ expected_body = JSON.parse(
176
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
177
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71-8662-803f'\
178
+ '-1bc27702eeec","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
179
+ 'initial_amount":null,"initial_amount_formatted":null,"subsequent_cycles'\
180
+ '_start":null,"schedule_settings":{"start_on":"2024-07-01","zone_id":"As'\
181
+ 'ia/Tokyo","preserve_end_of_month":false,"retry_interval":"P7D","termina'\
182
+ 'tion_mode":"immediate"},"only_direct_currency":false,"first_charge_capt'\
183
+ 'ure_after":null,"first_charge_authorization_only":false,"status":"curre'\
184
+ 'nt","metadata":{"order_id":"12345"},"mode":"test","created_on":"2024-06'\
185
+ '-26T01:51:28.627023Z","period":"monthly","next_payment":{"id":"11ef335e'\
186
+ '-9ae2-8322-8e79-e7ba4b56234e","due_date":"2024-07-26","zone_id":"Asia/T'\
187
+ 'okyo","amount":1250,"currency":"USD","amount_formatted":12.5,"is_paid":'\
188
+ 'false,"is_last_payment":false,"created_on":"2024-06-26T01:51:29.025129Z'\
189
+ '","updated_on":"2024-06-26T01:51:29.025129Z","retry_date":null}}'
190
+ )
191
+ received_body = JSON.parse(@response_catcher.response.raw_body)
192
+ assert(ComparisonHelper.match_body(expected_body, received_body))
193
+ end
194
+
195
+ # Updates the configuration, payment method, or schedule of a specific subscription.
196
+ def test_update_subscription
197
+ # Parameters for the API call
198
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
199
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
200
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
201
+ body = SubscriptionUpdateRequest.from_hash(APIHelper.json_deserialize(
202
+ '{"metadata":{"order_id":"12345"},"schedule_settings":{"termination_mode'\
203
+ '":"on_next_payment"}}', false))
204
+
205
+ # Perform the API call through the SDK function
206
+ result = @controller.update_subscription(store_id, id,
207
+ idempotency_key: idempotency_key,
208
+ body: body)
209
+
210
+ # Test response code
211
+ assert_equal(200, @response_catcher.response.status_code)
212
+ # Test headers
213
+ expected_headers = {}
214
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
215
+
216
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
217
+
218
+ # Test whether the captured response is as we expected
219
+ refute_nil(result)
220
+ expected_body = JSON.parse(
221
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
222
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef3362-3700-c54a-9baa'\
223
+ '-6f7e6527c9d9","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
224
+ 'initial_amount":null,"initial_amount_formatted":null,"subsequent_cycles'\
225
+ '_start":null,"schedule_settings":{"start_on":"2024-07-01","zone_id":"As'\
226
+ 'ia/Tokyo","preserve_end_of_month":false,"retry_interval":"P7D","termina'\
227
+ 'tion_mode":"on_next_payment"},"only_direct_currency":false,"first_charg'\
228
+ 'e_capture_after":null,"first_charge_authorization_only":false,"status":'\
229
+ '"current","metadata":{"order_id":"12345"},"mode":"test","created_on":"2'\
230
+ '024-06-26T01:51:28.627023Z","period":"monthly","next_payment":{"id":"11'\
231
+ 'ef335e-9ae2-8322-8e79-e7ba4b56234e","due_date":"2030-01-01","zone_id":"'\
232
+ 'Asia/Tokyo","amount":1250,"currency":"USD","amount_formatted":12.5,"is_'\
233
+ 'paid":false,"is_last_payment":false,"created_on":"2024-06-26T01:51:29.0'\
234
+ '25129Z","updated_on":"2024-06-26T01:51:29.025129Z","retry_date":null}}'
235
+ )
236
+ received_body = JSON.parse(@response_catcher.response.raw_body)
237
+ assert(ComparisonHelper.match_body(expected_body, received_body))
238
+ end
239
+
240
+ # Cancels an existing subscription. The subscription status will be permanently changed to `canceled` and it cannot be resumed. Please proceed with caution.
241
+ def test_cancel_subscription
242
+ # Parameters for the API call
243
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
244
+ id = 'c4e87129-cad4-47fb-8ded-b4c0a4ae0dd4'
245
+
246
+ # Perform the API call through the SDK function
247
+ @controller.cancel_subscription(store_id, id)
248
+
249
+ # Test response code
250
+ assert_equal(204, @response_catcher.response.status_code)
251
+ end
252
+
253
+ # Retrieves a list of all historical and scheduled payments for a specific subscription.
254
+ def test_list_subscription_payments
255
+ # Parameters for the API call
256
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
257
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
258
+ limit = 10
259
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
260
+ cursor_direction = 'desc'
261
+
262
+ # Perform the API call through the SDK function
263
+ result = @controller.list_subscription_payments(
264
+ store_id, subscription_id, limit: limit, cursor: cursor,
265
+ cursor_direction: cursor_direction
266
+ )
267
+
268
+ # Test response code
269
+ assert_equal(200, @response_catcher.response.status_code)
270
+ # Test headers
271
+ expected_headers = {}
272
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
273
+
274
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
275
+
276
+ # Test whether the captured response is as we expected
277
+ refute_nil(result)
278
+ expected_body = JSON.parse(
279
+ '{"items":[{"id":"11e89a0a-8cee-d660-b984-3fcaaed46e7c","due_date":"2018'\
280
+ '-08-21","zone_id":"Asia/Tokyo","amount":10000,"currency":"JPY","amount_'\
281
+ 'formatted":10000,"is_paid":false,"is_last_payment":false,"created_on":"'\
282
+ '2018-08-07T06:24:33.961256Z","updated_on":"2018-08-07T06:24:33.961256Z"'\
283
+ '},{"id":"11e89a0a-8cc5-2662-9460-2b14b1a601ba","due_date":"2018-08-07",'\
284
+ '"zone_id":"Asia/Tokyo","amount":1000,"currency":"JPY","amount_formatted'\
285
+ '":1000,"is_paid":true,"is_last_payment":false,"created_on":"2018-08-07T'\
286
+ '06:24:33.646223Z","updated_on":"2018-08-07T06:24:33.887760Z"}],"has_mor'\
287
+ 'e":false}'
288
+ )
289
+ received_body = JSON.parse(@response_catcher.response.raw_body)
290
+ assert(ComparisonHelper.match_body(expected_body, received_body))
291
+ end
292
+
293
+ # Retrieves the details of an individual payment associated with a specific subscription.
294
+ def test_get_subscription_payment
295
+ # Parameters for the API call
296
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
297
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
298
+ payment_id = '11e89a0a-8cee-d660-b984-3fcaaed46e7c'
299
+
300
+ # Perform the API call through the SDK function
301
+ result = @controller.get_subscription_payment(store_id, subscription_id,
302
+ payment_id)
303
+
304
+ # Test response code
305
+ assert_equal(200, @response_catcher.response.status_code)
306
+ # Test headers
307
+ expected_headers = {}
308
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
309
+
310
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
311
+
312
+ # Test whether the captured response is as we expected
313
+ refute_nil(result)
314
+ expected_body = JSON.parse(
315
+ '{"id":"11e89a0a-8cee-d660-b984-3fcaaed46e7c","due_date":"2018-08-21","z'\
316
+ 'one_id":"Asia/Tokyo","amount":10000,"currency":"JPY","amount_formatted"'\
317
+ ':10000,"is_paid":false,"is_last_payment":false,"created_on":"2018-08-07'\
318
+ 'T06:24:33.961256Z"}'
319
+ )
320
+ received_body = JSON.parse(@response_catcher.response.raw_body)
321
+ assert(ComparisonHelper.match_body(expected_body, received_body))
322
+ end
323
+
324
+ # Updates properties of a specific scheduled payment for a subscription. Can be used to change the due date when permitted, mark the payment as paid, schedule a termination status, or set a retry interval.
325
+ def test_update_subscription_payment
326
+ # Parameters for the API call
327
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
328
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
329
+ payment_id = '11e89a0a-8cee-d660-b984-3fcaaed46e7c'
330
+ body = SubscriptionPatchPaymentRequest.from_hash(APIHelper.json_deserialize(
331
+ '{"due_date":"2026-09-01","is_paid":false}', false))
332
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
333
+
334
+ # Perform the API call through the SDK function
335
+ result = @controller.update_subscription_payment(
336
+ store_id, subscription_id, payment_id, body,
337
+ idempotency_key: idempotency_key
338
+ )
339
+
340
+ # Test response code
341
+ assert_equal(200, @response_catcher.response.status_code)
342
+ # Test headers
343
+ expected_headers = {}
344
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
345
+
346
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
347
+
348
+ # Test whether the captured response is as we expected
349
+ refute_nil(result)
350
+ expected_body = JSON.parse(
351
+ '{"id":"11e89a0a-8cee-d660-b984-3fcaaed46e7c","due_date":"2026-09-01","z'\
352
+ 'one_id":"Asia/Tokyo","amount":10000,"currency":"JPY","amount_formatted"'\
353
+ ':10000,"is_paid":false,"is_last_payment":false,"created_on":"2018-08-07'\
354
+ 'T06:24:33.961256Z","updated_on":"2026-04-22T06:00:00.000000Z"}'
355
+ )
356
+ received_body = JSON.parse(@response_catcher.response.raw_body)
357
+ assert(ComparisonHelper.match_body(expected_body, received_body))
358
+ end
359
+
360
+ # Retrieves the most recent charge created for a specific subscription. Returns 404 if no charges have been attempted yet.
361
+ def test_get_subscription_latest_charge
362
+ # Parameters for the API call
363
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
364
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
365
+
366
+ # Perform the API call through the SDK function
367
+ result = @controller.get_subscription_latest_charge(store_id,
368
+ subscription_id)
369
+
370
+ # Test response code
371
+ assert_equal(200, @response_catcher.response.status_code)
372
+ # Test headers
373
+ expected_headers = {}
374
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
375
+
376
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
377
+
378
+ # Test whether the captured response is as we expected
379
+ refute_nil(result)
380
+ expected_body = JSON.parse(
381
+ '{"id":"6efb4e5c-690a-40f3-a4f1-0e19c5f84e98","store_id":"11edf541-c42d-'\
382
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71-8662-803f'\
383
+ '-1bc27702eeec","transaction_token_type":"recurring","subscription_id":"'\
384
+ '11ef335e-9aa5-c54a-8313-7f9847da313a","requested_amount":1250,"requeste'\
385
+ 'd_currency":"USD","requested_amount_formatted":12.5,"charged_amount":12'\
386
+ '50,"charged_currency":"USD","charged_amount_formatted":12.5,"only_direc'\
387
+ 't_currency":false,"status":"successful","error":null,"mode":"test","cre'\
388
+ 'ated_on":"2024-06-26T01:51:30.000000Z"}'
389
+ )
390
+ received_body = JSON.parse(@response_catcher.response.raw_body)
391
+ assert(ComparisonHelper.match_body(expected_body, received_body))
392
+ end
393
+
394
+ # Retrieves a paginated list of charges linked to a subscription. Backend search uses the same charge search surface as normal charge listing and adds a subscription filter for the requested subscription.
395
+ def test_list_subscription_charges
396
+ # Parameters for the API call
397
+ merchant_id = '01234567-89ab-cdef-0123-456789abcdef'
398
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
399
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
400
+ limit = 10
401
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
402
+ cursor_direction = 'desc'
403
+
404
+ # Perform the API call through the SDK function
405
+ result = @controller.list_subscription_charges(
406
+ merchant_id, store_id, subscription_id, limit: limit, cursor: cursor,
407
+ cursor_direction: cursor_direction
408
+ )
409
+
410
+ # Test response code
411
+ assert_equal(200, @response_catcher.response.status_code)
412
+ # Test headers
413
+ expected_headers = {}
414
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
415
+
416
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
417
+
418
+ # Test whether the captured response is as we expected
419
+ refute_nil(result)
420
+ expected_body = JSON.parse(
421
+ '{"items":[{"id":"6efb4e5c-690a-40f3-a4f1-0e19c5f84e98","store_id":"11ed'\
422
+ 'f541-c42d-653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71'\
423
+ '-8662-803f-1bc27702eeec","transaction_token_type":"recurring","subscrip'\
424
+ 'tion_id":"11ef335e-9aa5-c54a-8313-7f9847da313a","requested_amount":1250'\
425
+ ',"requested_currency":"USD","requested_amount_formatted":12.5,"charged_'\
426
+ 'amount":1250,"charged_currency":"USD","charged_amount_formatted":12.5,"'\
427
+ 'only_direct_currency":false,"status":"successful","error":{},"mode":"te'\
428
+ 'st","created_on":"2024-06-26T01:51:30.000000Z"}],"has_more":false,"tota'\
429
+ 'l_hits":1}'
430
+ )
431
+ received_body = JSON.parse(@response_catcher.response.raw_body)
432
+ assert(ComparisonHelper.match_body(expected_body, received_body))
433
+ end
434
+
435
+ # Retrieves a paginated list of all charge attempts made for a specific scheduled payment of a subscription. Useful for inspecting retry history.
436
+ def test_list_charges_for_subscription_payment
437
+ # Parameters for the API call
438
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
439
+ subscription_id = '25d0fb2c-18ef-11e7-9dd3-db8fb7b820e7'
440
+ payment_id = '11e89a0a-8cee-d660-b984-3fcaaed46e7c'
441
+ limit = 10
442
+ cursor = '3541d4fa-596d-428e-8a36-f274e1b3d505'
443
+ cursor_direction = 'desc'
444
+
445
+ # Perform the API call through the SDK function
446
+ result = @controller.list_charges_for_subscription_payment(
447
+ store_id, subscription_id, payment_id, limit: limit, cursor: cursor,
448
+ cursor_direction: cursor_direction
449
+ )
450
+
451
+ # Test response code
452
+ assert_equal(200, @response_catcher.response.status_code)
453
+ # Test headers
454
+ expected_headers = {}
455
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
456
+
457
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
458
+
459
+ # Test whether the captured response is as we expected
460
+ refute_nil(result)
461
+ expected_body = JSON.parse(
462
+ '{"items":[{"id":"6efb4e5c-690a-40f3-a4f1-0e19c5f84e98","store_id":"11ed'\
463
+ 'f541-c42d-653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71'\
464
+ '-8662-803f-1bc27702eeec","transaction_token_type":"recurring","subscrip'\
465
+ 'tion_id":"11ef335e-9aa5-c54a-8313-7f9847da313a","requested_amount":1250'\
466
+ ',"requested_currency":"USD","requested_amount_formatted":12.5,"charged_'\
467
+ 'amount":1250,"charged_currency":"USD","charged_amount_formatted":12.5,"'\
468
+ 'only_direct_currency":false,"status":"successful","error":{},"mode":"te'\
469
+ 'st","created_on":"2024-06-26T01:51:30.000000Z"}],"has_more":false,"tota'\
470
+ 'l_hits":1}'
471
+ )
472
+ received_body = JSON.parse(@response_catcher.response.raw_body)
473
+ assert(ComparisonHelper.match_body(expected_body, received_body))
474
+ end
475
+
476
+ # Suspends a subscription that is currently `current` or `unpaid`. The `termination_mode` controls when the suspension takes effect: `immediate` (default) suspends right away, `on_next_payment` waits until the next scheduled payment date before suspending.
477
+ def test_suspend_subscription
478
+ # Parameters for the API call
479
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
480
+ subscription_id = '11ef335e-9aa5-c54a-8313-7f9847da313a'
481
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
482
+ body = SubscriptionSuspendRequest.from_hash(APIHelper.json_deserialize(
483
+ '{"schedule_settings":{"termination_mode":"on_next_payment"}}', false))
484
+
485
+ # Perform the API call through the SDK function
486
+ result = @controller.suspend_subscription(store_id, subscription_id,
487
+ idempotency_key: idempotency_key,
488
+ body: body)
489
+
490
+ # Test response code
491
+ assert_equal(200, @response_catcher.response.status_code)
492
+ # Test headers
493
+ expected_headers = {}
494
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
495
+
496
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
497
+
498
+ # Test whether the captured response is as we expected
499
+ refute_nil(result)
500
+ expected_body = JSON.parse(
501
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
502
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71-8662-803f'\
503
+ '-1bc27702eeec","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
504
+ 'status":"suspended","mode":"test","created_on":"2024-06-26T01:51:28.627'\
505
+ '023Z","period":"monthly"}'
506
+ )
507
+ received_body = JSON.parse(@response_catcher.response.raw_body)
508
+ assert(ComparisonHelper.match_body(expected_body, received_body))
509
+ end
510
+
511
+ # Resumes a subscription that is currently `suspended`, setting its status back to `unpaid` and rescheduling the next payment. No request body is required.
512
+ def test_unsuspend_subscription
513
+ # Parameters for the API call
514
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
515
+ subscription_id = '11ef335e-9aa5-c54a-8313-7f9847da313a'
516
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
517
+
518
+ # Perform the API call through the SDK function
519
+ result = @controller.unsuspend_subscription(
520
+ store_id, subscription_id, idempotency_key: idempotency_key
521
+ )
522
+
523
+ # Test response code
524
+ assert_equal(200, @response_catcher.response.status_code)
525
+ # Test headers
526
+ expected_headers = {}
527
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
528
+
529
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
530
+
531
+ # Test whether the captured response is as we expected
532
+ refute_nil(result)
533
+ expected_body = JSON.parse(
534
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
535
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef32a7-3a71-8662-803f'\
536
+ '-1bc27702eeec","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
537
+ 'status":"unpaid","mode":"test","created_on":"2024-06-26T01:51:28.627023'\
538
+ 'Z","period":"monthly"}'
539
+ )
540
+ received_body = JSON.parse(@response_catcher.response.raw_body)
541
+ assert(ComparisonHelper.match_body(expected_body, received_body))
542
+ end
543
+
544
+ # Replaces the payment method (transaction token) used for a subscription. Useful when a card expires or a customer wants to switch payment methods. The new token must belong to the same store, be active, and match the subscription's processing mode (live/test). One-time tokens are not accepted; use a recurring or subscription token.
545
+ def test_update_subscription_token
546
+ # Parameters for the API call
547
+ store_id = '0cab399b-5621-425b-993b-f8507eba1e78'
548
+ subscription_id = '11ef335e-9aa5-c54a-8313-7f9847da313a'
549
+ body = SubscriptionPatchTokenRequest.from_hash(APIHelper.json_deserialize(
550
+ '{"transaction_token_id":"11ef3362-3700-c54a-9baa-6f7e6527c9d9"}', false))
551
+ idempotency_key = 'f64be872-353d-4c3c-84cb-3dc617fe89f7'
552
+
553
+ # Perform the API call through the SDK function
554
+ result = @controller.update_subscription_token(
555
+ store_id, subscription_id, body, idempotency_key: idempotency_key
556
+ )
557
+
558
+ # Test response code
559
+ assert_equal(200, @response_catcher.response.status_code)
560
+ # Test headers
561
+ expected_headers = {}
562
+ expected_headers['content-type'] = 'application/json; charset=utf-8'
563
+
564
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
565
+
566
+ # Test whether the captured response is as we expected
567
+ refute_nil(result)
568
+ expected_body = JSON.parse(
569
+ '{"id":"11ef335e-9aa5-c54a-8313-7f9847da313a","store_id":"11edf541-c42d-'\
570
+ '653c-8c3d-dfe0a55f95c0","transaction_token_id":"11ef3362-3700-c54a-9baa'\
571
+ '-6f7e6527c9d9","amount":1250,"currency":"USD","amount_formatted":12.5,"'\
572
+ 'status":"current","mode":"test","created_on":"2024-06-26T01:51:28.62702'\
573
+ '3Z","period":"monthly"}'
574
+ )
575
+ received_body = JSON.parse(@response_catcher.response.raw_body)
576
+ assert(ComparisonHelper.match_body(expected_body, received_body))
577
+ end
578
+
579
+ end