Edits history of script submission #2500 for ' Post identity verification sessions (stripe)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Stripe = {
      token: string;
    };
    /**
     * Post identity verification sessions
     * Creates a VerificationSession object.
    
    After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session’s url.
    
    If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.
    
    Related guide: Verify your users’ identity documents
     */
    export async function main(
      auth: Stripe,
      body: {
        client_reference_id?: string;
        expand?: string[];
        metadata?: { [k: string]: string };
        options?: {
          document?:
            | {
                allowed_types?: ("driving_license" | "id_card" | "passport")[];
                require_id_number?: boolean;
                require_live_capture?: boolean;
                require_matching_selfie?: boolean;
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        return_url?: string;
        type: "document" | "id_number";
      }
    ) {
      const url = new URL(
        `https://api.stripe.com/v1/identity/verification_sessions`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          Authorization: "Bearer " + auth.token,
        },
        body: encodeParams(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    
    function encodeParams(o: any) {
      function iter(o: any, path: string) {
        if (Array.isArray(o)) {
          o.forEach(function (a) {
            iter(a, path + "[]");
          });
          return;
        }
        if (o !== null && typeof o === "object") {
          Object.keys(o).forEach(function (k) {
            iter(o[k], path + "[" + k + "]");
          });
          return;
        }
        data.push(path + "=" + o);
      }
      const data: string[] = [];
      Object.keys(o).forEach(function (k) {
        if (o[k] !== undefined) {
          iter(o[k], k);
        }
      });
      return new URLSearchParams(data.join("&"));
    }
    

    Submitted by hugo697 368 days ago

  • nativets
    type Stripe = {
      token: string;
    };
    /**
     * Post identity verification sessions
     * Creates a VerificationSession object.
    
    After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session’s url.
    
    If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.
    
    Related guide: Verify your users’ identity documents
     */
    export async function main(
      auth: Stripe,
      body: {
        client_reference_id?: string;
        expand?: string[];
        metadata?: { [k: string]: string };
        options?: {
          document?:
            | {
                allowed_types?: ("driving_license" | "id_card" | "passport")[];
                require_id_number?: boolean;
                require_live_capture?: boolean;
                require_matching_selfie?: boolean;
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        return_url?: string;
        type: "document" | "id_number";
      }
    ) {
      const url = new URL(
        `https://api.stripe.com/v1/identity/verification_sessions`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          Authorization: "Bearer " + auth.token,
        },
        body: encodeParams(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    
    function encodeParams(o: any) {
      function iter(o: any, path: string) {
        if (Array.isArray(o)) {
          o.forEach(function (a) {
            iter(a, path + "[]");
          });
          return;
        }
        if (o !== null && typeof o === "object") {
          Object.keys(o).forEach(function (k) {
            iter(o[k], path + "[" + k + "]");
          });
          return;
        }
        data.push(path + "=" + o);
      }
      const data: string[] = [];
      Object.keys(o).forEach(function (k) {
        if (o[k] !== undefined) {
          iter(o[k], k);
        }
      });
      return new URLSearchParams(data.join("&"));
    }
    

    Submitted by hugo697 795 days ago

  • nativets
    type Stripe = {
      token: string;
    };
    /**
     * Post identity verification sessions
     * <p>Creates a VerificationSession object.</p>
    
    <p>After the VerificationSession is created, display a verification modal using the session <code>client_secret</code> or send your users to the session’s <code>url</code>.</p>
    
    <p>If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.</p>
    
    <p>Related guide: <a href="/docs/identity/verify-identity-documents">Verify your users’ identity documents</a></p>
     */
    export async function main(
      auth: Stripe,
      body: {
        expand?: string[];
        metadata?: { [k: string]: string };
        options?: {
          document?:
            | {
                allowed_types?: ("driving_license" | "id_card" | "passport")[];
                require_id_number?: boolean;
                require_live_capture?: boolean;
                require_matching_selfie?: boolean;
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        return_url?: string;
        type: "document" | "id_number";
      }
    ) {
      const url = new URL(
        `https://api.stripe.com/v1/identity/verification_sessions`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
          Authorization: "Bearer " + auth.token,
        },
        body: encodeParams(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    
    function encodeParams(o: any) {
      function iter(o: any, path: string) {
        if (Array.isArray(o)) {
          o.forEach(function (a) {
            iter(a, path + "[]");
          });
          return;
        }
        if (o !== null && typeof o === "object") {
          Object.keys(o).forEach(function (k) {
            iter(o[k], path + "[" + k + "]");
          });
          return;
        }
        data.push(path + "=" + o);
      }
      const data: string[] = [];
      Object.keys(o).forEach(function (k) {
        if (o[k] !== undefined) {
          iter(o[k], k);
        }
      });
      return new URLSearchParams(data.join("&"));
    }
    

    Submitted by hugo697 922 days ago