我对如何通过API网关将我的Lambda函数连接到Braintree的Webhooks感到困惑。我知道webhooks通过api gateway via和endpoint URL调用我的lambda函数,但是我不确定如何设置我的lambda函数来正确处理它并使用webhooks在调用函数时将作为参数传递的值。我现在有以下内容:
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;
}
}
但这不起作用或正确。我的意思是如何将这些bt_signature和by_payload值放入我的lambda函数中? webhooks通过相关的http-POST请求传递数据。
答案 0 :(得分:0)
嗯,您的Object request
正是这些请求参数的确切位置。
Java Lambdas有两种主要方案:
bt_signature
和by_payload
等参数的请求类。同样,AWS提供了一个很棒的模板/示例:http://docs.aws.amazon.com/lambda/latest/dg/java-handler-io-type-pojo.html