检查PayPal帐户是否存在使用电子邮件地址?

问题描述:

在我的iOS应用程序中,我需要检查用户的PayPal电子邮件地址是否有效。实现这个最简单的方法是什么?我一直都在使用GetVerifiedStatus API和尝试下面的代码:检查PayPal帐户是否存在使用电子邮件地址?

NSDictionary *dict1 = [[NSDictionary alloc]initWithObjectsAndKeys:email, @"emailAddress", nil]; 

NSDictionary *postDict = [[NSDictionary alloc]initWithObjectsAndKeys: dict1,@"accountIdentifier",@"NONE",@"matchCriteria", 
          [[NSDictionary alloc] initWithObjectsAndKeys:@"en_US", @"errorLanguage", @"detailLevel", @"ReturnAll", nil], @"requestEnvelope", nil]; 

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus"]] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0]; 

[request setHTTPMethod:@"POST"]; 
[request addValue:@"your_user_id" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"]; 
[request addValue:@"your_password" forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"]; 
[request addValue:@"your_signature" forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"]; 
[request addValue:@"APP-80W284485P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"]; 
[request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"]; 
[request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"]; 
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; 
[request addValue:@"en_US" forHTTPHeaderField:@"Accept-Language"]; 

NSError *dError = nil; 
NSData *postData = [NSJSONSerialization dataWithJSONObject:postDict options:0 error:&dError]; 

[request setHTTPBody:postData]; 

NSError *error = nil; 
NSHTTPURLResponse *res = nil; 

NSData *retData = [NSURLConnection sendSynchronousRequest:request returningResponse:&res error:&error]; 

if (error) 
{ 
    NSLog(@"Error getting paypal verification: %@", error); 
} 
else 
{ 

    NSError *jsonError = nil; 
    NSDictionary *details = [NSJSONSerialization JSONObjectWithData:retData options:kNilOptions error:&jsonError]; 

    if (jsonError != nil) { 

     NSLog(@"Error parsing JSON %@", jsonError); 
    } 
    else { 

     NSLog(@"Paypal Verified: %@", details); 

     [self savePayPal]; 
    } 

} 

但它不能正常工作,我得到如下回应:

淘宝钻石卖家:{ 误差=( { category = Application; domain = PLATFORM; errorId = 580023; message =“无法确定PayPal帐户状态”; severity =错误; subdomain = Appl ication; } ); responseEnvelope = { ack =失败; build = 21336090; correlationId = 96eea5ecc47fb; timestamp =“2016-04-26T13:41:52.437-07:00”; };

因此,没有人知道我为什么会收到“无法确定PayPal账户状态”,这是验证PayPal电子邮件地址的最佳方法吗?

根据错误消息,您的API请求中的电子邮件地址不是已有的PayPal沙箱帐户,因此PayPal会抛出“无法确定PayPal帐户状态”错误消息。 您可以在developer.paypal.com上注册一个沙盒帐户,请参阅https://developer.paypal.com/docs/integration/paypal-here/sandbox-testing/managing-sandbox-accounts/?mark=sandbox,然后将这个新的沙盒帐户放入您的API请求中,试试看。

+0

请检查[这里](http://*.com/questions/36887028/create-paypal-sandbox-merchant-seller-account) – fresher