What is paypal pro?
Paypal pro is the Direct Credit Card processing API that allows you to checkout with credit card payments via PayPal directly on your site. The customer enters their credit card details on your site, never has to leave your site and PayPal handles the payment.
Direct Payment API Introduction (By Paypal)
Source : https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside
Direct Payment API offers you direct credit card payment processing capability through PayPal. For credit card transactions, customers stay on your website as PayPal processes the payment in the background.
By integrating Direct Payment API with Express Checkout, as part of the Website Payments Pro solution, you can accept all major payment types, including PayPal, while working with a single provider that processes and manages all your online payments for you.
Direct Payment API is:
Customizable
- Direct Payment API lets you design and host your own checkout pages
- You keep your customers on your site instead of having them pay on PayPal; PayPal remains invisible
- PayPal authorizes transactions in a real-time process
Easy to implement
- Direct Payment API is already integrated with many leading shopping carts
- The API is built using the Name-Value Pair infrastructure, an industry standard that utilizes web services
- PayPal’s SDK toolkit lets you easily integrate the PayPal API into your website
Secure
- Transactions are sent over the internet using Secure Socket Layer (SSL)
- Direct Payment API lets you flag potentially fraudulent transactions, and provides you with industry-standard AVS and CVV2 responses for each transaction
- You use an API certificate, provided by PayPal, to make calls to the API through a secure connection
How it works
For each payment, Direct Payment API takes the billing address, transaction amount, credit card information, and item information as inputs. Within seconds, the API returns a confirmation that the transaction has been processed.
Please note: Direct Payment API is not a stand-alone product. You are required to use Direct Payment API and Express Checkout together as part of the Website Payments Pro solution.
Here is the code:
Click here to download this code
paypal component for cakephp
- <?php
- echo “<pre>”;
- $environment = ‘sandbox’; // ‘sandbox’ or ‘beta-sandbox’ or ‘live’
- function PPHttpPost($methodName_, $nvpStr_) {
- global $environment;
- // Set up your API credentials, PayPal end point, and API version.
- $API_UserName = urlencode(‘API User Name here’); // set your spi username
- $API_Password = urlencode(‘API Passwrd Here ‘); // set your spi password
- $API_Signature = urlencode(‘API Signature here’); // set your spi Signature
- $API_Endpoint = “https://api-3t.paypal.com/nvp”;
- if(“sandbox” === $environment || “beta-sandbox” === $environment) {
- $API_Endpoint = “https://api-3t.$environment.paypal.com/nvp”;
- }
- $version = urlencode(‘51.0’);
- // Set the curl parameters.
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- // Turn 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);
- // Set the API operation, version, and API signature in the request.
- $nvpreq = “METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_”;
- // Set the request as a POST FIELD for curl.
- curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
- // Get response from the server.
- $httpResponse = curl_exec($ch);
- if(!$httpResponse) {
- exit(“$methodName_ failed: “.curl_error($ch).‘(‘.curl_errno($ch).‘)’);
- }
- // Extract the response details.
- $httpResponseAr = explode(“&”, $httpResponse);
- $httpParsedResponseAr = array();
- foreach ($httpResponseAr as $i => $value) {
- $tmpAr = explode(“=”, $value);
- if(sizeof($tmpAr) > 1) {
- $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
- }
- }
- if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists(‘ACK’, $httpParsedResponseAr)) {
- exit(“Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.”);
- }
- return $httpParsedResponseAr;
- }
- // Set request-specific fields.
- $paymentType = urlencode(‘Sale’); // ‘Authorization’ or ‘Sale’
- $firstName = urlencode($_POST[‘customer_first_name’]);
- $lastName = urlencode($_POST[‘customer_last_name’]);
- $creditCardType = urlencode($_POST[‘customer_credit_card_type’]);
- $creditCardNumber = urlencode($_POST[‘customer_credit_card_number’]);
- $expDateMonth = $_POST[‘cc_expiration_month’];
- // Month must be padded with leading zero
- $padDateMonth = urlencode(str_pad($expDateMonth, 2, ‘0’, STR_PAD_LEFT));
- $expDateYear = urlencode($_POST[‘cc_expiration_year’]);
- $cvv2Number = urlencode($_POST[‘cc_cvv2_number’]);
- $address1 = urlencode($_POST[‘customer_address1’]);
- $address2 = urlencode($_POST[‘customer_address2’]);
- $city = urlencode($_POST[‘customer_city’]);
- $state = urlencode($_POST[‘customer_state’]);
- $zip = urlencode($_POST[‘customer_zip’]);
- $country = urlencode($_POST[‘customer_country’]); // US or other valid country code
- $amount = urlencode($_POST[‘example_payment_amuont’]);
- $currencyID = urlencode(‘USD’); // or other currency (‘GBP’, ‘EUR’, ‘JPY’, ‘CAD’, ‘AUD’)
- // Add request-specific fields to the request string.
- $nvpStr = “&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber”.
- “&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName”.
- “&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID”;
- // Execute the API operation; see the PPHttpPost function above.
- $httpParsedResponseAr = PPHttpPost(‘DoDirectPayment’, $nvpStr);
- if(“SUCCESS” == strtoupper($httpParsedResponseAr[“ACK”]) || “SUCCESSWITHWARNING” == strtoupper($httpParsedResponseAr[“ACK”])) {
- exit(‘Direct Payment Completed Successfully: ‘.print_r($httpParsedResponseAr, true));
- } else {
- exit(‘DoDirectPayment failed: ‘ . print_r($httpParsedResponseAr, true));
- }
- ?>
Source : paypal.com ,mmtutorialvault.com, google search