1
Cancel a Payment Intent
One script reply has been approved by the moderators Verified

Cancel a [payment intent (https://stripe.com/docs/payments/payment-intents). Once canceled, no additional charges will be made by the payment intent and any operations on the payment intent will fail with an error. For payment intents with status=requires_capture, the remaining amount_capturable will automatically be refunded. See the docs for more information.

Created by rossmccrann 852 days ago Viewed 9311 times
0
Submitted by rossmccrann Deno
Verified 852 days ago
1
type Stripe = {
2
  token: string;
3
};
4
export async function main(stripe_con: Stripe, cancel_id: string) {
5
  const STRIPE_CANCEL_PAYOUT_URL = `https://api.stripe.com/v1/payouts/:${cancel_id}/cancel`;
6

7
  const token = stripe_con["token"];
8

9
  const response = await fetch(STRIPE_CANCEL_PAYOUT_URL, {
10
    method: "POST",
11
    headers: {
12
      Authorization: "Bearer " + token,
13
      "Content-Type": "application/json",
14
    },
15
  });
16

17
  return await response.json();
18
}
19