Stripe -> Create an Invoice
Readonly
Action summary
Stripe → Create an Invoice
Overview
This Xano action enables you to create an invoice in Stripe by providing customer details, optional discount, description, and collection method. The action prepares the necessary request body, sends it to the Stripe API, and returns the resulting invoice data.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
stripe_api_key |
text | Yes | Your Stripe API key (from settings registry). |
customer_id |
text | Yes | The Stripe customer ID to invoice. |
discount |
text | No | Coupon code for discount (optional). |
description |
text | No | Description for the invoice (optional). |
collection_method |
enum | No | Invoice collection method (e.g., charge_automatically, send_invoice). |
Function Stack
1. Prepare Body Parameters
- Create Variable: Initializes an empty
body_paramsobject. - Update Variable: Adds
discountstobody_paramsifdiscountis provided. - Update Variable: Adds
collection_methodtobody_paramsif provided. - Update Variable: Adds
descriptiontobody_paramsif provided.
2. Stripe API Request
- API Request: Sends a POST request to
https://api.stripe.com/v1/invoiceswith the preparedbody_params. - Precondition: Ensures the response status is
200(success).
3. Response
- Returns the result from the Stripe API response.
Example Usage
Request
{
"stripe_api_key": "sk_test_...",
"customer_id": "cus_123456789",
"discount": "COUPON2024",
"description": "Consulting services for July 2025",
"collection_method": "send_invoice"
}
Response
{
"id": "in_1JYb2D2eZvKYlo2C...",
"object": "invoice",
"customer": "cus_123456789",
"description": "Consulting services for July 2025",
"collection_method": "send_invoice",
...
}
Notes
- Ensure your Stripe API key is kept secure and not shared publicly.
- Only include optional fields (
discount,description,collection_method) if needed; otherwise, they will be omitted from the request. - The action expects a valid Stripe customer ID.
Troubleshooting
- 401 Unauthorized: Check that your
stripe_api_keyis correct and active. - 400 Bad Request: Verify all required fields are provided and valid.
- Other Errors: Review the Stripe API documentation for further guidance on error messages.
References
⁂
Version notes
2025-03-31 20:30:32
Current