Stripe API 测试密钥是否仅限于某些功能?
Is the Stripe API test key limited to certain features?
我是第一次使用 Stripe 构建电子商务应用程序。我正在使用 Insomnia 或 Stripe npm 包向端点 /v1/products
发出 GET 请求,以获取我的完整产品数据,然后这些数据将填充目录页面。
我的问题是 Stripe 提供的测试密钥功能是否有限?当我使用它时,return 数据是一个空数组,与实时 api 键相比,return 数组填充了产品。
这个:
import Stripe from 'stripe';
const stripe = Stripe(process.env.STRIPE_TEST_SECRET_KEY);
stripe.products.list()
.then(console.log);
Returns这个:
{
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/products"
}
而将 STRIPE_TEST_SECRET_KEY
换成 STRIPE_LIVE_SECRET_KEY
return 是这样的:
{
"object": "list",
"data": [
{
"id": "tower",
"object": "product",
"active": true,
"attributes": [
"height",
"colour",
"waterproof"
],
"caption": "Tower",
"created": 1520612842,
"deactivate_on": [],
"description": null,
"images": [],
"livemode": true,
"metadata": {},
"name": "Tower",
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"shippable": true,
"skus": {
"object": "list",
"data": [
{
"id": "t001",
"object": "sku",
"active": true,
"attributes": {
"height": "1600",
"colour": "White",
"waterproof": "False"
},
"created": 1520612987,
"currency": "gbp",
"inventory": {
"quantity": 10,
"type": "finite",
"value": null
},
"livemode": true,
"metadata": {},
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"price": 90000,
"product": "tower",
"updated": 1520674446
},
{
"id": "t002",
"object": "sku",
"active": true,
"attributes": {
"height": "1600",
"colour": "White",
"waterproof": "True"
},
"created": 1520613174,
"currency": "gbp",
"image": null,
"inventory": {
"quantity": 10,
"type": "finite",
"value": null
},
"livemode": true,
"metadata": {},
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"price": 110000,
"product": "tower",
"updated": 1520613174
}
],
"has_more": false,
"total_count": 8,
"url": "/v1/skus?product=tower&active=true"
},
"type": "good",
"updated": 1520674071,
"url": null
}
],
"has_more": false,
"url": "/v1/products"
}
我已经解决了这个问题。我没有意识到实时数据和测试数据是完全分区的,必须在测试门户中单独创建产品才能使测试 api 密钥正常工作。
如果其他人遇到此问题,请在 Stripe 仪表板中单击 'View test data' 开关,然后按照流程再次创建产品。
虽然没有解决 OP 的具体问题,但我有相同的症状并记下解决方案,希望它能帮助其他人。
在开发人员仪表板中,当我们从一个系统迁移到新系统时,我被设置为使用旧的 API 版本。我需要更新以使用最新的 API 版本来解决问题并获得完全填充的 /v1/products 调用。
我是第一次使用 Stripe 构建电子商务应用程序。我正在使用 Insomnia 或 Stripe npm 包向端点 /v1/products
发出 GET 请求,以获取我的完整产品数据,然后这些数据将填充目录页面。
我的问题是 Stripe 提供的测试密钥功能是否有限?当我使用它时,return 数据是一个空数组,与实时 api 键相比,return 数组填充了产品。
这个:
import Stripe from 'stripe';
const stripe = Stripe(process.env.STRIPE_TEST_SECRET_KEY);
stripe.products.list()
.then(console.log);
Returns这个:
{
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/products"
}
而将 STRIPE_TEST_SECRET_KEY
换成 STRIPE_LIVE_SECRET_KEY
return 是这样的:
{
"object": "list",
"data": [
{
"id": "tower",
"object": "product",
"active": true,
"attributes": [
"height",
"colour",
"waterproof"
],
"caption": "Tower",
"created": 1520612842,
"deactivate_on": [],
"description": null,
"images": [],
"livemode": true,
"metadata": {},
"name": "Tower",
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"shippable": true,
"skus": {
"object": "list",
"data": [
{
"id": "t001",
"object": "sku",
"active": true,
"attributes": {
"height": "1600",
"colour": "White",
"waterproof": "False"
},
"created": 1520612987,
"currency": "gbp",
"inventory": {
"quantity": 10,
"type": "finite",
"value": null
},
"livemode": true,
"metadata": {},
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"price": 90000,
"product": "tower",
"updated": 1520674446
},
{
"id": "t002",
"object": "sku",
"active": true,
"attributes": {
"height": "1600",
"colour": "White",
"waterproof": "True"
},
"created": 1520613174,
"currency": "gbp",
"image": null,
"inventory": {
"quantity": 10,
"type": "finite",
"value": null
},
"livemode": true,
"metadata": {},
"package_dimensions": {
"height": 20.0,
"length": 20.0,
"weight": 700.0,
"width": 80.0
},
"price": 110000,
"product": "tower",
"updated": 1520613174
}
],
"has_more": false,
"total_count": 8,
"url": "/v1/skus?product=tower&active=true"
},
"type": "good",
"updated": 1520674071,
"url": null
}
],
"has_more": false,
"url": "/v1/products"
}
我已经解决了这个问题。我没有意识到实时数据和测试数据是完全分区的,必须在测试门户中单独创建产品才能使测试 api 密钥正常工作。
如果其他人遇到此问题,请在 Stripe 仪表板中单击 'View test data' 开关,然后按照流程再次创建产品。
虽然没有解决 OP 的具体问题,但我有相同的症状并记下解决方案,希望它能帮助其他人。
在开发人员仪表板中,当我们从一个系统迁移到新系统时,我被设置为使用旧的 API 版本。我需要更新以使用最新的 API 版本来解决问题并获得完全填充的 /v1/products 调用。