如何读取条带webhook响应 [英] How to read the stripe webhook response

查看:146
本文介绍了如何读取条带webhook响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了coldfusion文件以捕获STRIPE webhook响应。

I have created the coldfusion file to catch the STRIPE webhook response.

<cfsavecontent variable="headerdump">
    <cfdump var="#toString(getHttpRequestData().content, 'utf-8')#" expand="yes" format="text">
</cfsavecontent>

当我打印headerdump,得到以下响应。我想提取输出文本的节点值。

When i print the headerdump, got the below response. I want to extract the node values of the output text.

<pre>{
  "id": "evt_1041EO45YXiN2y2zPhZbNrgh",
  "created": 1399872268,
  "livemode": false,
  "type": "invoice.payment_succeeded",
  "data": {
    "object": {
      "date": 1399872268,
      "id": "in_1041EO45YXiN2y2zQF1xhLyl",
      "period_start": 1399872268,
      "period_end": 1399872268,
      "lines": {
        "object": "list",
        "total_count": 1,
        "has_more": false,
        "url": "/v1/invoices/in_1041EO45YXiN2y2zQF1xhLyl/lines",
        "data": [
          {
            "id": "sub_41EOmzNFelCyAL",
            "object": "line_item",
            "type": "subscription",
            "livemode": false,
            "amount": 0,
            "currency": "usd",
            "proration": false,
            "period": {
              "start": 1399872268,
              "end": 1399958668
            },
            "quantity": 1,
            "plan": {
              "interval": "month",
              "name": "test one day",
              "created": 1399536505,
              "amount": 500,
              "currency": "usd",
              "id": "test_001",
              "object": "plan",
              "livemode": false,
              "interval_count": 1,
              "trial_period_days": 1,
              "metadata": {
              },
              "statement_description": "half day trial"
            },
            "description": null,
            "metadata": null
          }
        ]
      },
      "subtotal": 0,
      "total": 0,
      "customer": "cus_41EOvhzjYGx7ci",
      "object": "invoice",
      "attempted": true,
      "closed": true,
      "paid": true,
      "livemode": false,
      "attempt_count": 0,
      "amount_due": 0,
      "currency": "usd",
      "starting_balance": 0,
      "ending_balance": null,
      "next_payment_attempt": null,
      "charge": null,
      "discount": null,
      "application_fee": null,
      "subscription": "sub_41EOmzNFelCyAL",
      "metadata": {
      },
      "description": null
    }
  },
  "object": "event",
  "pending_webhooks": 1,
  "request": "iar_41EO1vDF1gpnPn"
}</pre> 

请建议如何在coldfusion或javascript中阅读。

Please suggest how to read this either in coldfusion or javascript.

感谢

推荐答案

我这样做:

<cfscript>
  variables.requestdata = getHTTPRequestData();
  variables.sStripeData = toString(variables.requestdata.content);
  variables.stStripeData  = deserializeJSON(variables.sStripeData);
</cfscript>

这篇关于如何读取条带webhook响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆