Paypal REST API Verification

The REST Api for Paypal payment is used when the payment is made from a source other than Paypal account i.e.  using a Credit Card information.

Credit Card Payment

Before we verify credit card payments, there are few steps we should do to make REST Api available for our app.

  • Get Access Token for your App
  • Making sure the recipient is our account
  • Check the account and currency of Payment

Access token helps Paypal authenticate our app account and at the same time uniquely identify transactions.

    1. Getting Access Token
      This is an authorization key provided by Paypal to our app, we need to use this token whenever we want to verify credit card payment made in Paypal. To learn an stepwise process to gain access token and understand more about this visit Get an access token.
    2. Make REST Api call
      Once we have the access token it is quiet a simple task to verify transactions made through credit card on our app. Here is a sample code to make the get request of our verification api call.
      The “proof of payment” in credit card payment response will include “rest_api” key value pair the fields within this will we used along with our access token to verify payment.

      • state : The state of payment, is approved if the payment has been made from the user’s account.
      • payment_id : The Payment Id of the transaction, against we will check transaction completion in our account.

      Sample Code

      HttpGet Header

      getRequest.setHeader(“Content-Type”, “application/json”);

      getRequest.setHeader(“Authorization”, “Bearer <access_token>”);

      HttpGet Url

Note : We need to check the state for being approved and the Sale state to be completed to verify a complete transaction.
To test using sample credit card numbers in Sandbox mode :
Use Visa Card number adhering Luhn algorithm, set any valid expiration date and a neutral CVV code preferably 000.
Sample 16 digit Visa card numbers :
Visit for more sample credit card numbers : Darkcoding or CCsamples.

3 thoughts on “Paypal REST API Verification

  1. Ralry Ong says:

    hi fren, for this example, after testing,
    i get error as below
    {“name”:”INVALID_RESOURCE_ID”,”message”:”The requested resource ID was not found”,”information_link”:””,”debug_id”:”57500ff03384d”}
    are u know that what this error mean and how to solve this ?

    thank you.

    • Shilu Shrestha says:

      Hey Ralry,
      Sorry for a very late reply. But for the sake of other readers who might read this. The Id you are using for your call is incorrect.
      There are different APIs now for transaction like “auth”, “sale”, “capture” etc. You’ll have to use specific Id for the specific type of transaction here.
      Alot of have changed since this blog in Paypal integration, will update the blog post soon on this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s