Create a Refund  (stripe)
One script reply has been approved by the moderators

1 points by rossmccrann 41 days ago | 19 uses

Creating a new refund will refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged. You can optionally refund only part of a charge. You can do so multiple times, until the entire charge has been refunded. Once entirely refunded, a charge can't be refunded again. See the docs for more information

One script reply has been approved by the moderators
This version of script #125 was approved by the moderators as the one that fits the best the script ask: 'Create a Refund'. It is safe to use in your flows in production.
0 points
by rossmccrann 41 days ago
edit by rossmccrann 41 days ago
import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
import Stripe from "https://esm.sh/stripe?target=deno";

export async function main(
  stripe_con: wmill.Resource<"stripe">,
  charge_id: string,
) {
  const token = stripe_con["token"];
  const stripe = Stripe(
    `${token}`,
    {
      httpClient: Stripe.createFetchHttpClient(),
    },
  );

  const refund = await stripe.refunds.create({
    charge: `${charge_id}`,
  });

  return await refund.json();
}
edit/run in windmill raw embed