#neat_api

1 messages ยท Page 1 of 1 (latest)

late wharfBOT
#

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

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

copper kindle
#

Hi! You're trying to hide Link, am I understanding that right? May I ask why you don't want the option?

late ginkgo
#

I don't want this form to appear

#

it would make the experice annoying for my users

copper kindle
#

What happens if you collapse that box?

late ginkgo
#

when I fill the "security code" field then this form automagically appears and the cursor automatically moves to the email field

#

oh so you're saying I'm being shown this because I have opted in for this? so it will be only show to the users who have opted in?

copper kindle
#

No, I'm not saying that.

#

If you reload that page, does it show the whole Link form, or do you have to click on "Secure, 1-click checkout with Link" to make it appear?

late ginkgo
#

this is how it looks, I can expand and collapse it.

but even when I don't touch it and just fill out the card form fields, it then automatically appears below just like in the first screenshot

copper kindle
#

Can you share a URL where I can see that for myself?

late ginkgo
#

hmm it's running locally, I would need to deploy the app, let me try to do that

copper kindle
#

Or can you share the client-side code that creates the Stripe Element there?

late ginkgo
#

that's a little complicated! but let me try...

#

This is server side:

const paymentIntent = await stripe.paymentIntents.create({
      amount: pointPackage.priceInDollars * 100,
      currency: "USD",
      automatic_payment_methods: {
        enabled: true,
        allow_redirects: "never",
      },
      // payment_method_options: {
      //   // link: {
      //   //   capture_method: "manual",
      //   // },
      //   card: {},
      // },
    });
#

can't share code in it's entirety

copper kindle
#

No, I just need the client-side code that creates the Stripe Element.

late ginkgo
#
import { Elements } from "@stripe/react-stripe-js";
import { loadStripe, StripeElementsOptions } from "@stripe/stripe-js";

// Appearance settings
  const appearance: StripeElementsOptions["appearance"] = {
    theme: "stripe",
    variables: {
      colorPrimary: "#0f172a",
    },
  };

  // Options for Elements provider
  const elementsOptions: StripeElementsOptions | undefined = clientSecret
    ? { clientSecret, appearance }
    : undefined;

{clientSecret && elementsOptions && (
          <div className="py-4">
            <Elements stripe={stripePromise} options={elementsOptions}>
              <CheckoutForm />
            </Elements>
          </div>
        )}



#

// In a different component

const stripe = useStripe();
  const elements = useElements();
  
  const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();

    if (!stripe || !elements) {
      // Stripe.js hasn't yet loaded.
      // Make sure to disable form submission until Stripe.js has loaded.
      setMessage("Payment system is not ready. Please wait or refresh.");
      console.error("Stripe or Elements not loaded");
      return;
    }

    setIsLoading(true);
    setMessage(null);

    const { error } = await stripe.confirmPayment({
      elements,
      confirmParams: {
        // Redirect to the billing page with payment intent
        return_url: `${window.location.origin + redirect}`,
        // return_url: `${window.location.origin + '/'}`,
      },
    });

    // This point will only be reached if there is an immediate error when
    // confirming the payment. Otherwise, the customer is redirected.
    if (error) {
      if (error.type === "card_error" || error.type === "validation_error") {
        setMessage(error.message || "An unexpected error occurred.");
        toast.error(error.message || "Payment failed.");
      } else {
        setMessage("An unexpected error occurred during payment confirmation.");
        toast.error("An unexpected payment error occurred.");
        console.error("Stripe confirmPayment error:", error);
      }
    } else {
      toast.success("Payment successful");
      // Should not happen often as the user is usually redirected
      setMessage("Processing payment...");
      // Call onSuccess if provided
    }

    setIsLoading(false);
  };

return (<PaymentElement
        id="payment-element"
        options={{
          layout: "tabs",
          business: { name: "AI Image Generator pp" },
        }}
      />)
#

I extracted only the stripe code

copper kindle
late ginkgo
#

let me check

#

I'm using automatic payment methods options, I will try to use the manually one, thanks for your help

copper kindle
#

You're very welcome! I think you only need to set that particular option to include link: "never" and that should do what you're looking for.

late ginkgo
#

where on the client side?

#

I'm not using the "checkout"

#

I'm using elements

copper kindle
#
<Elements stripe={stripePromise} options={elementsOptions}>
    <CheckoutForm />  // <------- What is this?
</Elements>
late ginkgo
#

the option from the docs is not available

late ginkgo
copper kindle
#

You're creating a Checkout Session server-side, ya?

late ginkgo
#

No I'm using stripe "elements" for which I need to create a payment_intent

copper kindle
#

What guide are you following?

late wharfBOT
late ginkgo
late wharfBOT
late ginkgo
#

fixed it! had to disable it from the dashborad

versed rampart
#

๐Ÿ‘

#

Alternatively, you on your option here

options={{
          layout: "tabs",
          business: { name: "AI Image Generator pp" },
}}

You can also do wallets: link: never

#

For disabling frontend, per-element

late ginkgo
#

can you give me the code examples?

versed rampart
#

Sorry we don't have. But literally the wallets is on the same level with layout, so ideally

options={{
    layout: "tabs",
    business: { name: "AI Image Generator pp" },
    wallet: { link: "never"},
}}
late ginkgo
versed rampart
#

Hmm that's weird. Does it error if you just type it in? ie. ignoring the code completion suggestion