[英]How crypt SSL paypal button on windows web server 2008 R2 64bits ,
I try to crypt with SSL paypal button on my windows web server 2008 R2 64bits. 我尝试在Windows Web Server 2008 R2 64位上使用SSL paypal按钮进行加密。 I've installed apache 2.2.22 , php 5.4.3, and openssl . 我已经安装了Apache 2.2.22,php 5.4.3和openssl。
I find class to crypt in ssl paypal button but it doesn't working. 我在ssl paypal按钮中找到要加密的类,但是它不起作用。 I've nothing error , just code of button isn't crypted . 我没有什么错误,只是按钮的代码没有加密。
Class to crypt : 要加密的类:
<?php
class PaypalCrypt{
private $privateKey = '';
private $publicKey = '';
private $paypalKey = '';
//private $pathOpenSSL = '/usr/bin/openssl';
private $pathOpenSSL = 'C:/wamp/bin/apache/apache2.2.22/bin/openssl.exe';
private $data = array(
'bn' => 'Boutique_BuyNow_WPS_FR',
'cmd' => '_xclick',
'lc' => 'FR',
'custom' => '',
'invoice' => '',
'currency_code' => 'EUR',
'charset' => 'UTF-8', //Définit le charset utilisé sur le site
'no_shipping' => '1'
);
public function __construct(){
// Nothing
}
public function addData($key, $data){
$this->data[$key] = $data;
return $this;
}
public function setPrivateKey($privateKey){
$this->privateKey = $privateKey;
return $this;
}
public function setPublicKey($publicKey){
$this->publicKey = $publicKey;
return $this;
}
public function setPaypalKey($paypalKey){
$this->paypalKey = $paypalKey;
return $this;
}
public function getCryptedData(){
if (!file_exists($this->privateKey))
throw new Exception('ERROR: MY_KEY_FILE '.$this->privateKey.' not found');
if (!file_exists($this->publicKey))
throw new Exception('ERROR: MY_CERT_FILE '.$this->publicKey.' not found');
if (!file_exists($this->paypalKey))
throw new Exception('ERROR: PAYPAL_CERT_FILE '.$this->paypalKey.' not found');
$openssl_cmd = "$this->pathOpenSSL smime -sign -signer $this->publicKey -inkey $this->privateKey ".
"-outform der -nodetach -binary| $this->pathOpenSSL smime -encrypt ".
"-des3 -binary -outform pem $this->paypalKey";
$descriptors = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
);
$process = proc_open($openssl_cmd, $descriptors, $pipes);
if (is_resource($process)) {
foreach ($this->data as $key => &$value)
if ($value != "")
fwrite($pipes[0], "$key=$value\n");
fflush($pipes[0]);
fclose($pipes[0]);
$output = "";
while (!feof($pipes[1]))
$output .= fgets($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($process);
return $output;
}
throw new Exception('ERROR: encryption failed');
}
public function setOpenSSLPath($path){
if(!file_exists($path))
throw new Exception('OpenSSLPath "'.$path.'" don\'t exists');
$this->pathOpenSSL = $path;
}
}
$MY_KEY_FILE = "prvkey.pem";
# public certificate file to use
$MY_CERT_FILE = "pubcert.pem";
# Paypal?s public certificate
$PAYPAL_CERT_FILE = "paypal_cert.pem";
// Initialisation cryptage Paypal
$paypalCrypt = new PaypalCrypt();
$paypalCrypt->setPrivateKey($MY_KEY_FILE);
$paypalCrypt->setPublicKey($MY_CERT_FILE);
$paypalCrypt->setPaypalKey($PAYPAL_CERT_FILE);
$paypalCrypt->addData('cert_id','id_certificat_fourni_par_paypal')
->addData('business','email@email.com')
->addData('no_note','1')
->addData('shipping','0')
->addData('tax','0')
->addData('rm','2')
->addData('cbt','Retour sur la boutique')
->addData('custom','id_membre')
->addData('return','http://mon_site.com/return.php')
->addData('cancel_return','http://mon_site.com/cancel.php')
->addData('notify_url','http://mon_site.com/ipn.php')
->addData('amount','10')
->addData('item_name', 'Boite à meuh')
->addData('item_number', 'identifiant_produit');
$data = $paypalCrypt->getCryptedData();
?>
<form action="https://www.paypal.com/fr/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="<?php echo $data?>"/>
<input type="submit" value="Commander" class="input_button">
</form>
I don't know why it's doesn't working on windows , but it's working on 1and1 (linux ?) 我不知道为什么它不能在Windows上运行,但可以在1and1(Linux吗?)上运行
Thanks a lot cordially 非常感谢
i found a solution this night . 我今晚找到了解决方案。 In fact, solution is to use PHP to crypt SSL paypal button without command openssl. 实际上,解决方案是使用PHP来加密SSL paypal按钮而不使用openssl命令。 Paypal gives an example to use it : https://cms.paypal.com/fr/cgi-bin/?cmd=_render-content&content_ID=developer/library_download_sdks#WPST and download the Website Payments Standard toolkit. 贝宝(Paypal)给出了一个使用它的示例: https : //cms.paypal.com/fr/cgi-bin/?cmd= _render-content&content_ID=developer/library_download_sdks# WPST并下载“网站付款标准”工具包。
thanks a lot see you soon 非常感谢,很快见
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.