Edits history of script submission #12565 for ' Create profile (mollie)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Mollie = {
      token: string;
    };
    /**
     * Create profile
     * Create a profile to process payments on.
    
    Profiles are required for payment processing. Normally they are created via the Mollie dashboard. Alternatively, you can use this endpoint to automate profile creation.
    
    > 🔑 Access with
    >
    > Access token with **profiles.write**
     */
    export async function main(
      auth: Mollie,
      body: {
        resource?: string;
        id?: string;
        mode?: string;
        name: string;
        website: string;
        email: string;
        phone: string;
        description?: string;
        countriesOfActivity?: unknown[];
        businessCategory?: string;
        status?: string;
        review?: { status?: string };
        createdAt?: string;
        _links?: {
          self?: { href?: string; type?: string };
          dashboard?: { href?: string; type?: string };
          chargebacks?: { href?: string; type?: string };
          methods?: { href?: string; type?: string };
          payments?: { href?: string; type?: string };
          refunds?: { href?: string; type?: string };
          checkoutPreviewUrl?: { href?: string; type?: string };
          documentation?: { href?: string; type?: string };
        };
      },
    ) {
      const url = new URL(`https://api.mollie.com/v2/profiles`);
    
      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