Stripe does not have, by default, an easy way to refund a large number of people. This program is meant to:
- Fetch customers from the database after a specified date.
- Filter customers from this master list, only those which match the preferred refund 'criteria'.
- Convert the customer list into a CSV containing the format: [CUSTOMER EMAIL] [AMOUNT TO REFUND] [CHARGE ID]
- Actually process each refund from the CSV.
I wrote this script for my old company, and it has since been scrubbed for sensitive data. However, I have received persmission from the company to post the script.
This script is a bit manual, but that is mostly intentional. You need to run each part independently which is a safe-guard against accidental refund.
- Replace the API Key in the get_customers.py file with one you desire.
- Add filtering options to the filtering_method of the get_customers.py file
- Run charge_to_list.py to convert to an easier to view CSV
- Open the CSV and ensure all the the refunds are ones to perform, things can go very wrong.
- If everything seems swell, and you are sure, replace the API KEY in the actually_refund.py
- Run actually_refund.py
The API may change, the script may not work, check the scripts work before moving on because it could seriously mess up your bank account.
This has been tested on amounts larger than a million USD so I can't say forsure it works on more than that.