tôi thực hiện kịch bản sau đây trong PHP cho phương pháp GetVerifiedStatus với cuộc gọi API và nó hoạt động tốt cho tôi. Kịch bản này là dành cho sandbox vì vậy nếu bạn muốn kiểm tra nó, hãy kiểm tra nó với các tài khoản PayPal sandbox. Nếu bạn muốn sử dụng nó cho chế độ sản xuất, sau đó xóa các dòng cho sandbox (tôi đã cho thấy chúng trong các gợi ý bình luận). Tôi đã giải thích về những thứ bạn cần để lấy từ paypal để chạy mã này bên trong các bình luận PHP.
<?php
// create a new cURL resource
$ch = curl_init();
$ppUserID = "******************"; //Take it from sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppPass = "*************"; //Take it from sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppSign = "********************"; //Take it from sandbox dashboard for test mode or take it from paypal.com account in production mode, help: https://developer.paypal.com/docs/classic/api/apiCredentials/
$ppAppID = "***********"; //if it is sandbox then app id is always: APP-80W284485P519543T
$sandboxEmail = "********************"; //comment this line if you want to use it in production mode.It is just for sandbox mode
$emailAddress = "******************"; //The email address you wana verify
$firstName = "********"; //first name of the account holder you want to verify, sandbox personal account default first name is: test
$lastName = "*******"; //last name of the account holder you want to verify, sandbox personal account default last name is: buyer
//parameters of requests
$nvpStr = 'emailAddress='.$emailAddress.'&firstName='.$firstName.'&lastName='.$lastName.'&matchCriteria=NAME';
// RequestEnvelope fields
$detailLevel = urlencode("ReturnAll"); // See DetailLevelCode in the WSDL for valid enumerations
$errorLanguage = urlencode("en_US"); // This should be the standard RFC 3066 language identification tag, e.g., en_US
$nvpreq = "requestEnvelope.errorLanguage=$errorLanguage&requestEnvelope.detailLevel=$detailLevel";
$nvpreq .= "&$nvpStr";
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
$headerArray = array(
"X-PAYPAL-SECURITY-USERID:$ppUserID",
"X-PAYPAL-SECURITY-PASSWORD:$ppPass",
"X-PAYPAL-SECURITY-SIGNATURE:$ppSign",
"X-PAYPAL-REQUEST-DATA-FORMAT:NV",
"X-PAYPAL-RESPONSE-DATA-FORMAT:JSON",
"X-PAYPAL-APPLICATION-ID:$ppAppID",
"X-PAYPAL-SANDBOX-EMAIL-ADDRESS:$sandboxEmail" //comment this line in production mode. IT IS JUST FOR SANDBOX TEST
);
$url="https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$paypalResponse = curl_exec($ch);
//echo $paypalResponse; //if you want to see whole PayPal response then uncomment it.
curl_close($ch);
$data = json_decode($paypalResponse);
if($data->responseEnvelope->ack == "Success"){
$output = array('status' => true); //means user is verified successfully
} else {
$output = array('status' => false); //means verification was unsuccessful
}
echo $output;
?>
Nguồn
2015-04-23 05:44:22
Cần xác thực tự động khi người dùng đăng ký. – Andrey
bạn có nghĩa là bạn muốn kiểm tra xem họ có một tài khoản paypal hợp lệ trước khi bạn gửi tiền cho họ không? bạn phải có một vấn đề duy nhất bởi vì tôi sẽ chỉ yêu cầu họ nhập id paypal của họ và giả sử họ đang làm đúng, gửi cho họ tiền và được thực hiện với nó. đó là những người nên lo lắng về việc nhập đúng thông tin, chứ không phải bạn. trừ khi bạn đang đưa tiền cho những người không đặc biệt quan tâm đến việc nhận nó ... đó là những gì tôi có nghĩa là bạn phải có một vấn đề duy nhất. –
Lưu ý: API MassPay và Payments sẽ KHÔNG gửi tiền tới địa chỉ email chưa đăng ký tài khoản trước! –