#emilionicolas
1 messages · Page 1 of 1 (latest)
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?
should it work like that?
It's mentionned in the doc here: https://stripe.com/docs/payments/checkout/pricing-table#handle-fulfillment-with-the-stripe-api
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
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.
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.
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.
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?
It's a good practive yes to reuse the same customer ID when possible. However that's not possible with the Pricing Table.
is it a requested feature?
how much work would be to do it from scratch? where should i start?
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:
- Use Pricing Table, but it means you'll create a new customer object every time someone buys something. You could use the
client-reference-idto try to track things on your end - Don't use Pricing Table, and use Checkout Session directly by passing a customer object
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
Yes option 1 is the simplest option for sure.
in option 2 I should do front and back right? Do you have a quick example or code I could see?
Correct. And here's the best guide on Checkout Session to create Subscriptions: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=stripe-hosted
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
Yes that's correct.
okay thanks for your help!
Happy to help 🙂
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?
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 priceamountin Stripe. Instead you would need to create a brand new price.