Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 514

unable to generate Paypal Referal Link

$
0
0

I am working on paypal onboarding seller to my platform.I am following this paypal referral

but i got this error

{"msg": "{"name":"NOT_AUTHORIZED","debug_id":"f88411690d4c9","message":"Authorization failed due to insufficient permissions.","details":[{"issue":"NOT_AUTHORIZED","description":"Authorization failed due to insufficient permissions."}]}"}

can someone please elaborate which permission is required and how can i get those permissions

i am using this code

 @staticmethoddef create_paypal_referral(email, tracking_id, return_url):"""Create a PayPal partner referral."""    success = False    response = None    try:        # Get access token        access_token = PaypalrestSDk.get_access_token()        print(access_token)        # Define headers and payload for the referral request        headers = {'Content-Type': 'application/json','Authorization': f'Bearer {access_token}',        }        data = json.dumps({"email": email,"tracking_id": tracking_id,"partner_config_override": {"return_url": return_url,"return_url_description": "The URL to return the merchant after the PayPal onboarding process.","show_add_credit_card": True            },"operations": [                {"operation": "API_INTEGRATION","api_integration_preference": {"rest_api_integration": {"integration_method": "PAYPAL","integration_type": "THIRD_PARTY","third_party_details": {"features": ["PAYMENT", "REFUND", "PARTNER_FEE"]                            }                        }                    }                }            ],"products": ["PAYMENT_METHODS"],"capabilities": ["APPLE_PAY"],"legal_consents": [                {"type": "SHARE_DATA_CONSENT","granted": True                }            ]        })        # Make the request to PayPal's partner referrals API        referral_url = f'{settings.PAYPAL_BASE_URL}/v2/customer/partner-referrals'        response = requests.post(referral_url, headers=headers, data=data)        if response.status_code == 201:            success = True            response = response.json()        else:            response = response.text        return success, response    except Exception as e:        response = str(e)        return success, response@staticmethoddef get_access_token():"""Retrieve an access token using PayPal OAuth2 API."""    oauth_url = f'{settings.PAYPAL_BASE_URL}/v1/oauth2/token'    response = requests.post(        oauth_url,        headers={'Accept': 'application/json', 'Accept-Language': 'en_US'},        auth=HTTPBasicAuth(settings.PAYPAL_CLIENT_ID, settings.PAYPAL_CLIENT_SECRET),        data={'grant_type': 'client_credentials'}    )    if response.status_code == 200:        return response.json().get('access_token')

Viewing all articles
Browse latest Browse all 514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>