【发布时间】:2018-03-10 09:57:56
【问题描述】:
我是第一次使用 Stripe 构建电子商务应用程序。我正在使用 Insomnia 或 Stripe npm 包向端点 /v1/products 发出 GET 请求,以获取我的完整产品数据,然后这些数据将填充目录页面。
我的问题是 Stripe 提供的测试密钥是否功能有限?当我使用它时,返回数据是一个空数组,与返回填充有产品的数组的实时 api 键相比。
这个:
import Stripe from 'stripe';
const stripe = Stripe(process.env.STRIPE_TEST_SECRET_KEY);
stripe.products.list()
.then(console.log);
返回这个:
{
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/products"
}
而将STRIPE_TEST_SECRET_KEY 换成STRIPE_LIVE_SECRET_KEY 会返回:
{
"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"
}
【问题讨论】:
-
我投票结束这个问题,因为we are not Stripe customer support.
-
嗨 Jörg,您在客户支持问题上链接的帖子说询问使用公司的 API 是可以接受的。无论如何,尽管我现在已经发现了我的错误并解决了问题。我无法接受自己的答案,否则我会将其标记为已解决。
标签: javascript node.js stripe-payments api-key