Skip to content

Passing Options

anniel-stripe edited this page May 2, 2023 · 4 revisions

Stripe's Node.js bindings allow you to pass additional options in the form of an object after the required arguments to any given method, and additional parameters for when the method's first argument is a string.

Additional Parameters

The stripe.charges.refund() (documentation) method has a single required argument: the chargeId (ID of the charge that you wish to refund). The simplest way to use this method is to pass the chargeId in as an argument:

stripe.charges.refund(chargeId);

There are additional optional arguments though:

  • amount
  • refund_application_fee

These are passed as an object in the second argument:

stripe.charges.refund(chargeId, {
  amount: 123,
  refund_application_fee: true
});

For methods where all arguments are optional, e.g. the stripe.events.list() method (documentation), you would simply pass them all in via an object as the first argument:

stripe.events.list({
  limit: 20,
  starting_after: 40
});

Options

All methods can accept an optional options object containing one or more of the following:

This options object can be included as the last argument for any method:

// Just the Charge ID and an Idempotency Key:
stripe.charges.refund(chargeId, {
   idempotencyKey: refundIdempotencyKey,
});

// All of the Charge ID, additional parameters, and an Idempotency Key:
stripe.charges.refund(chargeId, {
  amount: 500,
}, {
   stripeAccount: connectedAccountId,
});