#toms_api

1 messages · Page 1 of 1 (latest)

remote cargoBOT
#

👋 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.

fathom hull
#

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

opal thunder
fathom hull
#

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

opal thunder
#

Which stripe-php version are you using?

fathom hull
#

lastest

#

Maybe this can help understand what i'm doing and what works and that that dont

opal thunder
#

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?

fathom hull
#

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?

opal thunder
#

Thanks for sharing! The discord is busy now, so it'll take time to respond

fathom hull
#

No worries, thanks in advance

tender hill
#

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

fathom hull
#

Nice to meet you Jack

#

Sure, acct_1K7PtKCb4w3iFYGx

#

Im on test environment

#

acct_1QUsrQCWWL62jZg8

tender hill
#

Thanks, I checked your logs but I don't see any request to detach pm_1Qx0DqCWWL62jZg8ZeFY7YHN

fathom hull
#

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

#
  • 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

opal thunder
#

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

fathom hull
#

Do you agree is not a server issue, neither customer scope, or api key issue?
As other methods work fine

opal thunder
#

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;
fathom hull
#

Sure, that's the same as my code

opal thunder
#

can you try to update your curl dependency?

fathom hull
#

done, I got
{
"require": {
"vlucas/phpdotenv": "^5.6",
"stripe/stripe-php": "^16.3"
}
}

opal thunder
#

it'll be the curl version on your server, not project level

#

can you check your curl version with:

curl --version
fathom hull
#

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

opal thunder
#

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

fathom hull
#

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

opal thunder
#

Does your code run based off the curl on your server / local machine?

fathom hull
#

Server

#

All in server

opal thunder
#

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

fathom hull
#

let me make a request now, a successful one, retreiving

opal thunder
#

that will be good, so that i can check the curl version! thanks!

fathom hull
#

Done

#

succesfully retreiving

opal thunder
#

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?

fathom hull
#

That's what I did, curl --version shows me curl 8.7.1 after rebooting

opal thunder
#

But your project didn't pick up the latest curl 8.7.1 when executing the code

#

Your project still uses the older version

fathom hull
#

I'm on it, let me check again is previous are existing yet

remote cargoBOT