来自iOS的PayPal错误580001 HTTP请求

前端之家收集整理的这篇文章主要介绍了来自iOS的PayPal错误580001 HTTP请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在iOS中实施自适应付款方面遇到困难,不幸的是PayPal的网站或响应文件很少.这是代码
  1. - (void)makePaymentSandBox{
  2.  
  3. NSError *error;
  4.  
  5. //NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  6. //NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
  7.  
  8. NSURL *url = [NSURL URLWithString:@"https://svcs.sandBox.paypal.com/AdaptivePayments/Pay"];
  9.  
  10. NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
  11. cachePolicy:NSURLRequestUseProtocolCachePolicy
  12. timeoutInterval:30.0];
  13.  
  14. //setting
  15. [request setHTTPMethod:@"POST"];
  16.  
  17. //headers
  18. [request addValue:@"alex.rietmann-facilitator_api1.fastwebnet.it" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
  19. [request addValue:@"FW79EZXPFP69NE8X" forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"];
  20. [request addValue:@"ABSua9nnv9nnkoN4MwVt15YdgetaJHcyzqOHjkLbuM-bGRoI7WRS" forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"];
  21. //NV
  22. [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"];
  23. [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"];
  24.  
  25. [request addValue:@"APP-80W284485P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];
  26.  
  27. [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  28. [request addValue:@"en_US" forHTTPHeaderField:@"Accept-Language"];
  29.  
  30.  
  31. //data
  32.  
  33. /*NSString *userUpdate =[NSString stringWithFormat:@"clientDetails.applicationId=%@&actionType=%@",@"APP-80W284485P519543T",@"PAY",nil];
  34. NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
  35. [request setHTTPBody:data1];
  36. [request setValue: [NSString stringWithFormat:@"%lu",(unsigned long)[data1 length]] forHTTPHeaderField:@"Content-Length"];*/
  37.  
  38.  
  39. NSDictionary *mapData = [[NSDictionary alloc] initWithObjectsAndKeys:
  40.  
  41. @"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];
  42. NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
  43. [request setHTTPBody:postData];
  44.  
  45.  
  46. [NSURLConnection connectionWithRequest:request delegate:self];
  47. }

这是响应:

  1. String: {
  2. error = (
  3. {
  4. category = Application;
  5. domain = PLATFORM;
  6. errorId = 580001;
  7. message = "Invalid request: {0}";
  8. severity = Error;
  9. subdomain = Application;
  10. }
  11. );
  12. responseEnvelope = {
  13. ack = Failure;
  14. build = 17325060;
  15. correlationId = e82ede718b929;
  16. timestamp = "2015-07-14T09:50:06.222-07:00";
  17. };
  18. }

解决方法

请检查:

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

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

猜你在找的iOS相关文章