Edits history of script submission #12637 for ' Request Apple Pay payment session (mollie)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Mollie = {
      token: string;
    };
    /**
     * Request Apple Pay payment session
     * When integrating Apple Pay in your own checkout on the web, you need to [provide merchant validation](https://developer.
     */
    export async function main(
      auth: Mollie,
      body: { validationUrl: string; domain: string; profileId?: string },
    ) {
      const url = new URL(`https://api.mollie.com/v2/wallets/applepay/sessions`);
    
      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