#rinorzk
1 messages · Page 1 of 1 (latest)
What don't you understand exactly
If you ask specific questions we can help
What doc are you looking at and which part is confusing?
here is what I have one the backend:
js```async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
try {
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000,
currency: "usd",
payment_method_types: ["klarna"],
});
res.status(HTTP_STATUS.OK.CODE).send({ clientSecret: paymentIntent.client_secret });
} catch (err) {
errorHandler(err, res);
}
}
and calling it on the frontend button click:
const { data } = await axios.get("/api/stripe/klarna-payment");
if (data.clientSecret)
stripe
.confirmKlarnaPayment(data.clientSecret, {
return_url: "https://example.com",
})
.then(function (result) {
if (result.error) {
// Handle payment confirmation error
console.error("Payment confirmation error:", result);
} else {
// Payment confirmation succeeded
console.log("Payment confirmation succeeded:", result.paymentIntent);
// You can then update your UI or perform other actions as needed
}
});
and then I get this error:
{
"type": "invalid_request_error",
"code": "payment_intent_incompatible_payment_method",
"doc_url": "https://stripe.com/docs/error-codes/payment-intent-incompatible-payment-method",
"message": "A payment method of type klarna was expected to be present, but this PaymentIntent does not have a payment method and none was provided. Try again providing either the payment_method or payment_method_data parameters.",
"payment_intent": {
"id": "pi_3NqHTkHe7BhUgpBH1OAzd9kF",
"object": "payment_intent",
"amount": 1000,
"amount_details": {
"tip": {}
},
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"client_secret": "pi_3NqHTkHe7BhUgpBH1OAzd9kF_secret_kVJLUcGCOFRlIEisxrRau9rhL",
"confirmation_method": "automatic",
"created": 1694705356,
"currency": "usd",
"description": null,
"last_payment_error": null,
"livemode": false,
"next_action": null,
"payment_method": null,
"payment_method_types": [
"klarna"
],
"processing": null,
"receipt_email": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"status": "requires_payment_method"
},
"request_log_url": "https://dashboard.stripe.com/test/logs/req_bUUVmFmuquDYmR?t=1694705357"
}
on backend using stripe, and on client side using stripe.js
maybe that's the issue, but it's impossible to get them get to work together.
As soon as I find something I need on one of them, it says go to the other one.
@haughty grove could you help me with this?
Yep looking
thank you, I have been struggling with this for days, it's not clear to me wherether I should create an Intent, a Payment Method or what?