简体   繁体   中英

Empty picture on checkout stripe

I have implemented the stripe checkout using node.js

product.photo is https://test.s3.amazonaws.com/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

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.

Similar 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM