我正在动态调整我的Paypal按钮,但是当点击“订阅”按钮时,我收到来自Paypal的错误:“调度错误,请检查日志文件以获取更多信息”。
我用来生成按钮的代码:
<form id="suf" onsubmit="return newUser();" action="<?php echo $PPBtnURL; ?>" method="POST">
<?php
$form = array();
$form['business']=$PPbtnUser;
$form['itemname']=$_POST['item_name'];
$form['itemnumber']=$_POST['item_number'];
$form['currency_code']="USD";
$skip_a2 = ($res['a2'] <= $res['a1']);
foreach($res as $k=>$v){
if($skip_a2 && ($k == "a2" || $k=="p2" || $k=="t2")){continue;}
if($k == "trial1" || $k == "trial2"){continue;}
$form[$k]=$v;
}
$form['src']=1;
$form['rm']=2;
$form['return']="https://www.mysite.com/signup2.php";
$form['cancel_return']="https://www.mysite.com/";
$form['bname']=$_POST['bname'];
$form['fname']=$_POST['fname'];
$form['lname']=$_POST['lname'];
$form['pwone']=$_POST['pwone'];
$form['pwtwo']=$_POST['pwtwo'];
$encrypted = paypal_encrypt($form);
function paypal_encrypt($hash){
global $MY_KEY_FILE;
global $MY_CERT_FILE;
global $PAYPAL_CERT_FILE;
global $OPENSSL;
// private key file to use
$MY_KEY_FILE = "/home/mysite/mysite.com/prvkey.pem";
// public certificate file to use
$MY_CERT_FILE = "/home/mysite/mysite.com/a62ecbe3015a2165c8859b953753038a-pubcert.pem";
// Paypal's public certificate
$PAYPAL_CERT_FILE = "/home/mysite/mysite.com/paypal_cert.pem";
// path to the openssl binary
$OPENSSL = "/usr/bin/openssl";
if (!file_exists($MY_KEY_FILE)) {
echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
}
if (!file_exists($MY_CERT_FILE)) {
echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
}
if (!file_exists($PAYPAL_CERT_FILE)) {
echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
}
//Assign Build Notation for PayPal Support
$hash['bn']= 'StellarWebSolutions.PHP_EWP2';
$data = "";
foreach ($hash as $key => $value) {
if ($value != "") {
$data .= "$key=$value\n";
}
}
$openssl_cmd = "($OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " .
"-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " .
"$OPENSSL smime -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE";
exec($openssl_cmd, $output, $error);
if(!$error){
return implode("\n",$output);
}else{
return "ERROR: encryption failed";
}
};
?>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="<?PHP echo $encrypted; ?>">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
我按照步骤使用了大部分示例代码here。
可能导致此错误的原因是什么?我没有PHP的错误。
奖金问题:Paypal指的是什么日志文件?
答案 0 :(得分:2)
现在已经晚了,但是如果它有帮助:我在遵循相同的教程后遇到了同样的错误,虽然我无法在代码中看到问题,但我发现每当有任何问题我都会收到此错误将$表单传递给PayPal不喜欢的paypal_encrypt()。
tl; dr:$ form中的无效数据可以触发这个&#34;有用的&#34;错误
另外,请注意,您将数据从$ _POST直接传递到$ openssl_cmd而不转义它。