Is the Stripe API test key limited to certain features?

122
March 10, 2018, at 11:32 PM

I'm building an ecommerce application using Stripe for the first time. I'm making a GET request to the endpoint /v1/products using either Insomnia or the Stripe npm package to get my complete product data which will then populate the catalogue page.

My question is whether there is limited functionality on the test secret key Stripe provides? As when I use it the return data is an empty array, compared with the live api key which returns the array populated with products.

This:

import Stripe from 'stripe';
const stripe = Stripe(process.env.STRIPE_TEST_SECRET_KEY);
stripe.products.list()
  .then(console.log);

Returns this:

{
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/products"
}

Whereas swapping STRIPE_TEST_SECRET_KEY for STRIPE_LIVE_SECRET_KEY returns this:

{
"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"
}
Answer 1

I have since solved this. I had not realised that live and test data were fully partitioned and it was necessary to create products separately in the test portal for the test api key to work.

On the off chance someone else encounters this issue, from the Stripe dashboard click the 'View test data' switch then follow the process to create products again.

READ ALSO
Getting functions from websites

Getting functions from websites

In a website how can I get the returned output from functions in chrome consoleFor example if the website was http://www

122
setup nodejs on aws ec2 windows server 2016

setup nodejs on aws ec2 windows server 2016

I have set up an EC2 windows server 2016

140
installation failed loopback cli on windows npm install -g loopback-cli

installation failed loopback cli on windows npm install -g loopback-cli

Trying to install loopback lead me to this errorcan anyone help to clear out this

166
Deploy complete but nothing shows up on Herokuapp site; React Webpack app

Deploy complete but nothing shows up on Herokuapp site; React Webpack app

I am trying to deploy my React Webpack app on Heroku and am going through some basic steps such as editing my scripts on my packagejson

145