2013-04-27 36 views
0

我已經爲CreateRecurringPaymentsProfile嵌入了此代碼,但是當我將此代碼放入expresscheckout模塊(paypalwpp.php)後付款返回到網站後,它顯示空白頁面,任何一個解決此問題的代碼均可。zencart中的快速結帳模塊

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)); 

    } 

    } 

回答

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)); 
    }