-
Notifications
You must be signed in to change notification settings - Fork 738
Passing Options
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.
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
});
All methods can accept an optional options
object containing one or more of the following:
-
apiKey
- use a different API Key for this particular request; -
idempotencyKey
- make your requests idempotent; -
stripeAccount
- authenticate as a Connected Account; -
apiVersion
- use a specific/different Stripe API Version for this request; -
maxNetworkRetries
- set the maximum amount of network retries for this request; -
timeout
- set the maximum time in ms before the request times out; -
host
- set the hostname for this particular request
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,
});