Edits history of script submission #14294 for ' Three DS.Authenticate Session (basis_theory)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Basistheory = {
      apiKey: string;
    };
    /**
     * Three DS.Authenticate Session
     * Three DS.Authenticate Session
     */
    export async function main(
      auth: Basistheory,
      sessionId: string,
      body: {
        authentication_category?: string;
        authentication_type?: string;
        broadcast_info?: { nullable?: false | true };
        cardholder_info?: {
          account_id?: string;
          account_info?: {
            account_age?: string;
            account_change_date?: string;
            account_created_date?: string;
            account_last_changed?: string;
            account_pwd_change_date?: string;
            account_pwd_last_changed?: string;
            payment_account_age?: string;
            payment_account_created?: string;
            purchase_count_half_year?: string;
            shipping_account_name_match?: string;
            shipping_address_first_used?: string;
            shipping_address_usage_date?: string;
            suspicious_activity_observed?: string;
            transaction_count_day?: string;
            transaction_count_year?: string;
          };
          account_type?: string;
          authentication_info?: {
            data?: string;
            method?: string;
            timestamp?: string;
          };
          billing_address?: {
            city?: string;
            country_code?: string;
            line1?: string;
            line2?: string;
            line3?: string;
            postal_code?: string;
            state_code?: string;
          };
          billing_shipping_address_match?: string;
          email?: string;
          mobile_phone_number?: { country_code?: string; number?: string };
          name?: string;
          phone_number?: { country_code?: string; number?: string };
          prior_authentication_info?: {
            data?: string;
            method?: string;
            reference_id?: string;
            timestamp?: string;
          };
          shipping_address?: {
            city?: string;
            country_code?: string;
            line1?: string;
            line2?: string;
            line3?: string;
            postal_code?: string;
            state_code?: string;
          };
          work_phone_number?: { country_code?: string; number?: string };
        };
        challenge_preference?: string;
        decoupled_challenge_max_time?: string;
        merchant_info?: {
          acquirer_bin?: string;
          category_code?: string;
          country_code?: string;
          mid?: string;
          name?: string;
          risk_info?: {
            delivery_email?: string;
            delivery_time_frame?: string;
            gift_card_amount?: string;
            gift_card_count?: string;
            gift_card_currency?: string;
            pre_order_date?: string;
            pre_order_purchase?: string;
            reordered_purchase?: string;
            shipping_method?: string;
          };
          url?: string;
        };
        message_extensions?: {
          critical?: string;
          data?: { nullable?: false | true };
          id?: string;
          name?: string;
        }[];
        purchase_info?: {
          amount?: string;
          currency?: string;
          date?: string;
          exponent?: string;
          installment_count?: string;
          recurring_expiration?: string;
          recurring_frequency?: string;
          transaction_type?: string;
        };
        request_decoupled_challenge?: string;
        requestor_info?: {
          amex_requestor_type?: string;
          cb_siret_number?: string;
          discover_client_id?: string;
          discover_requestor_id?: string;
          id?: string;
          name?: string;
          url?: string;
        };
      },
    ) {
      const url = new URL(
        `https://api.basistheory.com/3ds/sessions/${sessionId}/authenticate`,
      );
    
      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