Bob Tanner
Bob Tanner

Reputation: 260

Using PayPal NVP, METHOD=DoDirectPayment, no code changes I started to get intermittent ACK=Failure

Using PayPal NVP, METHOD=DoDirectPayment, and starting the first week of August 2024, I am intermittently getting ACK=Failure in the responses. I assumed the problem was in my code but production has not changed for since March 2023.

Took the code out of my test. Tried some POSTs with curl and got similar results. Intermittent ACK=Failure.

PayPal support has been little (to no help). They keep telling me it is my code. I keep telling them I am not using code, I am using curl. Or they tell me to move to BrainTree or REST. Not helpful.

Wrote a bash script to make testing easier (and so I could post it here).

#!/bin/bash

set -e

# Check that all required variables are set
required_vars=(
  "PAYPAL_WPP_USER"
  "PAYPAL_WPP_PASSWORD"
  "PAYPAL_WPP_SIGNATURE"
  "PAYPAL_WPP_CANCEL_URL"
  "PAYPAL_WPP_RETURN_URL"
  "PAYPAL_WPP_NOTIFY_URL"
)

for var in "${required_vars[@]}"; do
  if [ -z "${!var}" ]; then
    echo "Error: $var is not set or is empty."
    exit 1
  fi
done

nvp_response=$(curl -s --insecure -X POST https://api-3t.sandbox.paypal.com/nvp \
-d "USER=${PAYPAL_WPP_USER}" \
-d "PWD=${PAYPAL_WPP_PASSWORD}" \
-d "SIGNATURE=${PAYPAL_WPP_SIGNATURE}" \
-d "VERSION=204.0" \
-d "ACCT=4111111111111111" \
-d "AMT=100.00" \
-d "CITY=Thunder Bluff" \
-d "COUNTRYCODE=US" \
-d "CREDITCARDTYPE=Visa" \
-d "CURRENCYCODE=USD" \
-d "CUSTOM=100735" \
-d "CVV2=123" \
-d "[email protected]" \
-d "EXPDATE=012032" \
-d "FIRSTNAME=Ticky" \
-d "INVNUM=20240831691803" \
-d "IPADDRESS=8.8.8.8" \
-d "ITEM_NAME=Armour" \
-d "LASTNAME=Wicky" \
-d "METHOD=DoDirectPayment" \
-d "NOTIFYURL=${PAYPAL_WPP_NOTIFY_URL}" \
-d "PAYMENTACTION=Sale" \
-d "RETURNFMFDETAILS=1" \
-d "STATE=CA" \
-d "STREET=123 Mesa Road" \
-d "ZIP=90210")

echo "$nvp_response" | tr '&' '\n' | sed 's/%2d/-/g; s/%3a/:/g; s/%20/ /g; s/%2e/./g'

# Check for 'ACK=Failure' in the response
if echo "$nvp_response" | grep -q "ACK=Failure"; then
  exit 1
else
  exit 0
fi

Wrote another script to execute the above script 100 times, with random waits between executions and here is that result.

Number of successful executions (exit 0): 46
Number of failed executions (exit 1): 54

Edit All the failures are like below

TIMESTAMP=2024-09-01T01:13:13Z
CORRELATIONID=bf3ff29941fd1
ACK=Failure
VERSION=204.0
BUILD=000000
L_ERRORCODE0=10544
L_SHORTMESSAGE0=Gateway Decline.
L_LONGMESSAGE0=This transaction cannot be processed.
L_SEVERITYCODE0=Error
AMT=100.00
CURRENCYCODE=USD

Feels like a problem on PayPal's side but they keep informing me every things is working, my account is ok, etc.

Looking for any refactoring to the script to help prove the problem is on PayPal side (or show me what is wrong on my side).

Looking for any advise on how to troubleshoot this further.

Upvotes: 0

Views: 63

Answers (1)

Preston PHX
Preston PHX

Reputation: 30457

DoDirectPayment is 20 years old. You should move to Braintree or REST. That is the best advice.

When the API call does fail there will be a long and short message describing the type of failure, which your question does not include examples of.

Despite what you may see documented, the card 4111111111111111 should not be used when testing with PayPal. It has long been known that fixed test card numbers will intermittently fail in the PayPal sandbox. Use a randomly generated card always, from any source.

Upvotes: 0

Related Questions