Hi,
Im trying to implement payment with PaymentElement and have problem with multiple payment intents.
I noticed that, when I update my cart with new email (for example user moves step back and changes email address), it creates new payment intents on stripe (screenshot).
I guess it should know its the same cart and just update intent. I checked in stripe logs and all 3 have same cartId in resource_id. How to debug this to find out what is happening?
client secret also is changed (with new pi_)
Im using stripe plugin,
"medusa-payment-stripe": "^6.0.9",
"@medusajs/admin": "^7.1.14",
"@medusajs/medusa": "^1.20.6",
This is how my update cart looks like:
cartId,
cartData,
}: {
cartId: string;
cartData: StorePostCartsCartReq;
}) => {
try {
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/store/carts/${cartId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(cartData),
});
if (!res.ok) {
throw new Error(`Failed to add shipping address to a cart: ${cartId}`);
}
const data = (await res.json()) as { cart: Cart };
return data?.cart;
} catch (error) {
console.log('[ERROR] updateCartShippingAddress', error);
return null;
}
};
Any tips for understanding this would be super helpful!