I'm having a similar problem but I am coding in VS code. When I click the paypal button I get: "Could not initiate PayPal Checkout... Error: {"error":"invalid_token","error_description":"Token signature verification failed"}". How can I fix this in my environment? here is a code snippet where I found the problem to be. the "orderData.id" is returning false. why? window.paypal .Buttons({ async createOrder() { try { const response = await fetch("/api/orders", { method: "POST", headers: { "Content-Type": "application/json", }, // use the "body" param to optionally pass additional order information // like product ids and quantities body: JSON.stringify({ cart: [ { id: "YOUR_PRODUCT_ID", quantity: "YOUR_PRODUCT_QUANTITY", }, ], }), }); const orderData = await response.json(); if (orderData.id) { return orderData.id; } else { const errorDetail = orderData?.details?.[0]; const errorMessage = errorDetail ?`${errorDetail.issue} ${errorDetail.description} (${orderData.debug_id})` : JSON.stringify(orderData); throw new Error(errorMessage); } } catch (error) { console.error(error); resultMessage(`Could not initiate PayPal Checkout...<br><br>${error}`); } }
... View more