Paypal Adaptive Payment Verification

Paypal adaptive payment is the case when a user pays using their Paypal account.

Adaptive Payment

Once the “proof of payment” response is received we still have one simple step to do before we end our Paypal environment, that is we still need to verify if the payment has reached to our account (seller account). By doing so we are

  • authenticating the response we are receiving
  • making sure the recipient is our account
  • check the amount and currency of payment

From the response we will need pay_key and app_id to further authenticate the payment details.

  • pay_key : this key helps to identify the payment for which you want to retrieve details.
  • app_id : the unique id of your application.

Furthermore, we will need few credentials from our account (seller account) for verification. These are the API credentials of the facilitator account. For this go to; Sandbox accounts – Dropdown facilitator account – Profile – API Credentials.

  • userid : test api username
  • password : test api password
  • signature : test api signature

Sample HttpPost request for payment verification in android,

HttpRequestBody

  • Namevaluepair body

private static List<NameValuePair> verifypairs() {

List<NameValuePair> pair = new ArrayList<NameValuePair>();

pair.add(new BasicNameValuePair(“payKey”, “”+paykey));

pair.add(new BasicNameValuePair(“requestEnvelope.errorLanguage”, “en_US”));

return pair;

}

  • JSON body

JSONObject jsonObjDasUser = new JSONObject();

JSONObject jsonObj = new JSONObject()

try

{

jsonObj.put(“errorLanguage”,”en_US”);

jsonObjDasUser .put(“requestEnvelope”, jsonObj);

jsonObjDasUser .put(“payKey”, “”+paykey);

}

catch (JSONException e)

{

e.printStackTrace();

}

HttpPost Url

HttpPost Header

post.setHeader(“X-PAYPAL-SECURITY-USERID”, “<API Username>”);

post.setHeader(“X-PAYPAL-SECURITY-PASSWORD”, “<API Password>”);

post.setHeader(“X-PAYPAL-SECURITY-SIGNATURE”, “<API Signature>”);

post.setHeader(“X-PAYPAL-REQUEST-DATA-FORMAT”, “<Request_format>”);

post.setHeader(“X-PAYPAL-RESPONSE-DATA-FORMAT”, “<Response_format>”);

post.setHeader(“X-PAYPAL-APPLICATION-ID”, “<App_ID>”);

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s