PayPal Pro Payment Integration in PHP

 If you are using PayPal Payments Pro, then you will need to provide your web design company with the following details.
• API username
• signature
• password
Please note that this is different to your PayPal account details. The details you use to login to Paypal’s website to access your accounts is separate to the API details you need to provide your web designer. Please do not email or provide your account details to your web design company as the information is confidential.
Contrary to what some may think, the API details are not provided by PayPal to start with. Instead, the PayPal account holder is required to generate this information by logging on to their account on PayPal’s website.
Following are the instructions on how to obtain API details as per their user guide:

Creating API Signature for PayPal Pro Website Payments

An API signature consists of an API username along with an associated API password and signature, all of which are assigned by PayPal. This information needs to be supplied with all transaction requests made by your website.
You must have a PayPal Business account to create a signature.
To create an API signature:
1. Log into PayPal, then click Profile under My Account.
2. Click API Access.
3. Click Request API Credentials.
4. Check Request API signature and click Agree and Submit.


$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('Authorization');    // or 'Sale'
$firstName = urlencode('customer_first_name');
$lastName = urlencode('customer_last_name');
$creditCardType = urlencode('customer_credit_card_type');
$creditCardNumber = urlencode('customer_credit_card_number');
$expDateMonth = 'cc_expiration_month';
// Month must be padded with leading zero
$padDateMonth = urlencode(str_pad($expDateMonth, 2, '0', STR_PAD_LEFT));

$expDateYear = urlencode('cc_expiration_year');
$cvv2Number = urlencode('cc_cvv2_number');
$address1 = urlencode('customer_address1');
$address2 = urlencode('customer_address2');
$city = urlencode('customer_city');
$state = urlencode('customer_state');
$zip = urlencode('customer_zip');
$country = urlencode('customer_country');    // US or other valid country code
$amount = urlencode('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));
}

?>




2 comments:

  • Thanks for sharing. You can use our code of SMS API PHP for SMS notifications, signup messages, alert, reminder, and OTP. Make sure you have read developer guide that helps you to do SMS API integration into websites/applications/software in this language.

Post a Comment