I was editing the PayFlow Pro example API by Radu Manole (can't find link right now - check PDN forums) to add more fields to the authorization function and decided to redo this part:
// body of the POST $plist = 'USER=' . $this->user . '&'; $plist .= 'VENDOR=' . $this->vendor . '&'; $plist .= 'PARTNER=' . $this->partner . '&'; $plist .= 'PWD=' . $this->password . '&'; $plist .= 'TENDER=' . 'C' . '&'; $plist .= 'TRXTYPE=' . 'A' . '&'; $plist .= 'ACCT=' . $card_number . '&'; $plist .= 'EXPDATE=' . $card_expire . '&'; $plist .= 'NAME=' . $card_holder_name . '&'; $plist .= 'AMT=' . $amount . '&'; // amount $plist .= 'CURRENCY=' . $currency . '&'; $plist .= 'VERBOSITY=MEDIUM';
to something a little nicer with max field sizes and the rest of the fields I needed:
$plist = array( 'USER' => $this->user, 'VENDOR' => $this->vendor, 'PARTNER' => $this->partner, 'PWD' => $this->password, 'TENDER' => 'C', 'TRXTYPE' => 'A', 'ACCT' => $card_number, 'EXPDATE' => $card_expire, 'AMT' => $amount, 'CURRENCY' => $currency, 'VERBOSITY' => 'MEDIUM', 'CVV2' => substr($cvv2,0,4), 'FIRSTNAME' => substr($first_name,0,25), 'LASTNAME' => substr($last_name,0,25), 'STREET' => substr($street,0,100), 'STREET2' => substr($street2,0,100), 'CITY' => substr($city,0,40), 'STATE' => substr($state,0,40), 'COUNTRYCODE' => substr($country_code,0,2), 'ZIP' => substr($zip,0,20), 'PHONENUM' => substr($phone_num,0,20), 'SHIPTONAME' => substr($ship_name,0,32), 'SHIPTOSTREET' => substr($ship_street,0,100), 'SHIPTOSTREET2' => substr($ship_street2,0,40), 'SHIPTOCITY' => substr($ship_city,0,40), 'SHIPTOSTATE' => substr($ship_state,0,40), 'SHIPTOZIP' => substr($ship_zip,0,20), 'SHIPTOCOUNTRYCODE' => substr($ship_country_code,0,2), 'IPADDRESS' => $ip_address, 'DESC' => $order_id );
I figured this was the only change I needed to make because CURLOPT_POSTFIELDS can take a name=>value pair. However, PayPal started returning blank responses. While double checking that I could use an array, I saw this post: PHP curl_setopt comment To summarize in case the post disappears,
using CURLOPT_POSTFIELDS with array encoding is: multipart/form-data
using CURLOPT_POSTFIELDS with string encoding is: application/x-www-form-urlencoded
That turned out to be the problem so I used http_build_query($plist) for the CURLOPT_POSTFIELDS.