#Illes - PHP invalid request

1 messages ยท Page 1 of 1 (latest)

gritty widget
#

Hello. Give me a moment to catch up. Looking into this

light parrot
#

Hello, thank you

gritty widget
#

What request is creating the invalid request error?

#

Can you share a request ID?

light parrot
#

a moment

#

sorry, I am not sure that I understand your question

#

๐Ÿ™‚

gritty widget
#

No problem

#

The invalid request has to be coming from a specific api request to the stripe API

#

Do you know which api request is causing this error?

light parrot
gritty widget
#

I'll need a request ID to help you debug the error further

light parrot
#

OK, I see the Logs now

#

req_CyGweXs0aoleer

gritty widget
#

Ok I see the problem. One moment while I gather some resources for you

#

Here is the response for that request:

#
  error: {
    message: "You must specify either `product` or `product_data` when creating a price.",
    type: "invalid_request_error"
  }
}
#
#

If you don't have a product created then you can just pass in product_data

light parrot
#

I do not really undertand, sorry

#

I am quite tired already

gritty widget
#

So this is the current body of your request to create the checkout session (in your server-side PHP code):

  line_items: {
    0: {
      price_data: {
        unit_amount: "0",
        currency: "huf"
      },
      quantity: "1"
    }
  },
  mode: "payment",
  success_url: "http://localhost:8081/stripe-test/payment-success.php?session_id={CHECKOUT_SESSION_ID}",
  cancel_url: "http://localhost:8081/stripe-test/payment-cancel.php"
}```
#

You have price_data specified

#

Which is fine if you don't have a price object

#

However, you need to additionally pass in a product or product_data (as seen in my above 2 links)

light parrot
#

but I passed it in

gritty widget
#

That code looks different than what's used in the request you shared (notice the different unit_amount values)

light parrot
#

this is strange

#

i got the same log

#

even though in my code is different

#

maybe I should restart XAMPP

gritty widget
#

Have you changed the code recently?

light parrot
#

in the last half hour

gritty widget
#

Make sure the files are all saved and restart your server

#

See if it continues

light parrot
#

all files are saved

#

I restarted the server

#

but it is still not good

#

maybe I should logout an login stripe again

gritty widget
#

Add some log lines in that try block

#

makes sure that code is the code that's actually being run when you are making the request

#

Just to confirm your web server is using the latest code

light parrot
#

I logged out from Stripe, but there is 2 factor authentication, and the client didn't respond to my sms

#

(I asked him to send me the code)

gritty widget
#

Ok that's fine

#

Still add some of those log statements in your code and run it

#

We just need to verify that the code running on your server is actually the latest

light parrot
#

I succeeded to re-login with the backup code

#

I restarted the server

#

still the same errror message

gritty widget
#

Did you add log statements in that try block?

#

That is how we can know if you're deploying the latest code

light parrot
#

how do I do that?

#

sorry, I am not a big pro in PHP yet

gritty widget
#

Ok

#

From the requests being made it's clear that the code you're looking at isn't the code that's making the requests

#

Try adding print statements

#

Just basic ones in that try block

#

Then check the server logs to see if you see those print statements

#

when you create the checkout session you should see whatever you're printing out. if not, then that confirms that you're just deploying wrong.

light parrot
#

I don't see what I print out

gritty widget
#

Ok then you aren't deploying your latest code correctly

#

This isn't a stripe issue

#

But rather a code deployment issue, so you need to spend time debugging that on your own

light parrot
#

$stripeToken could not be the problem?

gritty widget
#

No

#

If you aren't even seeing the print statements you're making then you aren't deploying the code correctly

#

This isn't a stripe issue, so we really can't assist further here

light parrot
#

But don't you have any ideas what may be the reason?

gritty widget
#

It doesn't have to do with stripe code, so no. It has to do with your code deployment

light parrot
#

CHECKOUT_SESSION_ID

#

This is undefined

#

it says

#

may this be the cause?

#

Undefined constant 'CHECKOUT_SESSION_ID'.intelephense(1011)

low jasper
#

@light parrot CHECKOUT_SESSION_ID is not a variable you can print out - that's something we insert into the success and cancel URLs automatically, so you should remove that specific log line. Even logging/printing a simple string like "test" would be enough.

As @gritty widget already said, the core issue here is that the code you are looking at (which you have added print statements to) is not the same code that is currently running and making requests. We don't have any insight or control over how you're deploying or running your code so this is really something you need to look at yourself and debug.

light parrot
#

I am working on localhost with XAMPP

#

should I maybe change Port?

low jasper
#

I don't know if that'll work since we have no idea what you're doing on your end, but you're welcome to try it. Please take the time to try some things out and see what you can get working.

light parrot
#

Okay, thank you

#

ANd this may be the cause?

slim venture
#

I am not immediately sure. Where are you seeing this error?

#

What client side call is seeing this?