paid-python 1.0.0a0__py3-none-any.whl → 1.0.0a2__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 (137) hide show
  1. paid/__init__.py +61 -122
  2. paid/client.py +16 -22
  3. paid/contacts/client.py +417 -133
  4. paid/contacts/raw_client.py +1048 -118
  5. paid/core/client_wrapper.py +8 -10
  6. paid/customers/__init__.py +0 -3
  7. paid/customers/client.py +394 -1112
  8. paid/customers/raw_client.py +656 -1054
  9. paid/environment.py +1 -1
  10. paid/errors/bad_request_error.py +2 -2
  11. paid/errors/forbidden_error.py +2 -2
  12. paid/errors/internal_server_error.py +2 -2
  13. paid/errors/not_found_error.py +2 -2
  14. paid/invoices/client.py +369 -0
  15. paid/{plans → invoices}/raw_client.py +312 -201
  16. paid/orders/__init__.py +0 -3
  17. paid/orders/client.py +281 -471
  18. paid/orders/raw_client.py +552 -537
  19. paid/products/__init__.py +0 -3
  20. paid/products/client.py +129 -265
  21. paid/products/raw_client.py +565 -233
  22. paid/signals/client.py +130 -0
  23. paid/signals/raw_client.py +190 -0
  24. paid/tracing/autoinstrumentation.py +12 -6
  25. paid/tracing/context_manager.py +2 -6
  26. paid/tracing/distributed_tracing.py +3 -3
  27. paid/tracing/signal.py +3 -3
  28. paid/tracing/wrappers/openai_agents/openaiAgentsHook.py +1 -1
  29. paid/types/__init__.py +58 -110
  30. paid/types/attribution.py +8 -0
  31. paid/types/{agent_attribute.py → bulk_signals_response.py} +4 -5
  32. paid/types/contact.py +12 -20
  33. paid/types/{address.py → contact_billing_address.py} +6 -7
  34. paid/types/{traces_response.py → contact_list_response.py} +5 -9
  35. paid/types/customer.py +15 -22
  36. paid/types/customer_attribution.py +8 -0
  37. paid/types/customer_billing_address.py +26 -0
  38. paid/types/{usage_summary_order.py → customer_by_external_id.py} +3 -5
  39. paid/types/{usage_summary_order_line.py → customer_by_id.py} +3 -5
  40. paid/types/customer_creation_state.py +5 -0
  41. paid/types/customer_list_response.py +22 -0
  42. paid/types/empty_response.py +17 -0
  43. paid/types/{error.py → error_response.py} +4 -7
  44. paid/types/invoice.py +33 -51
  45. paid/types/invoice_line.py +42 -0
  46. paid/types/invoice_line_payment_status.py +7 -0
  47. paid/types/invoice_lines_response.py +22 -0
  48. paid/types/invoice_list_response.py +22 -0
  49. paid/types/invoice_payment_status.py +5 -0
  50. paid/types/invoice_source.py +5 -0
  51. paid/types/invoice_status.py +3 -1
  52. paid/types/invoice_tax_status.py +7 -0
  53. paid/types/order.py +30 -29
  54. paid/types/order_creation_state.py +5 -0
  55. paid/types/order_line.py +6 -24
  56. paid/types/order_lines_response.py +22 -0
  57. paid/types/order_list_response.py +22 -0
  58. paid/types/pagination.py +24 -0
  59. paid/types/product.py +4 -29
  60. paid/types/{tier.py → product_by_external_id.py} +5 -4
  61. paid/types/{cost_amount.py → product_by_id.py} +5 -12
  62. paid/types/product_list_response.py +22 -0
  63. paid/types/signal.py +8 -34
  64. paid/types/{agent_update.py → update_contact_request.py} +10 -9
  65. paid/types/update_customer_request.py +38 -0
  66. paid/types/{product_update.py → update_product_request.py} +2 -12
  67. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/METADATA +23 -8
  68. paid_python-1.0.0a2.dist-info/RECORD +110 -0
  69. paid/agents/client.py +0 -880
  70. paid/agents/raw_client.py +0 -785
  71. paid/customers/types/__init__.py +0 -8
  72. paid/customers/types/customers_check_entitlement_request_view.py +0 -5
  73. paid/customers/types/customers_check_entitlement_response.py +0 -22
  74. paid/orders/lines/client.py +0 -144
  75. paid/orders/lines/raw_client.py +0 -129
  76. paid/plans/__init__.py +0 -4
  77. paid/plans/client.py +0 -403
  78. paid/products/types/__init__.py +0 -7
  79. paid/products/types/product_create_type.py +0 -5
  80. paid/traces/__init__.py +0 -4
  81. paid/traces/client.py +0 -218
  82. paid/traces/raw_client.py +0 -226
  83. paid/types/agent.py +0 -31
  84. paid/types/agent_price_point.py +0 -27
  85. paid/types/agent_price_point_tiers.py +0 -23
  86. paid/types/api_error.py +0 -29
  87. paid/types/billing_frequency.py +0 -5
  88. paid/types/cancel_renewal_response.py +0 -49
  89. paid/types/charge_type.py +0 -5
  90. paid/types/contact_create_for_customer.py +0 -37
  91. paid/types/cost_trace.py +0 -55
  92. paid/types/cost_traces_response.py +0 -26
  93. paid/types/creation_source.py +0 -5
  94. paid/types/creation_state.py +0 -5
  95. paid/types/customer_update.py +0 -40
  96. paid/types/entitlement_usage.py +0 -48
  97. paid/types/order_line_attribute.py +0 -27
  98. paid/types/order_line_attribute_create_one.py +0 -5
  99. paid/types/order_line_attribute_pricing.py +0 -33
  100. paid/types/order_line_create.py +0 -72
  101. paid/types/pagination_meta.py +0 -84
  102. paid/types/payment_method.py +0 -58
  103. paid/types/payment_method_card.py +0 -49
  104. paid/types/payment_method_type.py +0 -5
  105. paid/types/payment_method_us_bank_account.py +0 -36
  106. paid/types/payment_method_us_bank_account_account_type.py +0 -5
  107. paid/types/plan.py +0 -81
  108. paid/types/plan_group.py +0 -60
  109. paid/types/plan_plan_products_item.py +0 -41
  110. paid/types/plan_plan_products_item_plan_product_attribute_item.py +0 -34
  111. paid/types/plan_with_features.py +0 -69
  112. paid/types/plan_with_features_features_item.py +0 -34
  113. paid/types/price_point.py +0 -25
  114. paid/types/pricing.py +0 -31
  115. paid/types/pricing_model_type.py +0 -7
  116. paid/types/product_type.py +0 -5
  117. paid/types/product_update_type.py +0 -5
  118. paid/types/proration_attribute_update.py +0 -44
  119. paid/types/proration_detail.py +0 -49
  120. paid/types/proration_upgrade_response.py +0 -73
  121. paid/types/salutation.py +0 -5
  122. paid/types/signal_v_2.py +0 -56
  123. paid/types/tax_exempt_status.py +0 -5
  124. paid/types/trace.py +0 -69
  125. paid/types/usage_pagination_meta.py +0 -43
  126. paid/types/usage_summaries_response.py +0 -26
  127. paid/types/usage_summary.py +0 -121
  128. paid/usage/__init__.py +0 -7
  129. paid/usage/client.py +0 -321
  130. paid/usage/raw_client.py +0 -387
  131. paid/usage/types/__init__.py +0 -7
  132. paid/usage/types/usage_check_usage_response.py +0 -53
  133. paid_python-1.0.0a0.dist-info/RECORD +0 -152
  134. /paid/{agents → invoices}/__init__.py +0 -0
  135. /paid/{orders/lines → signals}/__init__.py +0 -0
  136. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/LICENSE +0 -0
  137. {paid_python-1.0.0a0.dist-info → paid_python-1.0.0a2.dist-info}/WHEEL +0 -0
paid/orders/client.py CHANGED
@@ -5,13 +5,11 @@ import typing
5
5
 
6
6
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
7
  from ..core.request_options import RequestOptions
8
- from ..types.cancel_renewal_response import CancelRenewalResponse
9
- from ..types.invoice import Invoice
8
+ from ..types.empty_response import EmptyResponse
10
9
  from ..types.order import Order
11
- from ..types.order_line_create import OrderLineCreate
12
- from ..types.proration_attribute_update import ProrationAttributeUpdate
13
- from ..types.proration_upgrade_response import ProrationUpgradeResponse
14
- from .lines.client import AsyncLinesClient, LinesClient
10
+ from ..types.order_creation_state import OrderCreationState
11
+ from ..types.order_lines_response import OrderLinesResponse
12
+ from ..types.order_list_response import OrderListResponse
15
13
  from .raw_client import AsyncRawOrdersClient, RawOrdersClient
16
14
 
17
15
  # this is used as the default value for optional parameters
@@ -21,7 +19,6 @@ OMIT = typing.cast(typing.Any, ...)
21
19
  class OrdersClient:
22
20
  def __init__(self, *, client_wrapper: SyncClientWrapper):
23
21
  self._raw_client = RawOrdersClient(client_wrapper=client_wrapper)
24
- self.lines = LinesClient(client_wrapper=client_wrapper)
25
22
 
26
23
  @property
27
24
  def with_raw_response(self) -> RawOrdersClient:
@@ -34,17 +31,29 @@ class OrdersClient:
34
31
  """
35
32
  return self._raw_client
36
33
 
37
- def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Order]:
34
+ def list_orders(
35
+ self,
36
+ *,
37
+ limit: typing.Optional[int] = None,
38
+ offset: typing.Optional[int] = None,
39
+ request_options: typing.Optional[RequestOptions] = None,
40
+ ) -> OrderListResponse:
38
41
  """
42
+ Get a list of orders for the organization
43
+
39
44
  Parameters
40
45
  ----------
46
+ limit : typing.Optional[int]
47
+
48
+ offset : typing.Optional[int]
49
+
41
50
  request_options : typing.Optional[RequestOptions]
42
51
  Request-specific configuration.
43
52
 
44
53
  Returns
45
54
  -------
46
- typing.List[Order]
47
- Success response
55
+ OrderListResponse
56
+ 200
48
57
 
49
58
  Examples
50
59
  --------
@@ -53,49 +62,56 @@ class OrdersClient:
53
62
  client = Paid(
54
63
  token="YOUR_TOKEN",
55
64
  )
56
- client.orders.list()
65
+ client.orders.list_orders()
57
66
  """
58
- _response = self._raw_client.list(request_options=request_options)
67
+ _response = self._raw_client.list_orders(limit=limit, offset=offset, request_options=request_options)
59
68
  return _response.data
60
69
 
61
- def create(
70
+ def create_order(
62
71
  self,
63
72
  *,
64
- name: str,
65
- start_date: str,
66
- currency: str,
67
- customer_id: typing.Optional[str] = OMIT,
68
- customer_external_id: typing.Optional[str] = OMIT,
69
- billing_contact_id: typing.Optional[str] = OMIT,
70
- description: typing.Optional[str] = OMIT,
71
- end_date: typing.Optional[str] = OMIT,
72
- plan_id: typing.Optional[str] = OMIT,
73
- order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
73
+ customer_id: str,
74
+ billing_customer_id: typing.Optional[str] = OMIT,
75
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
76
+ name: typing.Optional[str] = OMIT,
77
+ start_date: typing.Optional[dt.datetime] = OMIT,
78
+ end_date: typing.Optional[dt.datetime] = OMIT,
79
+ subscription_terms: typing.Optional[int] = OMIT,
80
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
81
+ billing_anchor: typing.Optional[float] = OMIT,
82
+ payment_terms: typing.Optional[str] = OMIT,
83
+ external_id: typing.Optional[str] = OMIT,
84
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
74
85
  request_options: typing.Optional[RequestOptions] = None,
75
86
  ) -> Order:
76
87
  """
88
+ Creates a new order for the organization
89
+
77
90
  Parameters
78
91
  ----------
79
- name : str
92
+ customer_id : str
80
93
 
81
- start_date : str
94
+ billing_customer_id : typing.Optional[str]
82
95
 
83
- currency : str
96
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
84
97
 
85
- customer_id : typing.Optional[str]
98
+ name : typing.Optional[str]
86
99
 
87
- customer_external_id : typing.Optional[str]
100
+ start_date : typing.Optional[dt.datetime]
88
101
 
89
- billing_contact_id : typing.Optional[str]
102
+ end_date : typing.Optional[dt.datetime]
90
103
 
91
- description : typing.Optional[str]
104
+ subscription_terms : typing.Optional[int]
92
105
 
93
- end_date : typing.Optional[str]
106
+ creation_state : typing.Optional[OrderCreationState]
94
107
 
95
- plan_id : typing.Optional[str]
96
- Optional plan ID to associate with this order
108
+ billing_anchor : typing.Optional[float]
97
109
 
98
- order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
110
+ payment_terms : typing.Optional[str]
111
+
112
+ external_id : typing.Optional[str]
113
+
114
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
99
115
 
100
116
  request_options : typing.Optional[RequestOptions]
101
117
  Request-specific configuration.
@@ -103,7 +119,7 @@ class OrdersClient:
103
119
  Returns
104
120
  -------
105
121
  Order
106
- Success response
122
+ 201
107
123
 
108
124
  Examples
109
125
  --------
@@ -112,35 +128,34 @@ class OrdersClient:
112
128
  client = Paid(
113
129
  token="YOUR_TOKEN",
114
130
  )
115
- client.orders.create(
116
- customer_external_id="acme-inc",
117
- name="Acme Order",
118
- description="Acme Order is an order for Acme, Inc.",
119
- start_date="2025-01-01",
120
- end_date="2026-01-01",
121
- currency="USD",
131
+ client.orders.create_order(
132
+ customer_id="customerId",
122
133
  )
123
134
  """
124
- _response = self._raw_client.create(
135
+ _response = self._raw_client.create_order(
136
+ customer_id=customer_id,
137
+ billing_customer_id=billing_customer_id,
138
+ billing_contact_ids=billing_contact_ids,
125
139
  name=name,
126
140
  start_date=start_date,
127
- currency=currency,
128
- customer_id=customer_id,
129
- customer_external_id=customer_external_id,
130
- billing_contact_id=billing_contact_id,
131
- description=description,
132
141
  end_date=end_date,
133
- plan_id=plan_id,
134
- order_lines=order_lines,
142
+ subscription_terms=subscription_terms,
143
+ creation_state=creation_state,
144
+ billing_anchor=billing_anchor,
145
+ payment_terms=payment_terms,
146
+ external_id=external_id,
147
+ metadata=metadata,
135
148
  request_options=request_options,
136
149
  )
137
150
  return _response.data
138
151
 
139
- def get(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
152
+ def get_order_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
140
153
  """
154
+ Get an order by ID
155
+
141
156
  Parameters
142
157
  ----------
143
- order_id : str
158
+ id : str
144
159
 
145
160
  request_options : typing.Optional[RequestOptions]
146
161
  Request-specific configuration.
@@ -148,7 +163,7 @@ class OrdersClient:
148
163
  Returns
149
164
  -------
150
165
  Order
151
- Success response
166
+ 200
152
167
 
153
168
  Examples
154
169
  --------
@@ -157,89 +172,58 @@ class OrdersClient:
157
172
  client = Paid(
158
173
  token="YOUR_TOKEN",
159
174
  )
160
- client.orders.get(
161
- order_id="orderId",
175
+ client.orders.get_order_by_id(
176
+ id="id",
162
177
  )
163
178
  """
164
- _response = self._raw_client.get(order_id, request_options=request_options)
179
+ _response = self._raw_client.get_order_by_id(id, request_options=request_options)
165
180
  return _response.data
166
181
 
167
- def delete(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
182
+ def update_order_by_id(
183
+ self,
184
+ id: str,
185
+ *,
186
+ name: typing.Optional[str] = OMIT,
187
+ start_date: typing.Optional[dt.datetime] = OMIT,
188
+ end_date: typing.Optional[dt.datetime] = OMIT,
189
+ subscription_terms: typing.Optional[int] = OMIT,
190
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
191
+ billing_anchor: typing.Optional[float] = OMIT,
192
+ payment_terms: typing.Optional[str] = OMIT,
193
+ external_id: typing.Optional[str] = OMIT,
194
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
195
+ billing_customer_id: typing.Optional[str] = OMIT,
196
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
197
+ request_options: typing.Optional[RequestOptions] = None,
198
+ ) -> Order:
168
199
  """
200
+ Update an order by ID
201
+
169
202
  Parameters
170
203
  ----------
171
- order_id : str
204
+ id : str
172
205
 
173
- request_options : typing.Optional[RequestOptions]
174
- Request-specific configuration.
206
+ name : typing.Optional[str]
175
207
 
176
- Returns
177
- -------
178
- None
208
+ start_date : typing.Optional[dt.datetime]
179
209
 
180
- Examples
181
- --------
182
- from paid import Paid
210
+ end_date : typing.Optional[dt.datetime]
183
211
 
184
- client = Paid(
185
- token="YOUR_TOKEN",
186
- )
187
- client.orders.delete(
188
- order_id="orderId",
189
- )
190
- """
191
- _response = self._raw_client.delete(order_id, request_options=request_options)
192
- return _response.data
212
+ subscription_terms : typing.Optional[int]
193
213
 
194
- def activate(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
195
- """
196
- Parameters
197
- ----------
198
- order_id : str
214
+ creation_state : typing.Optional[OrderCreationState]
199
215
 
200
- request_options : typing.Optional[RequestOptions]
201
- Request-specific configuration.
216
+ billing_anchor : typing.Optional[float]
202
217
 
203
- Returns
204
- -------
205
- Order
206
- Success response
218
+ payment_terms : typing.Optional[str]
207
219
 
208
- Examples
209
- --------
210
- from paid import Paid
220
+ external_id : typing.Optional[str]
211
221
 
212
- client = Paid(
213
- token="YOUR_TOKEN",
214
- )
215
- client.orders.activate(
216
- order_id="orderId",
217
- )
218
- """
219
- _response = self._raw_client.activate(order_id, request_options=request_options)
220
- return _response.data
222
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
221
223
 
222
- def activate_and_pay(
223
- self,
224
- order_id: str,
225
- *,
226
- confirmation_token: str,
227
- return_url: str,
228
- request_options: typing.Optional[RequestOptions] = None,
229
- ) -> Order:
230
- """
231
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
224
+ billing_customer_id : typing.Optional[str]
232
225
 
233
- Parameters
234
- ----------
235
- order_id : str
236
- The order ID (can be internal ID or display ID)
237
-
238
- confirmation_token : str
239
- Stripe confirmation token for the payment method
240
-
241
- return_url : str
242
- URL to redirect to after payment processing
226
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
243
227
 
244
228
  request_options : typing.Optional[RequestOptions]
245
229
  Request-specific configuration.
@@ -247,7 +231,7 @@ class OrdersClient:
247
231
  Returns
248
232
  -------
249
233
  Order
250
- Order activated and payment processed successfully
234
+ 200
251
235
 
252
236
  Examples
253
237
  --------
@@ -256,154 +240,83 @@ class OrdersClient:
256
240
  client = Paid(
257
241
  token="YOUR_TOKEN",
258
242
  )
259
- client.orders.activate_and_pay(
260
- order_id="orderId",
261
- confirmation_token="ctoken_1234567890",
262
- return_url="https://example.com/payment-complete",
243
+ client.orders.update_order_by_id(
244
+ id="id",
263
245
  )
264
246
  """
265
- _response = self._raw_client.activate_and_pay(
266
- order_id, confirmation_token=confirmation_token, return_url=return_url, request_options=request_options
247
+ _response = self._raw_client.update_order_by_id(
248
+ id,
249
+ name=name,
250
+ start_date=start_date,
251
+ end_date=end_date,
252
+ subscription_terms=subscription_terms,
253
+ creation_state=creation_state,
254
+ billing_anchor=billing_anchor,
255
+ payment_terms=payment_terms,
256
+ external_id=external_id,
257
+ metadata=metadata,
258
+ billing_customer_id=billing_customer_id,
259
+ billing_contact_ids=billing_contact_ids,
260
+ request_options=request_options,
267
261
  )
268
262
  return _response.data
269
263
 
270
- def cancel_renewal(
271
- self,
272
- order_id: str,
273
- *,
274
- order_version: int,
275
- cancel_from_date: dt.datetime,
276
- request_options: typing.Optional[RequestOptions] = None,
277
- ) -> CancelRenewalResponse:
264
+ def delete_order_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> EmptyResponse:
278
265
  """
279
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
266
+ Delete an order by ID
280
267
 
281
268
  Parameters
282
269
  ----------
283
- order_id : str
284
- The order ID (can be internal ID or display ID)
285
-
286
- order_version : int
287
- The current version of the order (for optimistic locking)
288
-
289
- cancel_from_date : dt.datetime
290
- The date from which the renewal should be cancelled (ISO 8601 format)
270
+ id : str
291
271
 
292
272
  request_options : typing.Optional[RequestOptions]
293
273
  Request-specific configuration.
294
274
 
295
275
  Returns
296
276
  -------
297
- CancelRenewalResponse
298
- Order renewal cancelled successfully
277
+ EmptyResponse
278
+ 200
299
279
 
300
280
  Examples
301
281
  --------
302
- import datetime
303
-
304
282
  from paid import Paid
305
283
 
306
284
  client = Paid(
307
285
  token="YOUR_TOKEN",
308
286
  )
309
- client.orders.cancel_renewal(
310
- order_id="orderId",
311
- order_version=1,
312
- cancel_from_date=datetime.datetime.fromisoformat(
313
- "2025-12-31 00:00:00+00:00",
314
- ),
287
+ client.orders.delete_order_by_id(
288
+ id="id",
315
289
  )
316
290
  """
317
- _response = self._raw_client.cancel_renewal(
318
- order_id, order_version=order_version, cancel_from_date=cancel_from_date, request_options=request_options
319
- )
291
+ _response = self._raw_client.delete_order_by_id(id, request_options=request_options)
320
292
  return _response.data
321
293
 
322
- def schedule_plan_change(
294
+ def get_order_lines(
323
295
  self,
324
- order_id: str,
296
+ id: str,
325
297
  *,
326
- order_version: int,
327
- effective_date: dt.datetime,
328
- updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
298
+ limit: typing.Optional[int] = None,
299
+ offset: typing.Optional[int] = None,
329
300
  request_options: typing.Optional[RequestOptions] = None,
330
- ) -> ProrationUpgradeResponse:
301
+ ) -> OrderLinesResponse:
331
302
  """
332
- Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
303
+ Get the order lines for an order by ID
333
304
 
334
305
  Parameters
335
306
  ----------
336
- order_id : str
337
- The order ID (can be internal ID or display ID)
307
+ id : str
338
308
 
339
- order_version : int
340
- The current version of the order (for optimistic locking)
309
+ limit : typing.Optional[int]
341
310
 
342
- effective_date : dt.datetime
343
- The date when the plan change should take effect (ISO 8601 format)
344
-
345
- updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
346
- The list of order line attributes to update
311
+ offset : typing.Optional[int]
347
312
 
348
313
  request_options : typing.Optional[RequestOptions]
349
314
  Request-specific configuration.
350
315
 
351
316
  Returns
352
317
  -------
353
- ProrationUpgradeResponse
354
- Plan change scheduled successfully
355
-
356
- Examples
357
- --------
358
- import datetime
359
-
360
- from paid import Paid, ProrationAttributeUpdate
361
-
362
- client = Paid(
363
- token="YOUR_TOKEN",
364
- )
365
- client.orders.schedule_plan_change(
366
- order_id="orderId",
367
- order_version=1,
368
- effective_date=datetime.datetime.fromisoformat(
369
- "2025-02-01 00:00:00+00:00",
370
- ),
371
- updated_order_line_attributes=[
372
- ProrationAttributeUpdate(
373
- order_line_attribute_id="a1b2c3d4-5678-90ab-cdef-1234567890ab",
374
- new_pricing={"unitPrice": 200, "currency": "USD"},
375
- new_quantity=10.0,
376
- )
377
- ],
378
- )
379
- """
380
- _response = self._raw_client.schedule_plan_change(
381
- order_id,
382
- order_version=order_version,
383
- effective_date=effective_date,
384
- updated_order_line_attributes=updated_order_line_attributes,
385
- request_options=request_options,
386
- )
387
- return _response.data
388
-
389
- def get_invoices(
390
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
391
- ) -> typing.List[Invoice]:
392
- """
393
- Retrieves all invoices associated with a specific order.
394
-
395
- Parameters
396
- ----------
397
- order_id : str
398
- The order ID (can be internal ID or display ID)
399
-
400
- request_options : typing.Optional[RequestOptions]
401
- Request-specific configuration.
402
-
403
- Returns
404
- -------
405
- typing.List[Invoice]
406
- Success response
318
+ OrderLinesResponse
319
+ 200
407
320
 
408
321
  Examples
409
322
  --------
@@ -412,18 +325,17 @@ class OrdersClient:
412
325
  client = Paid(
413
326
  token="YOUR_TOKEN",
414
327
  )
415
- client.orders.get_invoices(
416
- order_id="orderId",
328
+ client.orders.get_order_lines(
329
+ id="id",
417
330
  )
418
331
  """
419
- _response = self._raw_client.get_invoices(order_id, request_options=request_options)
332
+ _response = self._raw_client.get_order_lines(id, limit=limit, offset=offset, request_options=request_options)
420
333
  return _response.data
421
334
 
422
335
 
423
336
  class AsyncOrdersClient:
424
337
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
425
338
  self._raw_client = AsyncRawOrdersClient(client_wrapper=client_wrapper)
426
- self.lines = AsyncLinesClient(client_wrapper=client_wrapper)
427
339
 
428
340
  @property
429
341
  def with_raw_response(self) -> AsyncRawOrdersClient:
@@ -436,17 +348,29 @@ class AsyncOrdersClient:
436
348
  """
437
349
  return self._raw_client
438
350
 
439
- async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Order]:
351
+ async def list_orders(
352
+ self,
353
+ *,
354
+ limit: typing.Optional[int] = None,
355
+ offset: typing.Optional[int] = None,
356
+ request_options: typing.Optional[RequestOptions] = None,
357
+ ) -> OrderListResponse:
440
358
  """
359
+ Get a list of orders for the organization
360
+
441
361
  Parameters
442
362
  ----------
363
+ limit : typing.Optional[int]
364
+
365
+ offset : typing.Optional[int]
366
+
443
367
  request_options : typing.Optional[RequestOptions]
444
368
  Request-specific configuration.
445
369
 
446
370
  Returns
447
371
  -------
448
- typing.List[Order]
449
- Success response
372
+ OrderListResponse
373
+ 200
450
374
 
451
375
  Examples
452
376
  --------
@@ -460,52 +384,59 @@ class AsyncOrdersClient:
460
384
 
461
385
 
462
386
  async def main() -> None:
463
- await client.orders.list()
387
+ await client.orders.list_orders()
464
388
 
465
389
 
466
390
  asyncio.run(main())
467
391
  """
468
- _response = await self._raw_client.list(request_options=request_options)
392
+ _response = await self._raw_client.list_orders(limit=limit, offset=offset, request_options=request_options)
469
393
  return _response.data
470
394
 
471
- async def create(
395
+ async def create_order(
472
396
  self,
473
397
  *,
474
- name: str,
475
- start_date: str,
476
- currency: str,
477
- customer_id: typing.Optional[str] = OMIT,
478
- customer_external_id: typing.Optional[str] = OMIT,
479
- billing_contact_id: typing.Optional[str] = OMIT,
480
- description: typing.Optional[str] = OMIT,
481
- end_date: typing.Optional[str] = OMIT,
482
- plan_id: typing.Optional[str] = OMIT,
483
- order_lines: typing.Optional[typing.Sequence[OrderLineCreate]] = OMIT,
398
+ customer_id: str,
399
+ billing_customer_id: typing.Optional[str] = OMIT,
400
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
401
+ name: typing.Optional[str] = OMIT,
402
+ start_date: typing.Optional[dt.datetime] = OMIT,
403
+ end_date: typing.Optional[dt.datetime] = OMIT,
404
+ subscription_terms: typing.Optional[int] = OMIT,
405
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
406
+ billing_anchor: typing.Optional[float] = OMIT,
407
+ payment_terms: typing.Optional[str] = OMIT,
408
+ external_id: typing.Optional[str] = OMIT,
409
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
484
410
  request_options: typing.Optional[RequestOptions] = None,
485
411
  ) -> Order:
486
412
  """
413
+ Creates a new order for the organization
414
+
487
415
  Parameters
488
416
  ----------
489
- name : str
417
+ customer_id : str
418
+
419
+ billing_customer_id : typing.Optional[str]
490
420
 
491
- start_date : str
421
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
492
422
 
493
- currency : str
423
+ name : typing.Optional[str]
494
424
 
495
- customer_id : typing.Optional[str]
425
+ start_date : typing.Optional[dt.datetime]
496
426
 
497
- customer_external_id : typing.Optional[str]
427
+ end_date : typing.Optional[dt.datetime]
498
428
 
499
- billing_contact_id : typing.Optional[str]
429
+ subscription_terms : typing.Optional[int]
500
430
 
501
- description : typing.Optional[str]
431
+ creation_state : typing.Optional[OrderCreationState]
502
432
 
503
- end_date : typing.Optional[str]
433
+ billing_anchor : typing.Optional[float]
504
434
 
505
- plan_id : typing.Optional[str]
506
- Optional plan ID to associate with this order
435
+ payment_terms : typing.Optional[str]
507
436
 
508
- order_lines : typing.Optional[typing.Sequence[OrderLineCreate]]
437
+ external_id : typing.Optional[str]
438
+
439
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
509
440
 
510
441
  request_options : typing.Optional[RequestOptions]
511
442
  Request-specific configuration.
@@ -513,7 +444,7 @@ class AsyncOrdersClient:
513
444
  Returns
514
445
  -------
515
446
  Order
516
- Success response
447
+ 201
517
448
 
518
449
  Examples
519
450
  --------
@@ -527,38 +458,37 @@ class AsyncOrdersClient:
527
458
 
528
459
 
529
460
  async def main() -> None:
530
- await client.orders.create(
531
- customer_external_id="acme-inc",
532
- name="Acme Order",
533
- description="Acme Order is an order for Acme, Inc.",
534
- start_date="2025-01-01",
535
- end_date="2026-01-01",
536
- currency="USD",
461
+ await client.orders.create_order(
462
+ customer_id="customerId",
537
463
  )
538
464
 
539
465
 
540
466
  asyncio.run(main())
541
467
  """
542
- _response = await self._raw_client.create(
468
+ _response = await self._raw_client.create_order(
469
+ customer_id=customer_id,
470
+ billing_customer_id=billing_customer_id,
471
+ billing_contact_ids=billing_contact_ids,
543
472
  name=name,
544
473
  start_date=start_date,
545
- currency=currency,
546
- customer_id=customer_id,
547
- customer_external_id=customer_external_id,
548
- billing_contact_id=billing_contact_id,
549
- description=description,
550
474
  end_date=end_date,
551
- plan_id=plan_id,
552
- order_lines=order_lines,
475
+ subscription_terms=subscription_terms,
476
+ creation_state=creation_state,
477
+ billing_anchor=billing_anchor,
478
+ payment_terms=payment_terms,
479
+ external_id=external_id,
480
+ metadata=metadata,
553
481
  request_options=request_options,
554
482
  )
555
483
  return _response.data
556
484
 
557
- async def get(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
485
+ async def get_order_by_id(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
558
486
  """
487
+ Get an order by ID
488
+
559
489
  Parameters
560
490
  ----------
561
- order_id : str
491
+ id : str
562
492
 
563
493
  request_options : typing.Optional[RequestOptions]
564
494
  Request-specific configuration.
@@ -566,7 +496,7 @@ class AsyncOrdersClient:
566
496
  Returns
567
497
  -------
568
498
  Order
569
- Success response
499
+ 200
570
500
 
571
501
  Examples
572
502
  --------
@@ -580,108 +510,61 @@ class AsyncOrdersClient:
580
510
 
581
511
 
582
512
  async def main() -> None:
583
- await client.orders.get(
584
- order_id="orderId",
513
+ await client.orders.get_order_by_id(
514
+ id="id",
585
515
  )
586
516
 
587
517
 
588
518
  asyncio.run(main())
589
519
  """
590
- _response = await self._raw_client.get(order_id, request_options=request_options)
520
+ _response = await self._raw_client.get_order_by_id(id, request_options=request_options)
591
521
  return _response.data
592
522
 
593
- async def delete(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
594
- """
595
- Parameters
596
- ----------
597
- order_id : str
598
-
599
- request_options : typing.Optional[RequestOptions]
600
- Request-specific configuration.
601
-
602
- Returns
603
- -------
604
- None
605
-
606
- Examples
607
- --------
608
- import asyncio
609
-
610
- from paid import AsyncPaid
611
-
612
- client = AsyncPaid(
613
- token="YOUR_TOKEN",
614
- )
615
-
616
-
617
- async def main() -> None:
618
- await client.orders.delete(
619
- order_id="orderId",
620
- )
621
-
622
-
623
- asyncio.run(main())
523
+ async def update_order_by_id(
524
+ self,
525
+ id: str,
526
+ *,
527
+ name: typing.Optional[str] = OMIT,
528
+ start_date: typing.Optional[dt.datetime] = OMIT,
529
+ end_date: typing.Optional[dt.datetime] = OMIT,
530
+ subscription_terms: typing.Optional[int] = OMIT,
531
+ creation_state: typing.Optional[OrderCreationState] = OMIT,
532
+ billing_anchor: typing.Optional[float] = OMIT,
533
+ payment_terms: typing.Optional[str] = OMIT,
534
+ external_id: typing.Optional[str] = OMIT,
535
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
536
+ billing_customer_id: typing.Optional[str] = OMIT,
537
+ billing_contact_ids: typing.Optional[typing.Sequence[str]] = OMIT,
538
+ request_options: typing.Optional[RequestOptions] = None,
539
+ ) -> Order:
624
540
  """
625
- _response = await self._raw_client.delete(order_id, request_options=request_options)
626
- return _response.data
541
+ Update an order by ID
627
542
 
628
- async def activate(self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Order:
629
- """
630
543
  Parameters
631
544
  ----------
632
- order_id : str
545
+ id : str
633
546
 
634
- request_options : typing.Optional[RequestOptions]
635
- Request-specific configuration.
547
+ name : typing.Optional[str]
636
548
 
637
- Returns
638
- -------
639
- Order
640
- Success response
549
+ start_date : typing.Optional[dt.datetime]
641
550
 
642
- Examples
643
- --------
644
- import asyncio
645
-
646
- from paid import AsyncPaid
647
-
648
- client = AsyncPaid(
649
- token="YOUR_TOKEN",
650
- )
551
+ end_date : typing.Optional[dt.datetime]
651
552
 
553
+ subscription_terms : typing.Optional[int]
652
554
 
653
- async def main() -> None:
654
- await client.orders.activate(
655
- order_id="orderId",
656
- )
555
+ creation_state : typing.Optional[OrderCreationState]
657
556
 
557
+ billing_anchor : typing.Optional[float]
658
558
 
659
- asyncio.run(main())
660
- """
661
- _response = await self._raw_client.activate(order_id, request_options=request_options)
662
- return _response.data
559
+ payment_terms : typing.Optional[str]
663
560
 
664
- async def activate_and_pay(
665
- self,
666
- order_id: str,
667
- *,
668
- confirmation_token: str,
669
- return_url: str,
670
- request_options: typing.Optional[RequestOptions] = None,
671
- ) -> Order:
672
- """
673
- Activates the order and processes the initial payment using the provided Stripe confirmation token.
561
+ external_id : typing.Optional[str]
674
562
 
675
- Parameters
676
- ----------
677
- order_id : str
678
- The order ID (can be internal ID or display ID)
563
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
679
564
 
680
- confirmation_token : str
681
- Stripe confirmation token for the payment method
565
+ billing_customer_id : typing.Optional[str]
682
566
 
683
- return_url : str
684
- URL to redirect to after payment processing
567
+ billing_contact_ids : typing.Optional[typing.Sequence[str]]
685
568
 
686
569
  request_options : typing.Optional[RequestOptions]
687
570
  Request-specific configuration.
@@ -689,7 +572,7 @@ class AsyncOrdersClient:
689
572
  Returns
690
573
  -------
691
574
  Order
692
- Order activated and payment processed successfully
575
+ 200
693
576
 
694
577
  Examples
695
578
  --------
@@ -703,54 +586,51 @@ class AsyncOrdersClient:
703
586
 
704
587
 
705
588
  async def main() -> None:
706
- await client.orders.activate_and_pay(
707
- order_id="orderId",
708
- confirmation_token="ctoken_1234567890",
709
- return_url="https://example.com/payment-complete",
589
+ await client.orders.update_order_by_id(
590
+ id="id",
710
591
  )
711
592
 
712
593
 
713
594
  asyncio.run(main())
714
595
  """
715
- _response = await self._raw_client.activate_and_pay(
716
- order_id, confirmation_token=confirmation_token, return_url=return_url, request_options=request_options
596
+ _response = await self._raw_client.update_order_by_id(
597
+ id,
598
+ name=name,
599
+ start_date=start_date,
600
+ end_date=end_date,
601
+ subscription_terms=subscription_terms,
602
+ creation_state=creation_state,
603
+ billing_anchor=billing_anchor,
604
+ payment_terms=payment_terms,
605
+ external_id=external_id,
606
+ metadata=metadata,
607
+ billing_customer_id=billing_customer_id,
608
+ billing_contact_ids=billing_contact_ids,
609
+ request_options=request_options,
717
610
  )
718
611
  return _response.data
719
612
 
720
- async def cancel_renewal(
721
- self,
722
- order_id: str,
723
- *,
724
- order_version: int,
725
- cancel_from_date: dt.datetime,
726
- request_options: typing.Optional[RequestOptions] = None,
727
- ) -> CancelRenewalResponse:
613
+ async def delete_order_by_id(
614
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
615
+ ) -> EmptyResponse:
728
616
  """
729
- Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
617
+ Delete an order by ID
730
618
 
731
619
  Parameters
732
620
  ----------
733
- order_id : str
734
- The order ID (can be internal ID or display ID)
735
-
736
- order_version : int
737
- The current version of the order (for optimistic locking)
738
-
739
- cancel_from_date : dt.datetime
740
- The date from which the renewal should be cancelled (ISO 8601 format)
621
+ id : str
741
622
 
742
623
  request_options : typing.Optional[RequestOptions]
743
624
  Request-specific configuration.
744
625
 
745
626
  Returns
746
627
  -------
747
- CancelRenewalResponse
748
- Order renewal cancelled successfully
628
+ EmptyResponse
629
+ 200
749
630
 
750
631
  Examples
751
632
  --------
752
633
  import asyncio
753
- import datetime
754
634
 
755
635
  from paid import AsyncPaid
756
636
 
@@ -760,114 +640,42 @@ class AsyncOrdersClient:
760
640
 
761
641
 
762
642
  async def main() -> None:
763
- await client.orders.cancel_renewal(
764
- order_id="orderId",
765
- order_version=1,
766
- cancel_from_date=datetime.datetime.fromisoformat(
767
- "2025-12-31 00:00:00+00:00",
768
- ),
643
+ await client.orders.delete_order_by_id(
644
+ id="id",
769
645
  )
770
646
 
771
647
 
772
648
  asyncio.run(main())
773
649
  """
774
- _response = await self._raw_client.cancel_renewal(
775
- order_id, order_version=order_version, cancel_from_date=cancel_from_date, request_options=request_options
776
- )
650
+ _response = await self._raw_client.delete_order_by_id(id, request_options=request_options)
777
651
  return _response.data
778
652
 
779
- async def schedule_plan_change(
653
+ async def get_order_lines(
780
654
  self,
781
- order_id: str,
655
+ id: str,
782
656
  *,
783
- order_version: int,
784
- effective_date: dt.datetime,
785
- updated_order_line_attributes: typing.Sequence[ProrationAttributeUpdate],
657
+ limit: typing.Optional[int] = None,
658
+ offset: typing.Optional[int] = None,
786
659
  request_options: typing.Optional[RequestOptions] = None,
787
- ) -> ProrationUpgradeResponse:
660
+ ) -> OrderLinesResponse:
788
661
  """
789
- Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
662
+ Get the order lines for an order by ID
790
663
 
791
664
  Parameters
792
665
  ----------
793
- order_id : str
794
- The order ID (can be internal ID or display ID)
795
-
796
- order_version : int
797
- The current version of the order (for optimistic locking)
666
+ id : str
798
667
 
799
- effective_date : dt.datetime
800
- The date when the plan change should take effect (ISO 8601 format)
668
+ limit : typing.Optional[int]
801
669
 
802
- updated_order_line_attributes : typing.Sequence[ProrationAttributeUpdate]
803
- The list of order line attributes to update
670
+ offset : typing.Optional[int]
804
671
 
805
672
  request_options : typing.Optional[RequestOptions]
806
673
  Request-specific configuration.
807
674
 
808
675
  Returns
809
676
  -------
810
- ProrationUpgradeResponse
811
- Plan change scheduled successfully
812
-
813
- Examples
814
- --------
815
- import asyncio
816
- import datetime
817
-
818
- from paid import AsyncPaid, ProrationAttributeUpdate
819
-
820
- client = AsyncPaid(
821
- token="YOUR_TOKEN",
822
- )
823
-
824
-
825
- async def main() -> None:
826
- await client.orders.schedule_plan_change(
827
- order_id="orderId",
828
- order_version=1,
829
- effective_date=datetime.datetime.fromisoformat(
830
- "2025-02-01 00:00:00+00:00",
831
- ),
832
- updated_order_line_attributes=[
833
- ProrationAttributeUpdate(
834
- order_line_attribute_id="a1b2c3d4-5678-90ab-cdef-1234567890ab",
835
- new_pricing={"unitPrice": 200, "currency": "USD"},
836
- new_quantity=10.0,
837
- )
838
- ],
839
- )
840
-
841
-
842
- asyncio.run(main())
843
- """
844
- _response = await self._raw_client.schedule_plan_change(
845
- order_id,
846
- order_version=order_version,
847
- effective_date=effective_date,
848
- updated_order_line_attributes=updated_order_line_attributes,
849
- request_options=request_options,
850
- )
851
- return _response.data
852
-
853
- async def get_invoices(
854
- self, order_id: str, *, request_options: typing.Optional[RequestOptions] = None
855
- ) -> typing.List[Invoice]:
856
- """
857
- Retrieves all invoices associated with a specific order.
858
-
859
- Parameters
860
- ----------
861
- order_id : str
862
- The order ID (can be internal ID or display ID)
863
-
864
- request_options : typing.Optional[RequestOptions]
865
- Request-specific configuration.
866
-
867
- Returns
868
- -------
869
- typing.List[Invoice]
870
- Success response
677
+ OrderLinesResponse
678
+ 200
871
679
 
872
680
  Examples
873
681
  --------
@@ -881,12 +689,14 @@ class AsyncOrdersClient:
881
689
 
882
690
 
883
691
  async def main() -> None:
884
- await client.orders.get_invoices(
885
- order_id="orderId",
692
+ await client.orders.get_order_lines(
693
+ id="id",
886
694
  )
887
695
 
888
696
 
889
697
  asyncio.run(main())
890
698
  """
891
- _response = await self._raw_client.get_invoices(order_id, request_options=request_options)
699
+ _response = await self._raw_client.get_order_lines(
700
+ id, limit=limit, offset=offset, request_options=request_options
701
+ )
892
702
  return _response.data