에 거래 ID를 얻기 위해 나는 응답 아래는있어?어떻게 아이폰 OS 페이팔 SDK
는 페이팔 REST API를 사용하여 는 TransactionId를 얻을 수있는 두 가지 단계가 있습니다, 1. AccessToken 2. AccessToken을 얻고 이 는 TransactionId를 얻을 수을 payment_id.
AccessToken을 얻으려면 아래에 몇 가지 참조 코드가 주어집니다. 마지막 두 줄에 대해 Objective-C로 코드를 변환하는 데 도움이 필요합니다. 헤더 (-H)를 알고 있지만 모르겠습니다. u는, 나는 아래의 코드를 사용
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
-d "grant_type=client_credentials"
을 -d하지만 오류주고있다 :.
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.sandbox.paypal.com/v1/oauth2/token"]];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];
[theRequest addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[theRequest addValue:@"Accept-Language" forHTTPHeaderField:@"en_US"];
[theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *strClientIdAndSecretKey=[NSString stringWithFormat:@"%@:%@",kPayPalClientId,kPayPalSecret];
[theRequest setValue:strClientIdAndSecretKey forHTTPHeaderField:@"client_id:secret"];
NSString *parameterString = [NSString stringWithFormat:@"grant_type=client_credentials"];
NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
//do post request for parameter passing
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[parameterString dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"Headers %@",[theRequest allHTTPHeaderFields]);
[NSURLConnection sendAsynchronousRequest:theRequest
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *dataOrder, NSError *error)
{
if(error == nil)
{
NSString *jsonString = [[[NSString alloc] initWithData:dataOrder encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"Result is %@",jsonString);
}
else
{
}
}
];
오류 도메인 = NSURLErrorDomain 코드 = -1012 "작업을 완료 할 수 없습니다 (NSURLErrorDomain를 오류 -1012). "UserInfo = 0xabd2bf0 {NSErrorFailingURLKey = https://api.sandbox.paypal.com/v1/oauth2/token, NSErrorFailingURL StringKey = https://api.sandbox.paypal.com/v1/oauth2/token, NSUnderlyingError = 0xabcf950 "작업을 완료 할 수 없습니다. (kCFErrorDomainCFNetwork 오류 -1012.) "}이 문제를 해결하기 위해, 어떤 아이디어 클라이언트 ID와 비밀을 통과하면서
내가 문제를 느낌?
참조 링크 : https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/#get-an-access-token –
안녕, 나는 동일한 문제가있는 경우 해당 URL을 사용하는 방법을 게시 코드로 알려주시겠습니까? – Minakshi