diff --git a/src/modules/market/views/CheckoutPage.vue b/src/modules/market/views/CheckoutPage.vue index e96f898..84940b8 100644 --- a/src/modules/market/views/CheckoutPage.vue +++ b/src/modules/market/views/CheckoutPage.vue @@ -272,6 +272,7 @@ import { ref, computed, onMounted } from 'vue' import { useRoute } from 'vue-router' import { useMarketStore } from '@/stores/market' +import { useNostrStore } from '@/stores/nostr' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import { Card, @@ -291,6 +292,7 @@ import { const route = useRoute() const marketStore = useMarketStore() +const nostrStore = useNostrStore() const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any // State @@ -410,14 +412,29 @@ const placeOrder = async () => { if (!currentStall.value) { throw new Error('Stall information not available') } - if (!authService.isAuthenticated.value || !authService.user.value?.pubkey) { + // Debug logging to understand auth state + console.log('Auth check:', { + isAuthenticated: authService.isAuthenticated.value, + user: authService.user.value, + hasPubkey: !!authService.user.value?.pubkey, + nostrPubkey: nostrStore.account?.pubkey + }) + + // Get pubkey from auth service or fallback to nostr store + const userPubkey = authService.user.value?.pubkey || nostrStore.account?.pubkey + + if (!authService.isAuthenticated.value) { throw new Error('You must be logged in to place an order') } + + if (!userPubkey) { + throw new Error('No Nostr public key found. Please ensure your Nostr identity is configured.') + } // Create the order using the market store's order placement functionality const orderData = { stallId: stallId.value, - buyerPubkey: authService.user.value?.pubkey || '', + buyerPubkey: userPubkey, sellerPubkey: currentStall.value.pubkey, status: 'pending' as const, items: checkoutCart.value.products.map(item => ({