Question

I've been banging my head enough:

I'm writing an Android app that will receive PayPal payments. So I'm using this.

In Java code for the Android app you'd find:

intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, PaymentActivity.ENVIRONMENT_NO_NETWORK);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "LARGE STRING AKA Client ID");
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "The email of the paying girl");
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, "The email I registered at PayPal");
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);

in the onActivityResult I get this JSON:

{
  "payment": {
    "short_description": "Donation to Saving The Amazon",
    "amount": "5",
    "currency_code": "USD"
  },
  "client": {
    "platform": "Android",
    "paypal_sdk_version": "1.2.5",
    "product_name": "PayPal Android SDK; ",
    "environment": "mock"
  },
  "proof_of_payment": {
    "adaptive_payment": {
      "timestamp": "2014-02-09T22:44:45+0000",
      "payment_exec_status": "COMPLETED",
      "app_id": "_FAKE_APPLICATION_ID_",
      "pay_key": "AP-70M68096ML426802W"
    }
  }
}

Now, I need to verify the payment. I'm supposed to make a request (from my server) that looks like this:

curl https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails \
 -H "X-PAYPAL-SECURITY-USERID: {userId}" \
 -H "X-PAYPAL-SECURITY-PASSWORD: {password}" \
 -H "X-PAYPAL-SECURITY-SIGNATURE: {signature}" \
 -H "X-PAYPAL-APPLICATION-ID: {appId}" \
 -H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
 -H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
 -d "payKey={payKey}
     &requestEnvelope.errorLanguage=en_US"

The PayPal page says I can find the userId the password and the signature here whereas I only find an API Username, an API Password and the signature. I've replaced userId with the value in API Username and password with the value in API Password (and obviously signature with the value). The payKey I take it from the proof_of_payment and the appId from an app I had to create here. Which is a different from the one I created here. Is this right?

Edit: My request now looks like this: (omitting some parts of the values)

curl https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails \
 -H "X-PAYPAL-SECURITY-USERID: info_api1.test.com" \
 -H "X-PAYPAL-SECURITY-PASSWORD: XXNXXXA6XXX3PGXX" \
 -H "X-PAYPAL-SECURITY-SIGNATURE: XXXXXvXXXXXqXXXXXm1XXXXXg3fOAuds4mc3XXXXXXXXJdy4XXXXXXqX" \
 -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" \
 -H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
 -H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
 -d "payKey=AP-70M68096ML426802W
     &requestEnvelope.errorLanguage=en_US"

After all this, PayPal is happy to tell me:

responseEnvelope.timestamp=2014-02-09T15%3A37%3A37.559-08%3A00&responseEnvelope.ack=Failure&responseEnvelope.correlationId=33628be038bc5&responseEnvelope.build=9641252&error(0).errorId=520003&error(0).domain=PLATFORM&error(0).subdomain=Application&error(0).severity=Error&error(0).category=Application&error(0).message=Authentication+failed.+API+credentials+are+incorrect.

I just can't get the information necessary to verify this payment. What I'm I doing wrong?

Was it helpful?

Solution

I pulled the logs for your error and you are not using the correct API credentials. It appears that you are using your Live account credentials as the API username you are using is not present in the Sandbox. The API credentials you should be using would be from your sandbox account that you used as the receiver in your Android SDK. This is most likely the -facilitator email address. You can find the API credentials for that account with the following steps:

  1. login to developer.paypal.com
  2. click applications tab
  3. click sandbox accounts on left menu
  4. click triangle to expand account section for -facilitator email address
  5. click profile link
  6. select the API Credentials tab

OTHER TIPS

The PayKey and App ID are different things. The App ID is what you get when you apply for the Adaptive Payments app and get it approved. It gets sent in the header along with your API Isername, API Password, and API Signature. You've even got a placeholder there for it in the sample you supplied.

The PayKey would be the key you get back after making the Pay request. It's sort of like a transaction ID. It's usually just something that comes back in a response, but if you're making a call to ExecutePayment, for example, you would include it in the request...but as a PayKey parameter...not app id.

The error you're getting simply means that your API un/pw/sig value(s) are incorrect. In many cases this just means you're sending sandbox credentials to the live PayPal endpoint or visa-verse. Double check that, and double check the actual values themselves. Also, make sure to get the App ID included in the header instead of the request body.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top