小编zam*_*ler的帖子

Play 框架的 Stripe Webhook 验证错误

我正在尝试使用播放框架应用程序设置条带支付。我在设置 webhook 时遇到问题。

com.stripe.exception.SignatureVerificationException: No signatures found matching the expected signature for payload
Run Code Online (Sandbox Code Playgroud)

这是我尝试构建从条带发送的事件时不断收到的错误。我打印出正文和签名的值,它们看起来应该是正确的。这是我用来收集 webhook 的代码。

 def webhook = Action { implicit request: Request[AnyContent] =>
println(request.headers.toMap)
val bodyOp:Option[JsValue] = request.body.asJson
val sigOp:Option[String] = request.headers.get("Stripe-Signature")
var event: Event = null
if (bodyOp.isEmpty || sigOp.isEmpty) {
  WebhookController.logger.write("EMPTY BODY OR SIG body-"+bodyOp+"   sig-"+sigOp,Logger.RED)
  BadRequest
} else {
  val body = bodyOp.get.toString
  val sig = sigOp.get
  println(body)
  println(sig)
  try {
    event = Webhook.constructEvent(body, sig, "whsec_5XwS8yCNOcq1CKfhh2Dtvm8RaoaE3p7b")
    val eventType: String = event.getType
    eventType match {
      case …
Run Code Online (Sandbox Code Playgroud)

scala webhooks playframework stripe-payments

4
推荐指数
1
解决办法
1241
查看次数

标签 统计

playframework ×1

scala ×1

stripe-payments ×1

webhooks ×1