如何验证PayPal帐户?

时间:2010-07-12 13:27:15

标签: api validation paypal

我想将paypal集成到我的网站,并要求用户输入paypal帐户以支付佣金。 如何检查他们的账户是否存在于PayPal? 我不想给他们发0.01美元,或者这是检查账户的唯一方法吗?

当用户注册网站时,它应自动验证。

5 个答案:

答案 0 :(得分:6)

GetVerifiedStatus应该做到这一点。您必须传递电子邮件地址和此人的姓名,然后它将返回其帐户是否已经过验证。

如果他们没有PayPal帐户,您将收到错误消息,说明"无法确定PayPal帐户状态。"

以下是我刚刚在沙盒上为经过验证的PayPal帐户运行的请求和响应示例...

<?xml version="1.0" encoding="utf-8"?>
<GetVerifiedStatusRequest xmlns="http://svcs.paypal.com/types/ap">
  <requestEnvelope xmlns="">
    <detailLevel>ReturnAll</detailLevel>
    <errorLanguage>en_US</errorLanguage>
  </requestEnvelope>
  <emailAddress xmlns="">sandbo_1204199080_biz@angelleye.com</emailAddress>
  <matchCriteria xmlns="">NAME</matchCriteria>
  <firstName xmlns="">Drew</firstName>
  <lastName xmlns="">Angell</lastName>
</GetVerifiedStatusRequest>

<?xml version='1.0' encoding='UTF-8'?>
<ns2:GetVerifiedStatusResponse xmlns:ns2="http://svcs.paypal.com/types/aa">
  <responseEnvelope>
    <timestamp>2013-01-05T00:07:01.729-08:00</timestamp>
    <ack>Success</ack>
    <correlationId>3fecb3e1f2011</correlationId>
    <build>4055066</build>
  </responseEnvelope>
  <accountStatus>VERIFIED</accountStatus>
  <userInfo>
    <emailAddress>sandbo_1204199080_biz@angelleye.com</emailAddress>
    <accountType>BUSINESS</accountType>
    <accountId>E7BTGVXBFSUAU</accountId>
    <name>
      <salutation></salutation>
      <firstName>Drew</firstName>
      <middleName></middleName>
      <lastName>Angell</lastName>
      <suffix></suffix>
    </name>
    <businessName>Drew Angell's Test Store</businessName>
  </userInfo>
</ns2:GetVerifiedStatusResponse>

以下是PayPal帐户不存在的请求和回复示例...

<?xml version="1.0" encoding="utf-8"?>
<GetVerifiedStatusRequest xmlns="http://svcs.paypal.com/types/ap">
  <requestEnvelope xmlns="">
    <detailLevel>ReturnAll</detailLevel>
    <errorLanguage>en_US</errorLanguage>
  </requestEnvelope>
  <emailAddress xmlns="">nodice@fail.com</emailAddress>
  <matchCriteria xmlns="">NAME</matchCriteria>
  <firstName xmlns="">Drew</firstName>
  <lastName xmlns="">Angell</lastName>
</GetVerifiedStatusRequest>

<?xml version='1.0' encoding='UTF-8'?>
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/aa">
  <responseEnvelope>
    <timestamp>2013-01-05T00:08:28.581-08:00</timestamp>
    <ack>Failure</ack>
    <correlationId>43364ce704211</correlationId>
    <build>4055066</build>
  </responseEnvelope>
  <error>
    <errorId>580023</errorId>
    <domain>PLATFORM</domain>
    <subdomain>Application</subdomain>
    <severity>Error</severity>
    <category>Application</category>
    <message>Cannot determine PayPal Account status</message>
  </error>
</ns3:FaultMessage>

答案 1 :(得分:4)

使用Java(我们可以使用adaptiveaccountssdk这样做)

<dependency>
    <groupId>com.paypal.sdk</groupId>
    <artifactId>adaptiveaccountssdk</artifactId>
    <version>LATEST</version>
</dependency>

...

Map<String, String> sdkConfig = new HashMap<>();
sdkConfig.put("mode", "sandbox/live");
sdkConfig.put("acct1.UserName", "");
sdkConfig.put("acct1.Password", ""));
sdkConfig.put("acct1.Signature", ""));
sdkConfig.put("acct1.AppId", ""));

GetVerifiedStatusRequest request = new GetVerifiedStatusRequest();
AccountIdentifierType accountIdentifierType = new AccountIdentifierType();
accountIdentifierType.setEmailAddress(accountEmail);
request.setAccountIdentifier(accountIdentifierType);
request.setMatchCriteria("NONE");
AdaptiveAccountsService aas = new AdaptiveAccountsService(sdkConfig);
GetVerifiedStatusResponse response = aas.getVerifiedStatus(request);
String status = response.getAccountStatus();

.....

答案 2 :(得分:3)

您可以要求他们输入他们在PayPal中使用的电子邮件地址。如果他们没有PayPal帐户,您仍然可以将资金发送给他们输入的任何电子邮件。 Paypal将负责让他们创建一个带有该电子邮件ID的PayPal帐户并向他们展示他们的资金。

您可能必须确保他们输入正确的电子邮件ID ..也许电子邮件地址验证步骤可以解决问题。

答案 3 :(得分:3)

I implemented following script in PHP for GetVerifiedStatus method with API call and it is working fine for me. This script is for sandbox so if you want to test it, please test it with sandbox PayPal accounts. If you want to use it for production mode, then delete the lines for sandbox (I showed them in the comment hints) . I explained about the things you need to get from paypal to run this code inside the PHP comments.

<?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;

?>

答案 4 :(得分:0)

拥有经过验证的PayPal帐户意味着您已提供PayPal附加信息以证明您的身份。这使潜在客户对您的合法性更有信心,并使您有资格享受PayPal的卖家保护。验证您的帐户还会删除帐户限制,并允许您在PayPal帐户和其他关联的银行帐户之间转帐。