
    <@g                     .   U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZ d dlZd dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZm Z  d dl!m"Z"m#Z#m$Z$m%Z%m&Z& 	 d dl'm(Z) d dl*m+Z, 	 d dl.Z.	 d dl/Z/d dl0Z0d d	l/m1Z2 d d
l/m3Z4 	 d dl5Z5d dl5m6Z7 d dl5m8Z9 	 d dl:Z:d dl:m;Z< 	 e=e>d<   e:j~                  Z@eAe>d<   eAe>d<   eAe>d<   e@j                  d      D  cg c]
  }  eA|        c} \  ZCZDZEeCeDeEfdk  r"ej                  j                  de@d       dZ:	 	 d dlImJZJ d dlKmLZLmMZM d ZNdededdfdZOdededdfdZP G d deQ      ZR G d  d!eR      ZS G d" d#eR      ZT G d$ d%e$      ZU G d& d'eR      ZV G d( d)eR      ZW G d* d+eR      ZX G d, d-eR      ZY G d. d/eR      ZZy# e-$ r Y <w xY w# e-$ r dZ.Y Ew xY w# e-$ r dZ/dZ0Y @w xY w# e-$ r dZ5Y =w xY wc c} w # eH$ r Y w xY w# e-$ r dZ:Y w xY w# e-$ r dZJY w xY w)0    )BytesION)HTTPResponse)_util)RequestMetrics)APIConnectionError)AnyDictIterableListMappingMutableMappingOptionalTupleClassVarUnioncastoverloadAsyncIterable)LiteralNoReturn	TypedDict	AwaitableNever)Timeout)Client)ClientTimeout)StreamReader)Sessionversionmajorminorpatch.)r      r$   zWarning: the Stripe library requires that your Python "requests" library be newer than version 0.8.8, but your "requests" library is version a#  . Stripe will fall back to an alternate HTTP library so everything should work. We recommend upgrading your "requests" library. If you have any questions, please contact support@stripe.com. (HINT: running "pip install -U requests" should upgrade your requests library to the latest version.))urlfetch)urlparseParseResultc                  T    t        t        t        j                         dz              S )Ni  )introundtime     R/var/www/html/AdoubleTech/venv/lib/python3.12/site-packages/stripe/_http_client.py_now_msr/   t   s    uTYY[4'())r-   argskwargsreturn
HTTPClientc                  l    t         rt        }n t        rt        }nt        rt
        }nt        } || i |S N)r%   UrlFetchClientrequestsRequestsClientpycurlPycurlClientUrllib2Clientr0   r1   impls      r.   new_default_http_clientr>   x   s/    		   r-   c                  R    t         rt        }nt        rt        }nt        } || i |S r5   )httpxHTTPXClientaiohttpAIOHTTPClientNoImportFoundAsyncClientr<   s      r.   new_http_client_async_fallbackrE      s'    	'   r-   c                      e Zd ZU ee   ed<    G d de      ZdZdZ	dZ
ee   ed<   eed<   	 	 	 d3dedeeeef      ded    fdZdeeeeeeeef      f      dee   dedee   fdZ	 d4deeeeeeef   f      fdZ	 d4dedeeeeeeef   f      defdZdedefdZdeeef   deeef   fdZd Z	 	 d5d
ddededeeef   dedee   d eee      deeeeeef   f   fd!Z	 	 d5d
ddededeeef   d eee      deeeeeef   f   f
d"Zd
ddededeeef   ded#edee   d eee      deeeeeef   f   fd$Z	 d4d
ddededeeeef      ded eee      deeeeeef   f   fd%Z	 d4d
ddededeeeef      ded eee      deeeeeef   f   fd&Z d' Z!	 	 d5d
ddededeeef   dee   d eee      deeeef   fd(Z"	 	 d5d
ddededeeef   d eee      dee#e$   eef   f
d)Z%e&d
ddededeeef   d#e'd*   dee   d eee      deeeeeef   f   fd+       Z(e&d
ddededeeef   d#e'd	   dee   d eee      dee#e$   eeeef   f   fd,       Z(d
ddededeeef   d#edee   d eee      deeeeeef   f   fd-Z(	 d4dededeeef   dee$eeeef   f   fd.Z)	 d4dededeeef   dee#e$   eeeef   f   fd/Z*d0 Z+d1ede,d
   fd2Z-y
)6r3   namec                   .    e Zd ZU ee   ed<   ee   ed<   y)HTTPClient._ProxyhttphttpsN)__name__
__module____qualname__r   str__annotations__r,   r-   r.   _ProxyrI      s    sm}r-   rQ            ?<   _proxy_verify_ssl_certsTNverify_ssl_certsproxyasync_fallback_clientc                     || _         |r0t        |t              r||d}t        |t              st	        d      |r|j                         nd | _        || _        t        j                         | _
        y )N)rJ   rK   zqProxy(ies) must be specified as either a string URL or a dict() with string URL under the https and/or http keys.)rV   
isinstancerO   dict
ValueErrorcopyrU   _async_fallback_client	threadinglocal_thread_local)selfrW   rX   rY   s       r.   __init__zHTTPClient.__init__   si     "2%%!&7eT*   ',ejjl&;#&__.r-   responseapi_connection_errornum_retriesmax_network_retriesc                     ||nd}||k\  ry||J |j                   S |\  }}}|d|v r|d   dk(  ry|d   dk(  ry|dk(  ry|dk\  ryy)	Nr   Fzstripe-should-retryfalsetrueTi  i  should_retry)rc   re   rf   rg   rh   _status_coderheaderss           r.   _should_retryzHTTPClient._should_retry   s     $7#B 	 --
 (333'444#+ ; $9X$E-.'9-.&8 # #r-   c                 \    |y |\  }}}	 t        |d         S # t        t        f$ r Y y w xY w)Nzretry-after)r)   KeyErrorr]   )rc   re   rn   rp   s       r.   _retry_after_headerzHTTPClient._retry_after_header   sD     !1h	x.//*% 		s    ++r2   c                 &   t        t        j                  d|dz
  z  z  t        j                        }| j	                  |      }t        t        j                  |      }| j                  |      xs d}|t        j                  k  rt        ||      }|S )z
        Apply exponential backoff with initial_network_retry_delay on the number of num_retries so far as inputs.
        Do not allow the number to exceed `max_network_retry_delay`.
              r   )minr3   INITIAL_DELAY	MAX_DELAY_add_jitter_timemaxrt   MAX_RETRY_AFTER)rc   rg   re   sleep_secondsretry_afters        r.   _sleep_time_secondszHTTPClient._sleep_time_seconds   s     $$kAo(>?  

 --m< J44mD ..x8=A*444];Mr-   r~   c                 D    |ddt        j                  dd      z   z  z  }|S )z
        Randomize the value in `[(sleep_seconds/ 2) to (sleep_seconds)]`.
        Also separated method here to isolate randomness for tests
        rS   rw   r   )randomuniform)rc   r~   s     r.   r{   zHTTPClient._add_jitter_time  s)    
 	FNN1a$8 899r-   headersc                     t        | j                  dd       }t        j                  r9|r7d|j	                         i}t        |      }t        j                  |      |d<   |S |S )Nlast_request_metricszX-Stripe-Client-Telemetry)getattrrb   stripeenable_telemetrypayloadr\   jsondumps)rc   r   r   	telemetryrets        r.   _add_telemetry_headerz HTTPClient._add_telemetry_header  sj      ' 6 
 ""';&(<(D(D(FI w-C/3zz)/DC+,Jr-   c                     |\  }}}d|v rAt         j                  r0|d   }t               |z
  }t        |||      | j                  _        y y y )Nz
Request-Idusage)r   r   r/   r   rb   r   )rc   re   request_startr   rn   rp   
request_idrequest_duration_mss           r.   _record_request_metricsz"HTTPClient._record_request_metrics"  sX    !1h8#(?(?!,/J"))m";6D/u7D3 )@#r-   )_usagemethodurl	post_datar   c          	      2    | j                  ||||d||      S NFis_streamingrh   r   _request_with_retries_internalrc   r   r   r   r   rh   r   s          r.   request_with_retrieszHTTPClient.request_with_retries+  s1     22 3 3 
 	
r-   c          	      2    | j                  ||||d||      S NTr   r   r   s          r.   request_stream_with_retriesz&HTTPClient.request_stream_with_retries?  s1     22 3 3 
 	
r-   r   c                   | j                  |      }d}	 t               }		 |r| j                  ||||      }
n| j                  ||||      }
d }| j                  |
|||      rm|r"t        j                  d|j                  z         |dz  }| j                  ||
      }t        j                  d||||fz         t        j                  |       n|
| j                  |
|	|       |
S |J |# t        $ r}|}d }
Y d }~d }~ww xY wNr   z Encountered a retryable error %srw   zBInitiating retry %i for request %s %s after sleeping %.2f seconds.r   )r   r/   request_streamrequestr   rq   r   log_infouser_messager   r+   sleepr   rc   r   r   r   r   r   rh   r   rg   r   re   connection_errore
sleep_times                 r.   r   z)HTTPClient._request_with_retries_internalS  sH    ,,W5#IM
 #22Wi H  $||FC)LH#' 
 !!*K9L $NN:*778 q !55k8L
1&Z@A 

:&'00 -v 1  $O+777**U  &  #$  s   -C- -	D6C??Dc                    t        d      )Nz.HTTPClient subclasses must implement `request`NotImplementedErrorrc   r   r   r   r   r   s         r.   r   zHTTPClient.request  s     "<
 	
r-   c                    t        d      )Nz5HTTPClient subclasses must implement `request_stream`r   r   s         r.   r   zHTTPClient.request_stream  s     "C
 	
r-   c                     t        d      )Nz,HTTPClient subclasses must implement `close`r   rc   s    r.   closezHTTPClient.close  s    !:
 	
r-   c          	      N   K   | j                  ||||d||       d {   S 7 wr   $_request_with_retries_internal_asyncr   s          r.   request_with_retries_asyncz%HTTPClient.request_with_retries_async  s?      >> 3 ? 
 
 	
 
   %#%c          	      N   K   | j                  ||||d||       d {   S 7 wr   r   r   s          r.   !request_stream_with_retries_asyncz,HTTPClient.request_stream_with_retries_async  s?      >> 3 ? 
 
 	
 
r   Fc                   K   y wr5   r,   rc   r   r   r   r   r   rh   r   s           r.   r   z/HTTPClient._request_with_retries_internal_async  s      .1   c                   K   y wr5   r,   r   s           r.   r   z/HTTPClient._request_with_retries_internal_async  s      ?Br   c                J  K   | j                  |      }d}	 t               }		 |r| j                  ||||       d {   }
n| j                  ||||       d {   }
d }| j                  |
|||      rq|r"t        j                  d|j                  z         |dz  }| j                  ||
      }t        j                  d||||fz         | j                  |       d {    n|
| j                  |
|	|       |
S |J |7 7 # t        $ r}|}d }
Y d }~d }~ww xY w7 Bwr   )r   r/   request_stream_asyncrequest_asyncr   rq   r   r   r   r   sleep_asyncr   r   s                 r.   r   z/HTTPClient._request_with_retries_internal_async  su     ,,W5#IM %)%>%>Wi&  H &*%7%7Wi&  H $( 
 !!*K9L $NN:*778 q !55k8L
1&Z@A &&z222'00 -v 1  $O+777**Y 
   &  #$  * 3s]   D#D DD DD A?D#D!$D#D D 	DDD#DD#c                    K   | j                   &| j                   j                  ||||       d {   S t        d      7 w)Nz4HTTPClient subclasses must implement `request_async`)r_   r   r   rc   r   r   r   r   s        r.   r   zHTTPClient.request_async,  sR      &&244BBWi   "B
 	
   .AA Ac                    K   | j                   &| j                   j                  ||||       d {   S t        d      7 w)Nz;HTTPClient subclasses must implement `request_stream_async`)r_   r   r   r   s        r.   r   zHTTPClient.request_stream_async7  sR      &&244IIWi   "I
 	
r   c                    K   | j                   "| j                   j                          d {   S t        d      7 w)Nz2HTTPClient subclasses must implement `close_async`)r_   close_asyncr   r   s    r.   r   zHTTPClient.close_asyncB  s@     &&244@@BBB!@
 	
 Cs   *><>secsc                 f    | j                   | j                   j                  |      S t        d      )Nz,HTTPClient subclasses must implement `sleep`)r_   r   r   rc   r   s     r.   r   zHTTPClient.sleep_asyncI  s5    &&2..::4@@!:
 	
r-   TNNr5   )NN).rL   rM   rN   r   rO   rP   r   rQ   rz   ry   r}   r   boolr   rd   r   r   r)   r   r   rq   rt   floatr   r{   r   r   r   r   r   r   r   r   r   r   r   bytesr   r   r   r   r   r   r   r   r   r,   r-   r.   r3   r3      s   
3-  IMOV "&.28<	// c6k*+/  (5	/2-5c8GCH4E+F!FGH- ''9:- 	-
 &c]-` HL
 sCc1B'B!CD
 BF 5c738+<!<=> 
	4e  sCx(	c	 -1
 '+

 
 c"	

 
 &c]
 c#
 
sCc**	+
2  
 '+

 
 c"	
 c#
 
sCc**	+
: '+9+9+ 9+ c"	9+
 9+ 9+ &c]9+ c#9+ 
sCc**	+9+@ 
 '+

 
 '#s(+,	

 
 c#
 
sCc**	+
$ 
 '+

 
 '#s(+,	

 
 c#
 
sCc**	+

 -1
 '+

 
 c"	
 &c]
 c#
 
sC}	
2  
 '+

 
 c"	
 c#
 
}U#S#-	.
(  '+
1
1 
1 c"	
1 en
1 &c]
1 c#
1 
sCc**	+
1 
1  '+
B
B 
B c"	
B dm
B &c]
B c#
B 
}U#S'#s(*;;	<
B 
B* '+;+;+ ;+ c"	;+ ;+ &c];+ c#;+ 
sCc**	+;+| LP	
	
 #	
.5c3h.?	
	uc738,,	-	
 LP	
	
 #	
.5c3h.?	
	}U#S'#s(*;;	<	


 
)D/ 
r-   c                       e Zd ZdZ	 	 	 	 	 ddeded   dedeeee	j                  f      dee	   f
 fd	Z	 dd
ededeeeef      deeeeeef   f   fdZ	 dd
ededeeeef      deeeeeef   f   fdZed
ededeeeef      ded   deeeeeef   f   f
d       Zed
ededeeeef      ded   deeeeeef   f   f
d       Zd
ededeeeef      dedeeeef   eeeef   f   f
dZdedefdZd Z xZS )r8   r7   TtimeoutsessionRequestsSessionrW   rX   rY   c                 t    t         t        |   |||       || _        || _        t
        J t
        | _        y NrW   rX   rY   )superr8   rd   _session_timeoutr7   )rc   r   r   rW   rX   rY   r1   	__class__s          r.   rd   zRequestsClient.__init__T  sE     	nd,-"7 	- 	

  ### r-   r   r   r   r2   c                 .    | j                  ||||d      S NFr   _request_internalr   s        r.   r   zRequestsClient.requesth  s'     %%C)% & 
 	
r-   c                 .    | j                  ||||d      S NTr   r   r   s        r.   r   zRequestsClient.request_streams  s'     %%C)$ & 
 	
r-   r   c                      y r5   r,   rc   r   r   r   r   r   s         r.   r   z RequestsClient._request_internal~       .1r-   Fc                      y r5   r,   r   s         r.   r   z RequestsClient._request_internal  s     03r-   c                    i }| j                   rt        j                  |d<   nd|d<   | j                  r| j                  |d<   |rd|d<   t	        | j
                  dd       7| j                  xs | j                  j                         | j
                  _	        	 	  t        d| j
                  j                        j                  ||f||| j                  d|}|r|j                  }	n|j                  }	|j                   }
	
j&                  fS # t        $ r}t        d	|      d }~ww xY w# t"        $ r}| j%                  |       Y d }~Md }~ww xY w)
NverifyFproxiesTstreamr   r   )r   datar   a  Warning: It looks like your installed version of the "requests" library is not compatible with Stripe's usage thereof. (HINT: The most likely cause is that your "requests" library is out of date. You can fix that by running "pip install -U requests".) The underlying error was: )rV   r   ca_bundle_pathrU   r   rb   r   r7   r   r   r   r   r   	TypeErrorrawcontentro   	Exception_handle_request_errorr   )rc   r   r   r   r   r   r1   resultr   r   ro   s              r.   r   z RequestsClient._request_internal  se    !!%44F8$F8;; $F9#F84%%y$7?8!6!6!8 &"	*%t'9'9'A'A'		
 $" MM	 	(  **
 !.. ,,K V^^331   346 &  	* &&q))	*s7   A D 'D/ 	D,D''D,,D/ /	E8EEr   c                    t        || j                  j                  j                        r)d}t	        |      j
                  dt        |      }d}nt        || j                  j                  j                  | j                  j                  j                  f      r(d}t	        |      j
                  dt        |      }d}nt        || j                  j                  j                        r(d}t	        |      j
                  dt        |      }d}n?d}dt	        |      j
                  d}t        |      r|d	t        |      z  }n|d
z  }d}t        j                  |      d|dz   }t        ||      |)NCould not verify Stripe's SSL certificate.  Please make sure that your network is not intercepting certificates.  If this problem persists, let us know at support@stripe.com.: FziUnexpected error communicating with Stripe.  If this problem persists, let us know at support@stripe.com.TzUnexpected error communicating with Stripe. It looks like there's probably a configuration issue locally.  If this problem persists, let us know at support@stripe.com.A  was raisedz with error message z with no error message

(Network error: )rl   )r[   r7   
exceptionsSSLErrortyperL   rO   r   ConnectionErrorRequestExceptiontextwrapfillr   rc   r   msgerrrm   s        r.   r   z$RequestsClient._handle_request_error  sT    a11::;&  #1g..A7C L((00((88
& 
 #1g..A7CL4==33DDE& 
 #1g..A7C L.  (,Aw'7'79C1v3q6;;// LmmC #EE <@aGr-   c                 |    t        | j                  dd       %| j                  j                  j                          y y )Nr   )r   rb   r   r   r   s    r.   r   zRequestsClient.close  s5    4%%y$7C&&,,. Dr-   )P   NTNNr5   )rL   rM   rN   rG   r)   r   r   r   rO   r3   rQ   rd   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r   s   @r.   r8   r8   Q  sh   D /3!%9=6:!! +,! 	!
 c:#4#4456!  (
3!2 	
	
 	
 '#s(+,		
 
uc738,,	-	
  	
	
 	
 '#s(+,		
 
sCc**	+	
 11 1 '#s(+,	1 dm1 
sCc**	+1 1 33 3 '#s(+,	3 en3 
uc738,,	-3 3=4=4 =4 '#s(+,	=4 =4 
uUCZ #wsCx'88	9=4~3Hy 3HX 3Hj/r-   r8   c                       e Zd ZdZ	 	 	 	 ddedeej                     dedee   f fdZ		 dde
d	e
d
ee
e
f   dee
eee
e
f   f   fdZ	 dde
d	e
d
ee
e
f   deeeee
e
f   f   fdZede
d	e
d
ee
e
f   ded   deeeef   f
d       Zede
d	e
d
ee
e
f   ded   dee
eef   f
d       Zde
d	e
d
ee
e
f   fdZded	e
defdZd Z xZS )r6   r%   TrW   rX   deadlinerY   c                     t         t        |   |||       |rt        d      || _        || _        t        J t        | _        y )Nr   zNo proxy support in urlfetch library. Set stripe.default_http_client to either RequestsClient, PycurlClient, or Urllib2Client instance to use a proxy.)r   r6   rd   r]   rV   	_deadliner%   )rc   rW   rX   r  rY   r   s        r.   rd   zUrlFetchClient.__init__  s`     	nd,-"7 	- 	
 J  "2 "### r-   r   r   r   r2   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zUrlFetchClient.request,  '     %%C)% & 
 	
r-   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zUrlFetchClient.request_stream3  '     %%C)$ & 
 	
r-   r   c                      y r5   r,   r   s         r.   r   z UrlFetchClient._request_internal:       $'r-   Fc                      y r5   r,   r   s         r.   r   z UrlFetchClient._request_internalD        #r-   c                    	 | j                   j                  |||| j                  | j                  |      }|r=t        j                  j                  t        j                  j                              }nj                  }||j                  |j                  fS # | j                   j                  $ r}| j                  ||       Y d }~d }~ww xY w)N)r   r   r   validate_certificater  r   )r%   fetchrV   r  Errorr   r   ior   rO   encoder   ro   r   )	rc   r   r   r   r   r   r   r   r   s	            r.   r   z UrlFetchClient._request_internalN  s    	/]](( &*%;%;! ) 
F hh&&szz&..'ABGnnG**FNN:: }}"" 	/&&q#..	/s   5B C4CCr   c                 F   t        || j                  j                        rd|d}nHt        || j                  j                        rd}n%t        || j                  j                        rd}nd}t        j                  |      dz   t        |      z   dz   }t        |      |)Nz6The Stripe library attempted to fetch an invalid URL (zg). This is likely due to a bug in the Stripe Python bindings. Please let us know at support@stripe.com.z0There was a problem retrieving data from Stripe.zThere was a problem receiving all of your data from Stripe.  This is likely due to a bug in Stripe. Please let us know at support@stripe.com.hUnexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com.r   r   )	r[   r%   InvalidURLErrorDownloadErrorResponseTooLargeErrorr  r  rO   r   )rc   r   r   r  s       r.   r   z$UrlFetchClient._handle_request_errorm  s    a667
 -02  4==667DC4==>>?< G 
 mmC #99CFBSH %1,r-   c                      y r5   r,   r   s    r.   r   zUrlFetchClient.close      r-   )TN7   Nr5   )rL   rM   rN   rG   r   r   r3   rQ   r)   rd   rO   r   r   r   r   r   r   r   r   r   r   r   r   r   r
  r  s   @r.   r6   r6     s   D "&-16:!! 
))*! 	!
  (
3!> LP

 #
.5c3h.?
	sCc**	+
 LP

 #
.5c3h.?
	wWS#X..	/
 '' ' c"	' dm' 
wS 	!' ' ## # c"	# en# 
sC}	# #;; ; c"	;>-y -s -x -2r-   r6   c                   .    e Zd ZU ee   ed<   ee   ed<   y)rQ   rJ   rK   NrL   rM   rN   r   r'   rP   r,   r-   r.   rQ   rQ     s    
;
K  r-   rQ   c                       e Zd ZU  G d ded      ZdZee   ed<   	 	 	 dded	ee	j                     d
ee	   f fdZd Z	 ddeeef   deeeeeef   f   fdZ	 ddeeef   deeeeeef   f   fdZedededeeef   ded   deeeef   f
d       Zedededeeef   ded   deeeeeef   f   f
d       Zdededeeef   deeeef   eeeef   f   fdZdedefdZdee   fdZd Z xZS )r:   c                   .    e Zd ZU ee   ed<   ee   ed<   y)PycurlClient._ParsedProxyrJ   rK   Nr'  r,   r-   r.   _ParsedProxyr*    s    {##$$r-   r+  F)totalr9   _parsed_proxyTrW   rX   rY   c                 F   t         t        |   |||       t        J t        | _        t        j                         | _        i | _        | j                  rK| j                  }|j                         D ]+  \  }}t        t        t        |            | j                  |<   - y y r   )r   r:   rd   r9   Curl_curlr-  rU   itemsr&   r   rO   )rc   rW   rX   rY   proxy_schemevaluer   s          r.   rd   zPycurlClient.__init__  s     	lD*-"7 	+ 	
 !!![[]
 ;;[[F!' H .6d36F-G""6*H r-   c                     d|vri S |j                  dd      d   }t        j                  |      }t        d t        |      j	                         D              S )Nz
rw   c              3   F   K   | ]  \  }}|j                         |f  y wr5   lower.0kvs      r.   	<genexpr>z-PycurlClient.parse_headers.<locals>.<genexpr>  s     Etq!QWWYNE   !)splitemailmessage_from_stringr\   r1  )rc   r   raw_headersr   s       r.   parse_headerszPycurlClient.parse_headers  sR    Ijj+A.++K8EtG}/B/B/DEEEr-   r   r2   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zPycurlClient.request  r  r-   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zPycurlClient.request_stream  r  r-   r   r   r   c                      y r5   r,   r   s         r.   r   zPycurlClient._request_internal  r  r-   c                      y r5   r,   r   s         r.   r   zPycurlClient._request_internal  r   r-   c           
      \
   t         j                  j                         }t         j                  j                         }| j                  j	                          | j                  |      }|r|j                  r:| j                  j                  | j                  j                  |j                         |j                  r:| j                  j                  | j                  j                  |j                         |j                  s|j                  rI| j                  j                  | j                  j                  |j                  d|j                         |dk(  r1| j                  j                  | j                  j                  d       n|dk(  ra| j                  j                  | j                  j                   d       | j                  j                  | j                  j"                  |       n>| j                  j                  | j                  j$                  |j'                                | j                  j                  | j                  j(                  |       | j                  j                  | j                  j*                  |j,                         | j                  j                  | j                  j.                  |j,                         | j                  j                  | j                  j0                  d       | j                  j                  | j                  j2                  d       | j                  j                  | j                  j4                  d       | j                  j                  | j                  j6                  t9        |      j;                         D 	
cg c]  \  }	}
|	d|
 c}
}	       | j<                  r?| j                  j                  | j                  j>                  t@        jB                         n0| j                  j                  | j                  jD                  d       	 | j                  jG                          |r|jM                  d	       |}n|jO                         jQ                  d
      }| j                  jS                  | j                  jT                        }| jW                  |jO                         jQ                  d
            }|||fS c c}
}	w # | j                  jH                  $ r}| jK                  |       Y d }~d }~ww xY w)N:getrw   post   r	  r   Fr   utf-8),r   r  r   r0  reset
_get_proxyhostnamesetoptr9   PROXYport	PROXYPORTusernamepasswordPROXYUSERPWDHTTPGETPOST
POSTFIELDSCUSTOMREQUESTupperURLWRITEFUNCTIONwriteHEADERFUNCTIONNOSIGNALCONNECTTIMEOUTTIMEOUT
HTTPHEADERr\   r1  rV   CAINFOr   r   SSL_VERIFYHOSTperformerrorr   seekgetvaluedecodegetinfoRESPONSE_CODErC  )rc   r   r   r   r   r   brp   rX   r;  r<  r   rcontentrcodes                 r.   r   zPycurlClient._request_internal  sv    HH88##% 	

$~~

!!$++"3"3U^^Dzz

!!$++"7"7D~~

!!KK,,$~~u~~>
 U?JJdkk1115vJJdkk..2JJdkk44i@JJdkk77H 	

$++//3/

$++33QWW=

$++44hnnE

$++..2

$++44b9

$++--r2

KK""+/=+>+>+@A41aAA	
 !!JJdkk00&2G2GHJJdkk88%@	*JJ  FF1IHzz|**73H

""4;;#<#<=$$X%6%6%8%?%?%HI''+ B {{   	*&&q))	*s   +S1 S7 7T+T&&T+r   c                    |j                   d   | j                  j                  | j                  j                  | j                  j                  fv rd}d}nD|j                   d   | j                  j
                  | j                  j                  fv rd}d}nd}d}t        j                  |      dz   |j                   d   z   d	z   }t        ||
      |)Nr   zCould not connect to Stripe.  Please check your internet connection and try again.  If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support@stripe.com.Tr   Fr  r   rw   r   rl   )
r0   r9   E_COULDNT_CONNECTE_COULDNT_RESOLVE_HOSTE_OPERATION_TIMEOUTEDE_SSL_CACERTE_SSL_PEER_CERTIFICATEr  r  r   )rc   r   r  rm   s       r.   r   z"PycurlClient._handle_request_error#  s    66!9KK))KK..KK--
 
&   LVVAYKK$$KK..
 

&  !LG  !LmmC #99AFF1IEK <@aGr-   c                     | j                   rJ| j                   }|r|j                  d      d   nd }|r$|j                  ||j                  |dd             S y )NrI  r   )r-  r?  rJ  )rc   r   rX   r3  s       r.   rO  zPycurlClient._get_proxyF  sR    &&E*-SYYs^A&4Fyy6!B<)@AAr-   c                      y r5   r,   r   s    r.   r   zPycurlClient.closeN  r$  r-   r   r5   ) rL   rM   rN   r   r+  rG   r   rP   r   r3   rQ   rd   rC  r   rO   r   r)   r   r   r   r   r   r   r   r   r   r   r   r'   rO  r   r
  r  s   @r.   r:   r:     s%   %y % DL)) "&-16:	HH 
))*H  (
3	H6F BF
$+CH$5
	sCc**	+
 BF
$+CH$5
	wWS#X..	/
 '' ' c"	' dm' 
wS 	!' ' 11 1 c"	1 en1 
sCc**	+1 1F(F( F( c"	F( 
uS'\"Cc)::	;F(P!Hy !HX !HF+!6 r-   r:   c                       e Zd ZdZ	 	 	 ddedeej                     dee   f fdZ	 dde	de	d	e
e	e	f   d
ee	ee
e	e	f   f   fdZ	 dde	de	d	e
e	e	f   d
eeee
e	e	f   f   fdZede	de	d	e
e	e	f   ded   d
ee	eef   f
d       Zede	de	d	e
e	e	f   ded   d
eeeef   f
d       Zde	de	d	e
e	e	f   fdZded
efdZd Z xZS )r;   zurllib.requestTrW   rX   rY   c                    t         t        |   |||       d | _        | j                  rUt        j                  t        t        t        t        f   | j                              }t        j                  |      | _        y y r   )r   r;   rd   _openerrU   urllibrequestProxyHandlerr   r	   rO   build_opener)rc   rW   rX   rY   proxy_handlerr   s        r.   rd   zUrllib2Client.__init__U  ss     	mT+-"7 	, 	
 ;; *66T#s(^T[[1M )55mDDL r-   r   r   r   r2   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zUrllib2Client.requestj  r  r-   c                 .    | j                  ||||d      S r   r   r   s        r.   r   zUrllib2Client.request_streamq  r  r-   r   Fc                      y r5   r,   r   s         r.   r   zUrllib2Client._request_internalx  r  r-   c                      y r5   r,   r   s         r.   r   zUrllib2Client._request_internal  s     ),r-   c           	      0   t        |t              r|j                  d      }t        j                  ||t        t        t        t        f   |            }dvr
fd|_        	 | j                  r| j                  j                  |      nt        j                  |      }|r|}n|j                         }|j                  }	t        |j                               }t        d t)        t        |      j+                               D              }	|fS # t        j                   $ r?}
|
j                  }	|
j                         }t        |
j                               }Y d }
~
d }
~
wt        j"                  t$        f$ r}
| j'                  |
       Y d }
~
d }
~
ww xY w)NrM  )rJ  rK  c                  $     j                         S r5   )r\  )r   s   r.   <lambda>z1Urllib2Client._request_internal.<locals>.<lambda>  s    V\\^ r-   c              3   F   K   | ]  \  }}|j                         |f  y wr5   r7  r9  s      r.   r=  z2Urllib2Client._request_internal.<locals>.<genexpr>  s     ITQ1779a.Ir>  )r[   rO   r  r}  Requestr   r   
get_methodr|  openurlopenreadcoder\   infourlliberror	HTTPErrorURLErrorr]   r   iterr1  )rc   r   r   r   r   r   reqre   ro  rp  r   lhs    `          r.   r   zUrllib2Client._request_internal  sK    i%!((1I##DS!97C
 (3CN	*
 << !!#&"**3/  ##==?MME8==?+G IT$w-2E2E2G-HII"" $$ 	%FFEvvxH1668nG$$j1 	*&&q))	*s%   $A6D F$5EF:FFr   c                 l    d}t        j                  |      dz   t        |      z   dz   }t        |      |)Nr  r   r   )r  r  rO   r   )rc   r   r  s      r.   r   z#Urllib2Client._handle_request_error  s>    K 	 mmC #99CFBSH %1,r-   c                      y r5   r,   r   s    r.   r   zUrllib2Client.close  r$  r-   r   r5   )rL   rM   rN   rG   r   r   r3   rQ   rd   rO   r   r   r)   r   r   r   r   r   r   r   r   r   r   r   r
  r  s   @r.   r;   r;   R  s   D "&-16:	EE 
))*E  (
3	E, LP

 #
.5c3h.?
	sCc**	+
 LP

 #
.5c3h.?
	|S'#s("33	4
 ## # c"	# en# 
sC}	# # ,, , c"	, dm, 
|S#%	&, ,)#)# )# c"	)#V-y -X -r-   r;   c                       e Zd ZU dZed   ed<   	 	 ddeeedf      f fdZd Z	de
d	e
d
ee
e
f   fdZ	 dde
d	e
d
ee
e
f   deeeee
e
f   f   fdZ	 dde
d	e
d
ee
e
f   deeeee
e
f   f   fdZdedefdZ	 dde
d	e
d
ee
e
f   deee   eee
e
f   f   fdZ	 dde
d	e
d
ee
e
f   deee   eee
e
f   f   fdZd Zd Z xZS )rA   r@   HTTPXClientType_clientr   HTTPXTimeoutc                    t        t        | 
  di | t        t	        d      t
        t	        d      t        | _        t
        | _        i }| j                  r(t        j                  t        j                        |d<   nd|d<   t        j                  di || _        d | _        |rt        j                  di || _        || _        y )NzPUnexpected: tried to initialize HTTPXClient but the httpx module is not present.zPUnexpected: tried to initialize HTTPXClient but the anyio module is not present.cafiler   Fr,   )r   rA   rd   r@   ImportErroranyiorV   sslcreate_default_contextr   r   AsyncClient_client_asyncr  r   r   )rc   r   allow_sync_methodsr1   r   s       r.   rd   zHTTPXClient.__init__  s     	k4)3F3=b  =b  

!!"99,, F8  %F8"..88 <<1&1DLr-   c                 8    | j                   j                  |      S r5   )r  r   r   s     r.   r   zHTTPXClient.sleep_async  s    zz%%r-   r   r   r   c                     i }| j                   r| j                   |d<   | j                  r| j                  |d<   ||f||xs i d|gS )Nr   r   )r   r   )rU   r   )rc   r   r   r   r   r1   s         r.   _get_request_args_kwargsz$HTTPXClient._get_request_args_kwargs  sU     ;; $F9== $F9SMbCFC
 	
r-   r2   c                 8   | j                   t        d      | j                  ||||      \  }}	  | j                   j                  |i |}j                  }	|j                  }
|j                  }|	|
|fS # t        $ r}| j                  |       Y d }~Hd }~ww xY w)NzqStripe: HTTPXClient was initialized with allow_sync_methods=False, so it cannot be used for synchronous requests.)	r  RuntimeErrorr  r   r   r   r   ro   r   rc   r   r   r   r   r0   r1   re   r   r   ro   response_headerss               r.   r   zHTTPXClient.request  s     <<A  44C)
f	*+t||++T<V<H ""**#++%555  	*&&q))	*s   A5 5	B>BBc                 &  K   | j                  ||||      \  }}	  | j                  j                  |i | d {   }j
                  }	|j                  }
|j                  }|	|
|fS 7 -# t        $ r}| j	                  |       Y d }~Jd }~ww xY wwr5   )r  r  r   r   r   r   ro   r   r  s               r.   r   zHTTPXClient.request_async  s      44C)
f	*7T//77HHHH ""**#++%555 I 	*&&q))	*=   BA* A(A* )B(A* *	B3B	B	BBr   c                     d}dt        |      j                  d}d}t        j                  |      d|dz   }t	        ||      |Nr  r   r   Tr   r   rl   r   rL   r  r  r   r  s        r.   r   z!HTTPXClient._handle_request_error*  K    C 	 $(7#3#35mmC #EE <@aGr-   c                 v   | j                   t        d      | j                  ||||      \  }}	 | j                   j                   | j                  j
                  |i |d      }j                         }	|j                  }
|j                  }|	|
|fS # t        $ r}| j                  |       Y d }~Ld }~ww xY w)NztStripe: HTTPXClient was not initialized with allow_sync_methods=True, so it cannot be used for synchronous requests.Tr   r   )r  r  r  sendr  build_requestr   r   
iter_bytesro   r   rc   r   r   r   r   r0   r1   re   r   r   ro   s              r.   r   zHTTPXClient.request_stream5  s     <<A  44C)
f	*||((8**88$I&I ) H %%'**""W,,  	*&&q))	*s   7B 	B8B33B8c                 d  K   | j                  ||||      \  }}	 | j                  j                   | j                  j                  |i |d       d {   }j                         }	|j                  }
|j                  }|	|
|fS 7 1# t        $ r}| j                  |       Y d }~Nd }~ww xY ww)NTr  )	r  r  r  r  r   r   aiter_bytesro   r   r  s              r.   r   z HTTPXClient.request_stream_asyncM  s      44C)
f	*!//448**88$I&I 5  H &&(**""W,,  	*&&q))	*s@   B0:B	 BB	 -B0B	 		B-B(#B0(B--B0c                 R    | j                   | j                   j                          y y r5   )r  r   r   s    r.   r   zHTTPXClient.close`  s!    <<#LL  $r-   c                 T   K   | j                   j                          d {    y 7 wr5   )r  acloser   s    r.   r   zHTTPXClient.close_asyncd  s       '')))   (&()r	  Fr5   )rL   rM   rN   rG   r   rP   r   r   rd   r   rO   r   r  r   r   r)   r   r   r   r   r   r
   r   r   r   r   r   r
  r  s   @r.   rA   rA     s   D'(( ;= ! %~ 567! F&

 #
.5c3h.?
( 66 6 c"	6 
uc738,,	-6< 66 6 c"	6 
uc738,,	-6(	Hy 	HX 	H LP-- #-.5c3h.?-	xWS#X%66	7-2 LP-- #-.5c3h.?-	}U#S'#s(*;;	<-&!*r-   rA   c                   N    e Zd ZdZ	 ddeeedf      f fdZed        Z	d Z
deeeeeef   f   fdZd	ed
edeeef   fdZ	 dd	ed
edeeef   deeeeeef   f   fdZdedefdZdeee   eeeef   f   fdZ	 dd	ed
edeeef   dedeeeef   f   fdZd Zd Z xZS )rC   rB   r   AIOHTTPTimeoutc                 j    t        t        | 
  di | t        t	        d      || _        d | _        y )NzTUnexpected: tried to initialize AIOHTTPClient but the aiohttp module is not present.r,   )r   rC   rd   rB   r  r   _cached_session)rc   r   r1   r   s      r.   rd   zAIOHTTPClient.__init__k  s=     	mT+5f5?f   #r-   c                 @   t         J | j                  i }| j                  r>t        j                  t
        j                        }t        j                  |      |d<   nt        j                  d      |d<   t        j                  di || _        | j                  S )Nr  )r  	connectorF)
verify_sslr,   )	rB   r  rV   r  r  r   r   TCPConnectorClientSession)rc   r1   ssl_contexts      r.   r   zAIOHTTPClient._sessionx  s    """'F%%!88!00 '.&:&:{&K{#&-&:&:e&L{##*#8#8#B6#BD ###r-   c                 ,    t        j                  |      S r5   )asyncior   r   s     r.   r   zAIOHTTPClient.sleep_async  s    }}T""r-   r2   c                     t        d      Nz4AIOHTTPClient does not support synchronous requests.r   r   s    r.   r   zAIOHTTPClient.request      !B
 	
r-   r   r   r   c                     ||f}i }| j                   r<| j                   d   | j                   d   k7  rt        d      | j                   d   |d<   | j                  r| j                  |d<   ||d<   ||d<   ||fS )NrJ   rK   zDAIOHTTPClient does not support different proxies for HTTP and HTTPS.rX   r   r   r   )rU   r]   r   )rc   r   r   r   r   r0   r1   s          r.   r  z&AIOHTTPClient._get_request_args_kwargs  s     };;{{6"dkk'&:: Z  #kk'2F7O== $F9#y"vV|r-   c                    K   | j                  ||||       d {   \  }}}|j                          d {   ||fS 7 #7 	w)N)r   )r   r  )rc   r   r   r   r   r   ro   r  s           r.   r   zAIOHTTPClient.request_async  s[      ++CI , 
 
		

 lln${4DDD	
 %s   A?AAAAr   c                     d}dt        |      j                  d}d}t        j                  |      d|dz   }t	        ||      |r  r  r  s        r.   r   z#AIOHTTPClient._handle_request_error  r  r-   c                     t        d      r  r   r   s    r.   r   zAIOHTTPClient.request_stream  r  r-   AIOHTTPStreamReaderc                 &  K   | j                  ||||      \  }}	  | j                  j                  |i | d {   }j
                  }	|j                  }
|j                  }|	|
|fS 7 -# t        $ r}| j	                  |       Y d }~Jd }~ww xY wwr5   )r  r   r   r   r   r   statusr   r  s               r.   r   z"AIOHTTPClient.request_stream_async  s      44C)
f	*2T]]22DCFCCH ""oo#++%555 D 	*&&q))	*r  c                      y r5   r,   r   s    r.   r   zAIOHTTPClient.close  r$  r-   c                 T   K   | j                   j                          d {    y 7 wr5   )r   r   r   s    r.   r   zAIOHTTPClient.close_async  s     mm!!###r  )r	  r5   )rL   rM   rN   rG   r   r   r   rd   propertyr   r   r   r   r)   r   rO   r   r  r   r   r   r   r
   r   r   r   r   r
  r  s   @r.   rC   rC   h  so   D CE$e-=&= >?$ $ $"#
uc738+<<= 

 #.5c3h.?. EE E c"	E 
uc738,,	-E"	Hy 	HX 	H
huosGCH<M&M N 
 LP66 #6.5c3h.?6	$c738+<<	=6 $r-   rC   c                        e Zd Z fdZedefd       Z	 d
dededeeef   de	e
eeeef   f   fdZ	 d
dededeeef   fdZd	 Z xZS )rD   c                 ,    t        t        | 
  di | y )Nr,   )r   rD   rd   )rc   r1   r   s     r.   rd   z!NoImportFoundAsyncClient.__init__  s    &6@@r-   r2   c                      t        d      )NzImport httpx not found. To make async http requests,You must either install httpx or define your ownasync http client by subclassing stripe.HTTPClientand setting stripe.default_http_client to an instance of it.)r  r,   r-   r.   raise_async_client_import_errorz8NoImportFoundAsyncClient.raise_async_client_import_error  s    O
 	
r-   r   r   r   c                 ,   K   | j                          y wr5   r  r   s        r.   r   z&NoImportFoundAsyncClient.request_async        	,,.   c                 ,   K   | j                          y wr5   r  r   s        r.   r   z-NoImportFoundAsyncClient.request_stream_async  r  r  c                 ,   K   | j                          y wr5   r  r   s    r.   r   z$NoImportFoundAsyncClient.close_async  s     ,,.r  r5   )rL   rM   rN   rd   staticmethodr   r  rO   r   r   r   r)   r   r   r   r
  r  s   @r.   rD   rD     s    A 
U 
 
 LP// #/.5c3h.?/	uc738,,	-/ LP// #/.5c3h.?/
/r-   rD   )[r  r   sysr  r@  r+   r   r`   r   r  r  http.clientr   r   r   stripe._request_metricsr   stripe._errorr   typingr   r	   r
   r   r   r   r   r   r   r   r   r   r   typing_extensionsr   r   r   r   r   urllib.requestr   r}  urllib.errorrh  r  r  r9   r@   r  r   r  r   r  rB   r   r  r   r  r7   r   r   rO   rP   __version__r   r)   r?  r    r!   r"   stderrr_  r   google.appengine.apir%   urllib.parser&   r'   r/   r>   rE   objectr3   r8   r6   rQ   r:   r;   rA   rC   rD   )is   0r.   <module>r     sl    
        
 $   2 ,    	*&
-/
7;3&&


/6}}S/AB!s1vBue
 5% 9,JJ 6=?	 H-
 /*
!3 
!# 
!, 
!!# ! ! !~
 ~
Bw/Z w/t|Z |~!Y !
@: @FnJ nbb** b*Jq$J q$h/z /S-  		  F  EE  G  C   H<  Hs   5F5 G G G -
G= 83G2 +G-:G2 ,H
 5F>=F>GG	GGG*)G*-G2 2G:9G:=HH
HH