-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detach Payment Method cause error. #1817
Comments
Update: I checked on several situation, and found
|
Update2: I put print_r in request() method of BaseStripeClient.php and checked variables.
Seems no problem, but request to api fails after this. |
Update3: I think there's nothing I can do anymore.
So, I have to release my application at least in first week of March. My customers are waiting for it. |
Hello @neleid , sorry for the trouble here. The breaking change release is at end of March. |
Ah sorry, I realize these are nginx errors so there is no request ID. We have seen a similar issue occur before, where there are null bytes present in the data being sent to the API. Please make sure that the path, and all data sent to the API does not include a null byte or special characters. v16.5.1 includes an improved error when a null byte is present in the URL (https://github.com/stripe/stripe-php/pull/1811/files) -- let us know if that did not catch your error! |
Hi @helenye-stripe, Thank you for your reply. I checked null bytes like below. I put error_log() in _requestRaw() method in ApiRequestor.php of php-stripe. But just in case, I checked all parameters of _requestRaw(). for example,
_log() is my utility method of error_log() which outputs only when debug mode is on. I checked if these variables includes null bytes.
And result is
I changed api key with xxxxxxxxxxxxx in log. Unfortunately, all parameters didn't includes null bytes, but api call failed. Only detach() method failed. Do you have any idea? |
Can you try hardcoding a payment method ID to detach and let me know if that fails? |
I put this code.
result is,
|
Update: I was just curious if call detach with parameters.
Then I got,
Of course it failed. But at least api server accepted detach call. |
I checked rawHeaders of local development server, and I found some difference. Succeeded detach call on local development server.
Most of data is same, but curl version is different. Do you think this might be problem? |
I have three other things that you might try, though I am a bit stumped and cannot reproduce this behavior.
$stripe->paymentMethods->detach( $payment_method->id, [] );
$payment_method = $stripe->paymentMethods->retrieve( <id> );
$payment_method->detach(); // or pass in empty params array
$response = $stripe->rawRequest('post', '/v1/payment_methods' . $payment_method->id . '/detach'); // or pass in empty params array
$obj = $stripe->deserialize($response->body); If those fail, I would also recommend reaching out to the developer Discord for additional advice. It definitely seems possible that the curl version is causing issues. Would it be possible to check with your hosting provider to update the curl version? |
@helenye-stripe I will investigate some more. especially constructRequest() method of HttpClient/CurlClient.php. |
Finally, I found solution. I added some code, then detach method has started to work. stripe-php/lib/HttpClient/CurlClient.php
CURLOPT_POSTFIELDS seems needed under a certain environment - maybe older curl versions, because $opts array will pass to curl_setopt_array() which is php function in executeRequestWithRetries() function. So, I think if there are same method like detach will fail too. Conditions are,
I think this additional code doesn't have bad effects to other method. |
Describe the bug
I'm trying to detach payment method using stripe/stripe-php library.
But, detach payment method api call fails and can not detach.
I'm confusing because,
I called api with specific api version '2025-01-27.acacia' with stripe-php v16.5.1.
I have no idea why this is happened.
Do you have any idea? Do any account settings cause this?
To Reproduce
The code to call api is almost like below.
Here is error log.
Expected behavior
Can detach payment method.
Code snippets
OS
Linux server
PHP version
PHP 8.1.29
Library version
stripe-php v16.5.1
API version
2025-01-27.acacia
Additional context
No response
The text was updated successfully, but these errors were encountered: