cancel
Showing results for 
Search instead for 
Did you mean: 

Hello I want use paypal pro for php

Member

Hello I want use paypal pro for php

I am using api for sandbox https://api-3t.sandbox.paypal.com/nvp. can you give proper reference URL ? 

 

I am using This curl for paypal pro so is it right way ?

 

Please give me proper guidance for paypal pro integration. and when i  use DOVOID Method then i can get response that " 

You do not have permissions to make this API call

" what is this solution

 

<?php
$sandbox = TRUE;

// Set PayPal API version and credentials.
$api_version = '85.0';
$api_endpoint = $sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
$api_username = $sandbox ? 'SANDBOX_USERNAME_GOES_HERE' : 'LIVE_USERNAME_GOES_HERE';
$api_password = $sandbox ? 'SANDBOX_PASSWORD_GOES_HERE' : 'LIVE_PASSWORD_GOES_HERE';
$api_signature = $sandbox ? 'SANDBOX_SIGNATURE_GOES_HERE' : 'LIVE_SIGNATURE_GOES_HERE';

$request_params = array
(
'METHOD' => 'DoDirectPayment',
'USER' => $api_username,
'PWD' => $api_password,
'SIGNATURE' => $api_signature,
'VERSION' => $api_version,
'PAYMENTACTION' => 'Sale',
'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
'CREDITCARDTYPE' => $_GET['card_type'],
'ACCT' => $_GET['card_code'],
'EXPDATE' => '022022',
'CVV2' => $_GET['cvv'],
'FIRSTNAME' => 'Tester',
'LASTNAME' => 'Testerson',
'STREET' => '707 W. Bay Drive',
'CITY' => 'Largo',
'STATE' => 'FL',
'COUNTRYCODE' => 'UK',
'ZIP' => '33770',
'AMT' => '100.00',
'CURRENCYCODE' => $_GET['currency'],
'DESC' => 'Testing Payments Pro',
//'PAYMENTACTION'=>'Authorization'
);

$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);
$nvp_response_array = parse_str($result);

curl_close($curl);
echo "<pre>";
print_r(NVPToArray($result));
// $test = NVPToArray($result);
// echo $test['TRANSACTIONID'];
// $request_params = array
// (
// 'METHOD' => 'DoVoid',
// 'AUTHORIZATIONID'=>$result['TRANSACTIONID']
// );
// $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);
// $nvp_response_array = parse_str($result);

// curl_close($curl);
// echo "<pre>";
// print_r(NVPToArray($result));

function NVPToArray($NVPString)
{
$proArray = array();
while(strlen($NVPString))
{
// name
$keypos= strpos($NVPString,'=');
$keyval = substr($NVPString,0,$keypos);
// value
$valuepos = strpos($NVPString,'&') ? strpos($NVPString,'&'): strlen($NVPString);
$valval = substr($NVPString,$keypos+1,$valuepos-$keypos-1);
// decoding the respose
$proArray[$keyval] = urldecode($valval);
$NVPString = substr($NVPString,$valuepos+1,strlen($NVPString));
}
return $proArray;
}
?>