jeck貓
2023-07-20 14:24:49
我正在嘗試從 stripe 返回所有產(chǎn)品和計(jì)劃列表。但是,即使active創(chuàng)建了產(chǎn)品,產(chǎn)品列表也會(huì)返回空。function getProductsAndPlans() { return Promise.all([ stripe.products.list({}), stripe.plans.list({}), ]).then(stripeData => { console.log('products', stripeData[0]) <-- this is empty console.log('plans', stripeData[1]) <-- this returns plans }).catch(err => { console.error('Error fetching Stripe products and plans: ', err); return []; });}以下是我的 Stripe 儀表板中的產(chǎn)品:計(jì)劃返回:但產(chǎn)品列表是空的:這是條紋文檔的副本。const stripe = require('stripe')('sk_test_smkOYa912GSsdfdfDDfByiohm');const products = await stripe.products.list({ limit: 3,});我在這里缺少什么?
1 回答

慕沐林林
TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊
這很可能與2018-02-05以來(lái)的 API 更改有關(guān),當(dāng)時(shí)默認(rèn)行為從 切換type=good
為type=service
,并且您的帳戶(hù)可能具有早于該版本的默認(rèn) API 版本。type=service
正如記錄的那樣,默認(rèn)情況下,對(duì)于舊 API 版本的產(chǎn)品列表請(qǐng)求,您的產(chǎn)品可能會(huì)被忽略。
要獲取產(chǎn)品列表請(qǐng)求以包含您在儀表板中使用的產(chǎn)品,您可以執(zhí)行以下操作之一:
明確請(qǐng)求
service
產(chǎn)品stripe.products.list({type: 'service'})
(如 API 變更日志中所述)使用(或任何更高版本)覆蓋該請(qǐng)求的默認(rèn) API
stripe.products.list({}, {apiVersion: '2018-02-05'})
升級(jí)您的賬戶(hù)默認(rèn)API版本
添加回答
舉報(bào)
0/150
提交
取消