dongyanju0945 2015-06-05 02:15
浏览 31

paypal中的订单摘要不显示项目

I used Express Checkout paypal for my siteweb but when I entre to payment page paypal I see in order summary just total price like that : http://i.stack.imgur.com/vPtkM.png

here is my code :

   <?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>

and here is code of my class 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;
      }

      }
  }}

  ?>

I want the users see's names and quantity and description of all items

  • 写回答

1条回答 默认 最新

  • dragon321723 2015-06-05 17:15
    关注

    I found solution : I had 2 errors : - the first is on the syntaxe of paramaters I put "L_PAYEMENTREQUEST" but the correct one is "L_PAYMENTREQUEST". - the second error is that I made space here : L_PAYMENTREQUEST_0_NAME0= in and paypal does'nt work with so I did remove the space and it works

    Thank you

    评论

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000