#susan_api

1 messages · Page 1 of 1 (latest)

sterile narwhalBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1344455034724683889

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

swift mason
#

Hi! That request was successful; where are you seeing the error?

north grove
#

In my code, I use exactly that line, with my own payment id but is not working

#

like this

swift mason
#

Ok cool. That's not the same request.

#

Or at least that request isn't Stripe's API.

#

What is it that you're trying to do exactly?

#

And how are you making your requests?

#

And what does your code look like?

north grove
#

I'm trying to detach a payment method to customer, first a retrieve the payment method and if it exist, I call a method to detach: detach_payment_method

swift mason
#

Or rather: the Request ID you gave me was not from Stripe-PHP.

#

That code appears to be.

#

That error page was from your app, ya?

north grove
#

I understand, it's true, I just saw that none of these requests appear in Stripe, nor in events, nor logs much less webhooks, but I don't understand why

#

yes, Im sorry, you`re right that error is from my app

swift mason
#

Are you sure your stripe_key is the correct one? Sounds like it might not be? Also you don't check to confirm that $pm_id contains anything; if it's an empty string you'd likely get an error back - but without seeing the actual error, it's hard to know.

I'd suggest confirming that $pm_id isn't empty, and also making sure that your $this->stripe_key is the one you expect.

north grove
#

I already did it, in fact I changed both values ​​and made them static but still not working

swift mason
#

Can you log the entire exception and see what's in there?

north grove
#

yes, what I can see when I print that response is like this:

Invalid response body from API: <html>\r\n<head><title>400 Bad Request</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n (HTTP response code was 400, json_last_error() was 4)"

swift mason
#

That's not the contents of $detach_response though.

#

Also not the contents of $e either, right?

#

Where are you running this?

north grove
#

Oh, it is running in a local environment and that message is coming from the exception, I mean $e

swift mason
#

Can you log the contents of $pm_id within that function, right before you make the Stripe API call?

north grove
#

To show that quickly, I can print it in the full answer, this is in the payment_id position

swift mason
#

Cool. Can you share that Payment Method ID with me in here?

north grove
#

sure, pm_1QwBrgCWWL62jZg89v00HmHs

swift mason
#

I'm not sure how you're losing the proper error and ending up with your own? internal error page there, but that's probably worth digging into so you're working with the raw error in your code.

#

Also that code you showed me as it was almost certainly did not make that request, since I don't see customer anywhere there.

#

Do you see where in your code you're supplying a customer to that API call?

north grove
#

I tried to send the customer Id as a parameter in that call, but I got an error, actually I can see that request in Stripe with the ID req_p7hXMstzRRYPp2

swift mason
#

Ah, ok - so your code is working now?

sterile narwhalBOT
north grove
#

no, it is not working yet 😦 detach is the only method that is not working

scarlet basalt
#

Hi @north grove I'm taking over this thread.

#

Can you share with mthe ID of the request (req_xxx) that returned you an error?

north grove
#

Thanks I don't have ID, it seems like my request doesn't appear in stripe

scarlet basalt
#

Ok, then you'll want to check your server logs and see what prevents your app from sending an API request to stripe.

north grove
#

Are there any particularities to pay attention when using the detach method? because everything seems fine except with that method which doesn't work

scarlet basalt
#

Based on what I understand so far, your server didn't manage to send a request to Stripe for payment method detachment, so I'd recommend check your server code first.