2012-07-12 1 views
0

내 앱에서 iPhone 앱으로 전자 송금 (e-commerce) 제품을 주문하고 싶습니다. 나는 쉽게 제품 이름과 세부 사항을 얻을 수 있지만, 제품에 대한 주문을 작성하는 동안 그것은 HTML 페이지에서 오류를 반환이다 :iOS 앱을 사용하여 전자 상거래를 유도하는 주문 만들기

NSString *str = [NSString stringWithFormat:@"http://localhost:3000/api/orders"]; 
NSURL *urlForBuy = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:urlForBuy]; 
NSString *idVariant = [NSString stringWithFormat:@"order[line_items][%d][variant_id]",0]; 
NSString *qnty = [NSString stringWithFormat:@"order[line_items][%d][quantity]",0]; 
NSString *idVariantValue = @"123456"; 
[request setPostValue:[NSString stringWithFormat:@"%d",[idVariantValue intValue]] forKey:idVariant]; 
[request setPostValue:[NSString stringWithFormat:@"%d",1] forKey:qnty]; 
[request setPostValue:@"<my admin token>" forKey:@"token"]; 
[request setRequestMethod:@"POST"]; 
[request setDelegate:self]; 
[request setDidFinishSelector:@selector(buyResponse:)]; 
[request setDidFailSelector:@selector(buyResponse_failed:)]; 
[networkQueue addOperation:request]; 
[networkQueue go]; 

또한,이 URL을 내가 얻을 : 나는 포스트 요청을 보내는거야

<h1> 
    TypeError 
    in Spree::Api::V1::OrdersController#create 
</h1> 
    <pre>can't convert Symbol into Integer</pre> 

http://guides.spreecommerce.com/rest.html

또 다른 것은 내가 알고 싶은 또 다른 것은이 URL에서 [line_items]가 무엇인지 알고 싶습니다 ... 또한 위의 URL과 다른 튜토리얼이라도 ...? 미리 감사드립니다.

답변

0

주문은 this test과 같이 광고 항목을 전달하여 API를 통해 생성됩니다.

api_post :create, :order => { 
    :line_items => [ 
    { 
     :variant_id => variant.to_param, 
     :quantity => 5 
    } 
    ] 
} 

line_items 파라미터는 variant_id 구성된 해시의 배열과 필드 quantity 것으로 예상된다. documentation는 요청은 다음과 같습니다 말한다 :

POST /api/orders?order[line_items][0][variant_id]=1&order[line_items[0][quantity]=5 

내가 그 당신이 그것을 더 잘 이해하는 데 도움이 바랍니다! 나는 그들이 두 개의 매개 변수를 전송하지 correct..here 메신저 생각으로 UR 대응을위한

+0

감사합니다 ... 당신이 내 매개 변수에서 봐 주시기 바랍니다 수 있습니다 ... iekey => 값 ("주문 [line_items] [0] [variant_id] => "12345"와 "order [line_items] [0] [quantity] => 1") ... 그들은 연금 계급입니까? reponse 얻어 올 기다리고 –

+0

당신은 당신의 첫번째 코멘트 후 * 한 시간 *을 "응답 대기"게시 된 –

+0

도움이됩니다. 즉시 다른 응답을 기대하는 것은 약간 무례합니다. 나는 네가 쓴 것이 아니다. –

관련 문제