I have a PayPal business account. I generated an API username, password, and signature, and copied some PHP code from a previously-made website that would process payment fields on a form.
In the previously-made website, everything runs fine, to this day. However, in this new website, as long as the credit card number is valid, I can make up a name, input the wrong expiration date, input a bogus card security code, and make up an address, and the payment still goes through! I see my PayPal balance increase, and I also see the charge on my credit card! I'm not using the sandboxed environment at the moment.
How can that be possible? Also, perhaps worth noting, the charge comes up on my credit card's pending transactions as some irrelevant business, "Sally Beauty Supply." Nowhere in my code have I written these words! I tried both an American Express and a Visa Card.
Here's my code. Everything is copied from the previously-made website, except where noted by <REPLACED>
. Code has been simplified a little bit.
$paypal = array(
'version' => '85.0',
'endpoint' => 'https://api-3t.paypal.com/nvp',
'username' => '<REPLACED>',
'password' => '<REPLACED>',
'signature' => '<REPLACED>',
);
$request_params = array
(
'METHOD' => 'DoDirectPayment',
'USER' => $paypal['username'],
'PWD' => $paypal['password'],
'SIGNATURE' => $paypal['signature'],
'VERSION' => $paypal['version'],
'PAYMENTACTION' => 'Sale',
'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
'ACCT' => $_POST['form_PaymentCardNumber'],
'EXPDATE' => $_POST['form_PaymentCardExpiryMonth'].$_POST['form_PaymentCardExpiryYear'],
'CVV2' => $_POST['form_PaymentCardCVV2'],
'FIRSTNAME' => $_POST['form_PaymentFirstName'],
'LASTNAME' => $_POST['form_PaymentLastName'],
'STREET' => $_POST['form_PaymentAddressLine1'],
'STREET2' => $_POST['form_PaymentAddressLine2'],
'CITY' => $_POST['form_PaymentCity'],
'STATE' => $_POST['form_PaymentStateProvince'],
'COUNTRYCODE' => $_POST['form_PaymentCountry'],
'ZIP' => $_POST['form_PaymentZipPostalCode'],
'AMT' => $_POST['form_PaymentAmount'],
'CURRENCYCODE' => 'USD',
'DESC' => "<REPLACED>"
);
$nvp_string = '';
foreach($request_params as $var=>$val)
{
$nvp_string .= '&'.$var.'='.urlencode($val);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_URL, $paypal['endpoint']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
$result = curl_exec($curl);
curl_close($curl);
function NVPToArray($str)
{
$proArray = array();
while(strlen($str))
{
// name
$keypos= strpos($str,'=');
$keyval = substr($str,0,$keypos);
// value
$valuepos = strpos($str,'&') ? strpos($str,'&'): strlen($str);
$valval = substr($str,$keypos+1,$valuepos-$keypos-1);
// decoding the respose
$proArray[$keyval] = urldecode($valval);
$str = substr($str,$valuepos+1,strlen($str));
}
return $proArray;
}
$result = NVPToArray($result);
$paid = false;
if (strtoupper($result['ACK']) === 'SUCCESS' ||
strtoupper($result['ACK']) === 'SUCCESSWITHWARNING')
{
$paid = true;
}
Should I not have copied 'version' => '85.0'
and/or 'endpoint' => 'https://api-3t.paypal.com/nvp'
? Or, what is it?