#toms_api
1 messages · Page 1 of 1 (latest)
👋 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/1344557013039972414
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi
I have an issue thst looks pretty strange
From my PHP application, i am able to create customers, attach payment methods to them, pay suscriptions for my app, everything, but detach a payment method from customers
Whenever I use $stripe->paymentMethods->detach('pm_1Qx0DqCWWL62jZg8ZeFY7YHN', []);, it seems the SDK file called ApiRequestor.php says I have a bad request code 400, with an (HTTP response code was 400, json_last_error() was 4)
It's weird, if I use $stripe->paymentMethods->retrieve('pm_1Qx0DqCWWL62jZg8ZeFY7YHN', []); it works, it retrieves it and I can see the customer who this payment method is attached to, everything, why would detach method fail?
the only thing i change is "retrieve" for "detach" and it fails
Can you share the request ID (req_xxx) that returned 400? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
It does not even reach Stripe
no register on stripe is shown so there is no req_id
I have the Req ID of the "retrieve" that works, but "detach" does not seem to reach Stripe dashboard
Which stripe-php version are you using?
lastest
https://xperiencefitness.online/quitar-pago here you can see the error
Maybe this can help understand what i'm doing and what works and that that dont
The output of that method is here:
https://xperiencefitness.online/quitar-pago
From your request history, you're using stripe-php v16.6.0
Checking on how to detach a payment method in this version
Could you share the full error trace of your exception in catch block?
let me see how
(HTTP response code was 400, json_last_error() was 4) Stack trace: #0 /home/xperiencefitness/vendor/stripe/stripe-php/lib/ApiRequestor.php(136): Stripe\ApiRequestor->_interpretResponse() #1 /home/xperiencefitness/vendor/stripe/stripe-php/lib/BaseStripeClient.php(184): Stripe\ApiRequestor->request() #2 /home/xperiencefitness/vendor/stripe/stripe-php/lib/Service/AbstractService.php(75): Stripe\BaseStripeClient->request() #3 /home/xperiencefitness/vendor/stripe/stripe-php/lib/Service/PaymentMethodService.php(101): Stripe\Service\AbstractService->request() #4 /home/xperiencefitness/application/controllers/Customer.php(87): Stripe\Service\PaymentMethodService->detach() #5 /home/xperiencefitness/system/core/CodeIgniter.php(533): Customer->detach_customer_payment() #6 /home/xperiencefitness/public_html/index.php(318): require_once('/home/xperience...') #7 {main}
Does this works?
Thanks for sharing! The discord is busy now, so it'll take time to respond
No worries, thanks in advance
Hi @fathom hull I'm Jack and I'm also an engineer from Stripe
Can you share with me your merchant ID? you can find it from the Stripe Dashboard -> Settings -> Business -> Account Details
Nice to meet you Jack
Sure, acct_1K7PtKCb4w3iFYGx
Im on test environment
acct_1QUsrQCWWL62jZg8
Thanks, I checked your logs but I don't see any request to detach pm_1Qx0DqCWWL62jZg8ZeFY7YHN
thats the main problem
it is not reaching Stripe
Look:
I am able to retrieve pm_1Qx0DqCWWL62jZg8ZeFY7YHN
but not able to detach, and that is what im trying to do
- I can retrieve that Payment Method
- I can list all of that customer's Payment Methods (where pm_1Qx0DqCWWL62jZg8ZeFY7YHN appears)
- i can not detach it
that's the whole thing
There is the URL of that method: https://xperiencefitness.online/quitar-pago
Right now output is the detach method, with the error
- If I change detach, for retrieve, just the method name, it works and indeed, retrieves, but changing to detach it do not detachs
I made this tests in order for you to know is not a customer thing, or scope thing, as retreiving all Payment Methods, and single Payment Method works fine
I'm starting to think it is an Stripe PHP SDK error, or the DOCS are not updated in Stripe DOC
We tried the same code on stripe-php v16.6.0 and it's working fine on our side
Checking if there is any other differences except for this line of code
Do you agree is not a server issue, neither customer scope, or api key issue?
As other methods work fine
This is what I tested with and works fine:
$key = $_ENV['STRIPE_SECRET_KEY'];
$stripe = new Stripe\StripeClient($key);
$response = $stripe->paymentMethods->detach('pm_123', []);
echo $response;
Sure, that's the same as my code
can you try to update your curl dependency?
done, I got
{
"require": {
"vlucas/phpdotenv": "^5.6",
"stripe/stripe-php": "^16.3"
}
}
it'll be the curl version on your server, not project level
can you check your curl version with:
curl --version
sure
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.90 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
i'm testing on curl v8.7.1 and it's working fine
could you update to this or the latest version?
it's observed error like yours can be returned on older curl version
understood, let me update
Done
curl 8.7.1 (x86_64-pc-linux-gnu) libcurl/8.7.1 OpenSSL/1.0.2k-fips zlib/1.2.7
Release-Date: 2024-03-27
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe UnixSockets
but same error remains
Does your code run based off the curl on your server / local machine?
Do you have any successful retrieval request based of the latest curl version 8.7.1? From your request history, the latest GET request is still in curl 7.29.0
let me make a request now, a successful one, retreiving
that will be good, so that i can check the curl version! thanks!
This is the latest request: https://dashboard.stripe.com/test/logs/req_iCJMKc5bZk9p6e on 2025-02-27 08:20:36 UTC. The curl version is still in 7.29.0
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Not curl 8.7.1
The curl version should be updated in your server
Have you tried to restart your server or recompile your project after updating the curl version?
That's what I did, curl --version shows me curl 8.7.1 after rebooting
But your project didn't pick up the latest curl 8.7.1 when executing the code
Your project still uses the older version
I'm on it, let me check again is previous are existing yet