#thiago-spindola_api

1 messages ¡ Page 1 of 1 (latest)

shy wadiBOT
#

👋 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/1237056709768249444

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

fading bluffBOT
#

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.

hearty drum
#

Hello

hidden cipher
#

Hi

#

How are you?

hearty drum
#

Good, thx

#

So on Sub creation you should expand pending_setup_intent and then using the setup_intent.client_secret to render Payment Element

hidden cipher
#

I'm tried this, but i'm having a error message: Invalid value for stripe.retrievePaymentIntent intent secret: value should be a PaymentIntent client secret. You specified: a SetupIntent client secret.

hearty drum
#

Why are you using stripe.retrievePaymentIntent?

hidden cipher
#

i'm using this code:

export const CheckoutForm: React.FC<StripeCheckoutProps> = ({ clientSecret }) => {
const stripe = useStripe();
const elements = useElements();

const [message, setMessage] = useState<null | string | undefined>(null);
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
if (!stripe) {
return;
}

// const clientSecret = new URLSearchParams(window.location.search).get('payment_intent_client_secret');
console.log('clientSecret', clientSecret);

if (!clientSecret) {
  return;
}

stripe.retrievePaymentIntent(clientSecret).then(({ paymentIntent }) => {
  switch (paymentIntent!.status) {
    case 'succeeded':
      setMessage('Payment succeeded!');
      break;
    case 'processing':
      setMessage('Your payment is processing.');
      break;
    case 'requires_payment_method':
      setMessage('Your payment was not successful, please try again.');
      break;
    default:
      setMessage('Something went wrong.');
      break;
  }
});

}, [stripe]);

#

and passing this value: seti_1P8R58DrhWjWTprTajuYzUba_secret_PyNqH5hMPJ1KBvE8uDzD0BGPk8Tp71y

hearty drum
hidden cipher
#

Can you explain confirm the SetupIntent?

hearty drum
#

That is how you collect the PaymentMethod. Notice in the docs that you call const {error} = await stripe.confirmPayment({ //`Elements` instance that was used to create the Payment Element elements, confirmParams: { return_url: "https://example.com/order/123/complete", } });

#

That would be to actually complete the payment

#

But here you don't have a payment, you just want to collect the PaymentMethod so that you use it in the future to charge the Subscription after the trial ends

#

So you do stripe.confirmSetup() there

#

Instead of stripe.confirmPayment()

#

Then you would check the status of the SetupIntent after that

#

Like you were doing above

hidden cipher
#

In this case, do I have the same result? Will I be able to collect payment details?

hearty drum
#

Yes -- I'm telling you the way to collect payment method details.

#

You do that by confirming the SetupIntent

#

That will create a PaymentMethod and attach it to the Customer

#

Then you set it as the default to be charged in the future

hidden cipher
#

Ok, thank's man