Home > Paypal, PHP > Paypal Certification Method

Paypal Certification Method

  1. Create a paypal developer account and login thru,https://developer.paypal.com/
  2. Click Test Accounts->Preconfigured
  3. Select Website Payments Pro (Use to represent yourself as a merchant using Pro) option & enter the amount and click Create Account button.
  4. Now select the radio button near the account created and click Enter Sandbox Site.
  5. Another window opens and login with the password given during creation of WPP
  6. Click My Account -> Profile -> Request API credentials -> Set up PayPal API credentials and permissions -> View API Certificate
  1. Download the file(cert_key_pem.txt) and paste it in the same or in appropriate folder.
  2. Once downloaded,Add the certificate and credentials in the code as follows,
<?phpini_set(‘display_errors’,’on’);/*

//Signature Method

//====================

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,”https://api-3t.sandbox.paypal.com/nvp&#8221;);

curl_setopt($ch, CURLOPT_VERBOSE, 1);

//turning off the server and peer verification(TrustManager Concept).

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POST, 1);

$nvpStr =”METHOD=doDirectPayment&VERSION=65.1&PWD=1255077037&USER=platfo_1255077030_biz_api1.gmail.com&SIGNATURE=Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf&PAYMENTACTION=Sale&AMT=1.00&CREDITCARDTYPE=Visa&ACCT=4670575402674487&EXPDATE=012012&CVV2=962&FIRSTNAME=John&LASTNAME=Doe&STREET=1+Main+St&CITY=San+Jose&STATE=CA&ZIP=95131&COUNTRYCODE=US&CURRENCYCODE=USD”;

curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpStr);

$response = curl_exec($ch); */

//Certification Method

//====================

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,”https://api.sandbox.paypal.com/nvp&#8221;);

//turning off the server and peer verification(TrustManager Concept).

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POST, 1);

$nvpStr =”METHOD=DoDirectPayment&VERSION=64.0&PWD=BQX4XKVGCEHB8X5Q&USER=vimala_1317117442_biz_api1.gmail.com&PAYMENTACTION=Sale&AMT=1.00&CREDITCARDTYPE=Visa&ACCT=4670575402674487&EXPDATE=012012&CVV2=962&FIRSTNAME=John&LASTNAME=Doe&STREET=1+Main+St&CITY=San+Jose&STATE=CA&ZIP=95131&COUNTRYCODE=US&CURRENCYCODE=USD”;

$cert_file = $_SERVER[‘DOCUMENT_ROOT’].”/users/kathir/paypalall/cert_key_pem1.txt”;

curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpStr);

curl_setopt($ch, CURLOPT_SSLCERT, $cert_file);

$response = curl_exec($ch);

$nvpResArray=deformatNVP($response);

echo “<pre>”;

print_r($nvpResArray);

echo “</pre>”;

function deformatNVP($nvpstr)

{

$intial=0;

$nvpArray = array();

while(strlen($nvpstr)){

//postion of Key

$keypos= strpos($nvpstr,’=’);

//position of value

$valuepos = strpos($nvpstr,’&’) ? strpos($nvpstr,’&’): strlen($nvpstr);

/*getting the Key and Value values and storing in a Associative Array*/

$keyval=substr($nvpstr,$intial,$keypos);

$valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);

//decoding the respose

$nvpArray[urldecode($keyval)] =urldecode( $valval);

$nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));

}

return $nvpArray;

}

?>


Advertisements
Categories: Paypal, PHP
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: