Edits history of script submission #23789 for ' Write Off Invoice (stripe)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Write Off Invoice
     * Mark an open invoice as uncollectible (bad debt) for accounting purposes.
     */
    export async function main(auth: RT.Stripe, invoice_id: string) {
      const response = await fetch(
        `https://api.stripe.com/v1/invoices/${invoice_id}/mark_uncollectible`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            Accept: "application/json",
            "Stripe-Version": "2025-03-31.basil",
          },
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 3 hours ago