【问题标题】:Stripe invoice.upcoming webhookStripe invoice.upcoming webhook
【发布时间】:2022-03-21 19:20:20
【问题描述】:

我想知道 invoice.upcoming webhook of stripe 的示例数据是什么。

data.object.id 是否为空?

我在哪里可以得到金额?是 data.object.amount_paid 还是 data.object.amount_due

这张发票的状态是什么?

我在 stackoverflow 中获得的示例数据,但我认为它不完整?

{
"created": 1326853478,
"livemode": false,
"id": "evt_000000000010000",
"type": "invoice.upcoming",
"object": "event",
"request": null,
"pending_webhooks": 1,
"api_version": "2017-06-05",
"data": {
  "object": {
    "id": null,
    "object": "invoice",
    "amount_due": 0,
    "amount_paid": 0,
    "application_fee": null,
    "attempt_count": 0,
    "attempted": true,
    "charge": null,
    "closed": true,
    "currency": "usd",
    "customer": "cus_J1QXR23OrUTxx1fk",
    "date": 1503541536,
    "description": null,
    "discount": null,
    "ending_balance": 0,
    "forgiven": false,
    "lines": {
      "data": [
        {
          "id": "sub_BNx15yNiTkAlQOye",
          "object": "line_item",
          "amount": 500,
          "currency": "jpy",
          "description": null,
          "discountable": true,
          "livemode": true,
          "metadata": {
          },
          "period": {
            "start": 1507604796,
            "end": 1510283196
          },
          "plan": {
            "id": "bplan",
            "object": "plan",
            "amount": 500,
            "created": 1504352393,
            "currency": "jpy",
            "interval": "month",
            "interval_count": 1,
            "livemode": false,
            "metadata": {
            },
            "name": "B plan",
            "statement_descriptor": null,
            "trial_period_days": null
          },
          "proration": false,
          "quantity": 1,
          "subscription": null,
          "subscription_item": "si_1B0LmKE9P3qCpf5erqbpMxkI",
          "type": "subscription"
        }
      ],
      "total_count": 1,
      "object": "list",
      "url": "/v1/invoices/in_1AuB2KE9P3qCpf5ekFh7qpAi/lines"
    },
    "livemode": false,
    "metadata": {
    },
    "next_payment_attempt": null,
    "paid": true,
    "period_end": 1503541536,
    "period_start": 1503541536,
    "receipt_number": null,
    "starting_balance": 0,
    "statement_descriptor": null,
    "subscription": "sub2JQx1xlg9zIFhk",
    "subtotal": 0,
    "tax": null,
    "tax_percent": null,
    "total": 0,
    "webhooks_delivered_at": 1503541537
  }
}

}

【问题讨论】:

    标签: javascript node.js stripe-payments


    【解决方案1】:

    从仪表板生成的那些事件完全是假的,所以我认为您永远不会在其中找到可用的数据,但 amount_due 是您想要的。

    由于尚未创建即将到来的发票 - 它们只是未来费用的预览 - 它们没有 ID 或状态。

    【讨论】:

    • 这里的data.object.lines也是空的吗?
    • @bossajie 使用stripe 的test clocks 功能,我可以告诉你data.object.linesinvoice.upcoming 事件对象中可用。
    【解决方案2】:

    这是 Stripe 的 invoice.upcoming 事件的完整示例。 我使用test clocks 功能找到了它。请注意,这是您通过续订年度订阅可获得的数据类型。

    {
      "object": "invoice",
      "account_country": "US",
      "account_name": "Your company",
      "account_tax_ids": null,
      "amount_due": 9900,
      "amount_paid": 0,
      "amount_remaining": 9900,
      "application_fee_amount": null,
      "attempt_count": 0,
      "attempted": false,
      "automatic_tax": {
        "enabled": false,
        "status": null
      },
      "billing_reason": "upcoming",
      "charge": null,
      "collection_method": "charge_automatically",
      "created": 1679397051,
      "currency": "usd",
      "custom_fields": null,
      "customer": "cus_XXXXXXXX",
      "customer_address": null,
      "customer_email": "xxxx@user.io",
      "customer_name": "Customer name",
      "customer_phone": null,
      "customer_shipping": null,
      "customer_tax_exempt": "none",
      "customer_tax_ids": [],
      "default_payment_method": null,
      "default_source": null,
      "default_tax_rates": [],
      "description": null,
      "discount": null,
      "discounts": [],
      "due_date": null,
      "ending_balance": 0,
      "footer": null,
      "last_finalization_error": null,
      "lines": {
        "object": "list",
        "data": [
          {
            "id": "il_tmp_xxxxxxxxxxxxxxxxxxxxxxx",
            "object": "line_item",
            "amount": 9900,
            "currency": "usd",
            "description": "1 × Your sub (at $99.00 / year)",
            "discount_amounts": [],
            "discountable": true,
            "discounts": [],
            "livemode": false,
            "metadata": {},
            "period": {
              "end": 1711019451,
              "start": 1679397051
            },
            "plan": {
              "id": "price_XXXXXXXXXXXXXXXX",
              "object": "plan",
              "active": true,
              "aggregate_usage": null,
              "amount": 9900,
              "amount_decimal": "9900",
              "billing_scheme": "per_unit",
              "created": 1600678675,
              "currency": "usd",
              "interval": "year",
              "interval_count": 1,
              "livemode": false,
              "metadata": {},
              "nickname": null,
              "product": "prod_XXXXXXXXXXXX",
              "tiers_mode": null,
              "transform_usage": null,
              "trial_period_days": null,
              "usage_type": "licensed"
            },
            "price": {
              "id": "price_XXXXXXXXXXXXXX",
              "object": "price",
              "active": true,
              "billing_scheme": "per_unit",
              "created": 1600678675,
              "currency": "usd",
              "livemode": false,
              "lookup_key": null,
              "metadata": {},
              "nickname": null,
              "product": "prod_XXXXXXXXXXXX",
              "recurring": {
                "aggregate_usage": null,
                "interval": "year",
                "interval_count": 1,
                "trial_period_days": null,
                "usage_type": "licensed"
              },
              "tax_behavior": "unspecified",
              "tiers_mode": null,
              "transform_quantity": null,
              "type": "recurring",
              "unit_amount": 9900,
              "unit_amount_decimal": "9900"
            },
            "proration": false,
            "proration_details": {
              "credited_items": null
            },
            "quantity": 1,
            "subscription": "sub_XXXXXXXXXXXXXX",
            "subscription_item": "si_XXXXXXXXXXXX",
            "tax_amounts": [],
            "tax_rates": [],
            "type": "subscription"
          }
        ],
        "has_more": false,
        "total_count": 1,
        "url": "/v1/invoices/upcoming/lines?customer=cus_XXXXXXXXXXXX&subscription=sub_XXXXXXXXXXX"
      },
      "livemode": false,
      "metadata": {},
      "next_payment_attempt": 1679400651,
      "number": null,
      "on_behalf_of": null,
      "paid": false,
      "paid_out_of_band": false,
      "payment_intent": null,
      "payment_settings": {
        "payment_method_options": null,
        "payment_method_types": null
      },
      "period_end": 1679397051,
      "period_start": 1647861051,
      "post_payment_credit_notes_amount": 0,
      "pre_payment_credit_notes_amount": 0,
      "quote": null,
      "receipt_number": null,
      "starting_balance": 0,
      "statement_descriptor": null,
      "status": "draft",
      "status_transitions": {
        "finalized_at": null,
        "marked_uncollectible_at": null,
        "paid_at": null,
        "voided_at": null
      },
      "subscription": "sub_XXXXXXXXXXXX",
      "subtotal": 9900,
      "tax": null,
      "test_clock": "clock_1Kfj8pAP8XE2C2mat1YQW7Rg",
      "total": 9900,
      "total_discount_amounts": [],
      "total_tax_amounts": [],
      "transfer_data": null,
      "webhooks_delivered_at": null
    }
    

    【讨论】:

      猜你喜欢
      • 2020-01-30
      • 2015-04-18
      • 2017-10-03
      • 2021-01-14
      • 2018-09-18
      • 2021-11-28
      • 2015-02-27
      • 2013-08-13
      • 2020-05-16
      相关资源
      最近更新 更多