来自iOS的PayPal错误580001 HTTP请求

前端之家收集整理的这篇文章主要介绍了来自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编码等,其他与使用的货币和货币格式有关(例如发送的值不应包含货币符号等)

原文链接:https://www.f2er.com/iOS/336003.html

猜你在找的iOS相关文章