I have implemented the stripe checkout using node.js
product.photo
is
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
line_items: [{
name: product.title,
description: product.description,
images: [product.photo],
amount: product.price * 100,
currency: "usd",
quantity: 1
}],
success_url: "http://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: "http://localhost:3000/cancel"
});
For some reason, the picture is always empty
Other data is fine
I have implemented the stripe checkout using node.js
product.photo
is https://test.s3.amazonaws./2213131
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
line_items: [{
name: product.title,
description: product.description,
images: [product.photo],
amount: product.price * 100,
currency: "usd",
quantity: 1
}],
success_url: "http://localhost:3000/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: "http://localhost:3000/cancel"
});
For some reason, the picture is always empty
Other data is fine
Share Improve this question edited Dec 30, 2019 at 14:03 Mr. Polywhirl 48.9k12 gold badges93 silver badges144 bronze badges asked Dec 30, 2019 at 13:58 airsoftFreakairsoftFreak 1,6088 gold badges39 silver badges68 bronze badges 11- 1 Can you view the image in the browser when you visit the url directly ? I get a "AccessDenied" error – Marc Commented Dec 30, 2019 at 14:12
-
How does
product.photo
looks like? Does request for the image returns anything / emty data / 404 ...? What actually downloads the data - server or client? – Zydnar Commented Dec 30, 2019 at 14:14 - Yeah I can access test.s3.amazonaws./2213131 but for some reason when passing to the create-session it shows 404 . – airsoftFreak Commented Dec 30, 2019 at 14:17
- 1 The photo is not publicly available, make it public in S3. – Marcos Casagrande Commented Dec 30, 2019 at 14:28
- 2 For anyone finding this: Turns out Stripe don't like .jfif files, added a jpg instead and it worked – Jimmy Commented Apr 15, 2020 at 8:01
3 Answers
Reset to default 5Similar to Sumit Datta, it was the content-type metadata on S3 that was causing this issue. Make sure you use image/jpeg
or image/png
as the content-type, else Stripe's CDN won't be able to cache your images!
I had the same issue. Please make sure to use the correct "content-type" for your images when storing to S3. That should fix it. Check that your browser does not download image as attachment, rather shows image in browser.
[https://domain/ + product.img] important not http