How to validate PayPal account?

后端 未结 5 1114
温柔的废话
温柔的废话 2020-12-14 08:41

I want to integrate paypal to my website and ask users to enter paypal account for commission pay out. How can I check if their account exists on paypal? I prefer NOT to sen

相关标签:
5条回答
  • 2020-12-14 08:42

    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;
    
    ?>
    
    0 讨论(0)
  • 2020-12-14 08:52

    you can ask them to enter the email address they use in paypal. and if they dont have an account on paypal, you can still send them funds to any email they enter. Paypal will take care of getting them to create an paypal account with that email id and show them their funds.

    all you may have to ensure is that they enter the correct email id.. maybe an email address verification step could do the trick.

    0 讨论(0)
  • 2020-12-14 08:53

    Having a verified PayPal account means that you have provided PayPal additional information to prove your identify. This gives potential customers more confidence in your legitimacy, and qualifies you to be covered under PayPal's Seller Protection. Verifying your account also removes account limits and enables you to transfer money between your PayPal account and your other linked bank accounts.

    0 讨论(0)
  • 2020-12-14 08:59

    With Java (we can do something like using 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();
    

    .....

    0 讨论(0)
  • 2020-12-14 09:07

    GetVerifiedStatus should do the trick. You'll have to pass the email address and the name of the person and it will then return whether or not their account has been verified.

    If they don't have a PayPal account you'll get an error back that says "Cannot determine PayPal Account status."

    Here's a sample of the request and response I just ran on the sandbox for a verified PayPal account...

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

    And here's a sample of a request and response where the PayPal account doesn't exist...

    <?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>
    
    0 讨论(0)
提交回复
热议问题