Stripe -> Retrieve a Product
Readonly
Action summary
Stripe - Retrieve a Product
Overview
This function retrieves a product from Stripe using its product_id. It makes an API request to Stripe and returns the product details.
Inputs
The function accepts the following inputs:
| Name | Type | Description |
|---|---|---|
| product_id | text | The ID of the product in Stripe |
| stripe_api_key | registry/text | The API key used to authenticate with Stripe |
Function Stack
The function consists of the following steps:
1. Stripe API Call
- API Request:
- Endpoint:
https://api.stripe.com/v1/products/{product_id} - Method:
GET - Authentication: Uses the
stripe_api_key - Returns:
stripe_api
- Endpoint:
2. Precondition Check
- Ensures that the API response status is
200before proceeding.
3. Response
- Key:
As Self - Value:
var: stripe_api.response.result - The function returns the response received from Stripe if the API call is successful.
How to Get the Stripe API Key
To retrieve your Stripe API key, follow these steps:
- Log in to your Stripe dashboard at https://dashboard.stripe.com.
- Navigate to Developers > API keys.
- Locate the Secret Key under the Standard keys section.
- Click Reveal test key (for testing) or use the live key for production.
- Copy the API key and store it securely.
Note: Never expose your API key in client-side applications.
Usage
- Provide a valid
product_idas input. - Ensure that
stripe_api_keyis correctly set up in the registry. - Call the function to retrieve the product details from Stripe.
- If successful, the function returns the product information in JSON format.
Example Response
{
"id": "prod_12345",
"object": "product",
"name": "Sample Product",
"description": "This is a sample product.",
"active": true,
"created": 1672531199,
"updated": 1672531200
}
Error Handling
- If the API response status is not
200, the function does not proceed. - Ensure the
product_idexists in Stripe; otherwise, Stripe may return an error.
Notes
- This function requires an active Stripe account and API key.
- API keys should be kept secure and not exposed in client-side applications.
Version notes
2025-03-03 17:13:31
Current