Edits history of script submission #12176 for ' Get the complete data associated with a debit/credit card (greip)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Greip = {
      apiKey: string;
    };
    /**
     * Get the complete data associated with a debit/credit card
     * Utilize this module to effortlessly retrieve comprehensive information associated with a debit or credit card.
    
    The API provides details such as card type (debit or credit), scheme (Visa, Mastercard, etc.), brand (gold, platinum, etc.), and bank information.
    
    This data is invaluable for various applications, including verifying customer payment details, detecting fraudulent transactions, and delivering personalized services to enhance user experiences.
     */
    export async function main(
      auth: Greip,
      bin: string,
      format: string | undefined,
      userID: string | undefined,
      mode: string | undefined,
      callback: string | undefined,
    ) {
      const url = new URL(`https://greipapi.com/lookup/bin`);
      for (const [k, v] of [
        ["bin", bin],
        ["format", format],
        ["userID", userID],
        ["mode", mode],
        ["callback", callback],
      ]) {
        if (v !== undefined && v !== "" && k !== undefined) {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago