55import logging
66import subprocess
77import sys
8+ import uuid
89from typing import Optional
910
1011from curl_cffi import requests as cffi_requests
@@ -154,12 +155,8 @@ def generate_team_link(
154155 "Authorization" : f"Bearer { account .access_token } " ,
155156 "Content-Type" : "application/json" ,
156157 "oai-language" : "zh-CN" ,
158+ "oai-device-id" : str (uuid .uuid4 ()),
157159 }
158- if account .cookies :
159- headers ["cookie" ] = account .cookies
160- oai_did = _extract_oai_did (account .cookies )
161- if oai_did :
162- headers ["oai-device-id" ] = oai_did
163160
164161 payload = {
165162 "plan_name" : "chatgptteamplan" ,
@@ -171,7 +168,7 @@ def generate_team_link(
171168 "billing_details" : {"country" : country , "currency" : currency },
172169 "promo_campaign" : {
173170 "promo_campaign_id" : "team-1-month-free" ,
174- "is_coupon_from_query_param" : True ,
171+ "is_coupon_from_query_param" : False ,
175172 },
176173 "cancel_url" : "https://chatgpt.com/#pricing" ,
177174 "checkout_ui_mode" : "custom" ,
@@ -187,9 +184,35 @@ def generate_team_link(
187184 )
188185 resp .raise_for_status ()
189186 data = resp .json ()
190- if "checkout_session_id" in data :
191- return TEAM_CHECKOUT_BASE_URL + data ["checkout_session_id" ]
192- raise ValueError (data .get ("detail" , "API 未返回 checkout_session_id" ))
187+ resp2 = cffi_requests .post (
188+ "https://api.stripe.com/v1/payment_pages/" + data ["checkout_session_id" ],
189+ headers = {
190+ "Content-Type" : "application/x-www-form-urlencoded" ,
191+ "accept" : "application/json" ,
192+ "referer" : "https://js.stripe.com/"
193+ },
194+ data = f"tax_region[country]={ country } "
195+ "&elements_session_client[client_betas][0]=custom_checkout_server_updates_1"
196+ "&elements_session_client[client_betas][1]=custom_checkout_manual_approval_1"
197+ "&elements_session_client[elements_init_source]=custom_checkout"
198+ "&elements_session_client[referrer_host]=chatgpt.com"
199+ "&elements_session_client[session_id]=elements_session_1rr8sS4PKIY"
200+ "&elements_session_client[stripe_js_id]=72d6a553-c2fb-4f85-941e-8022c8335a85"
201+ "&elements_session_client[locale]=zh"
202+ "&elements_session_client[is_aggregation_expected]=false"
203+ "&client_attribution_metadata[merchant_integration_additional_elements][0]=payment"
204+ "&client_attribution_metadata[merchant_integration_additional_elements][1]=address"
205+ f"&key={ data ["publishable_key" ]} "
206+ ,
207+ proxies = _build_proxies (proxy ),
208+ timeout = 30 ,
209+ impersonate = "chrome110" ,
210+ )
211+ resp2 .raise_for_status ()
212+ data2 = resp2 .json ()
213+ if "stripe_hosted_url" in data2 :
214+ return data2 ["stripe_hosted_url" ]
215+ raise ValueError (data .get ("detail" , "API 未返回 stripe_hosted_url" ))
193216
194217
195218def open_url_incognito (url : str , cookies_str : Optional [str ] = None ) -> bool :
0 commit comments