How to Receive Webhook from Stripe in Java

后端 未结 4 1804
眼角桃花
眼角桃花 2021-02-06 10:13

I am trying to receive a webhook via a post request from Stripe Payments. The java method to process it looks like this:

@ResponseBody
@RequestMapping(    consu         


        
4条回答
  •  你的背包
    2021-02-06 10:40

    public String stripeWebhookEndpoint(@RequestBody String json, HttpServletRequest request) {         
            String header = request.getHeader("Stripe-Signature");      
            String endpointSecret = "your stripe webhook secret";
            try {
                event = Webhook.constructEvent(json, header, endpointSecret);
                System.err.println(event);
            } catch (SignatureVerificationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
             //
             enter code here
          return "";
    
    }
    

提交回复
热议问题