#Marques
1 messages · Page 1 of 1 (latest)
You can get it from the subscription's items (https://stripe.com/docs/api/subscriptions/object#subscription_object-items)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I wasn't able to find I tat all in It
But at the moment that I would search It up the ID (that I also repeated in the metadata of It) I m getting the ID of the sub first created
Can you share with me the subscription ID?
for example
you created Sub "A" with me
then you update for "B"
my endpoint is receiving Sub A as ID being updated to
sub_1NTcuFCLLdrjzwRfysA4clLS
What do you mean by then you update for "B" ?
you have subscription "Basic"
then you update for subscription "Ultimate" for example
the system of stripe updates under customer that its new subscription is now "Ultimate"
but my endpoint using the webhook received "Basic" instead
https://dashboard.stripe.com/test/events/evt_1NTcvyCLLdrjzwRfGzVoAX3i Based on this event, the subscription item was changed from "Ultimate" plan to "Basic" plan
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I did it vice versa
I will create a new one for you to follow along ok one se
sec
sub_1NTd3DCLLdrjzwRfTDzgXQ1f | Ultimate created
my price registered is "price_1NSDd2CLLdrjzwRffISyFJOg"
now changing my plan
as you can see here, I'm getting the metadata from the Ultimate instead of the Basic see?
When is this updateSubscription function called? is it in your webhook event handler?
else if (stripeEvent.Type == Events.CustomerSubscriptionUpdated)
{
var session = stripeEvent.Data.Object as Stripe.Subscription;
// Update Subsription
await updateSubscription(session);
}
I've also tried going from Basic to Ultiamte memberships and I still got the same error
And how did you set the metadata?
manually in the website
each of them have their own price_id in the meta data
Did you update the metadata when creating the customer portal session?
no
the metadata that is retrieving is from the subscription thats the endpoint is receiving
Hello Orakaro
Hi there, taking over and gimme a few mins to catch up
sure
Sorry the content was a bit confusing. Can you list out
- Which Subscription Id you are currently testing?
- The request id when you created it req_xxx
- The request id when you updated it req_xxx
You can find 2 and 3 from your Dashboard log https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I will create one from scratch and get this data one sec
1- sub_1NTdEgCLLdrjzwRfUBaD2Iye
2- req_CSKM6lGvQr74pe
3- req_pb1yxez807TDHR
@last viper
Okie so I am seeing you updated from a $7 price to a $16.5 price, and this event showed you exactly the change
https://dashboard.stripe.com/test/events/evt_1NTdG4CLLdrjzwRfwVHDukys
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
yes
how do I get the new subscription thats being assigned in here?
thats the problem we are trying to figure out, because its currently passing the subscription that the user first assigned to
instead of getting the new one
Let's avoid confustion. There is only 1 Subscription. It changes the Price from price_1NSDWjCLLdrjzwRfbnN68Oev ($7) to price_1NSDZUCLLdrjzwRfH1zfJlqB ($16.5)
There is no old or new Subscription
ok I see what you mean makes sense
the problem is that we are not getting the new price thats its changing it to
it changes in the stripe server yes
but my endpoint ( from the webhook) is receiving the $7 instead of $16
You get the price from the metadata, correct?
yes
Metadata doesn't change in a Customer Portal action from customer
what would be the best way to retrieve the price_id from the new price its being assigned to?
So there are 2 issues here:
- You need to figure it out how to update the latest Price Id into the Subscription metadata
- You... shouldn't rely on the metadata in the first place. Why don't you just retrieve the price id inside the Subscription's items?
I think it's more of the 2. question
You look at the event https://dashboard.stripe.com/test/events/evt_1NTdG4CLLdrjzwRfwVHDukys, see items.data.price
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
would it be in here?
Yes, navigate to its items first, what do you see?
Yes let's look at the Data. It should be an array
Look at the elements inside that array
perfect finally lol
I get the object in a JSON object actually
oh wait
{<Stripe.Plan@18200632 id=price_1NSDZUCLLdrjzwRfH1zfJlqB> JSON: {
"id": "price_1NSDZUCLLdrjzwRfH1zfJlqB",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1650,
"amount_decimal": 1650.0,
"billing_scheme": "per_unit",
"created": 1688970464,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"product": "prod_OEgxOjINruzgmu",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}}
yes, I was able to get now the new price being assigned inside of this JSON being retrieved uhU!
np and good luck!
quick question since u here
my webhook is calling " else if (stripeEvent.Type == Events.CustomerSubscriptionUpdated)
"
even tho im just craeting a subsritpion (for the 1st time)
is it normal?
That event should only fired if the Sub is updated, ie. via the Customer Portal like you said
look
I just erased my customers and Im creating a new sub from scratch
3
my breakpoint is hitting here even tho Im just creating from scratch
I deleted customers from Stripe and also my db
So you want to look at your Subscription on Dashboard and see why did the event happen
Utilize https://dashboard.stripe.com/test/logs !
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Also past the Subscripiton Id directly to the Dashboard search bar
oh thats a new one
got it
Scroll down you will see the request and the events related
nothing abt update as you can see, all brand new
from the bottom to the top
?
from the top!
Can you give me that event id? evt_xxx
Ah I see, this is normal. You can see it has
previous_attributes: {
default_payment_method: null,
status: "incomplete"
}
hm
Which means it changes status from incomplete to active and attached a new payment method
oh I see
it happens when a customer paid your Checkout
oh ok just wanted to know that was all
thank you so much
the support that you guys provide
are just amazing
20 out of 10 congrats
Thanks for your kind words! Hope that unblocks you!