Last active
November 19, 2015 01:34
-
-
Save mgcon/67e70af92b7e044bea18 to your computer and use it in GitHub Desktop.
a small script to quickly report all transactions that made up a Stripe transfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import stripe | |
import decimal | |
import datetime | |
stripe.api_key ='yourStripeKey' | |
def runBalance(): | |
# change limit to suit taste | |
bal = stripe.BalanceTransaction.all(limit=30) | |
for b in bal.data: | |
transactionId = b.source | |
onDate = datetime.datetime.fromtimestamp(int(b.created)).strftime('%d-%b-%y') | |
details = stripe.BalanceTransaction.all(source=transactionId) | |
for d in details.data: | |
amount = decimal.Decimal(d.amount) / 100 | |
fee = decimal.Decimal(d.fee) / 100 | |
if d.type == "charge": | |
chargeDetail = stripe.Charge.retrieve(d.source) | |
# do not forget, we also have a chargeDetail.metadata values available for use | |
# along with all the other values available. | |
print "\t\t(%s) Charged - $%s - (fee of $%s) \n\t\tFrom: %s \n\t\tDescription: %s" % (onDate, amount, fee, chargeDetail.receipt_email, chargeDetail.description) | |
else: | |
print "(%s) Bank Deposit - $%s" % (onDate, amount) | |
print "\n" | |
if __name__ == "__main__": | |
runBalance() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment