Cancel a Payment Intent

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

Script stripe Verified

by rossmccrann ยท 8/23/2022

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 days ago
1
//native
2

3
type Stripe = {
4
  token: string;
5
};
6
export async function main(stripe_con: Stripe, cancel_id: string) {
7
  const STRIPE_CANCEL_PAYOUT_URL = `https://api.stripe.com/v1/payouts/:${cancel_id}/cancel`;
8

9
  const token = stripe_con["token"];
10

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

19
  return await response.json();
20
}
21

Other submissions
  • Submitted by rossmccrann Deno
    Created 396 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