Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions bot/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,18 @@ const cancelOrder = async (ctx: CommunityContext, orderId: string, user: UserDoc
return await cancelAddInvoice(ctx, order);
}

// let the user to cancel if the order is waiting for payment
if (order.status === 'WAITING_PAYMENT') {
return await cancelShowHoldInvoice(ctx, order);
if (order.type === 'buy') {
return cancelShowHoldInvoice(ctx, order);
}
// Seller wants to cancel in WAITING_PAYMENT
if (order.type === 'sell') {
const seller = await User.findById(order.seller_id);
if (!seller) throw new Error('sellerUser was not found');
if (String(ctx.from.id) === seller.tg_id) {
return cancelShowHoldInvoice(ctx, order);
}
}
}

if (order.status === 'CANCELED') {
Expand Down
Loading