#jskitz-subscriptions

1 messages · Page 1 of 1 (latest)

vapid lantern
left aspen
#

I just thought the plan object seemed easier to parse instead of price and makes more semantic sense to me. But probably I should not count on it and it's just there for backwards compatibility?

vapid lantern
#

i'm not seeing how the plan object would be easier to parse. The logic would be the same regardless of which parameter you choose.

You should always explicitly define the API version which you're using in your application. If there are breaking changes to the API, Stripe will cut a new version i.e. https://stripe.com/docs/upgrades#api-changelog. I can't say for sure what will happen in the future, but I would personally use the newest/latest parameters

left aspen
#

well in python for example, items is a function and so to get subscription.items, I need to use get_attr

#

the plan object comes back at top level, I don't have to cycle through the items when there is alway going to be one

#

I guess I can use subscription.get('items'), that seems to work in python

vapid lantern
#

uh, maybe i'm not seeing something? But the plan object is under items too

...
 "items": {
    "object": "list",
    "data": [
      {
        "id": "si_Lei2IzbufbmPzS",
        "object": "subscription_item",
        "billing_thresholds": null,
        "created": 1652072106,
        "metadata": {
        },
        "plan": {
          "id": "price_1KJUelJQtHgRImA7KnL24cg2",
          "object": "plan",
          "active": true,
...

left aspen
#

it's also at the top level

#
 "plan": {
    "active": true,
    "aggregate_usage": null,
    "amount": 600,
    "amount_decimal": "600",
    "billing_scheme": "per_unit",
    "created": 1645052573,
    "currency": "usd",
    "id": "price_1KTwWPGlyfQqa0B5pgR8rJJN",
    "interval": "month",
    "interval_count": 1,
    "livemode": false,
    "metadata": {},
    "nickname": null,
    "object": "plan",
    "product": "prod_LAH422PZ6dpXhY",
    "tiers_mode": null,
    "transform_usage": null,
    "trial_period_days": null,
    "usage_type": "licensed"
  },
  "quantity": 1,
  "schedule": null,
  "start_date": 1651617012,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_start": null
}
#

but I think I figured out how to get to items, but it's still a little clunky. I'm guessing most customers have one price in a subscription and don't need that to be a list of items

vapid lantern
#

if you have more than one price, the plan is null at the top level

left aspen
#

like people are subscribing to multiple products?

vapid lantern
#

yep

left aspen
#

Okay, got it... and looks like to get items, I can just do this in python items = sub.get('items') where sub is the subscription object. I was having problems because items is a function on a dictionary, so just a but of a naming conflict to get that attribute doing sub.items

#

something I'll need to be a little careful about in the future

vapid lantern
#

anything else i can help with?

left aspen
#

no that's it, thanks! Appreciate it