def get_refresh_token(self, authorization_code=None, headers=None):
     """Exchange authorization code for refresh token for future payments
     """
     if authorization_code is None:
         raise exceptions.MissingConfig("Authorization code needed to get new refresh token. \
         Refer to https://developer.paypal.com/docs/integration/mobile/make-future-payment/#get-an-auth-code")
     return self.get_token_hash(authorization_code, headers=headers or {})["refresh_token"]
Пример #2
0
def default():
    """Returns default api object and if not present creates a new one
    By default points to developer sandbox
    """
    global __api__
    if __api__ is None:
        try:
            client_id = os.environ["PAYPAL_CLIENT_ID"]
            client_secret = os.environ["PAYPAL_CLIENT_SECRET"]
        except KeyError:
            raise exceptions.MissingConfig("Required PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET. \
                Refer https://github.com/paypal/rest-api-sdk-python#configuration")

        __api__ = Api(mode=os.environ.get("PAYPAL_MODE", "sandbox"), client_id=client_id, client_secret=client_secret)
    return __api__
Пример #3
0
 def get_refresh_token(self, authorization_code=None):
     if authorization_code is None:
         raise exceptions.MissingConfig(
             "Authorization code needed to get new refresh token. Refer to https://developer.paypal.com/docs/integration/mobile/make-future-payment/#get-an-auth-code"
         )
     return self.get_token_hash(authorization_code)["refresh_token"]