Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify multiple scopes in PayPal RequestPermission API

Looking at the RequestPermissions API, it says that the scope is supposed to be a string. However, I have been unsuccessful in finding out how to specify more than one scope (specifically EXPRESS_CHECKOUT and REFUND). Comma-separated, semi-colon, and even using their NVP list syntax didn't work. A CURL sample would be greatly appreciated.

Comma-separated example...

curl -s --insecure -H 
"X-PAYPAL-SECURITY-USERID: API_USERNAME" 
-H "X-PAYPAL-SECURITY-PASSWORD: API_PASSWORD" 
-H "X-PAYPAL-SECURITY-SIGNATURE: API_SIGNATURE" 
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" 
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" 
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" 
https://svcs.sandbox.paypal.com/Permissions/RequestPermissions -d 
"requestEnvelope.errorLanguage=en_US&scope=EXPRESS_CHECKOUT,REFUND&callback=http://my/callback"

When I make that request, I get back "Invalid request parameter scope with value EXPRESS_CHECKOUT,REFUND"

like image 617
mikesir87 Avatar asked Jul 16 '12 13:07

mikesir87


2 Answers

If you're using their JSON API, scope can be an array.

like image 44
David Badley Avatar answered Oct 09 '22 13:10

David Badley


Ok. Found the answer randomly. The scope variables must be set using "scope(0)=SCOPE_1&scope(1)=SCOPE_2..."

So, the cURL request would look like this...

curl -s --insecure -H 
"X-PAYPAL-SECURITY-USERID: API_USERNAME" 
-H "X-PAYPAL-SECURITY-PASSWORD: API_PASSWORD" 
-H "X-PAYPAL-SECURITY-SIGNATURE: API_SIGNATURE" 
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" 
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" 
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" 
https://svcs.sandbox.paypal.com/Permissions/RequestPermissions -d 
"requestEnvelope.errorLanguage=en_US&scope(0)=EXPRESS_CHECKOUT&scope(1)=REFUND&callback=http://my/callback"
like image 90
mikesir87 Avatar answered Oct 09 '22 14:10

mikesir87