Hi I need to create Recurrent Billing with PayPal Pro.
I already completed and tested the ExpressCheckout Part.
Now need to do the DirectPay - Credit card with out redirection.
I have included the contents of a standalone demo file i use below, i used for testing DirectPay, however it always returns
Array ( [TIMESTAMP] => 2009-10-27T16:37:22Z [CORRELATIONID] => aace0727c2711 [ACK] => Failure [VERSION] => 50.0 [BUILD] => 1073465 [L_ERRORCODE0] => 10501 [L_SHORTMESSAGE0] => Invalid Configuration [L_LONGMESSAGE0] => This transaction cannot be processed due to an invalid merchant configuration. [L_SEVERITYCODE0] => Error [AMT] => 100.00 [CURRENCYCODE] => USD )
Can somebody please help ?
Also, Will I have to use an IPN notifier ?
And how does an IPN actually work ? Is that something like a Cron job that is initiated by the PayPal whenever a CCard txn is completed ?
thanks in advance.
============ ============ ============ ============ ============
<?php
/*
*/
define('PayPal_APIUser', '');
define('PayPal_APIPass', '');
define('PayPal_APISign', '');
define( 'Live', false );
class PayPalR{
private
$APIUserName = '',
$APIPassword = '',
$APISignature = '',
$APIURL = '',
$Version = '',
$CurlObj = false,
$Token = '',
$GateWay = '',
$nvpBase = ''
;
public function __construct(){
$this->APIUser = PayPal_APIUser;
$this->APIPass = PayPal_APIPass;
$this->APISign = PayPal_APISign;
$this->APIURL = Live
? 'https://api-3t.paypal.com/nvp'
: 'https://api-3t.sandbox.paypal.com/nvp'; //https://api-3t.beta-sandbox.paypal.com/nvp
$this->GateWay = Live
? 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout'
: 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout';
$this->Version = '50.0';
$this->nvpBase = 'VERSION=' . urlencode($this->Version) . '&PWD=' . urlencode($this->APIPass) . '&USER=' . urlencode($this->APIUser) . '&SIGNATURE=' . urlencode($this->APISign);
}
private function DoCURL($nvp){
# Init CURL & sent the CURL PARAMs
$curlObj = curl_init($this->APIURL);
// turning off the server and peer verification(TrustManager Concept).
curl_setopt($curlObj, CURLOPT_VERBOSE, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_POST, 1); // setting the nvpreq as POST FIELD to curl
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $nvp);
# Execute CURL request..
$httpResponse = curl_exec($curlObj);
if(!$httpResponse){
exit( 'SetExpressCheckout failed: ' . curl_error($curlObj) . ' ('.curl_errno($curlObj).')');
}
# Parse the CURL Respose to an Array
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value){
$tmpAr = explode("=", $value);
if(is_array($tmpAr)){
@$httpParsedResponseAr[$tmpAr[0]] = urldecode($tmpAr[1]);
}
}
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)){
exit("Invalid HTTP Response for POST request ($nvp) to {$this->APIURL}."

;
}
if(empty($this->Token)){
$this->Token = @$httpParsedResponseAr['TOKEN'];
}
return $httpParsedResponseAr;
}
public function GetRecurringPaymentsProfileDetails($p){
$nvpRequest = $this->nvpBase . '&METHOD=GetRecurringPaymentsProfileDetails'
. '&PROFILEID=' . urlencode($p['PROFILEID'])
;
return $this->DoCURL($nvpRequest);
}
public function DirectPay($p){
$nvpRequest = $this->nvpBase . '&METHOD=DoDirectPayment'
#. '&TOKEN=' . urlencode($p['TOKEN'])
. '&PAYMENTACTION=' . urlencode($p['PAYMENTACTION'])
. '&AMT=' . urlencode($p['AMT'])
. '&CREDITCARDTYPE=' . urlencode($p['CREDITCARDTYPE'])
. '&ACCT=' . urlencode($p['ACCT'])
. '&EXPDATE=' . urlencode($p['EXPDATE'])
. '&CVV2=' . urlencode($p['CVV2'])
. '&FIRSTNAME=' . urlencode($p['FIRSTNAME'])
. '&LASTNAME=' . urlencode($p['LASTNAME'])
. '&STREET=' . urlencode($p['STREET'])
. '&CITY=' . urlencode($p['CITY'])
. '&STATE=' . urlencode($p['STATE'])
. '&ZIP=' . urlencode($p['ZIP'])
. '&COUNTRYCODE=' . urlencode($p['COUNTRYCODE'])
. '&CURRENCYCODE=' . urlencode($p['CURRENCYCODE'])
. '&ORDERDESC=' . urlencode($p['ORDERDESC'])
. '&L_BILLINGTYPE0=' . urlencode($p['L_BILLINGTYPE0'])
. '&L_BILLINGAGREEMENTDESCRIPTION0=' . urlencode($p['L_BILLINGAGREEMENTDESCRIPTION0'])
. '&L_PAYMENTTYPE0=' . urlencode($p['L_PAYMENTTYPE0'])
;
$nvpRequest .= '&DESC=Organization Subscription';
$nvpRequest .= '&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=Organization Subscription';
return $this->DoCURL($nvpRequest);
}
}
$p = new PayPalR();
$card['PAYMENTACTION']="Sale";
$card['AMT']='100';
$card['CREDITCARDTYPE']="Visa";
$card['ACCT']="4397920706128982";
$card['EXPDATE']="022010";
$card['CVV2']="382";
$card['FIRSTNAME']="Test";
$card['LASTNAME']="User";
$card['STREET']="1 Main St";
$card['CITY']="San Jose";
$card['STATE']="CA";
$card['ZIP']="95131";
$card['COUNTRYCODE']="US";
$card['CURRENCYCODE']="USD";
$card['ORDERDESC']="ithano problem ?";
$card['L_BILLINGTYPE0']="RecurringPayments";
$card['L_BILLINGAGREEMENTDESCRIPTION0']="9.99 per month for whatever";
$card['L_PAYMENTTYPE0']="Any";
$r = $p->DirectPay($card);
print_r($r);
?>
============ ============ ============ ============ ============