在我的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電子郵件地址的最佳方法嗎?
請檢查[這裏](http://stackoverflow.com/questions/36887028/create-paypal-sandbox-merchant-seller-account) – fresher