#nicoyamx_code

1 messages ยท Page 1 of 1 (latest)

steel irisBOT
#

๐Ÿ‘‹ 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/1400396730452803704

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

faint ibex
#

๐Ÿ‘‹ happy to help

#

unfortunately your issue is not related to your integration

#

these declines can happen because the issuing bank refuses payment and your customers should contact their bank to sort this out. These cards can also be disabled for international payment. For more info please contact https://support.stripe.com/?contact=true

echo totem
#

I've tried to speak with the support about it. Can you please comfirm if my integration is ok:

#

import Stripe from "stripe";

export default async function handler(req, res) {
if (req.method !== "POST") {
res.setHeader("Allow", ["POST"]);
return res.status(405).json({ error: Method ${req.method} not allowed });
}

const { amount, currency, checkoutId, pspId } = req.body;

try {
    if (!pspId) {
        return res.status(400).json({ error: "Missing pspId in request" });
    }

    const API_URL = process.env.NEXT_PUBLIC_API_URL;
    const API_KEY = process.env.NEXT_PUBLIC_API_KEY;

    // ๐ŸŸข Get the correct PSP using pspId instead of top-daily
    const pspResponse = await fetch(`${API_URL}/psp/${pspId}`, {
        method: "GET",
        headers: {
            "Content-Type": "application/json",
            "x-api-key": API_KEY,
        },
    });

    if (!pspResponse.ok) {
        throw new Error(`Failed to fetch PSP: ${pspResponse.status} - ${pspResponse.statusText}`);
    }

    const pspData = await pspResponse.json();

    const { publicKey, secretKey, id } = pspData;

    // โœ… Init Stripe with correct PSP secretKey
    const stripe = new Stripe(secretKey);

    // โœ… Create the PaymentIntent
    const paymentIntent = await stripe.paymentIntents.create({
        amount: Math.round(amount),
        currency: currency.toLowerCase(),
        payment_method_types: ['card'],
        payment_method_options: {
            card: {
                request_three_d_secure: 'challenge'
            }
        }
    });

    res.status(200).json({
        clientSecret: paymentIntent.client_secret,
        paymentIntentId: paymentIntent.id,
        pspId: id,
        meta: pspData.meta
    });

} catch (error) {
    console.error("Error creating payment intent:", error.message);
    res.status(500).json({ error: "Failed to create payment intent" });
}

}

#

It is a 3DS issue? I've enabled it on radar

steel irisBOT
pine quarry
#

hi! I'm taking over this thread.

#

can you share a specific PaymentIntent ID (pi_xxx) with this issue?

echo totem
#

Sure

#

cus_SlLrnX9BvgTWlD

#

or this one: pm_1RpovmLfO8dSZu6B7kow6Zwm

#

pi_3RpooeLfO8dSZu6B3Zo1FaDS

#

pi_3Rpog2LfO8dSZu6B1OxGVdoG

#

We are building a checkout for our customers all of them are having issues with their payment only 30ish% of their customer are able to pay

pine quarry
#

Looking at pi_3RpooeLfO8dSZu6B3Zo1FaDS

  • you created the PaymentIntent, so its status was requires_payment_method as expected
  • then... nothing happened. you didn't collect a payment mehtod and try to confirm the PaymentIntent
    so as expected, you didn't collect any payment for that PaymentIntent
echo totem
#

so it's a code issue?

pine quarry
#

the code you have is correct. it's just missing a big part: collecting the payment method from the customer.

echo totem
#

But how come some end customer payment method is saved then?

#

using the same code

#

Seems like it work sometimes

#

30% of the traffic works fine

#

Im wondering if their bank has issues accepting the payment

#

but that's so many customers

pine quarry
#

the classic payment flow is like this:

  1. you create the PaymentIntent on the backend
  2. then you mount the Payment Element on the frontent with the client secret
  3. the user enters their payment details, then you confirm the PaymentIntent
    on the PaymentIntent you shared, I only see step 1. which can happen if the user simply decide to not complete the payment flow
#

Im wondering if their bank has issues accepting the payment
that can happen yes, but not in the 2 examples you shared.

echo totem
#

ok

#

It's very weird, I really can't see why people that are able to pay have their paymentmethod saved

#

but 70% not

#

using the same code

#

if it was a flow issue it would happen on all customer right?