def __init__(self, path): self.path = path self.crm = Civicrm(config.civicrm_db)
def main(): global config, messaging, options, civi parser = OptionParser(usage="usage: %prog [options]") parser.add_option("-c", "--config", dest='configFile', default=["paypal-audit.cfg"], action='append', help='Path to configuration file') parser.add_option("-f", "--auditFile", dest='auditFile', default=None, help='CSV of transaction history') parser.add_option( '-l', "--logFile", dest='logFile', default="audit.log", help='Destination logfile. New messages will be appended.') parser.add_option("-n", "--no-effect", dest='noEffect', default=False, action="store_true", help="Dummy no-effect mode") (options, args) = parser.parse_args() path = options.auditFile if re.search(r'[.]gz$', path): f = gzip.open(path, "rb") else: f = open(path, "rU") infile = csv.DictReader(f) config = SafeConfigParser() config.read(options.configFile) if options.noEffect: log("*** Dummy mode! Not injecting stomp messages ***") messaging = Stomp(config) civi = Civicrm(config.items('Db')) locale.setlocale(locale.LC_NUMERIC, "") # fix spurious whitespace around column header names infile.fieldnames = [name.strip() for name in infile.fieldnames] ignore_types = [ "Authorization", "Cancelled Fee", # currency conversion is an explanation of amounts which appear elsewhere "Currency Conversion", # TODO: handle in IPN "Temporary Hold", # seems to be the cancellation of a temporary hold "Update to Reversal", "Website Payments Pro API Solution", ] audit_dispatch = { "Reversal": handle_refund, "Chargeback Settlement": handle_refund, "Refund": handle_refund, "Subscription Payment Received": handle_payment, "Web Accept Payment Received": handle_payment, "Shopping Cart Payment Received": handle_payment, "Virtual Debt Card Credit Received": handle_payment, "Payment Received": handle_payment, "Update to eCheck Received": handle_payment, } for line in infile: if line['Type'] in ignore_types: log("Ignoring %s of type %s" % (line['Transaction ID'], line['Type'])) continue if line['Type'] in audit_dispatch: audit_dispatch[line['Type']](line) else: handle_unknown(line)
def __init__(self, path): self.path = path self.crm = Civicrm(config.civicrm_db) self.pending_data = None self.pending_supplemental_data = None