66from ... import errors
77from ...client import AuthenticatedClient , Client
88from ...models .http_validation_error import HTTPValidationError
9- from ...models .update_payment_method_request import UpdatePaymentMethodRequest
10- from ...models .update_payment_method_response import UpdatePaymentMethodResponse
9+ from ...models .portal_session_response import PortalSessionResponse
1110from ...types import Response
1211
1312
1413def _get_kwargs (
1514 org_id : str ,
16- * ,
17- body : UpdatePaymentMethodRequest ,
1815) -> dict [str , Any ]:
19- headers : dict [str , Any ] = {}
20-
2116 _kwargs : dict [str , Any ] = {
2217 "method" : "post" ,
23- "url" : f"/v1/billing/customer/{ org_id } /payment-method " ,
18+ "url" : f"/v1/billing/customer/{ org_id } /portal " ,
2419 }
2520
26- _kwargs ["json" ] = body .to_dict ()
27-
28- headers ["Content-Type" ] = "application/json"
29-
30- _kwargs ["headers" ] = headers
3121 return _kwargs
3222
3323
3424def _parse_response (
3525 * , client : Union [AuthenticatedClient , Client ], response : httpx .Response
36- ) -> Optional [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
26+ ) -> Optional [Union [HTTPValidationError , PortalSessionResponse ]]:
3727 if response .status_code == 200 :
38- response_200 = UpdatePaymentMethodResponse .from_dict (response .json ())
28+ response_200 = PortalSessionResponse .from_dict (response .json ())
3929
4030 return response_200
4131
@@ -52,7 +42,7 @@ def _parse_response(
5242
5343def _build_response (
5444 * , client : Union [AuthenticatedClient , Client ], response : httpx .Response
55- ) -> Response [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
45+ ) -> Response [Union [HTTPValidationError , PortalSessionResponse ]]:
5646 return Response (
5747 status_code = HTTPStatus (response .status_code ),
5848 content = response .content ,
@@ -65,32 +55,37 @@ def sync_detailed(
6555 org_id : str ,
6656 * ,
6757 client : AuthenticatedClient ,
68- body : UpdatePaymentMethodRequest ,
69- ) -> Response [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
70- """Update Organization Default Payment Method
58+ ) -> Response [Union [HTTPValidationError , PortalSessionResponse ]]:
59+ """Create Customer Portal Session
7160
72- Update the default payment method for the organization .
61+ Create a Stripe Customer Portal session for managing payment methods .
7362
74- This changes which payment method will be used for future subscription charges.
63+ The portal allows users to:
64+ - Add new payment methods
65+ - Remove existing payment methods
66+ - Update default payment method
67+ - View billing history
68+
69+ The user will be redirected to Stripe's hosted portal page and returned to the billing page when
70+ done.
7571
7672 **Requirements:**
7773 - User must be an OWNER of the organization
74+ - Organization must have a Stripe customer ID (i.e., has gone through checkout at least once)
7875
7976 Args:
8077 org_id (str):
81- body (UpdatePaymentMethodRequest): Request to update default payment method.
8278
8379 Raises:
8480 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
8581 httpx.TimeoutException: If the request takes longer than Client.timeout.
8682
8783 Returns:
88- Response[Union[HTTPValidationError, UpdatePaymentMethodResponse ]]
84+ Response[Union[HTTPValidationError, PortalSessionResponse ]]
8985 """
9086
9187 kwargs = _get_kwargs (
9288 org_id = org_id ,
93- body = body ,
9489 )
9590
9691 response = client .get_httpx_client ().request (
@@ -104,66 +99,76 @@ def sync(
10499 org_id : str ,
105100 * ,
106101 client : AuthenticatedClient ,
107- body : UpdatePaymentMethodRequest ,
108- ) -> Optional [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
109- """Update Organization Default Payment Method
102+ ) -> Optional [Union [HTTPValidationError , PortalSessionResponse ]]:
103+ """Create Customer Portal Session
104+
105+ Create a Stripe Customer Portal session for managing payment methods.
110106
111- Update the default payment method for the organization.
107+ The portal allows users to:
108+ - Add new payment methods
109+ - Remove existing payment methods
110+ - Update default payment method
111+ - View billing history
112112
113- This changes which payment method will be used for future subscription charges.
113+ The user will be redirected to Stripe's hosted portal page and returned to the billing page when
114+ done.
114115
115116 **Requirements:**
116117 - User must be an OWNER of the organization
118+ - Organization must have a Stripe customer ID (i.e., has gone through checkout at least once)
117119
118120 Args:
119121 org_id (str):
120- body (UpdatePaymentMethodRequest): Request to update default payment method.
121122
122123 Raises:
123124 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
124125 httpx.TimeoutException: If the request takes longer than Client.timeout.
125126
126127 Returns:
127- Union[HTTPValidationError, UpdatePaymentMethodResponse ]
128+ Union[HTTPValidationError, PortalSessionResponse ]
128129 """
129130
130131 return sync_detailed (
131132 org_id = org_id ,
132133 client = client ,
133- body = body ,
134134 ).parsed
135135
136136
137137async def asyncio_detailed (
138138 org_id : str ,
139139 * ,
140140 client : AuthenticatedClient ,
141- body : UpdatePaymentMethodRequest ,
142- ) -> Response [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
143- """Update Organization Default Payment Method
141+ ) -> Response [Union [HTTPValidationError , PortalSessionResponse ]]:
142+ """Create Customer Portal Session
144143
145- Update the default payment method for the organization .
144+ Create a Stripe Customer Portal session for managing payment methods .
146145
147- This changes which payment method will be used for future subscription charges.
146+ The portal allows users to:
147+ - Add new payment methods
148+ - Remove existing payment methods
149+ - Update default payment method
150+ - View billing history
151+
152+ The user will be redirected to Stripe's hosted portal page and returned to the billing page when
153+ done.
148154
149155 **Requirements:**
150156 - User must be an OWNER of the organization
157+ - Organization must have a Stripe customer ID (i.e., has gone through checkout at least once)
151158
152159 Args:
153160 org_id (str):
154- body (UpdatePaymentMethodRequest): Request to update default payment method.
155161
156162 Raises:
157163 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
158164 httpx.TimeoutException: If the request takes longer than Client.timeout.
159165
160166 Returns:
161- Response[Union[HTTPValidationError, UpdatePaymentMethodResponse ]]
167+ Response[Union[HTTPValidationError, PortalSessionResponse ]]
162168 """
163169
164170 kwargs = _get_kwargs (
165171 org_id = org_id ,
166- body = body ,
167172 )
168173
169174 response = await client .get_async_httpx_client ().request (** kwargs )
@@ -175,33 +180,38 @@ async def asyncio(
175180 org_id : str ,
176181 * ,
177182 client : AuthenticatedClient ,
178- body : UpdatePaymentMethodRequest ,
179- ) -> Optional [Union [HTTPValidationError , UpdatePaymentMethodResponse ]]:
180- """Update Organization Default Payment Method
183+ ) -> Optional [Union [HTTPValidationError , PortalSessionResponse ]]:
184+ """Create Customer Portal Session
185+
186+ Create a Stripe Customer Portal session for managing payment methods.
181187
182- Update the default payment method for the organization.
188+ The portal allows users to:
189+ - Add new payment methods
190+ - Remove existing payment methods
191+ - Update default payment method
192+ - View billing history
183193
184- This changes which payment method will be used for future subscription charges.
194+ The user will be redirected to Stripe's hosted portal page and returned to the billing page when
195+ done.
185196
186197 **Requirements:**
187198 - User must be an OWNER of the organization
199+ - Organization must have a Stripe customer ID (i.e., has gone through checkout at least once)
188200
189201 Args:
190202 org_id (str):
191- body (UpdatePaymentMethodRequest): Request to update default payment method.
192203
193204 Raises:
194205 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195206 httpx.TimeoutException: If the request takes longer than Client.timeout.
196207
197208 Returns:
198- Union[HTTPValidationError, UpdatePaymentMethodResponse ]
209+ Union[HTTPValidationError, PortalSessionResponse ]
199210 """
200211
201212 return (
202213 await asyncio_detailed (
203214 org_id = org_id ,
204215 client = client ,
205- body = body ,
206216 )
207217 ).parsed
0 commit comments