Archive

Archive for the ‘Paypal’ Category

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

Paypal Signature Method

Steps for accessing Paypal API Signature method

1. Choose Account type, as Website Payments Pro and create a Business account.

2. Log in to a Business account.

3. Click the Profile tab in the My Account sub-menu.

4. click Request API credentials under the Account Information header.

5. On the Request API Credentials page, click Set up PayPal API credentials and permissions link in the left-hand side box.

6. From the API Access page, click View API Signature link in the right-hand side box.

7. Save API Username, API Password, API Signature.

Setting Up PayPal DirectPayment

To set up your direct credit card payments, you will need to attach your PayPal account information.
Insert your PayPal information for the following:

API Username
API Password
API Signature

(For Front End- Fields Required to pay)
————————————————
Credit Card Type
Credit Card Number
Credit Card Expiry Date
Credit Card Verification Number

PHP Code for a Signature-Based Integration

<?php

$ch = curl_init();

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

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POST, 1);

//include your API Signature, API Password ,API Username
$nvpStr =”METHOD=DoDirectPayment&VERSION=64.0&SIGNATURE=API_Signature&PWD=API_Password&USER=API_Username&PAYMENTACTION=Sale&AMT=1.00&CREDITCARDTYPE=Visa&ACCT=4696479023299289&EXPDATE=092016&CVV2=962&FIRSTNAME=sasi&LASTNAME=Doe&STREET=1MainSt&CITY=SanJose&STATE=CA&ZIP=95131&COUNTRYCODE=US&CURRENCYCODE=USD”;

curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpStr);

$response = curl_exec($ch);

?>

Categories: Paypal, PHP