贝宝卷曲错误
PayPal Curl Error
我有以下代码,在成功付款后会出现错误。
<?php
$name = "pra_api1.mymail.sutd.edu.sg";
$password = "EJLV5PRE9Q3";
$signature = "AFcWxVRCpSSRl31NmODmpouHa5SPBWS1";
$endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
session_start();
$amtDonate = $_SESSION['try'];
$curren = $_SESSION['cure'];
$params2 = array(
'METHOD'=> 'DoExpressCheckoutPayment',
'VERSION'=> '74.0',
'TOKEN' => $_GET['token'],
'PAYMENTACTION' => 'Sale',
'USER'=> $name,
'SIGNATURE'=> $signature,
'PWD'=> $password,
'PAYERID' => $_GET['PayerID'],
'PAYMENTREQUEST_0_AMT'=> $amtDonate,
'PAYMENTREQUEST_0_CURRENCYCODE' =>$curren
);
$params2 = http_build_query($params2);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_URL => $endpoint,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $params2,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_VERBOSE => 1));
$response2 = curl_exec($curl2);
$responseArray2 = array();
parse_str($response2,$responseArray2);
//var_dump($responseArray2);
curl_close($curl2);
if (curl_errno($curl2)){
// var_dump(curl_error($curl2));
curl_close($curl2);
die();
} else {
if ($responseArray2['ACK']=="Success"){
} else {
var_dump($responseArray2);
die();
}
curl_close($curl2);
}
$params = array(
'METHOD'=> 'GetExpressCheckoutDetails',
'VERSION'=> '74.0',
'TOKEN' => $_GET['token'],
'USER'=> $name,
'SIGNATURE'=> $signature,
'PWD'=> $password);
$params = http_build_query($params);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $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);
//var_dump($responseArray);
curl_close($curl);
if (curl_errno($curl)){
// var_dump(curl_error($curl));
curl_close($curl);
die();
} else {
if ($responseArray['CHECKOUTSTATUS']=='PaymentActionCompleted'){
header( "refresh:3;url=index.php" );
} else {
var_dump($responseArray);
die();
}
curl_close($curl);
}
?>
<html>
<meta charset="UTF-8" />
<title>We Empower Her</title>
<style>
body {margin:0px;}
#whole{ margin:0px;
padding:0px;
width: 100vw;
height: 100vh;
background-color: #e25154;
}
#tex{
padding: 40px;
font-size: 30px;
}
</style>
<body>
<div id ="whole">
<p id="tex"> Your transaction has been completed. Thank you for your generous contribution.</p>
</div>
</body>
</html>
看起来你的代码有点过头了。我建议清理多余的 curl_close 调用
Warning#1 = You already closed the $curl2 handle on line 36
Warning#2 = $curl2 Handle already closed
Warning#3 = $curl handle already closed
Warning#4 = Looks like you're too late to set a header at this stage. As line#38 caused an error message, you might be fine as soon as you've fixed the warnings or as soon as you disable PHP warning messages in your php.ini file
Warning#5 = Yet another curl_close() for an already closed handle.
我有以下代码,在成功付款后会出现错误。
<?php
$name = "pra_api1.mymail.sutd.edu.sg";
$password = "EJLV5PRE9Q3";
$signature = "AFcWxVRCpSSRl31NmODmpouHa5SPBWS1";
$endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
session_start();
$amtDonate = $_SESSION['try'];
$curren = $_SESSION['cure'];
$params2 = array(
'METHOD'=> 'DoExpressCheckoutPayment',
'VERSION'=> '74.0',
'TOKEN' => $_GET['token'],
'PAYMENTACTION' => 'Sale',
'USER'=> $name,
'SIGNATURE'=> $signature,
'PWD'=> $password,
'PAYERID' => $_GET['PayerID'],
'PAYMENTREQUEST_0_AMT'=> $amtDonate,
'PAYMENTREQUEST_0_CURRENCYCODE' =>$curren
);
$params2 = http_build_query($params2);
$curl2 = curl_init();
curl_setopt_array($curl2, array(
CURLOPT_URL => $endpoint,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $params2,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_VERBOSE => 1));
$response2 = curl_exec($curl2);
$responseArray2 = array();
parse_str($response2,$responseArray2);
//var_dump($responseArray2);
curl_close($curl2);
if (curl_errno($curl2)){
// var_dump(curl_error($curl2));
curl_close($curl2);
die();
} else {
if ($responseArray2['ACK']=="Success"){
} else {
var_dump($responseArray2);
die();
}
curl_close($curl2);
}
$params = array(
'METHOD'=> 'GetExpressCheckoutDetails',
'VERSION'=> '74.0',
'TOKEN' => $_GET['token'],
'USER'=> $name,
'SIGNATURE'=> $signature,
'PWD'=> $password);
$params = http_build_query($params);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $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);
//var_dump($responseArray);
curl_close($curl);
if (curl_errno($curl)){
// var_dump(curl_error($curl));
curl_close($curl);
die();
} else {
if ($responseArray['CHECKOUTSTATUS']=='PaymentActionCompleted'){
header( "refresh:3;url=index.php" );
} else {
var_dump($responseArray);
die();
}
curl_close($curl);
}
?>
<html>
<meta charset="UTF-8" />
<title>We Empower Her</title>
<style>
body {margin:0px;}
#whole{ margin:0px;
padding:0px;
width: 100vw;
height: 100vh;
background-color: #e25154;
}
#tex{
padding: 40px;
font-size: 30px;
}
</style>
<body>
<div id ="whole">
<p id="tex"> Your transaction has been completed. Thank you for your generous contribution.</p>
</div>
</body>
</html>
看起来你的代码有点过头了。我建议清理多余的 curl_close 调用
Warning#1 = You already closed the $curl2 handle on line 36
Warning#2 = $curl2 Handle already closed
Warning#3 = $curl handle already closed
Warning#4 = Looks like you're too late to set a header at this stage. As line#38 caused an error message, you might be fine as soon as you've fixed the warnings or as soon as you disable PHP warning messages in your php.ini file
Warning#5 = Yet another curl_close() for an already closed handle.