Create a Refund

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](https://stripe.com/docs/api/refunds/create) for more information

Script stripe Verified

by rossmccrann ยท 8/23/2022

The script

Submitted by rossmccrann Deno
Verified 374 days ago
1
import Stripe from "https://esm.sh/stripe?target=deno";
2

3
type Stripe = {
4
  token: string;
5
};
6
export async function main(stripe_con: Stripe, charge_id: string) {
7
  const token = stripe_con["token"];
8
  const stripe = Stripe(`${token}`, {
9
    httpClient: Stripe.createFetchHttpClient(),
10
  });
11

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

16
  return await refund.json();
17
}
18