ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Stripe -> Finalize Invoice
Readonly
This function finalizes a draft invoice in Stripe, making it ready for payment.

Action summary

Stripe -> Finalize Invoice

Xano / Stripe

This function finalizes a draft invoice in Stripe, making it ready for payment.

How to Get the Stripe API Key

To retrieve your Stripe API key, follow these steps:

  1. Log in to your Stripe dashboard at https://dashboard.stripe.com.
  2. Navigate to Developers > API keys.
  3. Locate the Secret Key under the Standard keys section.
  4. Click Reveal test key (for testing) or use the live key for production.
  5. Copy the API key and store it securely.

Note: Never expose your API key in client-side applications.

Inputs

The function accepts the following inputs:

Name Type Description
invoice_id text The ID of the invoice to finalize
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 Request

  • API Request:
    • Endpoint: https://api.stripe.com/v1/invoices/{invoice_id}/finalize
    • Method: POST
    • Authentication: Uses the stripe_api_key
    • Returns: stripe_api

2. Precondition Check

  • Ensures that the API response status is 200 before proceeding.

3. Response

  • Key: As Self
  • Value: var: stripe_api.response.result
  • The function returns the finalized invoice details if the API call is successful.

Usage

  1. Provide a valid invoice_id for the invoice to be finalized.
  2. Ensure that stripe_api_key is correctly set up in the registry.
  3. Call the function to finalize the invoice in Stripe.
  4. If successful, the function returns the finalized invoice details.

Example Response

{
  "id": "in_12345",
  "object": "invoice",
  "status": "open",
  "total": 1000,
  "currency": "usd",
  "created": 1672531199,
  "finalized_at": 1672531200
}

Error Handling

  • If the API response status is not 200, the function does not proceed.
  • Ensure that invoice_id is valid and corresponds to an existing draft invoice.
  • The invoice must be in draft status before finalization.

Notes

  • This function requires an active Stripe account and API key.
  • API keys should be kept secure and not exposed in client-side applications.
  • Finalizing an invoice makes it uneditable, so ensure all details are correct before calling this function.

Version notes

2025-03-13 15:51:56
Current
2025-03-13T10:21:57.000+00:00