Edits history of script submission #13792 for ' Invoice Actions (vercel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vercel = {
      token: string;
    };
    /**
     * Invoice Actions
     * This endpoint allows the partner to request a refund for an invoice to Vercel. The invoice is created using the [Submit Invoice API](#submit-invoice-api).
     */
    export async function main(
      auth: Vercel,
      integrationConfigurationId: string,
      invoiceId: string,
      body: { action: "refund"; reason: string; total: string },
    ) {
      const url = new URL(
        `https://api.vercel.com/v1/installations/${integrationConfigurationId}/billing/invoices/${invoiceId}/actions`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago