【发布时间】:2021-07-03 23:10:25
【问题描述】:
我需要验证正确的 PayPal 电子邮件地址。因为我需要向那个 PayPal 电子邮件地址汇款。
此代码以前有效。但现在它没有经过验证。
我的代码是
$ch = curl_init();
//parameters of requests
$nvpStr = 'emailAddress=' . $request->email . '&matchCriteria=NONE';
// RequestEnvelope fields
$detailLevel = urlencode("ReturnAll");
$errorLanguage = urlencode("en_US");
$nvpreq = "requestEnvelope.errorLanguage=$errorLanguage&requestEnvelope.detailLevel=$detailLevel&";
$nvpreq .= "&$nvpStr";
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
$headerArray = array(
"X-PAYPAL-SECURITY-USERID:" . env('PAYPAL_USERNAME'),
"X-PAYPAL-SECURITY-PASSWORD:" . env('PAYPAL_PASSWORD'),
"X-PAYPAL-SECURITY-SIGNATURE:" . env('PAYPAL_SIGNATURE'),
"X-PAYPAL-REQUEST-DATA-FORMAT:JSON",
"X-PAYPAL-RESPONSE-DATA-FORMAT:JSON",
"X-PAYPAL-APPLICATION-ID:" . env('PAYPAL_APP_ID') //,
//"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')
return true;
else
return false;
我正在开发 PHP laravel。
如果有人有任何想法,请提供帮助。
【问题讨论】:
-
如果您使用的第三方服务突然停止工作(您没有进行任何更改),那么您应该首先联系服务提供商(贝宝)并检查是否有任何更改/问题您的帐户/他们的 api。我们不能检查/调试,因为我们不是他们。
-
感谢您的回复。我没有使用任何第三方服务。 svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus
-
您实际上是在询问 Paypal 的 API,它是这种情况下的第三方。
-
现在它正在工作。它来自贝宝端。