2017-05-01 8 views
1

나는 API 게이트웨이를 통해 나의 람다 기능을 Braintree의 Webhooks에 연결하는 방법에 대해 다소 혼란 스럽다. webhooks API를 통해 API를 통해 내 람다 함수를 호출하고 끝점 URL을 알고 있지만 내 람다 함수를 제대로 처리하고 웹 훅이 매개 변수로 함수를 호출 할 때 전달할 값을 사용하는 방법을 잘 모르겠습니다. 지금 당장 다음과 같은 메시지가 표시됩니다.webook 알림에서 AWS 람다 함수로 매개 변수를 가져 오는 방법은 무엇입니까?

package com.amazonaws.lambda.submerchantapproved; 

import java.util.HashMap; 

import com.amazonaws.services.lambda.runtime.Context; 
import com.amazonaws.services.lambda.runtime.RequestHandler; 

import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; 
import com.braintreegateway.BraintreeGateway; 
import com.braintreegateway.Environment; 
import com.braintreegateway.WebhookNotification; 
import com.braintreegateway.WebhookNotification.Kind; 

public class SubmerchantApproved implements RequestHandler<Object, String> { 


    public String handleRequest(Object request, Context context) { 

     BraintreeGateway gateway = new BraintreeGateway(
       Environment.SANDBOX, 
       "MyValue", 
       "MyValue", 
       "MyValue" 
     ); 

     WebhookNotification webhookNotification = gateway.webhookNotification().parse(
       request.queryParams("bt_signature"), 
       request.queryParams("bt_payload") 
     ); 


     String woofer = ""; 



     return woofer; 
    } 

} 

이것은 제대로 작동하지 않습니다. 얼마나 정확하게 내 lambda 함수에 이러한 bt_signature 및 by_payload 값을 가져다 줍니까? 웹 훅은 관련있는 http-POST 요청을 통해 데이터를 전달합니다.

+0

"* bt_signature 및 by_payload 값을 내 lambda 함수에 사용 하시겠습니까 ?? *" – hagrawal

답변

0

글쎄, Object request은 요청 매개 변수가 있어야하는 곳입니다.

  1. 당신은 프록시 모드로 API 게이트웨이를 구성하고 자바 코드를 입력 스트림을 구문 분석 할 수 있습니다 :

    자바 람다에 대한 두 가지 시나리오가 있습니다. AWS의 사람은 당신이 즉시 사용 예를 작성하는 매우 친절 : http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html#api-gateway-proxy-integration-lambda-function-java enter image description here

  2. 당신은 기존의 API 게이트웨이 매핑을 사용할 수 있습니다,하지만 당신은 bt_signature처럼 이러한 매개 변수를 구현하는 요구를 구현해야합니다 및 by_payload. 다시 말하지만 훌륭한 템플릿/예제는 AWS에서 구할 수 있습니다.