我已经为CreateRecurringPaymentsProfile嵌入了这个代码,但是当我把这个代码放在expresscheckout模块(paypalwpp.php)中然后在付款后返回到网站它显示空白页面可以解决这个问题,这里是代码。
if(isset($_SESSION['r'])){
$t = $_SESSION['paypal_ec_token'];
$amount = $_SESSION['total_amount'];
$frequency = $_SESSION['r'];
$d = date('c');
$token = urlencode("$t");
$paymentAmount = urlencode($amount);
$currencyID = urlencode("USD");
$startDate = urlencode("$d");
$billingPeriod = urlencode("Week");
$billingFreq = urlencode($frequency);
$nvpStr="&TOKEN=$token&AMT=$paymentAmount&CURRENCYCODE=$currencyID&PROFILESTARTDATE=$startDate";
$nvpStr .= "&BILLINGPERIOD=$billingPeriod&BILLINGFREQUENCY=$billingFreq";
$nvpStr .= "&DESC=Recurring Payment";
$httpParsedResponseAr = self::PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
$profile_id = $httpParsedResponseAr['PROFILEID'];
$profile_id = str_replace("%2d","-",$profile_id);
$q = mysql_query("insert into recurring_profiles(profile_id) values('$profile_id')") or die(mysql_error());
$recu_id = mysql_insert_id();
if($q){
unset($_SESSION['total_amount']);
$_SESSION['s'] = true;
$_SESSION['recu_id'] = $recu_id;
}
else{
echo "<h1>Sorry PROFILEID ERROR";
}
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($httpParsedResponseAr, true));
}
else {
//echo "<br/><h1>Problem Occurs please shop again sorry for this inconvinence<br/>";
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
}
}
答案 0 :(得分:1)
我尝试了一些默认的好值,并且机制有效。显然,如果您有一个空白页面,则其中一个条件出现故障,或者其中一个查询出现错误。
您应该允许注释并添加更多调试。
$httpParsedResponseAr = self::PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
/* check this when it comes from paypal or not. */
echo "<pre>";
print_r($httpParsedResponseAr);
echo "</pre>";
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"])
|| "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
$profile_id = $httpParsedResponseAr['PROFILEID'];
$profile_id = str_replace("%2d","-",$profile_id);
/* this query might be broke. Mabye there is no table to insert into.
* I mean, is this recurring_profiles a function work inside the quotes?
$q = mysql_query("insert into recurring_profiles(profile_id)
values('$profile_id')") or die(mysql_error());
*/
/* maybe this is better. There is a space at the table name and the
* (column). and you can bug check the query if if fails. */
$query = "insert into recurring_profiles (profile_id)
values('$profile_id')";
$q = mysql_query($query) or die(mysql_error() . "<br>Query: $query<br>");
$recu_id = mysql_insert_id();
if($q){
unset($_SESSION['total_amount']);
$_SESSION['s'] = true;
$_SESSION['recu_id'] = $recu_id;
}
else{
echo "<h1>Sorry PROFILEID ERROR";
}
exit('CreateRecurringPaymentsProfile Completed Successfully:'
.print_r($httpParsedResponseAr, true));
}
else {
echo "<br/><h1>Problem Occurs</h1> Please shop again sorry for this inconvinence<br/>";
exit('CreateRecurringPaymentsProfile failed: '
. print_r($httpParsedResponseAr, true));
}