#stripe_connect_platform
1 messages · Page 1 of 1 (latest)
This sub:
sub_1LhJvlGkntF0z1iAKEToyE9X
for example:
Bought this price_id which is still in the format
plan_LvqKgcteOBhNJj
this boggles my mind
sorry for the delay, catching up here
Plan objects can still be used with subscriptions, even though the latest object type to use is Price
the issue is about importing subscription that can go back 10 years
or 7 years
actually
why is the price on sub.plan.id?
I am confused
is that a remnant from the past....or because we are using an old Stripe.api_version?
Subscription.list
Then we are importing
And I need to look on the sub for the thing they bought and save it in our db.
Plans were an older way of working with subscriptions, yes
Is it always on sub.plan.id? whether it is in the old plan_xxxxxxx or price_xxxxx format? and there will always be a Price for it in the account even if the Price id is in the old format sometimes?
In the sub obj, I am confused and concerned by the id being on the sub.plan and no existence of a sub.price
is that due to our old API version or is that just the way it is
Our code is like this:
price_id = sub.try(:plan).try(:id)
Seems confusing
Getting some help from a colleague!
yeah I'm a difficult case
Hello
What's the exact question here @misty hemlock? As noted, Plans are legacy but still functional. If used they will appear in the subscription item as both the data.plan.id and data.price.id.
Not coming that way
(byebug) sub.data
*** NoMethodError Exception: undefined method `data' for #Stripe::Subscription:0x00007fdc4df98018
nil
(byebug) sub.plan
#<Stripe::Plan:0x3fee19098138 id=plan_LvqKgcteOBhNJj> JSON: {
"id": "plan_LvqKgcteOBhNJj",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 10000,
"amount_decimal": "10000",
"billing_scheme": "per_unit",
"created": 1656023801,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "Amazing Plan",
"nickname": null,
"product": "prod_LvqKHdrdEDw3Ln",
"statement_descriptor": null,
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}
(byebug)
sub.data is null
sub.plan is there
sub.price is not there
sub.data.plan is not there
sub.data.price is that
The first one I get when importing subs
one sec
(byebug) sub.id
"sub_1LhJvlGkntF0z1iAKEToyE9X"
(byebug) sub.data
*** NoMethodError Exception: undefined method `data' for #Stripe::Subscription:0x00007fdc4df98018
Do we have to do an import with a newer API version?
That is question #1.
i couldn't even explain really
but basically you own a standard Stripe account and you have been using it for 7 years before you guys switched from Plan to Price so you have 100,000 subscriptions that were made over the last 7 years. You want to use our app so you want to import those subscriptions into our app. We are making an API call to Stripe after Oauth Connect to pull in your subs. Then we need to store relevant data like the thing the person purchased and have it associated with the Plan or Price or whatever you want to call it (now "Price")
Back in the day, we have a TestPlan table and a Plan table - worst mistake of my life.
Now we hae a Price table with a livemode attr
I am trying to see if we can just store everything in the Price table and disregard the old Plan and TestPlan tables......
I'm trying to code it so no matter what the subscription is or when it was created, that we pull the plan_or_price_id_xxxxxxxxxxxxxx
Sorry, this change totally messed with our app and it is hard to deal with the legacy app that was created when you all had Plans
I think I am just going to treat everything like a price
my guess is we are using an old api version - is that why the sub has no sub.data perhaps????
We are doing that b/c you made yet another change in listing subs
So yeah, you should be able to treat Prices and Plans the same. Shouldn't really matter here for Subs that have already been created.
We only want ['active','past_due','trialing''
And you used to list one way and now list another so switching the API version means I need to re-write the listing of subs too
Not sure what you mean by that
I think you used to like not return a sub if it was not active or something?
like if you retrieved a sub and it was not active you returned nil or you now have to explicitly put the status you want to retrieve, or something...i don't remember, I have to check but I think status was assumed and now has to be explicit or vice versa
We are doing this now:
results = Stripe::Subscription.list({ limit: 100, starting_after: starting_after, expand: ['data.customer'], status: 'active'}, :stripe_account => site.stripe_user_id )
No the only real change was that we stopped returning Subs by default when retrieving Customers
hmm
Can we get active, trialing and past_due in one API call?
results = Stripe::Subscription.list({ limit: 100, starting_after: starting_after, expand: ['data.customer'], status: 'active'}, :stripe_account => site.stripe_user_id )
instead of just active?
Then just trialing:
results = Stripe::Subscription.list({ limit: 100, starting_after: starting_after, expand: ['data.customer'], status: 'trialing'}, :stripe_account => site.stripe_user_id )
etc.
status ['active','trialing','past_due']
No
You can set 1 of the enums, you can set all, or you can leave blank which will return all except for canceled.
right so to get ['active','trialing','past_due'] we have to do it 3 times
ok, that is the same in new API versions?
Yes
ok
so anyway, yes so why do you say to look at the sub.data.id when sub.data is nil?
everything is in plan:
"pending_setup_intent": null,
"pending_update": null,
"plan": {"id":"plan_LvqKgcteOBhNJj","object":"plan","active":true,"aggregate_usage":null,"amount":10000,"amount_decimal":"10000","billing_scheme":"per_unit","created":1656023801,"currency":"usd","interval":"month","interval_count":1,"livemode":false,"metadata":{},"name":"Amazing Plan","nickname":null,"product":"prod_LvqKHdrdEDw3Ln","statement_descriptor":null,"tiers":null,"tiers_mode":null,"transform_usage":null,"trial_period_days":null,"usage_type":"licensed"},
"quantity": 1,
sub.plan
Yeah checking on that. That may be due to old API version retrieval
which is weird since its now a price
Try listing with newest (2022-08-01)
OK, so just checking
given the scenario of someone who has a stripe account that has been gathering subs for like 7 years, nothing will be lost using Subscription.list with the new API version?
And do you suggest looking at
sub.data.price.id
There are some changes. It all depends on what you are using. I don't know your integration. You should check our Changelog (https://stripe.com/docs/upgrades) for full breaking changes. Things like start versus start_date did change: https://stripe.com/docs/upgrades#2019-10-17.
Are you listing and you have sub.data?
Yes, but mine weren't created with an old API version
That's what I still need to check on
oh
yeah, i am not getting that .data
we definitely don't want to corrupt the import and only get subs created with the new API versions.
ye
yes
just did
*** NoMethodError Exception: undefined method `data' for #Stripe::Subscription:0x00007ff5d74f1940
And the Subscription item data is under plan
yes sir
What is your exact log?
sorry i am not sure I know what you mean. When you say log I think you mean this, no:
*** NoMethodError Exception: undefined method `data' for #Stripe::Subscription:0x00007ff5d74f1940
the problem with us is we need to always deal with lots of edge cases like subs created over the last 7 years and need to know where to look in the object for the right data no matter the edge case
No sorry, I mean what exactly are you logging out? Like subscriptions.data[0].items.data?
?
subscriptions is an array of subscriptions we pulled from stripe
i am in one subscription stored as a sub
sub.data fails
with a NoMethodError
(byebug) subscriptions.data
*** NoMethodError Exception: undefined method `data' for #Array:0x00007ff5e1790e30
there is no subscriptions.data....It's an array of subscriptions
i am going to need to take a break for my sanity
thank you for trying