贝宝-使用php加密buynow动态签出按钮
我花了一个星期的时间试图做一个加密的“用贝宝结账”按钮 最后,我在这个网站上找到了用php加密的网络支付”https://ppmts.custhelp.com/app/answers/detail/a_id/502" 我试图在该示例中根据我在本地主机中的站点实现,但显示了一个错误“Received error#3” 这是我的密码 Example.php贝宝-使用php加密buynow动态签出按钮,php,paypal,localhost,paypal-ipn,paypal-sandbox,Php,Paypal,Localhost,Paypal Ipn,Paypal Sandbox,我花了一个星期的时间试图做一个加密的“用贝宝结账”按钮 最后,我在这个网站上找到了用php加密的网络支付”https://ppmts.custhelp.com/app/answers/detail/a_id/502" 我试图在该示例中根据我在本地主机中的站点实现,但显示了一个错误“Received error#3” 这是我的密码 Example.php <?php $config = array("cert_id" => "PHCVJS6GDV6T
<?php
$config = array("cert_id" => "PHCVJS6GDV6TY", "business" => "roki_1347003608_biz@gmail.com","basedir" => "./",
"certstore" => "./", "tempdir" => "./", "my_private" => "my-prvkey.pem", "my_public" => "my.pubcert.pem",
"paypal_public" => "paypal_cert_pem.txt");
$paypal = new PayPal_EncryptedButtons($config);
// You can add parameters to the button one by one (name, value) or you can pass two
// arrays of names and values, as documented below.
$names = array("amount", "currency_code", "item_name", "item_number");
$values = array("2.56", "USD", "Dave's secret encryption sauce (encryption via PHP)", "123456");
$paypal->addButtonParam($names, $values);
// We can now generate our code
$result = $paypal->encryptButtonData();
if ($result !== PP_ERROR_OK) {
// Something went wrong
echo "Received Error #".$result."\n";
exit;
}
// Get the string of encrypted button data
echo '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
echo '<input type="hidden" name="cmd" value="_s-xclick">';
echo '<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">';
echo '<input type="hidden" name="encrypted" value="';
echo $paypal->getButton();
echo '">';
echo "</form>\n";
?>
</body>
</html>
任何人都知道这是什么错误吗?任何人都可以帮助我如何修复这一错误。我真的没有什么帮助。谢谢问题是脚本是否正常工作需要使用OpenSSL。在脚本的注释中,它确实指定它使用它来加密PayPal按钮 这一行是导致问题的原因,因为它无法创建文件,因为尚未指定OpenSSL
$exec = $this->config->openssl." smime -encrypt -des3 -binary -outform pem ".$this->config->paypal_public." < ".$this->config->tempdir.$this->_rnd.".2 > ".$this->config->tempdir.$this->_rnd.".3";
有关在本地主机中使用OpenSSL的信息可以通过以下google查询找到:
OpenSSL:
希望这会有所帮助。在某些托管计划中,设置此设置可能会非常困难,也可能是不可能的。另一个建议是不要加密,而是使用篡改检测哈希技巧,然后在处理IPN时检查这一点。我在这里记录这一点:
您确定配置等中的所有目录/路径都正确吗?特别是tempdir.yes,如果删除,我会检查example.php中的所有目录是否正确!此$result=$paypal->encryptButtonData();如果($result==PP_ERROR_OK){//Something出错,则回显“Received ERROR#”。$result.\n;exit;}。它将转到paypal页面,并显示缺少或不完整的某些必需信息。请更正您的条目,然后再试一次。我不能肯定,但在测试之后,我有一种感觉,这与它试图执行本地无法执行的代码(openssl)有关。无法创建扩展名为.3的文件,但它会将文件写入临时目录。然后,您知道任何解决方案,请遵循您为本地主机提供的openssl链接。但它仍然显示相同的错误您确定openssl已安装且工作正常吗?-尝试执行“生成密钥”部分,如果有效,则执行后面的所有部分,包括正确生成密钥的“MODIFY HTTPD-SSL.CONF”。但是,虽然在localhost中安装,但我们是否需要更改路由器中的任何内容?不-localhost留在机器内,它甚至无法到达路由器(除非尝试从外部访问,如果已设置),好的,兄弟,它不起作用。现在我将在现场检查它。我使用debian linux。你能提供类似于如何在linux中进行paypal集成的任何信息吗
<?php
class PayPal_EncryptedButtons_Config {
var $cert_id = "PHCVJS6GDV6TY";
var $business = "roki_1347003608_biz@gmail.com";
var $receiver_email = "";
var $basedir = "/wamp/www/var/";
var $certstore = "/wamp/www/key/cert/";
var $tempdir = "/wamp/www/temp/";
var $openssl = "openssl";
var $my_private = "/wamp/www/key/cert/my-prvkey.pem";
/* Your Public Certificate Filename */
var $my_public = "/wamp/www/key/cert/my.pubcert.pem";
/* PayPal's Public Certificate Filename */
var $paypal_public = "/wamp/www/key/cert/paypal_cert_pem.txt";
}
?>
Received Error #3
$exec = $this->config->openssl." smime -encrypt -des3 -binary -outform pem ".$this->config->paypal_public." < ".$this->config->tempdir.$this->_rnd.".2 > ".$this->config->tempdir.$this->_rnd.".3";
/* OpenSSL Path - Path to the OpenSSL Binary */
/* If openssl isn't in your PATH, then change this to where it's located, otherwise leave it as it is */
/* No trailing slash */
var $openssl = "openssl";