admin管理员组文章数量:1122846
I'm trying to integrate Paddle's inline checkout into my React app. I followed the documentation and set up the initialization and checkout functions, but when I attempt to open the checkout, I receive a 400 Bad Request
error with the message:
One or more parameters (product id or seller) are missing.
Here's the error stack from my browser's console:
Details:
Vendor ID and Product ID are both set properly from environment variables.
The product ID is selected dynamically based on the user's plan, but it seems the request still fails.
The error suggests that the
product
orseller
parameters are missing.
What I’ve Tried:
Verified that
process.env.NEXT_PUBLIC_PADDLE_VENDOR_ID
andpaddleProductId
contain correct values.Checked if the environment variable
NEXT_PUBLIC_PADDLE_VENDOR_ID
is correctly set for the sandbox environment.Ensured that
productIds[selectedPlan.name]
andpriceIds[selectedPlan.name]
are properly defined.
Questions:
What might be missing in the request that causes the "400 Bad Request" error?
How can I ensure that all required parameters are being sent correctly?
Are there any issues with the way I'm setting up the Paddle checkout configuration?
Any help would be appreciated! Thanks in advance.
4.1ff59060.chunk.js:2
GET /?product=pro_01jd1w5q6dvfbj2c7r7dyydvry&parentURL=http%3A%2F%2Flocalhost%3A3000%2Fcheckout&parent_url=http%3A%2F%2Flocalhost%3A3000%2Fcheckout&referring_domain=localhost%3A3000%20%2F%20localhost%3A3000&locale=en&guest_email=xivo%40mailinator&guest_country=us&guest_postcode=14269&vendor=24755&passthrough=%7B%7D&disable_logout=true&display_mode=overlay&apple_pay_enabled=false&paddlejs-version=1.2.1&checkout_initiated=1732270263614&popup=true&paddle_js=true&is_popup=true 400 (Bad Request)
Code Snippet: Here’s the relevant code where I set up Paddle:
useEffect(() => {
const initializePaddle = () => {
if (typeof window.Paddle !== 'undefined') {
const vendorId = parseInt(process.env.NEXT_PUBLIC_PADDLE_VENDOR_ID);
if (isNaN(vendorId)) {
console.error("Invalid Vendor ID.");
return;
}
const environment = process.env.NEXT_PUBLIC_PADDLE_ENVIRONMENT || "sandbox";
Paddle.Environment.set(environment);
Paddle.Setup({
vendor: vendorId,
});
console.log(`Paddle initialized with vendor ${vendorId} in ${environment} mode.`);
} else {
console.error("Paddle is not loaded properly.");
}
};
if (isPaddleLoaded) {
initializePaddle();
}
}, [isPaddleLoaded]);
const handleCheckout = async (e) => {
e.preventDefault();
const paddlePriceId = priceIds[selectedPlan.name]?.[selectedPlan.planTime];
const paddleProductId = productIds[selectedPlan.name]?.[selectedPlan.planTime];
if (!paddlePriceId || !paddleProductId) {
alert('Invalid plan or plan time selected.');
return;
}
if (!formData.email || !formData.country || !formData.zipCode) {
alert('Please complete all required fields.');
return;
}
try {
Paddle.Checkout.open({
email: formData.email,
country: formData.country,
postcode: formData.zipCode,
product: paddleProductId, // This should be a valid product ID from your system
vendor: process.env.NEXT_PUBLIC_PADDLE_VENDOR_ID,
settings: {
displayMode: "inline",
frameTarget: "checkout-container",
frameInitialHeight: "450",
frameStyle: "width: 100%; min-width: 312px; background-color: transparent; border: none;",
},
items: [
{
price_id: paddlePriceId,
quantity: 1,
},
],
customer: [
{
name: selectedPlan.name,
amount: parseFloat(selectedPlan.currentPrice),
},
],
passthrough: JSON.stringify({
userId: formData.userId,
planId: selectedPlan.planId,
}),
currency: selectedPlan.selectedCurrency.code,
locale: "en",
method: "card",
disableLogout: true,
successCallback: (data) => {
console.log("Checkout complete:", data);
router.push("/thank-you");
},
closeCallback: () => console.log("Checkout closed"),
errorCallback: (error) => {
console.error("Paddle checkout error:", error);
alert(`Error: ${error.message}`);
},
});
} catch (error) {
console.error('Error during checkout:', error);
}
};
本文标签:
版权声明:本文标题:next.js - Paddle Checkout Integration Error: "One or more parameters (product id or seller) are missing" - Sta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299710a1930553.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论