#sreekanth_api

1 messages ยท Page 1 of 1 (latest)

plain novaBOT
#

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

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

trail acornBOT
#

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.

neat olive
#

hi

trail acornBOT
plush sphinx
#

Hi, let me help you with this.

#

Could you elaborate please? What do you mean by "what i should show"?

neat olive
#

I am trying to implement payment authentication in the frontend. If it fails authentication in the backend, what are the details that I should send to the frontend?

#

const CheckoutForm: React.FC<CheckoutFormProps> = () => {
const stripe = useStripe();
const elements = useElements();
const router = useRouter();
const [isProcessing, setIsProcessing] = useState<boolean>(false);
const [succeeded, setSucceeded] = useState<boolean>(false);
const secret = "pi_3P94WiJKyfLg4PX00hlBtRsZ_secret_0IHLqligPX1lEoohDbRjCGp8O";

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

if (!stripe || !elements) {
  // Stripe.js has not yet loaded.
  // Make sure to disable form submission until Stripe.js has loaded.
  return;
}

setIsProcessing(true);

const cardElement = elements.getElement(CardElement);

if (cardElement) {
    const { error, paymentIntent } = await stripe.confirmCardPayment(secret,);



  if (error) {
    toast.error(error.message);
    setIsProcessing(false);
  } else if (paymentIntent && paymentIntent.status === 'succeeded') {
    setSucceeded(true);
    router.push(`${window.location.origin}/success?payment_intent=${paymentIntent.id}&method=${paymentIntent.payment_method_types[0]}`);
  }
}

setIsProcessing(false);

};

return (
<div className="payment_container">
<form onSubmit={handleSubmit}>
<div className="card-element-container" style={{width:"400px"}}>
<CardElement />
</div>
<button type="submit" disabled={isProcessing}>
{isProcessing ? "Processing..." : "Pay Now"}
</button>
</form>
</div>
);
};

#

do i need to pass any adidtional parameters here => const { error, await stripe.confirmCardPayment(secret,);

plush sphinx
#

Do you need specifically only card authentication handling flow?
Or simply accept payments?

neat olive
#

For saved cards, we handle transactions on the backend. For authenticated flows, we're attempting to notify users via email to authenticate

plush sphinx
#

Basically, if an off-session charge fails, you're trying to bring customers on-session to confirm the payment again?

neat olive
#

yes, We save customers' cards in Stripe and display the same saved cards for payments. However, for cards with 3D Secure, payment cannot be completed without authentication from the user.

#

you can check previous conversations...

#

.

lean phoenix
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away. Please bear with me a moment while I catch up on the discussion here.

neat olive
#

okay sure

lean phoenix
#

If the payment fails, you'll need to get your customers to come back on-session to complete the payment. The failed payment is the indicator you'll receive that you need to do so.

confirmCardPayment seems like a valid approach for your frontend code, as long as you're only processing card payments. You'll need to ensure the Payment Method you're using is attached to the Payment Intent on the backend before doing the client-side confirmation, or you'll need to provide the ID of the Payment Method to use when making the confirmation request:
https://docs.stripe.com/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-payment_method

neat olive
#

why we need to pass, payment_method: {
card: cardElement,
billing_details: {
name: 'Jenny Rosen',
},
}, ?

#

i dont understand, why we need to pass cardElement here....

lean phoenix
#

You don't do that if you want to use an existing Payment Method, you pass the ID of the existing Payment Method instead of the instance of the Card Element.

neat olive
#

like this => = await stripe.confirmCardPayment(secret,
{
payment_method: "pm_1P904xJKyfLg4PX0nG4c0X34",
setup_future_usage: 'off_session',

    }
  );
lean phoenix
#

It sounds like you're using an already set up Payment Method, so you won't want to use setup_future_usage.

neat olive
#

okay

#

in case of subscription, we need to ask user for each payment ?

lean phoenix
#

Ask the user what?

neat olive
#

If a user has subscribed to pay monthly or annually, in the case of 3D Secure payments, will the amount be automatically deducted each month, or do we need to ask the user to authenticate each month?

lean phoenix
#

The payment is automatically attempted each month. If the payment fails, you'll need to bring your customers back on session to complete the payment.

neat olive
#

okay

#

Do we have any email services provided by Stripe for 3D Secure payments, to notify users to authenticate?

lean phoenix
neat olive
#

okay, thanks toby