#just4skiillz

1 messages · Page 1 of 1 (latest)

winged raftBOT
#

Hello! We'll be with you shortly. 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.

untold jolt
#

Hello! Are you intentionally choosing to use the custom FlowController integration path (you're setting customFlow: true )? If so, then the code for this is different

tame sun
#

no I dont even know what is the use of this

#

i just want to pay with a payment method Id that I setupIntent earlier

#

i just need to remove it?

untold jolt
#

Yes you should remove it if you don't intend to use FlowController

tame sun
#

now im getting this:

untold jolt
#

The error says exactly what the issue is - you can't use paymetn sheet with a Payment INtent that's already successful

tame sun
#

so what I need to change(im new to coding sorry)

untold jolt
#

You need to look atyour code that's generating the Payment Intent and see what it's doing

tame sun
#

app.post("/pay", async (req, res) => {
try {
const { name, amount, customerId, pmtMethodId } = req.body;
if (!name) return res.status(400).json({ message: "Please enter a name" });
const paymentIntent = await stripe.paymentIntents.create({
amount: Math.round(amount * 100),
currency: "CAD",
automatic_payment_methods: { enabled: true },
customer: customerId,
payment_method: pmtMethodId,
return_url: "https://example.com/order/123/complete",
off_session: true,
confirm: true,
});
const clientSecret = paymentIntent.client_secret;
res.json({ message: "Payment initiated", clientSecret });
} catch (err) {
console.error(err);
res.status(500).json({ message: "Internal server error" });
}
});

untold jolt
#

Why are you confirming that Payment Intent ifyou're intending to have it be charged through the Payment Sheet?

tame sun
#

I dont know I tought to make a paiment i Have to creat a payment Intent? I tought that my payment sheet was just to get the payment method?

untold jolt
#

Yeah let's back up for a minute - Yes, the Payment Sheet needs a Payment Intent to work, but more specifically it needs a Payment Intent that hasn't been completed. Your server-side code is incorrectly creating AND confirming the Payment Intent in the same call, and the confirmation is causing payment to be attempted and the payment to be successful (which is why payment sheet is failing)

#

If your intention is for payment to be triggered through the payment sheet, you need to be removing confirm: true from your Payment Intent creation.

winged raftBOT
tame sun
#

ok first im making a setupIntent.....
after My recap i hit pay:
now that I removed confirm:true im getting an error

#

StripeInvalidRequestError: The parameter return_url cannot be passed when creating a PaymentIntent unless confirm is set to true.

#

i just remove the return url?

untold jolt
#

yup

tame sun
#

oooh ok now i understand ... its not what I want.... now when i press pay there is a new payment sheet appearing, me i just want to process the payment with the payment methot set up earlier....
I dont want that:
I just want to process the payment and get the payment succeeded webhook

#

man Im so lost right now lol

untold jolt
#

Ah, so you don't want payment sheet at all then

#

What you had before with the Payment Intent confirmation iwas all you needed

tame sun
#

the payment sheet I used it for the setupIntent thats it

untold jolt
#

Yeah, you don't need it again for the Payment Intent though

#

And really, if you're planning to make a payment IMMEDIATELY after setting up a card you shouldn't be using a Setup Intent

#

You should be using a Payment Intetn w/ setup_future_usage

tame sun
#

but what if the customer comes for another buy 1 month laterm his cards will still be registered?

untold jolt
#

Yes, if you use a PaymentIntent w/ setup_future_usage, that also sets up the card to be used later

tame sun
#

but can PaymentIntent w/ setup_future_usage be setup without an amount at first?

untold jolt
#

No, it would need an amount

tame sun
#

so Thats why then

#

The mobile structure need to setup payment method but the mount of the order

#

befor the amount

#

so to finish My function just dont need payment sheet like this:
const payment = async () => {
try {
const response = await fetch(http://${IP_Address}:4000/pay, {
method: "POST",
body: JSON.stringify({
name: "Joey",
amount: total.toFixed(2),
customerId: customerId,
pmtMethodId: pmtMethodId,
}),
headers: {
"Content-Type": "application/json",
},
});
const data = await response.json();

  Alert.alert("Payment complete, thank you");
} catch (err) {
  console.error(err);
  Alert.alert("Something went wrong, try again later!");
}

};

#

?

untold jolt
#

Yes, try that out and make sure it works

tame sun
#

ok

#

Niiice:

#

thank you very much