Edits history of script submission #14295 for ' Three DS.Create Session (basis_theory)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Basistheory = {
      apiKey: string;
    };
    /**
     * Three DS.Create Session
     * Three DS.Create Session
     */
    export async function main(
      auth: Basistheory,
      body: {
        device?: string;
        device_info?: {
          browser_accept_header?: string;
          browser_color_depth?: string;
          browser_ip?: string;
          browser_java_enabled?: string;
          browser_javascript_enabled?: string;
          browser_language?: string;
          browser_screen_height?: string;
          browser_screen_width?: string;
          browser_tz?: string;
          browser_user_agent?: string;
          sdk_application_id?: string;
          sdk_encryption_data?: string;
          sdk_ephemeral_public_key?: string;
          sdk_max_timeout?: string;
          sdk_reference_number?: string;
          sdk_render_options?: { sdk_interface?: string; sdk_ui_type?: string[] };
          sdk_transaction_id?: string;
        };
        pan?: string;
        token_id?: string;
        token_intent_id?: string;
        type?: string;
        web_challenge_mode?: string;
      },
    ) {
      const url = new URL(`https://api.basistheory.com/3ds/sessions`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "BT-API-KEY": auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago