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

标签 ios objective-c email paypal paypal-adaptive-payments

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

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];
    }

}

但它无法正常工作,我收到以下响应:

Paypal Verified: { error = ( { category = Application; domain = PLATFORM; errorId = 580023; message = "Cannot determine PayPal Account status"; severity = Error; subdomain = Application; } ); responseEnvelope = { ack = Failure; 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 请求中,试一试。

关于ios - 使用电子邮件地址检查 PayPal 帐户是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36875645/

相关文章:

linux - 如果其中一个文件存在,则在 bash shell 脚本中发送电子邮件警报

android - 发送内容不可编辑的电子邮件

iOS 未收到通过 API 发送的 Firebase 推送通知

ios - UIToolbar 的自定义 UIBarButtonItem

ios - 将包含 Latex Command for Mathematical 公式的 HTML 文本转换为输出正确公式的纯文本或属性文本

javascript - 等待网站完成加载所有 javascript

iphone - Objective-C 矩形 CGPoint 到极坐标 CGPoint

ios - 在标签栏顶部显示 View

ios - 使用 Kii 查询结果

php - wp_mail() 函数发送单个邮件花费的时间太长