嗨,我正在用 php 编写的网站出现问题。我试图让 Paypal 接受用户输入的金额。但在重定向到 paypal 时它不接受,金额为空白。这可能与否。
这是我的表格
<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";
}
}
?>