#skammerens-datter_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1259899486667407421
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
You should store at least the Customer and Subscription IDs
okay, thank you for the clarification ๐
while I have you, I have another quick question;
we have been using the Stripe API in php with \Stripe\Stripe::setApiKey('sk_XYZ'); for Stripe Connect and that line is set in an environment file that is used everywhere, and we're not touching that legacy integration. But we need the $stripe = new \Stripe\StripeClient('sk_XYZ'); way of doing it with the new code method in your docs. Can we have both lines in our env?
or is there a way to set the api key that will both affect the legacy method and the new one? it is the same API library
Those are 2 different things, right? One sets the key on the server-side and one sets it on the client-side?
the first is the legacy way of initializing a stripe client, and the latter is the updated way of doing the same. Both are for server-side
both are PHP by the way
Got it. If you're using an old version of the SDK, then use the old API auth method. If you're using the new one, use the new auth method.
okay, but since the legacy method does not store the client as a variable, e.g. $stripe, how can we reference it when doing for example: $stripe->customers->create([? The docs do not include the legacy approach, so we have to do \Stripe\Customer::create ... or something similar, but those calls are not referenced anywhere anymore... Keep in mind the code using the "legacy" approach is 2 years old
You can't. If there's no Stripe object instantiated, then you can't use its methods
Thank you - i need to create a new thread, could you please close this one? ๐
If you have another question, just ask it here and I'll follow up
okay perfect: following the guide here: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements#change-price
it seems counter-intuitive that I supply a new price id for the subscription, without changing the product id... if the product id is not updated i cannot determine what features to provision access to
the guide just tells me to update the price id for the subscription, and "The subscription is now Premium, at 15 USD per month, instead of Basic at 5 USD per month." - but nowhere are we changing the product to Premium, just updating the price
You seem to misunderstand the relationship of Products and Prices: https://docs.stripe.com/products-prices/how-products-and-prices-work
One Product can have multiple Prices. If you're provisioning access to a Premium service, then you need to look at the Premium Price of the Product, instead of just the Product itself
if i have 3 products, one is a Free tier, the other is a Premium tier and the third an Enterprise tier, each of those have two prices associated with them (monthly and yearly). If a customer of mine has the Premium tier (product) with the price (monthly) and they decide to upgrade to Enterprise, if I simply update the price id for the subscription, how will Stripe know that the product has changed to Enterprise
I don't understand the question. If you have 3 Products and you add a new Price from one of them, the Subscription uses that new Price. We don't ask you to add a Product at any point as far as I know: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
Let me clarify; from the guide I just sent it explicitly mentions how to enable my customer to change their "plan". If i have a settings page where they can change their plan; either upgrade or downgrade, the guide tells me to simply update the subscription with the new price id, but I would imagine it should be updated with the product id of the new plan. Unless Stripe infers the product id from the price id (child of the product), I would assume that the price is indeed updated but the plan remains the same
okay, thank you - it might make sense to add "product id is inferred from the specified price id, since the price is a child of the product object, and thus Stripe automatically updates the product associated with the subscription when the price id is updated" or something along those lines to the docs in that guide, since it seems confusing in my opinion