Stripe -> Retrieve a Customer
Readonly
Action summary
Stripe - Retrieve a Customer
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.
Overview
This function retrieves a customer's details from Stripe using their unique customer_id.
Inputs
The function accepts the following inputs:
| Name | Type | Description |
|---|---|---|
| customer_id | text | The unique identifier of the Stripe customer |
| 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/customers/%s - Method:
GET - Authentication: Uses the
stripe_api_key - Path Parameter:
customer_id: The unique identifier of the Stripe customer
- 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 customer's details received from Stripe if the API call is successful.
Usage
- Provide a valid
customer_idto retrieve customer details. - Ensure that
stripe_api_keyis correctly set up in the registry. - Call the function to fetch customer information from Stripe.
- If successful, the function returns customer details in JSON format.
Example Response
{
"id": "cus_12345",
"object": "customer",
"email": "customer@example.com",
"created": 1672531199,
"name": "John Doe",
"phone": "+1234567890",
"metadata": {}
}
Error Handling
- If the API response status is not
200, the function does not proceed. - Ensure valid
customer_idis provided to prevent API errors.
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:35:46
Current