Open amir-saadallah opened 1 month ago
Hi @amir-saadallah - are you able to share a minimal reproduction of this
Hi @amir-saadallah - are you able to share a minimal reproduction of this
This is what I'm trying to do with a subscriber that acts upon webhook receive and this is the success case where I attempt to create an order from the cart
async function handleSuccessPayment(
payment_ref: string,
konnectService_: KonnectPaymentService,
cartService_: CartService,
paymentRepository_: Repository<Payment>,
orderService_: OrderService,
manager_: EntityManager
) {
// We need to ensure, that an order is created in situations, where the
// customer might have closed their browser before order creation
const paymentDetails = await konnectService_.retrievePayment({
payment_id: payment_ref,
});
const cart = await cartService_.retrieveWithTotals((paymentDetails as any).orderId);
try {
const orderPayment = await paymentRepository_.findOne({
where: { cart_id: cart.id },
});
if (!orderPayment) {
throw new Error("Order payment not found");
}
// save the ref
const updatedPayment = {
...orderPayment,
data: {
...orderPayment.data,
resultCode: "authorized",
payment_id: payment_ref,
},
};
console.log("attempt to save");
await paymentRepository_.save(updatedPayment);
// attempt to auto-capture
console.log("attempt to capture");
await konnectService_.capturePayment({ payment_id: payment_ref });
} catch (error) {
// not created -> let's do it
manager_.transaction(async (manager) => {
const session = {
payment_id: payment_ref,
resultCode: "authorized",
amount: cart.total,
};
await cartService_
.withTransaction(manager)
.updatePaymentSession(cart.id, session);
// authorize
await cartService_.withTransaction(manager).authorizePayment(cart.id);
// create the order
await orderService_.withTransaction(manager).createFromCart(cart.id);
});
}
}
Unfortunately, not able to reproduce with the provided information. Any chance you can create a repository where this issue occurs.
I figured it out. for some reason, if u don't set the shipping option from the methods available in the cart (in my case I was fetching all available shipping in the region) the dashboard will show the shipping price as total. I didn't dig into the API to see how we do stuff but changing the shipping methods selection from the methods available in the cart fixes that.
Bug report
Describe the bug
I have a subscriber that attempt to mark a cart paid and create an order from it. everything looks fine except for the order total in order summary
System information
Medusa version (including plugins): 1.20.8 Node.js version: 20.10 Database: PostgreSQL 16 Operating system: Browser (if relevant):