o
    h                     @   sH   d dl mZ d dlmZmZmZ G dd deZeeZeeZ	dS )    )get_adapter)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewc                   @   sD   e Zd ZdZedd Zedd Zedd Zdd	 Zd
d Z	dS )PaypalOAuth2Adapterpaypalc                 C      d}d |  |S )Nz0webapps/auth/protocol/openidconnect/v1/authorizezhttps://www.{0}/{1}format_get_endpointselfpath r   c/var/www/html/pos/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/paypal/views.pyauthorize_url      z!PaypalOAuth2Adapter.authorize_urlc                 C   r   )Nz&v1/identity/openidconnect/tokenservicehttps://api.{0}/{1}r	   r   r   r   r   access_token_url   r   z$PaypalOAuth2Adapter.access_token_urlc                 C   r   )Nz"v1/identity/openidconnect/userinfor   r	   r   r   r   r   profile_url   r   zPaypalOAuth2Adapter.profile_urlc                 C   s"   |    }|ddkrdS dS )NMODElivez
paypal.comzsandbox.paypal.com)get_providerget_settingsget)r   settingsr   r   r   r      s   z!PaypalOAuth2Adapter._get_endpointc                 K   s6   t   j| jd|jdd}| }|  ||S )Nopenid)schemaaccess_token)params)r   get_requests_sessionpostr   tokenjsonr   sociallogin_from_response)r   requestappr"   kwargsresponse
extra_datar   r   r   complete_login"   s   
z"PaypalOAuth2Adapter.complete_loginN)
__name__
__module____qualname__provider_idpropertyr   r   r   r   r*   r   r   r   r   r   	   s    


r   N)
allauth.socialaccount.adapterr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   r   adapter_viewoauth2_loginoauth2_callbackr   r   r   r   <module>   s
    
&