Paypal Pro NVP 沙盒 PHP 支付不可能

Posted

技术标签:

【中文标题】Paypal Pro NVP 沙盒 PHP 支付不可能【英文标题】:Paypal Pro NVP Sandbox PHP Payment Impossible 【发布时间】:2013-08-14 10:42:16 【问题描述】:

我已经建立了自己的 Paypal Pro 系统,但他不工作我无法访问模板,但 NVP ACK 成功。 我试图改变编码,但没有任何改变。我唯一得到的是

无法处理您的付款。请直接联系商家。
我的代码是:
    session_start();

    $total = 0;

    $total = $_SESSION['navig']->commande->total;
    $total -= $_SESSION["navig"]->commande->remise;

// R?f?rence
$Reference_Cde = urlencode($_SESSION['navig']->commande->transaction);

// Montant
$Montant = $total;

// Récupération de l'adresse de payement
$server = $serveur_api;
$version = "87.0";
$method = "BMCreateButton";
$user = $username_api;
$pwd = $password_api;
$signature = $key_api;
$buttoncode = "TOKEN";
$buttontype = "PAYMENT";

$data = array(
    "PAYMENTACTION" => urlencode("sale"),
    "AMOUNT"        => urlencode(round($Montant, 2)),
    "TAX"           => urlencode("19.6"),
    "FIRST_NAME"    => urlencode($_SESSION["navig"]->client->prenom),
    "LASR_NAME"     => urlencode($_SESSION["navig"]->client->nom),
    "ADDRESS1"      => urlencode($_SESSION["navig"]->client->adresse1),
    "ADDRESS2"      => urlencode($_SESSION["navig"]->client->adresse2),
    "CITY"          => urlencode($_SESSION["navig"]->client->ville),
    "ZIP"           => urlencode($_SESSION["navig"]->client->cpostal),
    "EMAIL"         => urlencode($_SESSION["navig"]->client->email),
    "SHIPPING_1"    => urlencode($_SESSION["navig"]->commande->port),
    "CURRENCY_CODE" => urlencode($Devise),
    "PAYER_ID"      => urlencode($_SESSION["navig"]->client->id),
    "PAYER_EMAIL"   => urlencode($_SESSION["navig"]->client->email),
    "RETURN"        => urlencode($retourok),
    "NOTIFY_URL"    => urlencode($confirm),
    "CANCEL_RETURN" => urlencode($retournok),
    "INVOICE"       => urlencode($Reference_Cde)
);

$request[] = "VERSION=".$version;
$request[] = "METHOD=".$method;
$request[] = "USER=".$user;
$request[] = "PWD=".$pwd;
$request[] = "SIGNATURE=".$signature;
$request[] = "BUTTONCODE=".$buttoncode;
$request[] = "BUTTONTYPE=".$buttontype;

$i = 0;
foreach ($data as $key => $value) 
    $request[] = "L_BUTTONVAR".$i."=".$key."=".$value;
    $i++;


$requestcurl = "";

foreach ($request as $data => $value) 
    $requestcurl .= $value . "&";


$requestcurl = substr($requestcurl, 0, -1);
$requestcurl = str_replace(" ", "+", $requestcurl);
$requestcurl = utf8_encode($requestcurl);
$url = parse_url($serveur_api);
$reponse = "";

$fp = fsockopen("ssl://".$url['host'],"443",$err_num,$err_str,30); 
if(!$fp) 
     return false;
  else  

   fputs($fp, "POST $url[path] HTTP/1.1\r\n"); 
   fputs($fp, "Host: $url[host]\r\n"); 
   fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
   fputs($fp, "Content-length: ".strlen($requestcurl)."\r\n");
   fputs($fp, "Charset: utf-8\r\n");
   fputs($fp, "Connection: close\r\n\r\n"); 
   fputs($fp, $requestcurl . "\r\n\r\n"); 

   while(!feof($fp))  
      $reponse .= fgets($fp, 4096); 

   fclose($fp); 
;

$rep = explode("&", $reponse);
$rep = explode("=", $rep[1]);
$result = urldecode($rep[1]);
header("Location:".$result);

【问题讨论】:

【参考方案1】:

我已经找到了解决该问题的方法,我将“AMOUNT”替换为“subtotal”,并将数据数组中的所有大写字母替换为小写字母。

真诚的

【讨论】:

以上是关于Paypal Pro NVP 沙盒 PHP 支付不可能的主要内容,如果未能解决你的问题,请参考以下文章

使用 PayPal-PHP-SDK 进行第三方支付的 Paypal 沙盒测试

Paypal NVP 身份验证失败

Payal nvp vs Paypal Pro?

为啥 Paypal 沙盒不处理付款?

自适应支付 PayPal 中不支持卡支付

paypal PHP并行支付期间如何显示物品描述和送货地址?