Edits history of script submission #2537 for ' Post issuing disputes (stripe)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Stripe = {
      token: string;
    };
    /**
     * Post issuing disputes
     * Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to Dispute reasons and evidence for more details about evidence requirements.
     */
    export async function main(
      auth: Stripe,
      body: {
        amount?: number;
        evidence?: {
          canceled?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_policy_provided?: boolean | "";
                cancellation_reason?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          duplicate?:
            | {
                additional_documentation?: string | "";
                card_statement?: string | "";
                cash_receipt?: string | "";
                check_image?: string | "";
                explanation?: string | "";
                original_transaction?: string;
                [k: string]: unknown;
              }
            | "";
          fraudulent?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                [k: string]: unknown;
              }
            | "";
          merchandise_not_as_described?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                return_description?: string | "";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          not_received?:
            | {
                additional_documentation?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          other?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          reason?:
            | "canceled"
            | "duplicate"
            | "fraudulent"
            | "merchandise_not_as_described"
            | "not_received"
            | "other"
            | "service_not_as_described";
          service_not_as_described?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_reason?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string };
        transaction?: string;
        treasury?: { received_debit: string; [k: string]: unknown };
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/issuing/disputes`);
    
      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 issuing disputes
     * Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to Dispute reasons and evidence for more details about evidence requirements.
     */
    export async function main(
      auth: Stripe,
      body: {
        amount?: number;
        evidence?: {
          canceled?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_policy_provided?: boolean | "";
                cancellation_reason?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          duplicate?:
            | {
                additional_documentation?: string | "";
                card_statement?: string | "";
                cash_receipt?: string | "";
                check_image?: string | "";
                explanation?: string | "";
                original_transaction?: string;
                [k: string]: unknown;
              }
            | "";
          fraudulent?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                [k: string]: unknown;
              }
            | "";
          merchandise_not_as_described?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                return_description?: string | "";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          not_received?:
            | {
                additional_documentation?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          other?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          reason?:
            | "canceled"
            | "duplicate"
            | "fraudulent"
            | "merchandise_not_as_described"
            | "not_received"
            | "other"
            | "service_not_as_described";
          service_not_as_described?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_reason?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string };
        transaction?: string;
        treasury?: { received_debit: string; [k: string]: unknown };
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/issuing/disputes`);
    
      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 issuing disputes
     * <p>Creates an Issuing <code>Dispute</code> object. Individual pieces of evidence within the <code>evidence</code> object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to <a href="/docs/issuing/purchases/disputes#dispute-reasons-and-evidence">Dispute reasons and evidence</a> for more details about evidence requirements.</p>
     */
    export async function main(
      auth: Stripe,
      body: {
        amount?: number;
        evidence?: {
          canceled?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_policy_provided?: boolean | "";
                cancellation_reason?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          duplicate?:
            | {
                additional_documentation?: string | "";
                card_statement?: string | "";
                cash_receipt?: string | "";
                check_image?: string | "";
                explanation?: string | "";
                original_transaction?: string;
                [k: string]: unknown;
              }
            | "";
          fraudulent?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                [k: string]: unknown;
              }
            | "";
          merchandise_not_as_described?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                return_description?: string | "";
                return_status?: "" | "merchant_rejected" | "successful";
                returned_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          not_received?:
            | {
                additional_documentation?: string | "";
                expected_at?: number | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          other?:
            | {
                additional_documentation?: string | "";
                explanation?: string | "";
                product_description?: string | "";
                product_type?: "" | "merchandise" | "service";
                [k: string]: unknown;
              }
            | "";
          reason?:
            | "canceled"
            | "duplicate"
            | "fraudulent"
            | "merchandise_not_as_described"
            | "not_received"
            | "other"
            | "service_not_as_described";
          service_not_as_described?:
            | {
                additional_documentation?: string | "";
                canceled_at?: number | "";
                cancellation_reason?: string | "";
                explanation?: string | "";
                received_at?: number | "";
                [k: string]: unknown;
              }
            | "";
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string };
        transaction?: string;
        treasury?: { received_debit: string; [k: string]: unknown };
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/issuing/disputes`);
    
      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