您好我正在使用php写一个网站的问题。我正在尝试让Paypal接受用户输入金额。但它不接受重定向到PayPal金额是空白的。这可能与否。< / p>
这是我的表格
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target=_blank>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="<?PHP echo $encrypted; ?>">
<div class="paypal_list2">
<input type="hidden"><h3>Enter the amount</h3><br /> </div>
<input id="total" class="paypal_input_1" type="text" value="" name="amount">
<input class="paypal_btn" type="image"src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>
这是我的PHP代码
<?php
$MY_KEY_FILE = "/home/khader/smsmobilebase/certs/private-key.pem";
$MY_CERT_FILE = "/home/khader/smsmobilebase/certs/publi-cert.pem";
$PAYPAL_CERT_FILE = "/home/khader/smsmobilebase/certs/paypal_cert_pem.txt";
$OPENSSL = "/usr/bin/openssl";
$form = array('cmd' => '_xclick','business' => 'roki_1347003608_biz@gmail.com','cert_id' => '6BPQP9KEEBCJ6','currency_code' => 'USD',
'no_shipping' => '1',
'item_name' => 'PayNow',
'cancel_return' => 'http://mobiletool.xichlomobile.com/',
'amount' => "'$amount'"
);
$encrypted = paypal_encrypt($form);
function paypal_encrypt($hash)
{
global $MY_KEY_FILE;
global $MY_CERT_FILE;
global $PAYPAL_CERT_FILE;
global $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";
}
$data = "";
foreach ($hash as $key => $value) {
if ($value != "") {
//echo "Adding to blob: $key=$value\n";
$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);
print $hash;
} else {
return "ERROR: encryption failed";
}
}
?>
答案 0 :(得分:0)
您只需跳过表单中的amount
字段或其值即可。
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me@mybusiness.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Teddy Bear">
<input type="hidden" name="amount" value="">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
这将要求您的用户输入金额!