mollie-api-py 1.0.0__py3-none-any.whl

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 (337) hide show
  1. mollie/__init__.py +18 -0
  2. mollie/_hooks/__init__.py +5 -0
  3. mollie/_hooks/mollie_hooks.py +165 -0
  4. mollie/_hooks/registration.py +18 -0
  5. mollie/_hooks/sdkhooks.py +76 -0
  6. mollie/_hooks/types.py +113 -0
  7. mollie/_version.py +15 -0
  8. mollie/balance_transfers.py +651 -0
  9. mollie/balances.py +1105 -0
  10. mollie/basesdk.py +360 -0
  11. mollie/capabilities.py +209 -0
  12. mollie/captures.py +677 -0
  13. mollie/chargebacks_sdk.py +675 -0
  14. mollie/client_links.py +325 -0
  15. mollie/clients.py +409 -0
  16. mollie/customers.py +1563 -0
  17. mollie/delayed_routing.py +421 -0
  18. mollie/httpclient.py +125 -0
  19. mollie/invoices.py +429 -0
  20. mollie/mandates.py +895 -0
  21. mollie/methods.py +789 -0
  22. mollie/models/__init__.py +4002 -0
  23. mollie/models/address.py +29 -0
  24. mollie/models/amount.py +25 -0
  25. mollie/models/amount_nullable.py +24 -0
  26. mollie/models/apierror.py +40 -0
  27. mollie/models/balance_card_audience.py +10 -0
  28. mollie/models/balance_card_issuer.py +12 -0
  29. mollie/models/balance_card_region.py +12 -0
  30. mollie/models/balance_fee_type.py +43 -0
  31. mollie/models/balance_prepayment_part_type.py +13 -0
  32. mollie/models/balance_report_grouping.py +10 -0
  33. mollie/models/balance_transaction_type.py +47 -0
  34. mollie/models/balance_transfer_category.py +17 -0
  35. mollie/models/balance_transfer_category_response.py +18 -0
  36. mollie/models/balance_transfer_destination_type.py +14 -0
  37. mollie/models/balance_transfer_party_type.py +10 -0
  38. mollie/models/balance_transfer_party_type_response.py +11 -0
  39. mollie/models/balance_transfer_status.py +13 -0
  40. mollie/models/balance_transfer_status_reason_response.py +19 -0
  41. mollie/models/billingaddress.py +154 -0
  42. mollie/models/cancel_paymentop.py +93 -0
  43. mollie/models/cancel_refundop.py +86 -0
  44. mollie/models/cancel_subscriptionop.py +100 -0
  45. mollie/models/capability_requirement_status.py +15 -0
  46. mollie/models/capability_status.py +12 -0
  47. mollie/models/capability_status_reason.py +10 -0
  48. mollie/models/capture_mode.py +15 -0
  49. mollie/models/capture_mode_response.py +16 -0
  50. mollie/models/capture_response.py +265 -0
  51. mollie/models/client_link_request.py +210 -0
  52. mollie/models/client_link_response.py +56 -0
  53. mollie/models/clienterror.py +30 -0
  54. mollie/models/components_sub_totals.py +127 -0
  55. mollie/models/create_captureop.py +43 -0
  56. mollie/models/create_client_linkop.py +29 -0
  57. mollie/models/create_connect_balance_transferop.py +32 -0
  58. mollie/models/create_customer_paymentop.py +43 -0
  59. mollie/models/create_customerop.py +29 -0
  60. mollie/models/create_mandateop.py +43 -0
  61. mollie/models/create_payment_linkop.py +325 -0
  62. mollie/models/create_paymentop.py +73 -0
  63. mollie/models/create_profileop.py +29 -0
  64. mollie/models/create_refundop.py +43 -0
  65. mollie/models/create_sales_invoiceop.py +29 -0
  66. mollie/models/create_subscriptionop.py +43 -0
  67. mollie/models/create_webhook.py +123 -0
  68. mollie/models/create_webhookop.py +69 -0
  69. mollie/models/currencies.py +20 -0
  70. mollie/models/customer_response.py +169 -0
  71. mollie/models/delete_customerop.py +91 -0
  72. mollie/models/delete_payment_linkop.py +91 -0
  73. mollie/models/delete_profileop.py +29 -0
  74. mollie/models/delete_sales_invoiceop.py +44 -0
  75. mollie/models/delete_values_sales_invoice.py +54 -0
  76. mollie/models/delete_webhookop.py +56 -0
  77. mollie/models/entity_balance.py +325 -0
  78. mollie/models/entity_balance_report.py +541 -0
  79. mollie/models/entity_balance_transaction.py +1068 -0
  80. mollie/models/entity_balance_transfer.py +62 -0
  81. mollie/models/entity_balance_transfer_party.py +28 -0
  82. mollie/models/entity_balance_transfer_party_response.py +32 -0
  83. mollie/models/entity_balance_transfer_response.py +159 -0
  84. mollie/models/entity_capability.py +75 -0
  85. mollie/models/entity_capability_requirement.py +87 -0
  86. mollie/models/entity_capture.py +63 -0
  87. mollie/models/entity_chargeback.py +247 -0
  88. mollie/models/entity_customer.py +86 -0
  89. mollie/models/entity_event.py +46 -0
  90. mollie/models/entity_invoice.py +247 -0
  91. mollie/models/entity_method_get.py +329 -0
  92. mollie/models/entity_onboarding_status.py +95 -0
  93. mollie/models/entity_organization.py +178 -0
  94. mollie/models/entity_payment_route.py +111 -0
  95. mollie/models/entity_payment_route_response.py +140 -0
  96. mollie/models/entity_permission.py +61 -0
  97. mollie/models/entity_refund_response.py +361 -0
  98. mollie/models/entity_route.py +96 -0
  99. mollie/models/entity_settlement.py +467 -0
  100. mollie/models/entity_terminal.py +160 -0
  101. mollie/models/entity_webhook.py +122 -0
  102. mollie/models/entity_webhook_event.py +149 -0
  103. mollie/models/error_response.py +70 -0
  104. mollie/models/get_balance_reportop.py +126 -0
  105. mollie/models/get_balanceop.py +71 -0
  106. mollie/models/get_captureop.py +129 -0
  107. mollie/models/get_chargebackop.py +129 -0
  108. mollie/models/get_clientop.py +216 -0
  109. mollie/models/get_connect_balance_transferop.py +71 -0
  110. mollie/models/get_current_organizationop.py +22 -0
  111. mollie/models/get_current_profileop.py +22 -0
  112. mollie/models/get_customerop.py +286 -0
  113. mollie/models/get_invoiceop.py +29 -0
  114. mollie/models/get_mandateop.py +86 -0
  115. mollie/models/get_methodop.py +199 -0
  116. mollie/models/get_next_settlementop.py +22 -0
  117. mollie/models/get_onboarding_statusop.py +22 -0
  118. mollie/models/get_open_settlementop.py +22 -0
  119. mollie/models/get_organizationop.py +71 -0
  120. mollie/models/get_partner_statusop.py +231 -0
  121. mollie/models/get_payment_link_paymentsop.py +188 -0
  122. mollie/models/get_payment_linkop.py +77 -0
  123. mollie/models/get_paymentop.py +128 -0
  124. mollie/models/get_permissionop.py +73 -0
  125. mollie/models/get_primary_balanceop.py +22 -0
  126. mollie/models/get_profileop.py +71 -0
  127. mollie/models/get_refundop.py +129 -0
  128. mollie/models/get_sales_invoiceop.py +75 -0
  129. mollie/models/get_settlementop.py +29 -0
  130. mollie/models/get_subscriptionop.py +86 -0
  131. mollie/models/get_terminalop.py +77 -0
  132. mollie/models/get_webhook_eventop.py +71 -0
  133. mollie/models/get_webhookop.py +71 -0
  134. mollie/models/internal/__init__.py +54 -0
  135. mollie/models/internal/globals.py +59 -0
  136. mollie/models/line_categories.py +13 -0
  137. mollie/models/line_categories_response.py +14 -0
  138. mollie/models/list_all_chargebacksop.py +236 -0
  139. mollie/models/list_all_methodsop.py +249 -0
  140. mollie/models/list_all_refundsop.py +230 -0
  141. mollie/models/list_all_subscriptionsop.py +202 -0
  142. mollie/models/list_balance_transactionsop.py +174 -0
  143. mollie/models/list_balancesop.py +171 -0
  144. mollie/models/list_capabilitiesop.py +62 -0
  145. mollie/models/list_capture_response.py +264 -0
  146. mollie/models/list_capturesop.py +185 -0
  147. mollie/models/list_chargebacksop.py +185 -0
  148. mollie/models/list_clientsop.py +269 -0
  149. mollie/models/list_connect_balance_transfersop.py +177 -0
  150. mollie/models/list_customer_paymentsop.py +231 -0
  151. mollie/models/list_customer_response.py +164 -0
  152. mollie/models/list_customersop.py +172 -0
  153. mollie/models/list_entity_balance.py +322 -0
  154. mollie/models/list_entity_chargeback.py +244 -0
  155. mollie/models/list_entity_invoice.py +244 -0
  156. mollie/models/list_entity_method.py +315 -0
  157. mollie/models/list_entity_method_all.py +391 -0
  158. mollie/models/list_entity_permission.py +56 -0
  159. mollie/models/list_entity_refund.py +352 -0
  160. mollie/models/list_entity_settlement.py +457 -0
  161. mollie/models/list_entity_terminal.py +157 -0
  162. mollie/models/list_entity_webhook.py +117 -0
  163. mollie/models/list_invoicesop.py +175 -0
  164. mollie/models/list_links.py +68 -0
  165. mollie/models/list_mandate_response.py +261 -0
  166. mollie/models/list_mandatesop.py +186 -0
  167. mollie/models/list_methodsop.py +332 -0
  168. mollie/models/list_payment_linksop.py +159 -0
  169. mollie/models/list_payment_response.py +1953 -0
  170. mollie/models/list_paymentsop.py +217 -0
  171. mollie/models/list_permissionsop.py +85 -0
  172. mollie/models/list_profile_response.py +194 -0
  173. mollie/models/list_profilesop.py +118 -0
  174. mollie/models/list_refundsop.py +189 -0
  175. mollie/models/list_route_get_response.py +97 -0
  176. mollie/models/list_sales_invoice_response.py +505 -0
  177. mollie/models/list_sales_invoicesop.py +172 -0
  178. mollie/models/list_settlement_capturesop.py +187 -0
  179. mollie/models/list_settlement_chargebacksop.py +187 -0
  180. mollie/models/list_settlement_paymentsop.py +233 -0
  181. mollie/models/list_settlement_refundsop.py +191 -0
  182. mollie/models/list_settlementsop.py +178 -0
  183. mollie/models/list_subscription_paymentsop.py +242 -0
  184. mollie/models/list_subscription_response.py +344 -0
  185. mollie/models/list_subscriptionsop.py +189 -0
  186. mollie/models/list_terminalsop.py +172 -0
  187. mollie/models/list_webhooksop.py +189 -0
  188. mollie/models/locale.py +32 -0
  189. mollie/models/locale_response.py +33 -0
  190. mollie/models/mandate_details_card_label_response.py +22 -0
  191. mollie/models/mandate_method.py +15 -0
  192. mollie/models/mandate_method_response.py +16 -0
  193. mollie/models/mandate_request.py +160 -0
  194. mollie/models/mandate_response.py +264 -0
  195. mollie/models/metadata.py +19 -0
  196. mollie/models/method.py +50 -0
  197. mollie/models/method_include_wallets_parameter.py +8 -0
  198. mollie/models/method_resource_parameter.py +9 -0
  199. mollie/models/method_response.py +59 -0
  200. mollie/models/method_status.py +15 -0
  201. mollie/models/mode.py +12 -0
  202. mollie/models/no_response_error.py +17 -0
  203. mollie/models/onboarding_vat_regulation.py +16 -0
  204. mollie/models/organization_vat_regulation.py +17 -0
  205. mollie/models/payment_address.py +130 -0
  206. mollie/models/payment_create_routeop.py +43 -0
  207. mollie/models/payment_details_card_audition_response.py +12 -0
  208. mollie/models/payment_details_card_funding_response.py +14 -0
  209. mollie/models/payment_details_card_label_response.py +23 -0
  210. mollie/models/payment_details_card_security_response.py +12 -0
  211. mollie/models/payment_details_failure_reason_response.py +25 -0
  212. mollie/models/payment_details_fee_region_response.py +20 -0
  213. mollie/models/payment_details_receipt_card_read_method_response.py +17 -0
  214. mollie/models/payment_details_receipt_card_verification_method_response.py +21 -0
  215. mollie/models/payment_details_seller_protection_response.py +20 -0
  216. mollie/models/payment_details_wallet_response.py +11 -0
  217. mollie/models/payment_line_item.py +96 -0
  218. mollie/models/payment_line_item_response.py +104 -0
  219. mollie/models/payment_line_type.py +20 -0
  220. mollie/models/payment_line_type_response.py +21 -0
  221. mollie/models/payment_link_method.py +36 -0
  222. mollie/models/payment_link_method_response.py +37 -0
  223. mollie/models/payment_link_response.py +348 -0
  224. mollie/models/payment_link_sequence_type.py +9 -0
  225. mollie/models/payment_link_sequence_type_response.py +10 -0
  226. mollie/models/payment_list_routesop.py +140 -0
  227. mollie/models/payment_method.py +53 -0
  228. mollie/models/payment_request.py +919 -0
  229. mollie/models/payment_response.py +1953 -0
  230. mollie/models/profile_request.py +67 -0
  231. mollie/models/profile_response.py +197 -0
  232. mollie/models/profile_review_status_response.py +12 -0
  233. mollie/models/recurring_line_item.py +77 -0
  234. mollie/models/refund_external_reference_type.py +10 -0
  235. mollie/models/refund_external_reference_type_response.py +11 -0
  236. mollie/models/refund_request.py +200 -0
  237. mollie/models/release_authorizationop.py +108 -0
  238. mollie/models/request_apple_pay_payment_sessionop.py +76 -0
  239. mollie/models/responsevalidationerror.py +27 -0
  240. mollie/models/revoke_mandateop.py +100 -0
  241. mollie/models/route_create_response.py +97 -0
  242. mollie/models/route_destination_type.py +10 -0
  243. mollie/models/route_destination_type_response.py +11 -0
  244. mollie/models/sales_invoice_discount.py +21 -0
  245. mollie/models/sales_invoice_discount_response.py +25 -0
  246. mollie/models/sales_invoice_discount_type.py +11 -0
  247. mollie/models/sales_invoice_discount_type_response.py +12 -0
  248. mollie/models/sales_invoice_email_details.py +20 -0
  249. mollie/models/sales_invoice_line_item.py +67 -0
  250. mollie/models/sales_invoice_line_item_response.py +70 -0
  251. mollie/models/sales_invoice_payment_details.py +59 -0
  252. mollie/models/sales_invoice_payment_details_response.py +66 -0
  253. mollie/models/sales_invoice_payment_details_source.py +12 -0
  254. mollie/models/sales_invoice_payment_details_source_response.py +13 -0
  255. mollie/models/sales_invoice_payment_term.py +16 -0
  256. mollie/models/sales_invoice_payment_term_response.py +17 -0
  257. mollie/models/sales_invoice_recipient.py +176 -0
  258. mollie/models/sales_invoice_recipient_locale.py +18 -0
  259. mollie/models/sales_invoice_recipient_locale_response.py +19 -0
  260. mollie/models/sales_invoice_recipient_response.py +182 -0
  261. mollie/models/sales_invoice_recipient_type.py +13 -0
  262. mollie/models/sales_invoice_recipient_type_response.py +14 -0
  263. mollie/models/sales_invoice_request.py +256 -0
  264. mollie/models/sales_invoice_response.py +509 -0
  265. mollie/models/sales_invoice_status.py +25 -0
  266. mollie/models/sales_invoice_status_response.py +26 -0
  267. mollie/models/sales_invoice_vat_mode.py +13 -0
  268. mollie/models/sales_invoice_vat_mode_response.py +14 -0
  269. mollie/models/sales_invoice_vat_scheme.py +11 -0
  270. mollie/models/sales_invoice_vat_scheme_response.py +12 -0
  271. mollie/models/security.py +35 -0
  272. mollie/models/sequence_type.py +10 -0
  273. mollie/models/sequence_type_response.py +11 -0
  274. mollie/models/sorting.py +9 -0
  275. mollie/models/status_reason.py +168 -0
  276. mollie/models/sub_group.py +52 -0
  277. mollie/models/sub_totals.py +120 -0
  278. mollie/models/submit_onboarding_dataop.py +214 -0
  279. mollie/models/subscription_method.py +12 -0
  280. mollie/models/subscription_method_response.py +13 -0
  281. mollie/models/subscription_request.py +213 -0
  282. mollie/models/subscription_response.py +349 -0
  283. mollie/models/terminal_brand.py +12 -0
  284. mollie/models/terminal_model.py +16 -0
  285. mollie/models/test_webhookop.py +64 -0
  286. mollie/models/update_customerop.py +43 -0
  287. mollie/models/update_payment_linkop.py +172 -0
  288. mollie/models/update_paymentop.py +332 -0
  289. mollie/models/update_profileop.py +147 -0
  290. mollie/models/update_sales_invoiceop.py +44 -0
  291. mollie/models/update_subscriptionop.py +188 -0
  292. mollie/models/update_values_sales_invoice.py +176 -0
  293. mollie/models/update_webhookop.py +83 -0
  294. mollie/models/url.py +24 -0
  295. mollie/models/url_nullable.py +25 -0
  296. mollie/models/webhook_event_types.py +18 -0
  297. mollie/models/webhook_status.py +14 -0
  298. mollie/onboarding.py +403 -0
  299. mollie/organizations.py +579 -0
  300. mollie/payment_links.py +1323 -0
  301. mollie/payments_sdk.py +1385 -0
  302. mollie/permissions.py +397 -0
  303. mollie/profiles.py +1209 -0
  304. mollie/py.typed +1 -0
  305. mollie/refunds_sdk.py +1111 -0
  306. mollie/sales_invoices.py +1121 -0
  307. mollie/sdk.py +265 -0
  308. mollie/sdkconfiguration.py +50 -0
  309. mollie/settlements.py +1735 -0
  310. mollie/subscriptions.py +1617 -0
  311. mollie/terminals.py +427 -0
  312. mollie/types/__init__.py +21 -0
  313. mollie/types/basemodel.py +39 -0
  314. mollie/utils/__init__.py +200 -0
  315. mollie/utils/annotations.py +79 -0
  316. mollie/utils/datetimes.py +23 -0
  317. mollie/utils/enums.py +74 -0
  318. mollie/utils/eventstreaming.py +248 -0
  319. mollie/utils/forms.py +223 -0
  320. mollie/utils/headers.py +136 -0
  321. mollie/utils/logger.py +27 -0
  322. mollie/utils/metadata.py +118 -0
  323. mollie/utils/queryparams.py +205 -0
  324. mollie/utils/requestbodies.py +66 -0
  325. mollie/utils/retries.py +217 -0
  326. mollie/utils/security.py +195 -0
  327. mollie/utils/serializers.py +249 -0
  328. mollie/utils/unmarshal_json_response.py +24 -0
  329. mollie/utils/url.py +155 -0
  330. mollie/utils/values.py +137 -0
  331. mollie/wallets.py +263 -0
  332. mollie/webhook_events.py +211 -0
  333. mollie/webhooks.py +1305 -0
  334. mollie_api_py-1.0.0.dist-info/METADATA +834 -0
  335. mollie_api_py-1.0.0.dist-info/RECORD +337 -0
  336. mollie_api_py-1.0.0.dist-info/WHEEL +4 -0
  337. mollie_api_py-1.0.0.dist-info/licenses/LICENSE.md +24 -0
mollie/refunds_sdk.py ADDED
@@ -0,0 +1,1111 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from mollie import models, utils
5
+ from mollie._hooks import HookContext
6
+ from mollie.types import OptionalNullable, UNSET
7
+ from mollie.utils import get_security_from_env
8
+ from mollie.utils.unmarshal_json_response import unmarshal_json_response
9
+ from typing import Any, Mapping, Optional, Union
10
+
11
+
12
+ class RefundsSDK(BaseSDK):
13
+ def create(
14
+ self,
15
+ *,
16
+ payment_id: str,
17
+ idempotency_key: Optional[str] = None,
18
+ refund_request: Optional[
19
+ Union[models.RefundRequest, models.RefundRequestTypedDict]
20
+ ] = None,
21
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
22
+ server_url: Optional[str] = None,
23
+ timeout_ms: Optional[int] = None,
24
+ http_headers: Optional[Mapping[str, str]] = None,
25
+ ) -> models.EntityRefundResponse:
26
+ r"""Create payment refund
27
+
28
+ Creates a refund for a specific payment. The refunded amount is credited to your customer usually either via a bank
29
+ transfer or by refunding the amount to your customer's credit card.
30
+
31
+ :param payment_id: Provide the ID of the related payment.
32
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
33
+ :param refund_request:
34
+ :param retries: Override the default retry configuration for this method
35
+ :param server_url: Override the default server URL for this method
36
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
37
+ :param http_headers: Additional headers to set or replace on requests.
38
+ """
39
+ base_url = None
40
+ url_variables = None
41
+ if timeout_ms is None:
42
+ timeout_ms = self.sdk_configuration.timeout_ms
43
+
44
+ if server_url is not None:
45
+ base_url = server_url
46
+ else:
47
+ base_url = self._get_url(base_url, url_variables)
48
+
49
+ request = models.CreateRefundRequest(
50
+ payment_id=payment_id,
51
+ idempotency_key=idempotency_key,
52
+ refund_request=utils.get_pydantic_model(
53
+ refund_request, Optional[models.RefundRequest]
54
+ ),
55
+ )
56
+
57
+ req = self._build_request(
58
+ method="POST",
59
+ path="/payments/{paymentId}/refunds",
60
+ base_url=base_url,
61
+ url_variables=url_variables,
62
+ request=request,
63
+ request_body_required=False,
64
+ request_has_path_params=True,
65
+ request_has_query_params=True,
66
+ user_agent_header="user-agent",
67
+ accept_header_value="application/hal+json",
68
+ http_headers=http_headers,
69
+ security=self.sdk_configuration.security,
70
+ get_serialized_body=lambda: utils.serialize_request_body(
71
+ request.refund_request,
72
+ False,
73
+ True,
74
+ "json",
75
+ Optional[models.RefundRequest],
76
+ ),
77
+ timeout_ms=timeout_ms,
78
+ )
79
+
80
+ if retries == UNSET:
81
+ if self.sdk_configuration.retry_config is not UNSET:
82
+ retries = self.sdk_configuration.retry_config
83
+ else:
84
+ retries = utils.RetryConfig(
85
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
86
+ )
87
+
88
+ retry_config = None
89
+ if isinstance(retries, utils.RetryConfig):
90
+ retry_config = (retries, ["5xx"])
91
+
92
+ http_res = self.do_request(
93
+ hook_ctx=HookContext(
94
+ config=self.sdk_configuration,
95
+ base_url=base_url or "",
96
+ operation_id="create-refund",
97
+ oauth2_scopes=None,
98
+ security_source=get_security_from_env(
99
+ self.sdk_configuration.security, models.Security
100
+ ),
101
+ ),
102
+ request=req,
103
+ error_status_codes=["404", "409", "422", "4XX", "5XX"],
104
+ retry_config=retry_config,
105
+ )
106
+
107
+ response_data: Any = None
108
+ if utils.match_response(http_res, "201", "application/hal+json"):
109
+ return unmarshal_json_response(models.EntityRefundResponse, http_res)
110
+ if utils.match_response(
111
+ http_res, ["404", "409", "422"], "application/hal+json"
112
+ ):
113
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
114
+ raise models.ErrorResponse(response_data, http_res)
115
+ if utils.match_response(http_res, "4XX", "*"):
116
+ http_res_text = utils.stream_to_text(http_res)
117
+ raise models.APIError("API error occurred", http_res, http_res_text)
118
+ if utils.match_response(http_res, "5XX", "*"):
119
+ http_res_text = utils.stream_to_text(http_res)
120
+ raise models.APIError("API error occurred", http_res, http_res_text)
121
+
122
+ raise models.APIError("Unexpected response received", http_res)
123
+
124
+ async def create_async(
125
+ self,
126
+ *,
127
+ payment_id: str,
128
+ idempotency_key: Optional[str] = None,
129
+ refund_request: Optional[
130
+ Union[models.RefundRequest, models.RefundRequestTypedDict]
131
+ ] = None,
132
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
133
+ server_url: Optional[str] = None,
134
+ timeout_ms: Optional[int] = None,
135
+ http_headers: Optional[Mapping[str, str]] = None,
136
+ ) -> models.EntityRefundResponse:
137
+ r"""Create payment refund
138
+
139
+ Creates a refund for a specific payment. The refunded amount is credited to your customer usually either via a bank
140
+ transfer or by refunding the amount to your customer's credit card.
141
+
142
+ :param payment_id: Provide the ID of the related payment.
143
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
144
+ :param refund_request:
145
+ :param retries: Override the default retry configuration for this method
146
+ :param server_url: Override the default server URL for this method
147
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
148
+ :param http_headers: Additional headers to set or replace on requests.
149
+ """
150
+ base_url = None
151
+ url_variables = None
152
+ if timeout_ms is None:
153
+ timeout_ms = self.sdk_configuration.timeout_ms
154
+
155
+ if server_url is not None:
156
+ base_url = server_url
157
+ else:
158
+ base_url = self._get_url(base_url, url_variables)
159
+
160
+ request = models.CreateRefundRequest(
161
+ payment_id=payment_id,
162
+ idempotency_key=idempotency_key,
163
+ refund_request=utils.get_pydantic_model(
164
+ refund_request, Optional[models.RefundRequest]
165
+ ),
166
+ )
167
+
168
+ req = self._build_request_async(
169
+ method="POST",
170
+ path="/payments/{paymentId}/refunds",
171
+ base_url=base_url,
172
+ url_variables=url_variables,
173
+ request=request,
174
+ request_body_required=False,
175
+ request_has_path_params=True,
176
+ request_has_query_params=True,
177
+ user_agent_header="user-agent",
178
+ accept_header_value="application/hal+json",
179
+ http_headers=http_headers,
180
+ security=self.sdk_configuration.security,
181
+ get_serialized_body=lambda: utils.serialize_request_body(
182
+ request.refund_request,
183
+ False,
184
+ True,
185
+ "json",
186
+ Optional[models.RefundRequest],
187
+ ),
188
+ timeout_ms=timeout_ms,
189
+ )
190
+
191
+ if retries == UNSET:
192
+ if self.sdk_configuration.retry_config is not UNSET:
193
+ retries = self.sdk_configuration.retry_config
194
+ else:
195
+ retries = utils.RetryConfig(
196
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
197
+ )
198
+
199
+ retry_config = None
200
+ if isinstance(retries, utils.RetryConfig):
201
+ retry_config = (retries, ["5xx"])
202
+
203
+ http_res = await self.do_request_async(
204
+ hook_ctx=HookContext(
205
+ config=self.sdk_configuration,
206
+ base_url=base_url or "",
207
+ operation_id="create-refund",
208
+ oauth2_scopes=None,
209
+ security_source=get_security_from_env(
210
+ self.sdk_configuration.security, models.Security
211
+ ),
212
+ ),
213
+ request=req,
214
+ error_status_codes=["404", "409", "422", "4XX", "5XX"],
215
+ retry_config=retry_config,
216
+ )
217
+
218
+ response_data: Any = None
219
+ if utils.match_response(http_res, "201", "application/hal+json"):
220
+ return unmarshal_json_response(models.EntityRefundResponse, http_res)
221
+ if utils.match_response(
222
+ http_res, ["404", "409", "422"], "application/hal+json"
223
+ ):
224
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
225
+ raise models.ErrorResponse(response_data, http_res)
226
+ if utils.match_response(http_res, "4XX", "*"):
227
+ http_res_text = await utils.stream_to_text_async(http_res)
228
+ raise models.APIError("API error occurred", http_res, http_res_text)
229
+ if utils.match_response(http_res, "5XX", "*"):
230
+ http_res_text = await utils.stream_to_text_async(http_res)
231
+ raise models.APIError("API error occurred", http_res, http_res_text)
232
+
233
+ raise models.APIError("Unexpected response received", http_res)
234
+
235
+ def list(
236
+ self,
237
+ *,
238
+ payment_id: str,
239
+ from_: Optional[str] = None,
240
+ limit: OptionalNullable[int] = UNSET,
241
+ embed: OptionalNullable[str] = UNSET,
242
+ testmode: Optional[bool] = None,
243
+ idempotency_key: Optional[str] = None,
244
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
245
+ server_url: Optional[str] = None,
246
+ timeout_ms: Optional[int] = None,
247
+ http_headers: Optional[Mapping[str, str]] = None,
248
+ ) -> models.ListRefundsResponse:
249
+ r"""List payment refunds
250
+
251
+ Retrieve a list of all refunds created for a specific payment.
252
+
253
+ The results are paginated.
254
+
255
+ :param payment_id: Provide the ID of the related payment.
256
+ :param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
257
+ :param limit: The maximum number of items to return. Defaults to 50 items.
258
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
259
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
260
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
261
+ :param retries: Override the default retry configuration for this method
262
+ :param server_url: Override the default server URL for this method
263
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
264
+ :param http_headers: Additional headers to set or replace on requests.
265
+ """
266
+ base_url = None
267
+ url_variables = None
268
+ if timeout_ms is None:
269
+ timeout_ms = self.sdk_configuration.timeout_ms
270
+
271
+ if server_url is not None:
272
+ base_url = server_url
273
+ else:
274
+ base_url = self._get_url(base_url, url_variables)
275
+
276
+ request = models.ListRefundsRequest(
277
+ payment_id=payment_id,
278
+ from_=from_,
279
+ limit=limit,
280
+ embed=embed,
281
+ testmode=testmode,
282
+ idempotency_key=idempotency_key,
283
+ )
284
+
285
+ req = self._build_request(
286
+ method="GET",
287
+ path="/payments/{paymentId}/refunds",
288
+ base_url=base_url,
289
+ url_variables=url_variables,
290
+ request=request,
291
+ request_body_required=False,
292
+ request_has_path_params=True,
293
+ request_has_query_params=True,
294
+ user_agent_header="user-agent",
295
+ accept_header_value="application/hal+json",
296
+ http_headers=http_headers,
297
+ _globals=models.ListRefundsGlobals(
298
+ testmode=self.sdk_configuration.globals.testmode,
299
+ ),
300
+ security=self.sdk_configuration.security,
301
+ timeout_ms=timeout_ms,
302
+ )
303
+
304
+ if retries == UNSET:
305
+ if self.sdk_configuration.retry_config is not UNSET:
306
+ retries = self.sdk_configuration.retry_config
307
+ else:
308
+ retries = utils.RetryConfig(
309
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
310
+ )
311
+
312
+ retry_config = None
313
+ if isinstance(retries, utils.RetryConfig):
314
+ retry_config = (retries, ["5xx"])
315
+
316
+ http_res = self.do_request(
317
+ hook_ctx=HookContext(
318
+ config=self.sdk_configuration,
319
+ base_url=base_url or "",
320
+ operation_id="list-refunds",
321
+ oauth2_scopes=None,
322
+ security_source=get_security_from_env(
323
+ self.sdk_configuration.security, models.Security
324
+ ),
325
+ ),
326
+ request=req,
327
+ error_status_codes=["400", "404", "4XX", "5XX"],
328
+ retry_config=retry_config,
329
+ )
330
+
331
+ response_data: Any = None
332
+ if utils.match_response(http_res, "200", "application/hal+json"):
333
+ return unmarshal_json_response(models.ListRefundsResponse, http_res)
334
+ if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
335
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
336
+ raise models.ErrorResponse(response_data, http_res)
337
+ if utils.match_response(http_res, "4XX", "*"):
338
+ http_res_text = utils.stream_to_text(http_res)
339
+ raise models.APIError("API error occurred", http_res, http_res_text)
340
+ if utils.match_response(http_res, "5XX", "*"):
341
+ http_res_text = utils.stream_to_text(http_res)
342
+ raise models.APIError("API error occurred", http_res, http_res_text)
343
+
344
+ raise models.APIError("Unexpected response received", http_res)
345
+
346
+ async def list_async(
347
+ self,
348
+ *,
349
+ payment_id: str,
350
+ from_: Optional[str] = None,
351
+ limit: OptionalNullable[int] = UNSET,
352
+ embed: OptionalNullable[str] = UNSET,
353
+ testmode: Optional[bool] = None,
354
+ idempotency_key: Optional[str] = None,
355
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
356
+ server_url: Optional[str] = None,
357
+ timeout_ms: Optional[int] = None,
358
+ http_headers: Optional[Mapping[str, str]] = None,
359
+ ) -> models.ListRefundsResponse:
360
+ r"""List payment refunds
361
+
362
+ Retrieve a list of all refunds created for a specific payment.
363
+
364
+ The results are paginated.
365
+
366
+ :param payment_id: Provide the ID of the related payment.
367
+ :param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
368
+ :param limit: The maximum number of items to return. Defaults to 50 items.
369
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
370
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
371
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
372
+ :param retries: Override the default retry configuration for this method
373
+ :param server_url: Override the default server URL for this method
374
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
375
+ :param http_headers: Additional headers to set or replace on requests.
376
+ """
377
+ base_url = None
378
+ url_variables = None
379
+ if timeout_ms is None:
380
+ timeout_ms = self.sdk_configuration.timeout_ms
381
+
382
+ if server_url is not None:
383
+ base_url = server_url
384
+ else:
385
+ base_url = self._get_url(base_url, url_variables)
386
+
387
+ request = models.ListRefundsRequest(
388
+ payment_id=payment_id,
389
+ from_=from_,
390
+ limit=limit,
391
+ embed=embed,
392
+ testmode=testmode,
393
+ idempotency_key=idempotency_key,
394
+ )
395
+
396
+ req = self._build_request_async(
397
+ method="GET",
398
+ path="/payments/{paymentId}/refunds",
399
+ base_url=base_url,
400
+ url_variables=url_variables,
401
+ request=request,
402
+ request_body_required=False,
403
+ request_has_path_params=True,
404
+ request_has_query_params=True,
405
+ user_agent_header="user-agent",
406
+ accept_header_value="application/hal+json",
407
+ http_headers=http_headers,
408
+ _globals=models.ListRefundsGlobals(
409
+ testmode=self.sdk_configuration.globals.testmode,
410
+ ),
411
+ security=self.sdk_configuration.security,
412
+ timeout_ms=timeout_ms,
413
+ )
414
+
415
+ if retries == UNSET:
416
+ if self.sdk_configuration.retry_config is not UNSET:
417
+ retries = self.sdk_configuration.retry_config
418
+ else:
419
+ retries = utils.RetryConfig(
420
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
421
+ )
422
+
423
+ retry_config = None
424
+ if isinstance(retries, utils.RetryConfig):
425
+ retry_config = (retries, ["5xx"])
426
+
427
+ http_res = await self.do_request_async(
428
+ hook_ctx=HookContext(
429
+ config=self.sdk_configuration,
430
+ base_url=base_url or "",
431
+ operation_id="list-refunds",
432
+ oauth2_scopes=None,
433
+ security_source=get_security_from_env(
434
+ self.sdk_configuration.security, models.Security
435
+ ),
436
+ ),
437
+ request=req,
438
+ error_status_codes=["400", "404", "4XX", "5XX"],
439
+ retry_config=retry_config,
440
+ )
441
+
442
+ response_data: Any = None
443
+ if utils.match_response(http_res, "200", "application/hal+json"):
444
+ return unmarshal_json_response(models.ListRefundsResponse, http_res)
445
+ if utils.match_response(http_res, ["400", "404"], "application/hal+json"):
446
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
447
+ raise models.ErrorResponse(response_data, http_res)
448
+ if utils.match_response(http_res, "4XX", "*"):
449
+ http_res_text = await utils.stream_to_text_async(http_res)
450
+ raise models.APIError("API error occurred", http_res, http_res_text)
451
+ if utils.match_response(http_res, "5XX", "*"):
452
+ http_res_text = await utils.stream_to_text_async(http_res)
453
+ raise models.APIError("API error occurred", http_res, http_res_text)
454
+
455
+ raise models.APIError("Unexpected response received", http_res)
456
+
457
+ def get(
458
+ self,
459
+ *,
460
+ payment_id: str,
461
+ refund_id: str,
462
+ embed: OptionalNullable[str] = UNSET,
463
+ testmode: Optional[bool] = None,
464
+ idempotency_key: Optional[str] = None,
465
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
466
+ server_url: Optional[str] = None,
467
+ timeout_ms: Optional[int] = None,
468
+ http_headers: Optional[Mapping[str, str]] = None,
469
+ ) -> models.EntityRefundResponse:
470
+ r"""Get payment refund
471
+
472
+ Retrieve a single payment refund by its ID and the ID of its parent payment.
473
+
474
+ :param payment_id: Provide the ID of the related payment.
475
+ :param refund_id: Provide the ID of the related refund.
476
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
477
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
478
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
479
+ :param retries: Override the default retry configuration for this method
480
+ :param server_url: Override the default server URL for this method
481
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
482
+ :param http_headers: Additional headers to set or replace on requests.
483
+ """
484
+ base_url = None
485
+ url_variables = None
486
+ if timeout_ms is None:
487
+ timeout_ms = self.sdk_configuration.timeout_ms
488
+
489
+ if server_url is not None:
490
+ base_url = server_url
491
+ else:
492
+ base_url = self._get_url(base_url, url_variables)
493
+
494
+ request = models.GetRefundRequest(
495
+ payment_id=payment_id,
496
+ refund_id=refund_id,
497
+ embed=embed,
498
+ testmode=testmode,
499
+ idempotency_key=idempotency_key,
500
+ )
501
+
502
+ req = self._build_request(
503
+ method="GET",
504
+ path="/payments/{paymentId}/refunds/{refundId}",
505
+ base_url=base_url,
506
+ url_variables=url_variables,
507
+ request=request,
508
+ request_body_required=False,
509
+ request_has_path_params=True,
510
+ request_has_query_params=True,
511
+ user_agent_header="user-agent",
512
+ accept_header_value="application/hal+json",
513
+ http_headers=http_headers,
514
+ _globals=models.GetRefundGlobals(
515
+ testmode=self.sdk_configuration.globals.testmode,
516
+ ),
517
+ security=self.sdk_configuration.security,
518
+ timeout_ms=timeout_ms,
519
+ )
520
+
521
+ if retries == UNSET:
522
+ if self.sdk_configuration.retry_config is not UNSET:
523
+ retries = self.sdk_configuration.retry_config
524
+ else:
525
+ retries = utils.RetryConfig(
526
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
527
+ )
528
+
529
+ retry_config = None
530
+ if isinstance(retries, utils.RetryConfig):
531
+ retry_config = (retries, ["5xx"])
532
+
533
+ http_res = self.do_request(
534
+ hook_ctx=HookContext(
535
+ config=self.sdk_configuration,
536
+ base_url=base_url or "",
537
+ operation_id="get-refund",
538
+ oauth2_scopes=None,
539
+ security_source=get_security_from_env(
540
+ self.sdk_configuration.security, models.Security
541
+ ),
542
+ ),
543
+ request=req,
544
+ error_status_codes=["404", "4XX", "5XX"],
545
+ retry_config=retry_config,
546
+ )
547
+
548
+ response_data: Any = None
549
+ if utils.match_response(http_res, "200", "application/hal+json"):
550
+ return unmarshal_json_response(models.EntityRefundResponse, http_res)
551
+ if utils.match_response(http_res, "404", "application/hal+json"):
552
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
553
+ raise models.ErrorResponse(response_data, http_res)
554
+ if utils.match_response(http_res, "4XX", "*"):
555
+ http_res_text = utils.stream_to_text(http_res)
556
+ raise models.APIError("API error occurred", http_res, http_res_text)
557
+ if utils.match_response(http_res, "5XX", "*"):
558
+ http_res_text = utils.stream_to_text(http_res)
559
+ raise models.APIError("API error occurred", http_res, http_res_text)
560
+
561
+ raise models.APIError("Unexpected response received", http_res)
562
+
563
+ async def get_async(
564
+ self,
565
+ *,
566
+ payment_id: str,
567
+ refund_id: str,
568
+ embed: OptionalNullable[str] = UNSET,
569
+ testmode: Optional[bool] = None,
570
+ idempotency_key: Optional[str] = None,
571
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
572
+ server_url: Optional[str] = None,
573
+ timeout_ms: Optional[int] = None,
574
+ http_headers: Optional[Mapping[str, str]] = None,
575
+ ) -> models.EntityRefundResponse:
576
+ r"""Get payment refund
577
+
578
+ Retrieve a single payment refund by its ID and the ID of its parent payment.
579
+
580
+ :param payment_id: Provide the ID of the related payment.
581
+ :param refund_id: Provide the ID of the related refund.
582
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
583
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
584
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
585
+ :param retries: Override the default retry configuration for this method
586
+ :param server_url: Override the default server URL for this method
587
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
588
+ :param http_headers: Additional headers to set or replace on requests.
589
+ """
590
+ base_url = None
591
+ url_variables = None
592
+ if timeout_ms is None:
593
+ timeout_ms = self.sdk_configuration.timeout_ms
594
+
595
+ if server_url is not None:
596
+ base_url = server_url
597
+ else:
598
+ base_url = self._get_url(base_url, url_variables)
599
+
600
+ request = models.GetRefundRequest(
601
+ payment_id=payment_id,
602
+ refund_id=refund_id,
603
+ embed=embed,
604
+ testmode=testmode,
605
+ idempotency_key=idempotency_key,
606
+ )
607
+
608
+ req = self._build_request_async(
609
+ method="GET",
610
+ path="/payments/{paymentId}/refunds/{refundId}",
611
+ base_url=base_url,
612
+ url_variables=url_variables,
613
+ request=request,
614
+ request_body_required=False,
615
+ request_has_path_params=True,
616
+ request_has_query_params=True,
617
+ user_agent_header="user-agent",
618
+ accept_header_value="application/hal+json",
619
+ http_headers=http_headers,
620
+ _globals=models.GetRefundGlobals(
621
+ testmode=self.sdk_configuration.globals.testmode,
622
+ ),
623
+ security=self.sdk_configuration.security,
624
+ timeout_ms=timeout_ms,
625
+ )
626
+
627
+ if retries == UNSET:
628
+ if self.sdk_configuration.retry_config is not UNSET:
629
+ retries = self.sdk_configuration.retry_config
630
+ else:
631
+ retries = utils.RetryConfig(
632
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
633
+ )
634
+
635
+ retry_config = None
636
+ if isinstance(retries, utils.RetryConfig):
637
+ retry_config = (retries, ["5xx"])
638
+
639
+ http_res = await self.do_request_async(
640
+ hook_ctx=HookContext(
641
+ config=self.sdk_configuration,
642
+ base_url=base_url or "",
643
+ operation_id="get-refund",
644
+ oauth2_scopes=None,
645
+ security_source=get_security_from_env(
646
+ self.sdk_configuration.security, models.Security
647
+ ),
648
+ ),
649
+ request=req,
650
+ error_status_codes=["404", "4XX", "5XX"],
651
+ retry_config=retry_config,
652
+ )
653
+
654
+ response_data: Any = None
655
+ if utils.match_response(http_res, "200", "application/hal+json"):
656
+ return unmarshal_json_response(models.EntityRefundResponse, http_res)
657
+ if utils.match_response(http_res, "404", "application/hal+json"):
658
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
659
+ raise models.ErrorResponse(response_data, http_res)
660
+ if utils.match_response(http_res, "4XX", "*"):
661
+ http_res_text = await utils.stream_to_text_async(http_res)
662
+ raise models.APIError("API error occurred", http_res, http_res_text)
663
+ if utils.match_response(http_res, "5XX", "*"):
664
+ http_res_text = await utils.stream_to_text_async(http_res)
665
+ raise models.APIError("API error occurred", http_res, http_res_text)
666
+
667
+ raise models.APIError("Unexpected response received", http_res)
668
+
669
+ def cancel(
670
+ self,
671
+ *,
672
+ payment_id: str,
673
+ refund_id: str,
674
+ testmode: Optional[bool] = None,
675
+ idempotency_key: Optional[str] = None,
676
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
677
+ server_url: Optional[str] = None,
678
+ timeout_ms: Optional[int] = None,
679
+ http_headers: Optional[Mapping[str, str]] = None,
680
+ ):
681
+ r"""Cancel payment refund
682
+
683
+ Refunds will be executed with a delay of two hours. Until that time, refunds may be canceled manually via the
684
+ Mollie Dashboard, or by using this endpoint.
685
+
686
+ A refund can only be canceled while its `status` field is either `queued` or `pending`. See the
687
+ [Get refund endpoint](get-refund) for more information.
688
+
689
+ :param payment_id: Provide the ID of the related payment.
690
+ :param refund_id: Provide the ID of the related refund.
691
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
692
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
693
+ :param retries: Override the default retry configuration for this method
694
+ :param server_url: Override the default server URL for this method
695
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
696
+ :param http_headers: Additional headers to set or replace on requests.
697
+ """
698
+ base_url = None
699
+ url_variables = None
700
+ if timeout_ms is None:
701
+ timeout_ms = self.sdk_configuration.timeout_ms
702
+
703
+ if server_url is not None:
704
+ base_url = server_url
705
+ else:
706
+ base_url = self._get_url(base_url, url_variables)
707
+
708
+ request = models.CancelRefundRequest(
709
+ payment_id=payment_id,
710
+ refund_id=refund_id,
711
+ testmode=testmode,
712
+ idempotency_key=idempotency_key,
713
+ )
714
+
715
+ req = self._build_request(
716
+ method="DELETE",
717
+ path="/payments/{paymentId}/refunds/{refundId}",
718
+ base_url=base_url,
719
+ url_variables=url_variables,
720
+ request=request,
721
+ request_body_required=False,
722
+ request_has_path_params=True,
723
+ request_has_query_params=True,
724
+ user_agent_header="user-agent",
725
+ accept_header_value="application/hal+json",
726
+ http_headers=http_headers,
727
+ _globals=models.CancelRefundGlobals(
728
+ testmode=self.sdk_configuration.globals.testmode,
729
+ ),
730
+ security=self.sdk_configuration.security,
731
+ timeout_ms=timeout_ms,
732
+ )
733
+
734
+ if retries == UNSET:
735
+ if self.sdk_configuration.retry_config is not UNSET:
736
+ retries = self.sdk_configuration.retry_config
737
+ else:
738
+ retries = utils.RetryConfig(
739
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
740
+ )
741
+
742
+ retry_config = None
743
+ if isinstance(retries, utils.RetryConfig):
744
+ retry_config = (retries, ["5xx"])
745
+
746
+ http_res = self.do_request(
747
+ hook_ctx=HookContext(
748
+ config=self.sdk_configuration,
749
+ base_url=base_url or "",
750
+ operation_id="cancel-refund",
751
+ oauth2_scopes=None,
752
+ security_source=get_security_from_env(
753
+ self.sdk_configuration.security, models.Security
754
+ ),
755
+ ),
756
+ request=req,
757
+ error_status_codes=["404", "4XX", "5XX"],
758
+ retry_config=retry_config,
759
+ )
760
+
761
+ response_data: Any = None
762
+ if utils.match_response(http_res, "204", "*"):
763
+ return
764
+ if utils.match_response(http_res, "404", "application/hal+json"):
765
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
766
+ raise models.ErrorResponse(response_data, http_res)
767
+ if utils.match_response(http_res, "4XX", "*"):
768
+ http_res_text = utils.stream_to_text(http_res)
769
+ raise models.APIError("API error occurred", http_res, http_res_text)
770
+ if utils.match_response(http_res, "5XX", "*"):
771
+ http_res_text = utils.stream_to_text(http_res)
772
+ raise models.APIError("API error occurred", http_res, http_res_text)
773
+
774
+ raise models.APIError("Unexpected response received", http_res)
775
+
776
+ async def cancel_async(
777
+ self,
778
+ *,
779
+ payment_id: str,
780
+ refund_id: str,
781
+ testmode: Optional[bool] = None,
782
+ idempotency_key: Optional[str] = None,
783
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
784
+ server_url: Optional[str] = None,
785
+ timeout_ms: Optional[int] = None,
786
+ http_headers: Optional[Mapping[str, str]] = None,
787
+ ):
788
+ r"""Cancel payment refund
789
+
790
+ Refunds will be executed with a delay of two hours. Until that time, refunds may be canceled manually via the
791
+ Mollie Dashboard, or by using this endpoint.
792
+
793
+ A refund can only be canceled while its `status` field is either `queued` or `pending`. See the
794
+ [Get refund endpoint](get-refund) for more information.
795
+
796
+ :param payment_id: Provide the ID of the related payment.
797
+ :param refund_id: Provide the ID of the related refund.
798
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
799
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
800
+ :param retries: Override the default retry configuration for this method
801
+ :param server_url: Override the default server URL for this method
802
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
803
+ :param http_headers: Additional headers to set or replace on requests.
804
+ """
805
+ base_url = None
806
+ url_variables = None
807
+ if timeout_ms is None:
808
+ timeout_ms = self.sdk_configuration.timeout_ms
809
+
810
+ if server_url is not None:
811
+ base_url = server_url
812
+ else:
813
+ base_url = self._get_url(base_url, url_variables)
814
+
815
+ request = models.CancelRefundRequest(
816
+ payment_id=payment_id,
817
+ refund_id=refund_id,
818
+ testmode=testmode,
819
+ idempotency_key=idempotency_key,
820
+ )
821
+
822
+ req = self._build_request_async(
823
+ method="DELETE",
824
+ path="/payments/{paymentId}/refunds/{refundId}",
825
+ base_url=base_url,
826
+ url_variables=url_variables,
827
+ request=request,
828
+ request_body_required=False,
829
+ request_has_path_params=True,
830
+ request_has_query_params=True,
831
+ user_agent_header="user-agent",
832
+ accept_header_value="application/hal+json",
833
+ http_headers=http_headers,
834
+ _globals=models.CancelRefundGlobals(
835
+ testmode=self.sdk_configuration.globals.testmode,
836
+ ),
837
+ security=self.sdk_configuration.security,
838
+ timeout_ms=timeout_ms,
839
+ )
840
+
841
+ if retries == UNSET:
842
+ if self.sdk_configuration.retry_config is not UNSET:
843
+ retries = self.sdk_configuration.retry_config
844
+ else:
845
+ retries = utils.RetryConfig(
846
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
847
+ )
848
+
849
+ retry_config = None
850
+ if isinstance(retries, utils.RetryConfig):
851
+ retry_config = (retries, ["5xx"])
852
+
853
+ http_res = await self.do_request_async(
854
+ hook_ctx=HookContext(
855
+ config=self.sdk_configuration,
856
+ base_url=base_url or "",
857
+ operation_id="cancel-refund",
858
+ oauth2_scopes=None,
859
+ security_source=get_security_from_env(
860
+ self.sdk_configuration.security, models.Security
861
+ ),
862
+ ),
863
+ request=req,
864
+ error_status_codes=["404", "4XX", "5XX"],
865
+ retry_config=retry_config,
866
+ )
867
+
868
+ response_data: Any = None
869
+ if utils.match_response(http_res, "204", "*"):
870
+ return
871
+ if utils.match_response(http_res, "404", "application/hal+json"):
872
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
873
+ raise models.ErrorResponse(response_data, http_res)
874
+ if utils.match_response(http_res, "4XX", "*"):
875
+ http_res_text = await utils.stream_to_text_async(http_res)
876
+ raise models.APIError("API error occurred", http_res, http_res_text)
877
+ if utils.match_response(http_res, "5XX", "*"):
878
+ http_res_text = await utils.stream_to_text_async(http_res)
879
+ raise models.APIError("API error occurred", http_res, http_res_text)
880
+
881
+ raise models.APIError("Unexpected response received", http_res)
882
+
883
+ def all(
884
+ self,
885
+ *,
886
+ from_: Optional[str] = None,
887
+ limit: OptionalNullable[int] = UNSET,
888
+ sort: Optional[models.Sorting] = None,
889
+ embed: OptionalNullable[str] = UNSET,
890
+ profile_id: Optional[str] = None,
891
+ testmode: Optional[bool] = None,
892
+ idempotency_key: Optional[str] = None,
893
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
894
+ server_url: Optional[str] = None,
895
+ timeout_ms: Optional[int] = None,
896
+ http_headers: Optional[Mapping[str, str]] = None,
897
+ ) -> models.ListAllRefundsResponse:
898
+ r"""List all refunds
899
+
900
+ Retrieve a list of all of your refunds.
901
+
902
+ The results are paginated.
903
+
904
+ :param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
905
+ :param limit: The maximum number of items to return. Defaults to 50 items.
906
+ :param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
907
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
908
+ :param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve the resources for. Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is required.
909
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
910
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
911
+ :param retries: Override the default retry configuration for this method
912
+ :param server_url: Override the default server URL for this method
913
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
914
+ :param http_headers: Additional headers to set or replace on requests.
915
+ """
916
+ base_url = None
917
+ url_variables = None
918
+ if timeout_ms is None:
919
+ timeout_ms = self.sdk_configuration.timeout_ms
920
+
921
+ if server_url is not None:
922
+ base_url = server_url
923
+ else:
924
+ base_url = self._get_url(base_url, url_variables)
925
+
926
+ request = models.ListAllRefundsRequest(
927
+ from_=from_,
928
+ limit=limit,
929
+ sort=sort,
930
+ embed=embed,
931
+ profile_id=profile_id,
932
+ testmode=testmode,
933
+ idempotency_key=idempotency_key,
934
+ )
935
+
936
+ req = self._build_request(
937
+ method="GET",
938
+ path="/refunds",
939
+ base_url=base_url,
940
+ url_variables=url_variables,
941
+ request=request,
942
+ request_body_required=False,
943
+ request_has_path_params=False,
944
+ request_has_query_params=True,
945
+ user_agent_header="user-agent",
946
+ accept_header_value="application/hal+json",
947
+ http_headers=http_headers,
948
+ _globals=models.ListAllRefundsGlobals(
949
+ profile_id=self.sdk_configuration.globals.profile_id,
950
+ testmode=self.sdk_configuration.globals.testmode,
951
+ ),
952
+ security=self.sdk_configuration.security,
953
+ timeout_ms=timeout_ms,
954
+ )
955
+
956
+ if retries == UNSET:
957
+ if self.sdk_configuration.retry_config is not UNSET:
958
+ retries = self.sdk_configuration.retry_config
959
+ else:
960
+ retries = utils.RetryConfig(
961
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
962
+ )
963
+
964
+ retry_config = None
965
+ if isinstance(retries, utils.RetryConfig):
966
+ retry_config = (retries, ["5xx"])
967
+
968
+ http_res = self.do_request(
969
+ hook_ctx=HookContext(
970
+ config=self.sdk_configuration,
971
+ base_url=base_url or "",
972
+ operation_id="list-all-refunds",
973
+ oauth2_scopes=None,
974
+ security_source=get_security_from_env(
975
+ self.sdk_configuration.security, models.Security
976
+ ),
977
+ ),
978
+ request=req,
979
+ error_status_codes=["400", "4XX", "5XX"],
980
+ retry_config=retry_config,
981
+ )
982
+
983
+ response_data: Any = None
984
+ if utils.match_response(http_res, "200", "application/hal+json"):
985
+ return unmarshal_json_response(models.ListAllRefundsResponse, http_res)
986
+ if utils.match_response(http_res, "400", "application/hal+json"):
987
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
988
+ raise models.ErrorResponse(response_data, http_res)
989
+ if utils.match_response(http_res, "4XX", "*"):
990
+ http_res_text = utils.stream_to_text(http_res)
991
+ raise models.APIError("API error occurred", http_res, http_res_text)
992
+ if utils.match_response(http_res, "5XX", "*"):
993
+ http_res_text = utils.stream_to_text(http_res)
994
+ raise models.APIError("API error occurred", http_res, http_res_text)
995
+
996
+ raise models.APIError("Unexpected response received", http_res)
997
+
998
+ async def all_async(
999
+ self,
1000
+ *,
1001
+ from_: Optional[str] = None,
1002
+ limit: OptionalNullable[int] = UNSET,
1003
+ sort: Optional[models.Sorting] = None,
1004
+ embed: OptionalNullable[str] = UNSET,
1005
+ profile_id: Optional[str] = None,
1006
+ testmode: Optional[bool] = None,
1007
+ idempotency_key: Optional[str] = None,
1008
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1009
+ server_url: Optional[str] = None,
1010
+ timeout_ms: Optional[int] = None,
1011
+ http_headers: Optional[Mapping[str, str]] = None,
1012
+ ) -> models.ListAllRefundsResponse:
1013
+ r"""List all refunds
1014
+
1015
+ Retrieve a list of all of your refunds.
1016
+
1017
+ The results are paginated.
1018
+
1019
+ :param from_: Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
1020
+ :param limit: The maximum number of items to return. Defaults to 50 items.
1021
+ :param sort: Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
1022
+ :param embed: This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
1023
+ :param profile_id: The identifier referring to the [profile](get-profile) you wish to retrieve the resources for. Most API credentials are linked to a single profile. In these cases the `profileId` can be omitted. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is required.
1024
+ :param testmode: Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter can be omitted. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
1025
+ :param idempotency_key: A unique key to ensure idempotent requests. This key should be a UUID v4 string.
1026
+ :param retries: Override the default retry configuration for this method
1027
+ :param server_url: Override the default server URL for this method
1028
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1029
+ :param http_headers: Additional headers to set or replace on requests.
1030
+ """
1031
+ base_url = None
1032
+ url_variables = None
1033
+ if timeout_ms is None:
1034
+ timeout_ms = self.sdk_configuration.timeout_ms
1035
+
1036
+ if server_url is not None:
1037
+ base_url = server_url
1038
+ else:
1039
+ base_url = self._get_url(base_url, url_variables)
1040
+
1041
+ request = models.ListAllRefundsRequest(
1042
+ from_=from_,
1043
+ limit=limit,
1044
+ sort=sort,
1045
+ embed=embed,
1046
+ profile_id=profile_id,
1047
+ testmode=testmode,
1048
+ idempotency_key=idempotency_key,
1049
+ )
1050
+
1051
+ req = self._build_request_async(
1052
+ method="GET",
1053
+ path="/refunds",
1054
+ base_url=base_url,
1055
+ url_variables=url_variables,
1056
+ request=request,
1057
+ request_body_required=False,
1058
+ request_has_path_params=False,
1059
+ request_has_query_params=True,
1060
+ user_agent_header="user-agent",
1061
+ accept_header_value="application/hal+json",
1062
+ http_headers=http_headers,
1063
+ _globals=models.ListAllRefundsGlobals(
1064
+ profile_id=self.sdk_configuration.globals.profile_id,
1065
+ testmode=self.sdk_configuration.globals.testmode,
1066
+ ),
1067
+ security=self.sdk_configuration.security,
1068
+ timeout_ms=timeout_ms,
1069
+ )
1070
+
1071
+ if retries == UNSET:
1072
+ if self.sdk_configuration.retry_config is not UNSET:
1073
+ retries = self.sdk_configuration.retry_config
1074
+ else:
1075
+ retries = utils.RetryConfig(
1076
+ "backoff", utils.BackoffStrategy(500, 5000, 2, 7500), True
1077
+ )
1078
+
1079
+ retry_config = None
1080
+ if isinstance(retries, utils.RetryConfig):
1081
+ retry_config = (retries, ["5xx"])
1082
+
1083
+ http_res = await self.do_request_async(
1084
+ hook_ctx=HookContext(
1085
+ config=self.sdk_configuration,
1086
+ base_url=base_url or "",
1087
+ operation_id="list-all-refunds",
1088
+ oauth2_scopes=None,
1089
+ security_source=get_security_from_env(
1090
+ self.sdk_configuration.security, models.Security
1091
+ ),
1092
+ ),
1093
+ request=req,
1094
+ error_status_codes=["400", "4XX", "5XX"],
1095
+ retry_config=retry_config,
1096
+ )
1097
+
1098
+ response_data: Any = None
1099
+ if utils.match_response(http_res, "200", "application/hal+json"):
1100
+ return unmarshal_json_response(models.ListAllRefundsResponse, http_res)
1101
+ if utils.match_response(http_res, "400", "application/hal+json"):
1102
+ response_data = unmarshal_json_response(models.ErrorResponseData, http_res)
1103
+ raise models.ErrorResponse(response_data, http_res)
1104
+ if utils.match_response(http_res, "4XX", "*"):
1105
+ http_res_text = await utils.stream_to_text_async(http_res)
1106
+ raise models.APIError("API error occurred", http_res, http_res_text)
1107
+ if utils.match_response(http_res, "5XX", "*"):
1108
+ http_res_text = await utils.stream_to_text_async(http_res)
1109
+ raise models.APIError("API error occurred", http_res, http_res_text)
1110
+
1111
+ raise models.APIError("Unexpected response received", http_res)