【发布时间】:2011-03-14 19:48:39
【问题描述】:
我想将 paypal 整合到我的网站,并要求用户进入 paypal 帐户以支付佣金。 我如何检查他们的帐户是否存在于贝宝上? 我不想给他们 0.01 美元,否则这是检查帐户的唯一方法?
它应该在用户注册网站时自动验证。
【问题讨论】:
标签: api validation paypal
我想将 paypal 整合到我的网站,并要求用户进入 paypal 帐户以支付佣金。 我如何检查他们的帐户是否存在于贝宝上? 我不想给他们 0.01 美元,否则这是检查帐户的唯一方法?
它应该在用户注册网站时自动验证。
【问题讨论】:
标签: api validation paypal
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>
【讨论】:
matchCriteria 字段设置为NONE,则不需要用户名
您可以要求他们输入他们在贝宝中使用的电子邮件地址。如果他们在贝宝上没有帐户,您仍然可以将资金发送到他们输入的任何电子邮件中。 Paypal 将负责让他们使用该电子邮件 ID 创建一个 paypal 帐户并向他们显示他们的资金。
您可能需要确保他们输入正确的电子邮件 ID。也许电子邮件地址验证步骤可以解决问题。
【讨论】:
使用 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();
.....
【讨论】:
我在 PHP 中使用 API 调用为 GetVerifiedStatus 方法实现了以下脚本,它对我来说工作正常。此脚本适用于沙盒,因此如果您想对其进行测试,请使用沙盒 PayPal 帐户对其进行测试。如果您想将其用于生产模式,请删除沙箱的行(我在评论提示中显示了它们)。我解释了在 PHP cmets 中运行此代码需要从 paypal 获取的内容。
<?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;
?>
【讨论】:
拥有经过验证的 PayPal 帐户意味着您已提供 PayPal 附加信息来证明您的身份。这让潜在客户对您的合法性更有信心,并使您有资格享受 PayPal 的卖家保护。验证您的帐户还可以消除帐户限制,并使您能够在您的 PayPal 帐户和其他关联的银行帐户之间进行转账。
【讨论】: