#udzhin_dev
1 messages · Page 1 of 1 (latest)
Hi 👋
I can't really debug your entire server code here. But what are the details for that first POST error?
I have thrown the code of the php file, but what exactly is the error I can not understand. I've connected the library and made the response in JSON, but I have no idea what the problem is
Okay so the error appears to be coming from the code /create-payment-intent.php so let's focus there
And is that all the 200 or so lines of code you dumped?
No, this is my php code, the one in the file is js.
<?php
require_once('/vendor/stripe/stripe-php/lib/Stripe.php');
\Stripe\Stripe::setApiKey('YOUR_SECRET_KEY');
try {
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $_POST['price'],
'currency' => 'chf',
'payment_method_types' => ['card'],
]);
echo json_encode(['clientSecret' => $paymentIntent->client_secret]);
} catch (\Stripe\Exception\ApiErrorException $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
?>
Okay and what is calling this function?
Can you log the error that you are receiving?
This error block right here:
catch (\Stripe\Exception\ApiErrorException $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}
Can you print out what is in the $e variable and share it?
Sure, but can I do it in half an hour?
Sure, depending on the activity on the server this thread may get archived but you are welcome to come back and share these details
Okay, thanks