#steven-gauerke_code

1 messages ¡ Page 1 of 1 (latest)

prime cipherBOT
#

👋 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/1245351738291261471

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

grand pasture
#

Hi, let me help you with this.

#

There's no need to worry about this as long as it doesn't impact payments.

snow oar
#

ok thank you

#

ok i have a different question on the server side of things

#

I get an error like this in my error logs
PHP Fatal error: Uncaught (Status 402) (Request req_vCN57lnzxxxxx) Your card's security code is incorrect.\n thrown in /home/admin/web/rida.io/public_html/classes/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38

so my script that runs the PHP sdk ->stripe->charges->create throws a 500 server error.

I have a try catch and I'm catching these 2 exceptions

\Stripe\Exception\CardException
\Stripe\Exception\ApiErrorException

But its still throwing 500 error instead of processing the catch code....which leads me to think im missing an exception

What exception should I be watching for on a card declined or security code is incorrect?

grand pasture
snow oar
#

req_lHiFGE4Q8bAdVc

#

I know the error is security code is invalid.

grand pasture
#

Are you building a new integration?

snow oar
#

no this is existing. I think I need to try to catch a general exception

grand pasture
grand pasture
#

Not sure why the error wasn't caught, if you're expecting a ApiErrorException. Perhaps it's best to expect a general error.

snow oar
#

yeah im going to try that

prime cipherBOT
snow oar
#

yeah it must be a PHP issue then because in the dev tools of chrome it shows 500 server error and no response from PHP

serene fractal
snow oar
#

ok i just did some trials, it appears its not even catching. I put error_log commands in my catches and they aren't even firing. So its like the try part is not throwing a catch. Here's the code I have

`try {
$response = $pg->stripe->charges->create([
'amount' => $amount * 100,
'currency' => 'usd',
'customer' => $office['stripeCustomerId'],
'source' => $office['stripeDefaultPM'],
'description' => 'RIDA Onboarding Fee',
], [
'idempotency_key' => $pass
]);
} catch(\Stripe\Exception\CardException $e) {
error_log("Catch at Card Exception");

    $pg->DeletePaymentMethod($office['stripeDefaultPM']);
    $pg->stripe->customers->delete(
        $office['stripeCustomerId'],
        []
    );
    $sc->pdo->delete("offices", array("_key" => $ores['okey']));
    echo json_encode(array("status" => 0, "msg" => $e->getMessage() . " <br />Please try again.", "vardump" => var_dump($e)));
    http_response_code(402);
    die();
    
}`
serene fractal
#

The code you've shared is to create a charge

snow oar
#

thats the ONLY time i call stripe

#

so is it that stripe handles the add token to source first behind the scenes?

serene fractal
#

I realise that the request ID you shared is different from the error message you shared

PHP Fatal error: Uncaught (Status 402) (Request req_vCN57lnzxxxxx) Your card's security code is incorrect.\n thrown in /home/admin/web/rida.io/public_html/classes/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38

snow oar
#

all of these requests are throwing the same error. So the request ID is one of these error log entries

#

I'm intenionally entering a bad cvv

serene fractal
#

You're only catching CardException but the error throws an ApiErrorException

snow oar
#

oh wait.....

#

i might have found the error

snow oar
#

You were right. It was in creating the token first that was throwing the error. Thank you for your help!