Archived Forum Post

Index of archived forum posts

Question:

Request for Paypal oAuth Example

Apr 18 '13 at 05:33

Hi Matt,

Can you please craft an example for me of how to use your HTTP library with the new Paypal oAuth/Rest payment gateway. All of the PayPal examples are written in cURL. The site for PayPal is developer.paypal.com

Thanks,

Erik

Step 1 - Access Token

curl https://api.sandbox.paypal.com/v1/oauth2/token 
 -H "Accept: application/json" 
 -H "Accept-Language: en_US" 
 -u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" 
 -d "grant_type=client_credentials"

Step 2 - Make API call

curl -v https://api.sandbox.paypal.com/v1/payments/payment 
-H "Content-Type:application/json" 
-H "Authorization:Bearer EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG" 
-d '{
  "intent": "sale",
  "payer": {
    "payment_method": "credit_card",
    "funding_instruments": [
      {
        "credit_card": {
          "number": "5500005555555559",
          "type": "mastercard",
          "expire_month": 12,
          "expire_year": 2018,
          "cvv2": 111,
          "first_name": "Joe",
          "last_name": "Shopper"
        }
      }
    ]
  },
  "transactions": [
    {
      "amount": {
        "total": "7.47",
        "currency": "USD"
      },
      "description": "This is the payment transaction description."
    }
  ]
}'