ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Stripe -> Create an Invoice
Readonly
Stripe → Create an Invoice

Action summary

Stripe -> Create an Invoice

Xano / Stripe

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_params object.
  • Update Variable: Adds discounts to body_params if discount is provided.
  • Update Variable: Adds collection_method to body_params if provided.
  • Update Variable: Adds description to body_params if provided.

2. Stripe API Request

  • API Request: Sends a POST request to https://api.stripe.com/v1/invoices with the prepared body_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_key is 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

  • Stripe API: Create an Invoice
⁂

Version notes

2025-03-31 20:30:32
Current
2025-03-31T15:00:33.000+00:00