dayhaysoos / use-shopping-cart

Shopping cart state and logic for Stripe
MIT License
907 stars 118 forks source link

price_id not recognised by Stripe #331

Open timothyylim opened 1 year ago

timothyylim commented 1 year ago

Even though the id and price_id match the ones defined in the Stripe Dashboard, a successful payment results in a new 'one-off' product being created in Stripe.

const product = [
  {
    name: 'Test Single Ticket',
    description: '',
    id: 'prod_OIwl4mK9AcDPO3',
    price_id: 'price_1NWKruCoph6BjxBAVl5k5od7',
    price: 1000,
    currency: 'USD',
  },
]

Is there anything I'm missing?

dayhaysoos commented 1 year ago

Hey @timothyylim, sorry for the delayed response. Can you try submitting this data with ONLY the price id? Leave out price, currency, name etc etc.

At least exclude those things just before creating the checkout session.

There's a helper function called formatLineItems() that actually does this for you if you pass it the cartDetails just before checkout session creation. Lemme know if that creates the results you want!