您好我正在嘗試實現PAYPAL PARALLEL API,並且我試圖將自定義變量傳遞給PayPal IPN 這是我的PHP代碼,它的工作沒有自定義變量,和我不「知道在哪裏添加此自定義字段:向PayPal並行支付添加自定義變量IPN PHP
$apiUrl = "https://svcs.sandbox.paypal.com/AdaptivePayments/";
$paypalUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=";
$headers = array(
"X-PAYPAL-SECURITY-USERID : ".$paypal_user_id,
"X-PAYPAL-SECURITY-PASSWORD : ".$paypal_pass,
"X-PAYPAL-SECURITY-SIGNATURE : ".$paypal_user_signature,
"X-PAYPAL-APPLICATION-ID : ".$paypal_app_id,
"X-PAYPAL-REQUEST-DATA-FORMAT : JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT : JSON"
);
// curl wrapper for sending thhings to paypal
function paypalSend($data,$call){
global $apiUrl;
global $headers;
$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);
}
//create the pay request
$createPacket = array(
"actionType"=>"PAY",
"currencyCode"=>"USD",
"receiverList"=> array(
"receiver" => array(
array(
"amount" => $amount,
"email" => $email
)
)
),
"returnUrl" => "http://www.mywebsite.com/finish_withdraw.php",
"cancelUrl" => "http://www.mywebsite.com/cancel_withdraw.php",
"requestEnvelope"=> array(
"errorLanguage"=>"en_US", // Language used to display errors
"detailLevel"=>"ReturnAll"
)
);
$response = paypalSend($createPacket, "Pay");
$payKey = $response['payKey'];
$paymentExecStatus = $response['paymentExecStatus'];
$detailPacket = array(
"requestEnvelope"=> array(
"errorLanguage"=>"en_US", // Language used to display errors
"detailLevel"=>"ReturnAll"
),
"payKey" => $payKey,
"receiverOptions" => array(
array(
"receiver"=> array("email" => $email),
"invoiceData" => array(
"item" => array(
array(
"name" => "product 1",
"price" => $amount,
"identifier" => "p1"
)
)
)
)
)
);
$response = paypalSend($detailPacket, "SetPaymentOptions");
//Wrapper to get payent details
$packet = array(
"requestEnvelope"=> array(
"errorLanguage"=>"en_US", // Language used to display errors
"detailLevel"=>"ReturnAll"
),
"payKey" => $payKey,
);
$dets = paypalSend($packet, "GetPaymentOptions");
header('location: '.$paypalUrl.$payKey);
告訴我更多關於什麼樣的自定義數據要發送,以及如何使用它 – 2015-03-13 21:55:34
感謝您的答覆^^,我試圖發送的是一個變量,其中包含用戶執行付款的id,這個id我可以從我的數據庫中得到它,並且我想在ipn通知中收到這個id,以便將這筆付款插入到我的數據庫中,並通過他的ID將支付與特定用戶相關聯。 – EssaidiM 2015-03-13 22:06:17