#steven-gauerke_code
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/1245351738291261471
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, let me help you with this.
There's no need to worry about this as long as it doesn't impact payments.
However, it's recommended to follow this guide on CSP: https://docs.stripe.com/security/guide#content-security-policy
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?
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Are you building a new integration?
no this is existing. I think I need to try to catch a general exception
I just wanted to flag that Sources API is deprecated and I strongly recommend migrating to PaymentIntent/PaymentMethod: https://docs.stripe.com/payments/payment-methods/transitioning
For the issue, it seems like we got a response for the network that CVC is incorrect, not sure if there's more.
Not sure why the error wasn't caught, if you're expecting a ApiErrorException. Perhaps it's best to expect a general error.
yeah im going to try that
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
Hello
We have a doc here that shows you how you can handle errors with PHP SDK
I'd recommend taking a look at it as that may help handle the exceptions gracefully
https://docs.stripe.com/error-handling?lang=php
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();
}`
Are you sure you're looking at the right code?
The request here is failing when you're trying to add a token to customer sources
https://dashboard.stripe.com/logs/req_lHiFGE4Q8bAdVc
The code you've shared is to create a charge
thats the ONLY time i call stripe
so is it that stripe handles the add token to source first behind the scenes?
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
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
You're only catching CardException but the error throws an ApiErrorException
You were right. It was in creating the token first that was throwing the error. Thank you for your help!