SALIDA
Código HTML:
Ver original
[TOKEN] => EC-663124349Y4395H [TIMESTAMP] => 2012-07-06T13:18:20Z [CORRELATIONID] => 554fcc646a0 [ACK] => Success [VERSION] => 85.0 [BUILD] => 3242673
CODIGO
Código PHP:
$request_params = array
(
'METHOD' => 'SetExpressCheckout',
'USER' => $api_username,
'PWD' => $api_password,
'SIGNATURE' => $api_signature,
'VERSION' => $api_version,
'PAYMENTACTION' => 'Sale',
'RETURNURL'=> 'http://www.midominio.com/index.php',
'CANCELURL'=> 'http://www.midominio.com/index.php',
'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
'CREDITCARDTYPE' => 'Visa',
'ACCT' => 'XXXXXXXXXXXXXXXX',
'EXPDATE' => '122021',
'CVV2' => 'XXX',
'FIRSTNAME' => 'Xxxxxx',
'LASTNAME' => 'Xxxxxx',
'STREET' => 'Xxxxxx',
'CITY' => 'Xxxxxx',
'STATE' => 'Xxxxxx',
'COUNTRYCODE' => 'PA',
'ZIP' => '33770',
'AMT' => '1.00',
'CURRENCYCODE' => 'USD',
'DESC' => 'Testing Payments Pro'
);
$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, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
$result = curl_exec($curl);
echo $result.'<br /><br />';
curl_close($curl);
$result_array = NVPToArray($result);
echo '<pre />';
print_r($result_array);
function NVPToArray($NVPString)
{
$proArray = array();
while(strlen($NVPString))
{
$keypos= strpos($NVPString,'=');
$keyval = substr($NVPString,0,$keypos);
$valuepos = strpos($NVPString,'&') ? strpos($NVPString,'&'): strlen($NVPString);
$valval = substr($NVPString,$keypos+1,$valuepos-$keypos-1);
$proArray[$keyval] = urldecode($valval);
$NVPString = substr($NVPString,$valuepos+1,strlen($NVPString));
}
return $proArray;
}