我正在使用nestjs和html将
payment code
写在sandbox
的paddle
中。
我做了两种产品,一种是普通的
product
,一种是plan
。
如果我支付了
plan
费用,我可以从 webhook 接收 checkout_id
信息。
但是,在购买一般产品时,通过webhook获取了以下信息。
{
event_time: '2022-08-22 08:54:19',
p_country: 'CN',
p_coupon: '',
p_coupon_savings: '0.00',
p_currency: 'CNY',
p_custom_data: '',
p_earnings: '{"7668":"3.2000"}',
p_order_id: '407118',
p_paddle_fee: '3.77',
p_price: '6.97',
p_product_id: '33625',
p_quantity: '1',
p_sale_gross: '6.97',
p_tax_amount: '0.00',
p_used_price_override: '0',
passthrough: '{"userId":9}',
quantity: '1',
p_signature: 'bZhkDR+M/G...HIU+D8ZaQ9BKMGL2a/K63eoAdkU='
}
并且在订单页面,我选择数量为3,数量为1,webhook被调用3次...
//sandbox
Paddle.Environment.set('sandbox');
Paddle.Setup({
vendor: xxxx,
eventCallback: function (data) {
// The data.event will specify the event type
if (data.event === 'Checkout.Loaded') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Complete') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Close') {
console.log(data.eventData) // Data specifics on the event
}
}
});
Paddle.Checkout.open({
product: xxxxx
, allowQuantity:true
, passthrough:{
userId:9
}
});
上面是我的html代码。该页面未调用 eventCallback 函数。
这是一个
sandbox
问题吗?请告诉我如何解决以上问题!
[总结]
checkout_id
。3
,则数量在 Webhook 中显示为 1
,并且 Webhook 称为 3 times
。eventCallback
函数不会在html
中调用。有同样的问题 Paddle eventCallbacks 在开发中工作,但在 Nextjs 的构建中不起作用,请帮助我,如果有人知道的话。
useEffect(() => {
initializePaddle({ environment: 'sandbox',
token: 'test_dc6bbc0c15c532af5915996babb',
eventCallback(event) {
console.log(event);
// router.push('/');
}, }).then(
(paddleInstance: Paddle | undefined) => {
if (paddleInstance) {
setPaddle(paddleInstance);
}
},
);
}, []);