I'm using the following PHP code to encrypt the billing details I'm passing to PayPal: <?php
# private key file to use
$MY_KEY_FILE = "my-prvkey.pem";
# public certificate file to use
$MY_CERT_FILE = "my-pubcert.pem";
# Paypal's public certificate
$PAYPAL_CERT_FILE = "paypal_cert.pem";
# path to the openssl binary
$OPENSSL = "/usr/bin/openssl";
$form = array(
'cmd' => '_xclick',
'cert_id' => 'HSFU5KJLFS8JD',
'business' => 'test[et]example.com',
'currency_code' => 'EUR',
'no_shipping' => '1',
'charset' => 'utf-8',
'lc' => 'DE',
'item_name' => 'My test product',
'amount' => '4.20',
'return' => 'http://www.example.com/success.php',
'cancel_return' => 'http://www.example.com/error.php',
);
$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";
}
$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";
}
};
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP Sample Donation using PayPal Encrypted Buttons</title>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="get">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value=" <?PHP echo $encrypted;?>">
<input type="submit">
</form>
</body>
</html> When clicking on the submit button I'll get redirected to PayPal and can make the payment. I can either send the form data with method="post" or method="get". If I'm using my code with `method="post"` I'm getting redirected to a page looking like this: When using exactly the same code but changing method="post" to method="get" I'm getting redirected to a page looking like this: This doesn't really look beautiful. I prefer the first one and I think my customers will do so, too. Does anybody know how I can fix that? Is there any PayPal value I can pass with my form to get the new layout?
... View more