#brain_code

1 messages ยท Page 1 of 1 (latest)

silk ospreyBOT
#

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

๐Ÿ“ 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.

tardy lantern
#

So, in a nutshell, this would be related to "dynamic pricing" or similar. Unsure how to categorize it.

#

I migrated out of PaymentRequestButtonElement earlier today (which had shorter loading times), but it takes too long with the ExpressCheckoutElement and doesn't look good.

#

Are there any best practices recommendations for me?

dusky prism
tardy lantern
#

Beautiful

#

This stripe discord is the best support any company ever had. Thank you so much Rubeus.

#

I will let you know in a few minutes how that goes

silk ospreyBOT
tardy lantern
#

I'm attempting to change it this way:

  useEffect(() => {
    if (paymentIntentId && message && amount) {
      updatePaymentIntentMetadata(paymentIntentId, message, amount);
    }
  }, [paymentIntentId, message, amount]);
    useEffect(() => {
      if (elements && !changedDetails) {
        elements.fetchUpdates().then((result) => {
          if (result.error) {
            console.error("Error fetching updates:", result.error);
          } else {
            // Updates fetched successfully
            console.log("Payment Element updated");
          }
        });
      }
    }, [elements, amount, changedDetails]);

& getting Payment Element updated logged to console

Having no success. On the Backend, we are correclty changing the payment intent:

// get previous metadata
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
const previousMetadata = paymentIntent.metadata;
const updates: {
  metadata: Record<string, string>;
  amount?: number;
} = {
  metadata: {
    ...previousMetadata,
  };

  if (amount) {
    // Convert amount to cents
    const amountCents = Math.round(amount * 100);
    updates.amount = amountCents;
  }
  const updatedPaymentIntent = await stripe.paymentIntents.update(
    paymentIntentId,
    updates,
  );
  console.log(updatedPaymentIntent);
  return res.json({ message: "Payment intent updated" });

-- having the correct details in the updated payment intent.

charred cradle
#

๐Ÿ‘‹ stepping in here

#

fetchUpdates doesn't really apply here since the PaymentIntent doesn't come into play until the actual payment is being made.