#just4skiillz-intent-metadata

1 messages · Page 1 of 1 (latest)

waxen nexusBOT
#

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.

hallow minnow
#

Hello! You'll need to give a lot more context - What does your code looks like?

warped sparrow
#

ok one sec

#

my backend
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,
confirm: true,
return_url: "pestControl://checkout/success",
});
const clientSecret = paymentIntent.client_secret;
res.json({ message: "Payment initiated", clientSecret });
} catch (err) {
console.error(err);
res.status(500).json({ message: "Internal server error" });
}
});

#

my front:
const payment = async () => {
try {
const response = await fetch(http://${IP_Address}:4000/pay, {
method: "POST",
body: JSON.stringify({
name: "Joey",
amount: total,
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!");
}

};

hallow minnow
#

Sorry to be specific - I just want to know the exact code you're using that's resulting in those logs

#

I don't see anything there that has "succeeded payment" or "initiated payment"

warped sparrow
#

ok yes sorry

#

app.post("/stripe", async (req, res) => {
const sig = req.headers["stripe-signature"];
let event;
try {
event = await stripe.webhooks.constructEvent(
req.body,
sig,
process.env.STRIPE_WEBHOOK_SECRET
);
} catch (err) {
console.error(err);
res.status(400).json({ message: err.message });
}
// Event when a payment is initiated
if (event.type === "payment_intent.created") {
console.log(${event.data.object.metadata.name} initated payment!);
}
// Event when a payment is succeeded
if (event.type === "payment_intent.succeeded") {
console.log(${event.data.object.metadata.name} succeeded payment!);
// fulfilment
}
// Event when a setup is succeeded
if (event.type === "setup_intent.succeeded") {
console.log(
${event.data.object.metadata.name} paiement method registered!
);
// fulfilment
}
res.json({ ok: true });
});

hallow minnow
#

I'm not seeing you set PaymentIntent metadata at all in your creation code - is there a reason you're expecting it to be set?

warped sparrow
#

that so true its code coming from a tutorial but I changed it after, my bad sorry

#

If i want to pass the order number paid in the payment is it in the metadata that I putting it ?

hallow minnow
#

You would need to set that when you create the PaymentIntent (yes you can put it in metadata)

warped sparrow
#

ok thank you, because i created setupIntend before, when im creating a paymentIntent im passing it in the same request but thank you

hallow minnow
#

👍

#

just4skiillz-intent-metadata