pinax/pinax-stripe-light

Handle product.updated webhook for plans (name)

blueyed opened this issue · 0 comments

If the name of a plan product is changed, a product.updated event is emitted,
but not handled by pinax-stripe to update the plan.

Example event:

{
  "id":"evt_1D6kEgIuxbTU2od2Zgc5sH2K",
  "object":"event",
  "account":"acct_XXX",
  "api_version":"2017-08-15",
  "created":1536089450,
  "data":{
    "object":{
      "id":"prod_XXX",
      "object":"product",
      "active":true,
      "attributes":[],
      "caption":null,
      "created":1535729477,
      "description":null,
      "images":[],
      "livemode":true,
      "metadata":{},
      "name":"WEEKLY",
      "package_dimensions":null,
      "shippable":null,
      "skus":{
        "object":"list",
        "data":[],
        "has_more":false,
        "total_count":0,
        "url":"/v1/skus?product=prod_XXX&active=true"
      },
      "statement_descriptor":null,
      "type":"service",
      "unit_label":null,
      "updated":1536089450,
      "url":null
    },
    "previous_attributes":{
      "name":"WEEKLY (fixed, with tax)",
      "updated":1536089439
    }
  },
  "livemode":true,
  "pending_webhooks":1,
  "request":{
    "id":"req_vcSdyW9nLWVM34",
    "idempotency_key":null
  },
  "type":"product.updated"
}

Code: https://github.com/pinax/pinax-stripe/blob/master/pinax/stripe/webhooks.py#L484-L512

"plan.updated" still gets used, but only if changing the nickname for example:

{
  "id":"evt_1D6kE7IuxbTU2od2DZJ7UpWX",
  "object":"event",
  "account":"acct_XXX",
  "api_version":"2017-08-15",
  "created":1536089415,
  "data":{
    "object":{
      "id":"prod-New Rochelle#77-WEEKLY-#42",
      "object":"plan",
      "active":true,
      "aggregate_usage":null,
      "amount":1295,
      "billing_scheme":"per_unit",
      "created":1535729477,
      "currency":"usd",
      "interval":"week",
      "interval_count":1,
      "livemode":true,
      "metadata":{},
      "name":"WEEKLY (fixed, with tax)",
      "nickname":"Weekly (fixed, with tax)",
      "product":"prod_XXX",
      "statement_descriptor":null,
      "tiers":null,
      "tiers_mode":null,
      "transform_usage":null,
      "trial_period_days":null,
      "usage_type":"licensed"
    },
    "previous_attributes":{
      "nickname":null
    }
  },
  "livemode":true,
  "pending_webhooks":1,
  "request":{
    "id":"req_5ri98H6uv3uIF6",
    "idempotency_key":null
  },
  "type":"plan.updated"
}