来自iOS的PayPal错误580001 HTTP请求

在iOS中实施自适应付款方面遇到困难,不幸的是PayPal的网站或响应文件很少.这是代码:
- (void)makePaymentSandbox{

    NSError *error;

    //NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    //NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];

    NSURL *url = [NSURL URLWithString:@"https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
                                                           cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:30.0];

    //setting
    [request setHTTPMethod:@"POST"];

    //headers
    [request addValue:@"alex.rietmann-facilitator_api1.fastwebnet.it" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
    [request addValue:@"FW79EZXPFP69NE8X" forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"];
    [request addValue:@"ABSua9nnv9nnkoN4MwVt15YdgetaJHcyzqOHjkLbuM-bGRoI7WRS" forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"];
    //NV
    [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"];
    [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"];

    [request addValue:@"APP-80W284485P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];

    [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request addValue:@"en_US" forHTTPHeaderField:@"Accept-Language"];


    //data

    /*NSString *userUpdate =[NSString stringWithFormat:@"clientDetails.applicationId=%@&actionType=%@",@"APP-80W284485P519543T",@"PAY",nil];
    NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data1];
    [request setValue: [NSString stringWithFormat:@"%lu",(unsigned long)[data1 length]] forHTTPHeaderField:@"Content-Length"];*/


    NSDictionary *mapData = [[NSDictionary alloc] initWithObjectsAndKeys:

                             @"PAY",@"actionType",@"USD",@"currencyCode",@"http:\\www.cleverlyapp.com",@"cancelUrl",@"returnUrl",@"ReturnAll",@"requestEnvelope.detailLevel",@"en_US",@"requestEnvelope.errorLanguage",@"seneder@email.com",@"senderEmail",@"0.1",@"receiverList.receiver(0).amount",@"a-buyer@fastwebnet.it",@"receiverList.receiver(0).email",@"receiverList.receiver(1).amount",@"a-facilitator@fastwebnet.it",@"receiverList.receiver(1).email",@"clientDetails.applicationId",nil];
    NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
    [request setHTTPBody:postData];


    [NSURLConnection connectionWithRequest:request delegate:self];
}

这是响应:

String: {
    error =     (
                {
            category = Application;
            domain = PLATFORM;
            errorId = 580001;
            message = "Invalid request: {0}";
            severity = Error;
            subdomain = Application;
        }
    );
    responseEnvelope =     {
        ack = Failure;
        build = 17325060;
        correlationId = e82ede718b929;
        timestamp = "2015-07-14T09:50:06.222-07:00";
    };
}

解决方法

请检查:

> Adaptive Payments Pay API Error 580001
> 580001 Invalid request: {0} PayPal (PHP)
> Error 580001

一些与编码有关,设置为JSON,但实际发送为URL编码等,其他与使用的货币和货币格式有关(例如发送的值不应包含货币符号等)

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...