#skammerens-datter_api

1 messages ยท Page 1 of 1 (latest)

open lynxBOT
#

๐Ÿ‘‹ 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.

wary kayak
#

You should store at least the Customer and Subscription IDs

sturdy ice
#

okay, thank you for the clarification ๐Ÿ˜„

sturdy ice
#

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

wary kayak
#

Those are 2 different things, right? One sets the key on the server-side and one sets it on the client-side?

sturdy ice
#

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

wary kayak
#

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.

sturdy ice
#

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

wary kayak
#

You can't. If there's no Stripe object instantiated, then you can't use its methods

sturdy ice
#

Thank you - i need to create a new thread, could you please close this one? ๐Ÿ™‚

wary kayak
#

If you have another question, just ask it here and I'll follow up

sturdy ice
#

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

wary kayak
sturdy ice
#

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

wary kayak
sturdy ice
#

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

wary kayak
#

Stripe does infer

#

There's no need to explicitly pass the Product as well

sturdy ice
#

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