#matrix-product-error

1 messages · Page 1 of 1 (latest)

cosmic knot
#

@mint yew hello! can you provide a bit more details like your exact code?

mint yew
#

for (var i = 0; i < name.length; i++) {
const product = await stripe.products.create({
name: name[i],
description: description[i],
statement_descriptor: 'xxx',
metadata: {
category: category[i],
categoryNumber:categoryNumber[i],
itemNumber: itemNumber[i],
readyForSale: 'yes'
},
}, {
stripeAccount: 'xxx',
});

    const price = await stripe.prices.create({
      unit_amount: price[i],
      currency: 'gbp',
      product: product.id,
    }, {
      stripeAccount: 'xxx',
    });
  }
#

this is the code

#

and this is the price declared before the for

#

const price = [1050]

cosmic knot
#

so it seems to crash on unit_amount: price[i], right?

mint yew
#

yes

cosmic knot
#

hmmm sorry I don't really get your question

#

like this isn't a Stripe error as far as I can tell, it's just an error/typo in your language no? If you remove all Stripe code and just print the price does it work?

mint yew
#

ok will try to print the price

#

i was not sure if there was another way to create product and price in one go

cosmic knot
#

that's the right way, create a product and then a price and that just works. The bug right now is in your own code/initialization

mint yew
#

well the price is initiatilized

cosmic knot
#

ah wait

#
          unit_amount: price[i],```
#

see how you re-define price

#

that's your bug

mint yew
#

it should be an integer in pence right?

#

i am passing 1050

#

ahhh

cosmic knot
#

yeah you have 2 variables called price and it just breaks your code

mint yew
#

I was definiing price twice

#

😱

#

thanks!