#khalil-order-stripejs

1 messages · Page 1 of 1 (latest)

gleaming knoll
#

Can you share the exact code?

novel onyx
#

Yep

#

If I call this function:

async function retreiveStripeOrder(stripe: Stripe| null, secret: string) {
  console.log("in retreive order")
  if(!stripe) {
    return
  }
  let myOrder = null
  stripe.retrieveOrder(secret).then(({ order }) => {
    if (order) {
      myOrder = order
    } else {
    }
  });
  return "dummy value"
}

the log shows in retreive order only once

#

if I call

async function retreiveStripeOrder(stripe: Stripe| null, secret: string) {
  console.log("in retreive order")
  if(!stripe) {
    return
  }
  const myOrder = await stripe.retrieveOrder(secret)
  return "dummy value"
}

I enter into an infinite loop "in retreive order" is printed indefinitely

gleaming knoll
#

that seems not possible. Is this real code? Can you show me a basic jsfiddle?

novel onyx
#

Hi @gleaming knoll, I think my problem is that I am trying to use react query with stripe js, it might be on the react query side. Let me dive a bit into that first, and I’ll circle back if I am still stuck.

My current assumption is that the stripe object might be changing every time I call ‘processOrder’, and is causing the react query to call again that function since it’s listening to changes on the stipe object

bleak shuttle
#

koopajah had to head out, but if you have any other questions I can help