spring-bootpaypalpayment-gatewaypayflowpropaypal-here

paypal refund order API return Authorization failed due to insufficient permissions


Currently i am redirecting order amount to merchant account that is working fine

but now when i perform refund operation getting persmission error

steps i followed :

  1. gettting access token of merchant from his/her refresh token(stored in database) (using https://api-m.sandbox.paypal.com/v1/identity/openidconnect/tokenservice API)

  2. now using above token(from step 1) for refund process in below API https://api.sandbox.paypal.com/v2/payments/captures/{captureId}/refund where

captureId : got from order details

response of refund api :

{
    "name": "NOT_AUTHORIZED",
    "message": "Authorization failed due to insufficient permissions.",
    "debug_id": "60091a8e09195",
    "details": [
        {
            "issue": "PERMISSION_DENIED",
            "field": "capture_id",
            "value": "90Y75959CH863854A",
            "description": "You do not have permission to access or perform operations on this resource.",
            "location": "path"
        }
    ],
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/payments/v2/#error-PERMISSION_DENIED",
            "rel": "information_link"}
    ]}

can someone help me to find what mistake am i doing ? and how can i resolve this issue ?


Solution

  • To determine which scopes you should try asking for during authorization, do a normal access_token request using your own credentials and look at the scopes variable returned.

    https://uri.paypal.com/services/payments/refund seems relevant.