Paynow refusing to intergrate on Amazon dormain


#1

Payment Error

Invalid JWT
create-paynow-payment:1 POST https://vxlfgmyawtzrangphbhs.supabase.co/functions/v1/create-paynow-payment 401 (Unauthorized)
index-C0-hYqAk.js:351 User signed in


#2

U need to grab the current session’s access token & include it in your invoke or fetch call. Supabase handels headers auto, for client side try

const { data, error } = await supabase.functions.invoke(‘create-paynow-payment’, {
body: { amount: 100, reference: ‘123’ },
// 1. This automatically injects the current user’s JWT
})
Raw fetch try manual

// 1. Get the current session
const { data: { session } } = await supabase.auth.getSession();

// 2. Call the function with the token in the header
const response = await fetch(‘https://vxlfgmyawtzrangphbhs.supabase.co/functions/v1/create-paynow-payment’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
// CRITICAL: Send the user’s specific access token
‘Authorization’: Bearer ${session?.access_token}
},
body: JSON.stringify({ … })
});