#emilionicolas

1 messages · Page 1 of 1 (latest)

boreal heraldBOT
lunar dune
#

Hi there!

#

Give me a few minutes to look into this.

#

Can you clarify what "not working like that" means?

#

Do you get an error message or something?

thin fable
#

should it work like that?

lunar dune
thin fable
#

can you give me some doc to read?

#

this is the error message: TypeError: Cannot read properties of null (I guess that code is not working because the pricing table is not printed yet)

#

pricingTable.setAttribute('customer', customerId) this is not working

lunar dune
#

Oh wait, it should be like this:

const pt = document.getElementById("pricingtable");
pt.setAttribute("client-reference-id", "abc");

You can't set a customer with the pricing table, but you can set client-reference-id.

#

Also you can directly set client-reference-id="abc", no need to use Javascript for this.

thin fable
#

Please, understand my use case. I would like to use an Stripe customer id because I already have it for each user of my platform.

lunar dune
#

That's not possible with the Pricing Table. It will always create a new customer.

#

If you reall need this, they you should use Checkout Session instead and build your own pricng table.

thin fable
#

aha, so my case it's not a common case? each user of my platform should have a customer-id?

#

an stripe customer i mean?

lunar dune
#

It's a good practive yes to reuse the same customer ID when possible. However that's not possible with the Pricing Table.

thin fable
#

is it a requested feature?

#

how much work would be to do it from scratch? where should i start?

lunar dune
#

is it a requested feature?
We are aware of this limitation yes.
how much work would be to do it from scratch? where should i start?
What do you mean? You have two main options:

  1. Use Pricing Table, but it means you'll create a new customer object every time someone buys something. You could use the client-reference-id to try to track things on your end
  2. Don't use Pricing Table, and use Checkout Session directly by passing a customer object
thin fable
#

I like pricing-table because of the simplicity and maybe I try with option 1. I have never worked with checkout session and don't now where should I start to take a quick analysis for option 2

lunar dune
#

Yes option 1 is the simplest option for sure.

thin fable
#

in option 2 I should do front and back right? Do you have a quick example or code I could see?

lunar dune
thin fable
#

ok I am on it, to get it clear, If I go with option 2, I still need my products and price in the dashboard and I can manage it from Stripe Dashboard. However I have to create my own frontend from scratch and the "Subscribe" buttons I should make will lead to my backend to create a checkout session with the appropiate stripe customer for my application user

lunar dune
#

Yes that's correct.

thin fable
#

okay thanks for your help!

lunar dune
#

Happy to help 🙂

thin fable
#

Hello again Soma, I am still figuring out which path I should take. I am considering option 2 seriously. How could I print easyly product/price boxes getting the info from my stripe account so if I change a price in stripe dashbord I could see it in my frontend dinamically? some doc about it?

lunar dune
#

How could I print easyly product/price boxes getting the info from my stripe account
You could list price form the API: https://stripe.com/docs/api/prices/list. However it's probably better to store that information in your own database.
if I change a price in stripe dashbord I could see it in my frontend dinamically?
Note you can't update a price amount in Stripe. Instead you would need to create a brand new price.