我使用Express Checkout paypal为我的siteweb,但是当我进入支付页面paypal时,我看到订单摘要只是这样的总价: http://i.stack.imgur.com/vPtkM.png
这是我的代码:
<?php
require('connexion2.php');
require 'paypal.php';
$total=0;
$product='';
$paypal = new Paypal();
$params = array(
'RETURNURL' => 'http://localhost/SFE/pages/process.php',
'CANCELURL' => 'http://localhost/SFE/pages/cancel.php',
//'PAYMENTREQUEST_0_AMT' => $total,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
);
foreach($_POST["cle"] as $k => $value){
//$valeur est la Num de la facture croche
$sql="SELECT * from facture WHERE NumFacture = '$value'";
$res = $conn->query($sql) or die(print_r($connexion->errorInfo()));
$i=0;
$k=0;
while ( $data=$res->fetch_assoc()){
$NumFact=$data['NumFacture'];
$Montant=$data['Montant'];
//Capture les items :
$params["L_PAYEMENTREQUEST_0_NAME$k"] = $NumFact;
//Capture le montant :
$params["L_PAYEMENTREQUEST_0_ITEMAMT"] = $Montant;
//Capture la quantity :
$params["L_PAYEMENTREQUEST_0_QTY$k"] = $NumFact;
//Valorisation du total general :
$total+= $Montant;
$i=$i+1;
$k=$k+1;
}//fin while
}//fin foreach
$params["PAYMENTREQUEST_0_AMT"] = $total;
//ferme la connextion
$conn->close();
$response = $paypal->request('SetExpressCheckout', $params);
if($response){
$paypal = 'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=' . $response['TOKEN'];
}
else {
var_dump($paypal->errors);
die('ERREUR ');
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $paypal; ?>" method="post" target="_blank" >
<br /><br />
<input type="submit" value="Pay with PayPal!">
</body>
</html>
这是我的班级paypal的代码:
<?php
class Paypal{
private $user = "";
private $pwd = "";
private $signature = "";
private $endpoint = "https://api-3t.sandbox.paypal.com/nvp";
public $errors = array();
public function __construct($user = false, $pwd = false, $signature = false, $prod = false){
if($user){
$this->user = $user;
}
if($pwd){
$this->user = $pwd;
}
if($signature){
$this->user = $signature;
}
if($prod){
$this->endpoint = str_replace('sandbox.','', $this->endpoint);
}
}
public function request($method, $params){
$params = array_merge($params, array(
'METHOD' => $method,
'VERSION' => '74.0',
'USER' => $this->user,
'SIGNATURE' => $this->signature,
'PWD' => $this->pwd,));
$params = http_build_query($params);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->endpoint,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_VERBOSE => 1,
)
);
$response = curl_exec($curl);
$responseArray = array();
parse_str($response, $responseArray);
if(curl_errno($curl)){
$this->errors= curl_errno($curl);
curl_close($curl);
return false;
}
else {
if($responseArray['ACK'] == 'Success'){
return $responseArray;
}
else {
$this->errors = $responseArray;
curl_close($curl);
return false;
}
}
}}
?>
我希望用户看到所有项目的名称,数量和描述
答案 0 :(得分:0)
我找到了解决方案: 我有2个错误: - 第一个是关于我放置的参数的语法&#34; L_PAYEMENTREQUEST&#34;但正确的是&#34; L_PAYMENTREQUEST&#34;。 - 第二个错误是我在这里留出了空间: L_PAYMENTREQUEST_0_NAME0 = in 和PayPal一起工作所以我确实删除了空间并且它可以工作
谢谢