Hi I'm getting Recurring Payment Profile Details but this is not working here my all functions
Echo Profile id (I-9DEF0R5BAGTX) is showing but not working with functions
Array ( [TIMESTAMP] => 2016-10-29T13:15:39Z [CORRELATIONID] => 2b31d73fc8140 [ACK] => Failure [VERSION] => 64 [BUILD] => 24616352 [L_ERRORCODE0] => 11551 [L_ERRORCODE1] => 11552 [L_SHORTMESSAGE0] => Profile Id is missing from the request [L_SHORTMESSAGE1] => Invalid profile ID [L_LONGMESSAGE0] => Profile Id is missing from the request [L_LONGMESSAGE1] => The profile ID is invalid [L_SEVERITYCODE0] => Error [L_SEVERITYCODE1] => Error )
GetRecurringPaymentsProfileDetails API call failed. Detailed Error Message: Profile Id is missing from the requestShort Error Message: Profile Id is missing from the requestError Code: 11551Error Severity Code: Error
Paypal Library Functions
$PROXY_HOST = '127.0.0.1';
$PROXY_PORT = '808';
global $redux_demo;
$paypal_api_environment = $redux_demo['paypal_api_environment'];
$paypal_success = $redux_demo['paypal_success'];
$paypal_fail = $redux_demo['paypal_fail'];
$paypal_api_username = $redux_demo['paypal_api_username'];
$paypal_api_password = $redux_demo['paypal_api_password'];
$paypal_api_signature = $redux_demo['paypal_api_signature'];
if ( $paypal_api_environment == '1' ){
$SandboxFlag = true;
}else{
$SandboxFlag = false;
}
//'------------------------------------
//' PayPal API Credentials
//' Replace <API_USERNAME> with your API Username
//' Replace <API_PASSWORD> with your API Password
//' Replace <API_SIGNATURE> with your Signature
//'------------------------------------
$API_UserName=$paypal_api_username;
$API_Password=$paypal_api_password;
$API_Signature=$paypal_api_signature;
// BN Code is only applicable for partners
$sBNCode = "PP-ECWizard";
if ($SandboxFlag == true)
{
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=";
}
else
{
$API_Endpoint = "https://api-3t.paypal.com/nvp";
$PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
}
$USE_PROXY = false;
$version="64";
function GetProfileRecurring( $profileid )
{
//Construct the parameter string that describes GetRecurringPaymentsProfileDetails
$nvpstr = "&PROFILEID=" . $paymentAmount;
$resArray=hash_calls("GetRecurringPaymentsProfileDetails", $nvpstr);
return $resArray;
}
function hash_calls($methodName,$nvpStr)
{
//declaring of global variables
global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature;
global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
global $gv_ApiErrorURL;
global $sBNCode;
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
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);
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
if($USE_PROXY)
curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
//NVPRequest for submitting to server
$nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode);
//setting the nvpreq as POST FIELD to curl
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
//getting response from server
$response = curl_exec($ch);
//convrting NVPResponse to an Associative Array
$nvpResArray=deformatNVPs($response);
$nvpReqArray=deformatNVPs($nvpreq);
$_SESSION['nvpReqArray']=$nvpReqArray;
if (curl_errno($ch))
{
// moving to display page to display curl errors
$_SESSION['curl_error_no']=curl_errno($ch) ;
$_SESSION['curl_error_msg']=curl_error($ch);
//Execute the Error handling module to display errors.
}
else
{
//closing the curl
curl_close($ch);
}
return $nvpResArray;
}
function deformatNVPs($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;
}
Here is action Function RunProfileRecurring
add_action('wp','RunProfileRecurring');
function RunProfileRecurring(){
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM wpcads_paypal ORDER BY main_id DESC" );
if (!empty($result )){
foreach ( $result as $key => $row ) {
if ($row->pay_check == 'recurring' && $row->p_profileid != ''){
echo $row->p_profileid;
$profileid = $row->p_profileid ;
$resArray = GetProfileRecurring($profileid);
print_r($resArray);
$ack = strtoupper($resArray["ACK"]);
if( $ack == "SUCCESS" || $ack == "SUCESSWITHWARNING")
{
echo 'Response Ok' ;
}else{
//Display a user friendly Error on the page using any of the following error information returned by PayPal
$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);
$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
echo "<div>GetRecurringPaymentsProfileDetails API call failed. ";
echo "Detailed Error Message: " . $ErrorLongMsg;
echo "Short Error Message: " . $ErrorShortMsg;
echo "Error Code: " . $ErrorCode;
echo "Error Severity Code: " . $ErrorSeverityCode."</div>";
}
}else{
}
}
}
}
var_dump this is profile that i echo -> I-GS6BRWYTM2BC and this is var_dump string(218) "METHOD=GetRecurringPaymentsProfileDetails&VERSION=64&PWD=mycorrectpassword&USER=pfmmod_1360821006_biz_api1.gmail.com&SIGNATURE=mycorrectsign&PROFILEID=&BUTTONSOURCE=PP-ECWizard" Array ( [TIMESTAMP] => 2016-11-02T08:04:13Z [CORRELATIONID] => 222af821e510f [ACK] => Failure [VERSION] => 64 [BUILD] => 24616352 [L_ERRORCODE0] => 11551 [L_ERRORCODE1] => 11552 [L_SHORTMESSAGE0] => Profile Id is missing from the request [L_SHORTMESSAGE1] => Invalid profile ID [L_LONGMESSAGE0] => Profile Id is missing from the request [L_LONGMESSAGE1] => The profile ID is invalid [L_SEVERITYCODE0] => Error [L_SEVERITYCODE1] => Error )
I found what was previous error
function GetProfileRecurring( $profileid )
{
$nvpstr = "&PROFILEID=" . $paymentAmount; // replace with this $profileid
$resArray=hash_calls("GetRecurringPaymentsProfileDetails", $nvpstr);
return $resArray;
}
but now receiving new error "METHOD=GetRecurringPaymentsProfileDetails&VERSION=64&PWD=mycorrectpassword&USER=pfmmod_1360821006_biz_api1.gmail.com&SIGNATURE=mycorrectsign&PROFILEID=I-GS6BRWYTM2BC&BUTTONSOURCE=PP-ECWizard" Array ( [TIMESTAMP] => 2016-11-02T08:14:44Z [CORRELATIONID] => 31347296c48eb [ACK] => Failure [VERSION] => 64 [BUILD] => 24616352 [L_ERRORCODE0] => 10001 [L_SHORTMESSAGE0] => Internal Error [L_LONGMESSAGE0] => Internal Error [L_SEVERITYCODE0] => Error ) GetRecurringPaymentsProfileDetails API call failed. Detailed Error Message: Internal ErrorShort Error Message: Internal ErrorError Code: 10001Error Severity Code: Error