'The first stage of payday where we charge credit cards and transfer
money internally between participants.'

def payin(self):

    with self.db.get_cursor() as cursor:
        self.prepare(cursor)
        holds = self.create_card_holds(cursor)
        self.process_payment_instructions(cursor)
        self.process_takes(cursor, self.ts_start)
        self.process_remainder(cursor)
        _payments_for_debugging = cursor.all(u'\n                                                                SELECT    *    FROM    payments    WHERE    "timestamp"    >    %s\n                                                ', (self.ts_start,))
        try:
            self.settle_card_holds(cursor, holds)
            self.update_balances(cursor)
            check_db(cursor)
        except:
            import csv
            from time import time
            with open((u'%s_payments.csv' % time()), u'wb') as f:
                csv.writer(f).writerows(_payments_for_debugging)
            raise
    self.take_over_balances()
