#rinorzk
1 messages · Page 1 of 1 (latest)
Hi there!
to mention I also have swell as my ecom service store.
How are you accepting payments? Checkout Session, Payment Element, something else?
Did you read this guide: https://stripe.com/docs/payments/klarna/accept-a-payment?platform=web&ui=API
in the backend:
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);
async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
const { amount, currency } = req.body;
try {
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: currency,
payment_method_types: ["klarna"],
});
res.status(HTTP_STATUS.OK.CODE).send({ clientSecret: paymentIntent.client_secret, paymentIntent });
} catch (err) {
errorHandler(err, res);
}
}
export default withHighlight(handler);
I did
and on the frontend:
const { data } = await axios.post("/api/stripe/klarna-payment", { amount, currency: "usd" });
const returnUrl = getBaseUrl();
returnUrl.pathname = "/order/submitting";
if (data.clientSecret)
stripe
.confirmKlarnaPayment(data.clientSecret, {
payment_method: {
billing_details: {
address: {
country: "US",
},
email: owner.email,
},
},
return_url: returnUrl.toString(),
})
.then(function (result) {
if (result.error) {
console.error("Payment confirmation error:", result);
} else {
// eslint-disable-next-line no-console
console.log("result", result);
}
});
now when I try to update my swell store order it says that it's unpaid.
I think one of the problems is that, it's hard to work with the given params and a successful payment
I only get stuff like payment_intent and stuff
and in the old ways
before having payment intent, I was getting the "source" param
Can you share a PaymentIntent ID (pi_xxx) with this issue?
sure, give me 1m please
@golden sorrel here it is: pi_3NreSSHe7BhUgpBH0eWwuhZW
would this payment be considered successful in all ways in Stripe, with Klarna?
This PaymentIntent has status: "succeeded". So everything worked!
What's the issue?
so as far as stripe and klarna are concerned that payment is paid right?
if that's the case I guess that's all what you guys (Stripe) can do for me, the rest is making that payment valid in Swell.is
and one last thing
after the Klarna payment is done, I get returned to my site again, with some params in the url, before implementing the payment Intent method, I was getting a source param which I used for the Swell.is order. Here is what I had in the old ways (which doesn't work no more):
const intent = await stripe.createSource({
type: "klarna",
flow: "redirect",
amount,
currency: "USD",
owner,
klarna: {
product: "payment",
purchase_country: "US",
...klarna,
},
source_order: {
items,
},
redirect: {
return_url: returnUrl.toString(),
},
});
return intent;
so as far as stripe and klarna are concerned that payment is paid right?
Yes
Here is what I had in the old ways (which doesn't work no more):
So what's your question? What are you trying to do? Here we know nothing about Swell
I think I got what I wanted here, thanks a lot Soma, the rest is with swell I think, which they didn't update to the latest Stripe changes I think.