paypal响应返回一个空数组我做错了什么?这是我在paypal发送的数据,它回来了一个响应,作为空帖我使用json发送数据。抱歉英语不好。
<?php
$apiUrl = "https://svcs.sandbox.paypal.com/AdaptivePayments/";
$paypalUrl = "https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=";
$headers = array(
"X-PAYPAL-SECURITY-USERID: ".API_USER,
"X-PAYPAL-SECURITY-PASSWORD: ".API_PASS,
"X-PAYPAL-SECURITY-SIGNATURE: ".API_SIG,
"X-PAYPAL-REQUEST-DATA-FORMAT: JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",
"X-PAYPAL-APPLICATION-ID: ".APP_ID
);
$envelope = array(
"errorLanguage" => "en_US",
"detailLevel" => "ReturnAll"
);
$create = array(
"actionType" => "PAY",
"currencyCode" => "USD",
"receiverList" => array(
"receiver" => array(
array(
"amount" => "2.00",
"email" => "1@gmail.com"
),
array(
"amount" => "5.00",
"email" => "2@gmail.com"
)
)
),
"returnUrl" => "domain.php",
"cancelUrl" => "domain.php",
"ipnNotificationUrl" => "ipn.php",
"requestEnvelope" => $envelope
);
$response = paypalSend($createPacket,"Pay");
$payKey = $response['payKey'];
$details = array(
"requestEnvelope" => $envelope,
"payKey" => $payKey,
"receiverOptions" => array(
array(
"receiver" => array("email" => "1@gmail.com"),
"invoiceData" => array(
"item" => array(
array(
"name" => "product 1",
"price" => "1.00",
"identifier" => "p1"
),
array(
"name" => "product 1",
"price" => "1.00",
"identifier" => "p1"
)
)
)
),
array(
"receiver" => array("email" => "2@gmail.com"),
"invoiceData" => array(
"item" => array(
array(
"name" => "product 1",
"price" => "2.00",
"identifier" => "p1"
),
array(
"name" => "product 1",
"price" => "3.00",
"identifier" => "p1"
)
)
)
),
)
);
$res = paypalSend($details, "PaymentDetails");
?>
<?php
function paypalSend($data,$call) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
return json_decode(curl_exec($ch), TRUE);
}
?>
答案 0 :(得分:0)
看起来你有很多东西不属于PaymentDetails请求。该请求中只有3个参数:PayKey,TransactionID和TrackingID。
你已经接收到了有关receiverOptions的所有这些东西。我认为你只是让PayPal服务器感到困惑。
除了payKey之外,除去那个$ details值中的所有内容,看看是否有帮助。