#ali-raza_code

1 messages · Page 1 of 1 (latest)

copper barnBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1319247878887051316

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

deft gale
#

Do I need to update the price or create new price when from front-end Community creator updates the price?

#

Also, what happens in this case.

  • One product created on stripe has 20 subscriptions.
  • Community creator updates the price from 10$/month to 15$/month.
  • Now, the old users and new users. What will be the price for them? 10$/month or 15$/month?
eager cobalt
eager cobalt
copper barnBOT
deft gale
tacit lark
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

tacit lark
deft gale
#

Which subscription needs to be updated?

#

all members subscription?

#

or the specific product subscription?

tacit lark
#

all members subscription?
or the specific product subscription?
Could you please clarify what this means in Stripe API terms?

deft gale
#

Basically.

There is a community. This has a price which members pay to subscribe to the community

community creator
community members

tacit lark
#

Each member is a Stripe Customer? And each of them have their own Subscription object?

deft gale
#

Yes.

#

you are correct.

tacit lark
#

And what is "all members subscription"?

deft gale
#

community is a product that is created on stripe and each community member then subscribes to that product Created on Stripe

tacit lark
#

I am not sure I understand. Is this the answer to my last question?

#

Okay, we clarified this:

Each member is a Stripe Customer? And each of them have their own Subscription object?

Is there any other Subscriptions?

deft gale
#

It is very simple.

Let me explain again:

  • Platform name is Amigo

  • Each member registering to amigo is registered to stripe - Customer ID is attached with each Amigo user

  • Single user can create or join multiple communities.

  • When a user creates a community. I create a product on stripe for that community to which all To be joined users aka members will subscribe.

  • After product creation, I will get the product id from stripe which will be attached to the community.

  • Now, the member will join the community by subscribing to the product.

tacit lark
#

I just want to stress that normally Subscriptions are created using the Price ID, not the Product ID. Product ID just holds metadata like image, name, description. But the pricing is set by the Price object and you use that when creating Subscriptions.

deft gale
#

Yes, the subscription is made via priceID not productID

#

in my code

tacit lark
#

Now, if you want your members to pay a new amount per month for a given community, you need to create a new Price for this Product, and update each member's Subscription with the new Price. You can then archive the old Price.

deft gale
#

Yes, this is what I was asking.

I was curious if I update the price for the product would it directly effect the subscribed users or I have to manually update all subscriptions.

#

So, according to you I have to update all on-going Members subscriptions.

#

after creating new price for a product

tacit lark
#

update the price for the product
Product can have multiple prices, and the default one is just a Dashboard feature. You always have to specify the Price explicitly via API so which Price is the default is irrelevant.

deft gale
#

Don't you think this is a bit complex. As I have to run a query, fetch all active users for that product, and then update the price for them

tacit lark
#

What would be a better way, without risking changing the amount for a large number of customers by accident?

deft gale
#

Well, it is an automated job via code.
If I run a query with wrong data it will produce the same error.

Nevermind, thanks for the help @tacit lark 🙂

tacit lark
#

Happy to help.

deft gale
#

One last question. If I create a new price, should I delete/archieve old price?

tacit lark
#

For the sake of keeping things tidy, you can, if you're not planning to use it again.

deft gale
#

Ok, thanks.

#
 await stripe.products.update(productId, {
      default_price: monthlyPriceId?.id || null,
      
      metadata: {
        updated_at: new Date().toISOString(),
        oldPrice: `The old price was ${community.monthly_subscription_price} and ${community.yearly_subscription_price}`,
        oldPriceMonthlyId: community.stripe_monthly_price_id ?? null,
        oldPriceYearlyId: community.stripe_yearly_price_id ?? null,
      },
    });

#

I don't find any key to update a price and make it archieve

#

can you tell me the key?

#

active: false will do the archieve part?

tacit lark
#

Yeah, right, that's the property