#Nick137645
1 messages ยท Page 1 of 1 (latest)
๐ How can I help?
@rigid phoenix At which stage did you see the error from? When I load your website, I don't see the errors
Simply load the page
Same Safari, Chrome and Firefox
I just did a test with my wife's macbook. I get the same errors
Are you able to validate a test payment?
Does Payment Element load for you? And can you perform payment on it?
Yes it loads but I am not able to send the form.
<meta http-equiv="Content-Security-Policy" content="Content-Security-Policy: default-src 'self'; connect-src https://api.stripe.com https://maps.googleapis.com https://carsoftwarepro.com; frame-src https://js.stripe.com https://hooks.stripe.com; script-src https://js.stripe.com https://maps.googleapis.com https://carsoftwarepro.com"> is it correct ?
If you remove content-security-policy, does it work?
no
My NGINX server seems to be correctly configured and no Cloudflare option seems to modify the content of the pages or the headers.
When I test on your website, I was redirected to the same page after completing the payment. I don't have any CSP error in the console
Per my checking on your account, the payment wasn't successfully made
Could you share the code about how you confirm the payment using stripe.confirmPayment()?
yes
one moment
require_once '../stripe/vendor/autoload.php';
require_once 'secrets.php';
\Stripe\Stripe::setApiKey($stripeSecretKey);
function calculateOrderAmount(array $items): int {
// Replace this constant with a calculation of the order's amount
// Calculate the order total on the server to prevent
// people from directly manipulating the amount on the client
return 2900;
}
header('Content-Type: application/json');
try {
// retrieve JSON from POST body
$jsonStr = file_get_contents('php://input');
$jsonObj = json_decode($jsonStr);
// Create a PaymentIntent with amount and currency
$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => calculateOrderAmount($jsonObj->items),
'currency' => 'usd',
'automatic_payment_methods' => [
'enabled' => false,
],
]);
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}```
This is the server side code which looks fine to me. stripe.confirmPayment() is the client code using StripeJS. Can you share your client code?
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Accept a payment</title>
<meta name="description" content="A demo of a payment on Stripe" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="checkout.css" />
<!--Content-Security-Policy: frame-ancestors 'self' 'unsafe-inline' -->
<meta http-equiv="Content-Security-Policy" content="Content-Security-Policy: default-src 'self'; connect-src https://api.stripe.com https://maps.googleapis.com https://carsoftwarepro.com; frame-src https://js.stripe.com https://hooks.stripe.com; script-src https://js.stripe.com https://maps.googleapis.com https://carsoftwarepro.com">
<script src="https://js.stripe.com/v3/"></script>
<script src="checkout.js?4dfdvfddd343" defer></script>
</head>
<body>
<!-- Display a payment form -->
<form id="payment-form address-form">
<div id="link-authentication-element">
<!--Stripe.js injects the Link Authentication Element-->
</div>
<h3>Address</h3>
<div id="address-element">
<!-- Elements will create form elements here -->
</div>
<h3>Payment methode</h3>
<div id="payment-element">
<!--Stripe.js injects the Payment Element-->
</div>
<button id="submit">
<div class="spinner hidden" id="spinner"></div>
<span id="button-text">Pay now</span>
</button>
<div id="payment-message" class="hidden"></div>
</form>
</body>
</html>```
From the error here, it looks like your addEventListener isn't registered properly. When clicking the PayNow button, it doesn't invoke handleSubmit
Do you download the example code from https://stripe.com/docs/payments/quickstart?
When you run the app locally, does it work?
I tried to run the example code directly without any modification, the payment was successfully completed
I don't have a local server to install on my macbook
for address collect
Can you remove address-form? In your submit event registration, it's looking for payment-form which can't be found
payment-form is just an ID. you can still collect customer address and phone number
which error?
I'm able to complete the payment in your website: https://dashboard.stripe.com/test/payments/pi_3N3qLBFpRI5msanC0TW68ZXG
I don't see any CSP error on my end
This is what I see
On my side it doesn't work. Even the 3d secure validation window doesn't want to be displayed. I have tried on my wife's macbook.
I don't have any ad blocker or other extension installed that could block the iframes.
The event listener is able to register the handleSubmit event successfully since it is able to look for payment-form div
Hmm.. can you try clearing the cache?
yes
I can't validate the payment on my iphone. I am redirected to the forum without errors displayed
I deleted the browser cache, deleted the cloudflare caches. Still the same errors.
I will try with the cellular network of my phone to make sure I don't have a problem with the fixed internet connection
I'm unable to reproduce any error like what you mentioned
Your website is working fine and the payment is completed successfully on my end
The issue is likely not because of your integration/code
Is it the right link that I'm tested on https://carsoftwarepro.com/sample/checkout.html?
It works now but there are still errors
I was able to validate a payment with 3d secure
but mistakes are always there
If the payment is working fine, it's safe to ignore the errors since it's report only
Will alerts appear on my customers' browser at checkout?
So I can't use "address element" together with "payment element"?
It would seem so.
I thank you for your time and your precious help.