module/endpoint for handling some common homelike stripe operations
npm install stripetoolsSome common operations we were doing with the stripe module.
How to use
```
npm install --save stripetools
then in your file
``
const stripetools = require('stripetools')('
Params
- resource : the name of the stripe resource you want to call. Eg 'charges' or 'applicationFees'
- startDate (format 'YYYY-MM-DD) the earliest date the results should be from
- endDate (format 'YYYY-MM-DD) the lastest date the results should be from
eg find all charges in March:
``
const marchCharges = await stripetools.getBetweenDates({
resource : 'charges',
startDate : '2018-03-01',
endDate : '2018-03-31
})
Params
- collection : the collection to loop through and resolve from
- targetResource : the target resource you want to pull onto this collection
- foreignKey : the field used to look on stripe to find the target resource
- as = targetResource : what field should the results be saved on to (defaults to targetResource name)
eg populate all charges onto applicationFees using orginating_transaction
``
//assume you have an array of applicationFees already
const feesAndCharges = await stripetools.populateStripeResource({
collection : applicationFees,
targetResource : 'charges',
foreignKey : 'originating_charge',
as : 'chargeObject'
})
Params
- chargeId
- amount : amount to refund (defaults to full amount)
- refundApplicationFee : refund the applicationFee (defaults to true)
- reverseTransfer = reverse the associatedTransfer (defaults to true)
eg refund a charge
`
await stripetools.refund('
``
Params
- resource : the resource we want to get
- customLimit : the max number of items we want to return (default is 500)
- stripeArgs = { limit : 100 } number of elements to grab in each step, default and maximum is 100