Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple the Price_id and Id in Product type #337

Open
franva opened this issue Dec 8, 2023 · 3 comments
Open

Decouple the Price_id and Id in Product type #337

franva opened this issue Dec 8, 2023 · 3 comments

Comments

@franva
Copy link

franva commented Dec 8, 2023

I have products in the cartDetails with my own IDs not the price ids, also I have the price_id set correctly corresponding to the the price created in the Product section I created on Stripe under test mode.

When I set my own product_id(could be any string) and use the redirectToCheckout() method, it throws an error:

app-index.js:32 IntegrationError: No such plan: and it shows my product_id

then I removed my product_id (not assign it when creating a new product), but do have the price_id set up for each created product, it works correctly as expected.

This creates an issue:
I have many digital photos with different resolutions, e.g. 2K, 4K.
I sell all my different photos at same price under same resolution e.g. photo1_2k is $5 and photo6_2k is also $5.
With an unique product ID for each photos(photo1_2k and photo2_2k), the shopping cart can list all of them.
However, due to the explained reason that I cannot use my own product IDs, but the price_ids, then all products with same price_id aggregated into 1 product showing in my ShoppingCart, but charged correctly when on the Stripe page.

So this is the reason why I am asking for decoupling the Price_id from the cartDetails property in the use-Shopping-Cart package, so that we can have all products listed out in shopping cart and also have the correct amount of money charged.

I hope my explanation makes sense to you.

Thank you.

@dayhaysoos
Copy link
Owner

Hmm @franva I don't know if I fully understand the issue. You think you can provide a bit of what the product objects look like? Maybe you can show me the log results after adding to cartDetails too?

In the mean time, I have an update I've been super slow on working on and maybe I can provide a fix for you there if I can understand the issue better, but you might be able to get away with something that's not so ideal.

You think you can use the price_metadata attribute to help you differentiate between the prices and what not? Maybe you can use a custom value to handle the differentiation for you.

Lemme know if you have questions or if I don't make any sense!

@franva
Copy link
Author

franva commented Dec 16, 2023

Hi @dayhaysoos thank you for your kind attitude and willingness to help :)

Here is my objects:
image

As you can see that the cartDetails have 2 price items, so the cartCount shows 2.
But the real number of the shopping cart is 3 as there are 2 items under price item 1 and 1 item under the price item 2.
The reason for this is : I have a collection of digital arts which has 1K, 2K, 4K etc. resolutions. The price differs according to the resolution selected not the products themselves.

So there are 2 features I would like to request:

  1. I would like there could be a way to set the logic of the calculation of the "cartCount" besides the default caratCount(the default behaviour of cartCount is good, so please keep it).

  2. When I set both id and price_id of the Product type from useShoppingCart, then when redirectToCheckout() is called and the Stripe errors out, because somehow the useShoppingCart uses id property rather than the price_id in the Stripe request. So I would like there is a way to set which property inside the Product to use when charging on Stripe.

Hope the explanation makes sense to you.

@dayhaysoos
Copy link
Owner

hey @franva thanks for the explanation! Okay so, soon I will be doing a staycation and I plan on getting the next release out.

I'm gonna do my best to try to support your needs! If anything, I'll ping you here for feedback.

Thank you for bringing this to my attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants