Edits history of script submission #2467 for ' Post disputes dispute (stripe)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Stripe = {
      token: string;
    };
    /**
     * Post disputes dispute
     * When you get a dispute, contacting your customer is always the best first step. If that doesn’t work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to submit evidence programmatically.
    
    Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our guide to dispute types.
     */
    export async function main(
      auth: Stripe,
      dispute: string,
      body: {
        evidence?: {
          access_activity_log?: string;
          billing_address?: string;
          cancellation_policy?: string;
          cancellation_policy_disclosure?: string;
          cancellation_rebuttal?: string;
          customer_communication?: string;
          customer_email_address?: string;
          customer_name?: string;
          customer_purchase_ip?: string;
          customer_signature?: string;
          duplicate_charge_documentation?: string;
          duplicate_charge_explanation?: string;
          duplicate_charge_id?: string;
          product_description?: string;
          receipt?: string;
          refund_policy?: string;
          refund_policy_disclosure?: string;
          refund_refusal_explanation?: string;
          service_date?: string;
          service_documentation?: string;
          shipping_address?: string;
          shipping_carrier?: string;
          shipping_date?: string;
          shipping_documentation?: string;
          shipping_tracking_number?: string;
          uncategorized_file?: string;
          uncategorized_text?: string;
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string } | "";
        submit?: boolean;
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/disputes/${dispute}`);
    
      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 disputes dispute
     * When you get a dispute, contacting your customer is always the best first step. If that doesn’t work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to submit evidence programmatically.
    
    Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our guide to dispute types.
     */
    export async function main(
      auth: Stripe,
      dispute: string,
      body: {
        evidence?: {
          access_activity_log?: string;
          billing_address?: string;
          cancellation_policy?: string;
          cancellation_policy_disclosure?: string;
          cancellation_rebuttal?: string;
          customer_communication?: string;
          customer_email_address?: string;
          customer_name?: string;
          customer_purchase_ip?: string;
          customer_signature?: string;
          duplicate_charge_documentation?: string;
          duplicate_charge_explanation?: string;
          duplicate_charge_id?: string;
          product_description?: string;
          receipt?: string;
          refund_policy?: string;
          refund_policy_disclosure?: string;
          refund_refusal_explanation?: string;
          service_date?: string;
          service_documentation?: string;
          shipping_address?: string;
          shipping_carrier?: string;
          shipping_date?: string;
          shipping_documentation?: string;
          shipping_tracking_number?: string;
          uncategorized_file?: string;
          uncategorized_text?: string;
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string } | "";
        submit?: boolean;
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/disputes/${dispute}`);
    
      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 disputes dispute
     * <p>When you get a dispute, contacting your customer is always the best first step.
     */
    export async function main(
      auth: Stripe,
      dispute: string,
      body: {
        evidence?: {
          access_activity_log?: string;
          billing_address?: string;
          cancellation_policy?: string;
          cancellation_policy_disclosure?: string;
          cancellation_rebuttal?: string;
          customer_communication?: string;
          customer_email_address?: string;
          customer_name?: string;
          customer_purchase_ip?: string;
          customer_signature?: string;
          duplicate_charge_documentation?: string;
          duplicate_charge_explanation?: string;
          duplicate_charge_id?: string;
          product_description?: string;
          receipt?: string;
          refund_policy?: string;
          refund_policy_disclosure?: string;
          refund_refusal_explanation?: string;
          service_date?: string;
          service_documentation?: string;
          shipping_address?: string;
          shipping_carrier?: string;
          shipping_date?: string;
          shipping_documentation?: string;
          shipping_tracking_number?: string;
          uncategorized_file?: string;
          uncategorized_text?: string;
          [k: string]: unknown;
        };
        expand?: string[];
        metadata?: { [k: string]: string } | "";
        submit?: boolean;
      }
    ) {
      const url = new URL(`https://api.stripe.com/v1/disputes/${dispute}`);
    
      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