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.
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.
- 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.
- 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.
getRequest.setHeader(“Authorization”, “Bearer <access_token>”);
- For SandBox Mode:
PAY_KEY : The payment_id received earlier in response of credit card payment.
Sample 16 digit Visa card numbers :