website/conservancy/supporters/management/commands/export_stripe.py

34 lines
1.2 KiB
Python
Raw Permalink Normal View History

import csv
import sys
from django.core.management.base import BaseCommand
from ...models import SustainerPayment
class Command(BaseCommand):
help = "Closes the specified poll for voting"
def handle(self, *args, **options):
payments = SustainerPayment.objects.select_related('order').order_by('paid_time')
columns = ['order_time', 'payment_time', 'name', 'email', 'amount', 'transaction_id', 'public_ack', 'shirt_size', 'join_list', 'street', 'city', 'state', 'zip_code', 'country']
writer = csv.writer(sys.stdout)
writer.writerow(columns)
for payment in payments:
order = payment.order
writer.writerow([
order.created_time,
payment.paid_time,
order.name,
order.email,
payment.amount,
payment.stripe_payment_intent_ref,
order.acknowledge_publicly,
repr(order.tshirt_size if order.tshirt_size else ''),
order.add_to_mailing_list,
order.street,
order.city,
order.state,
order.zip_code,
order.country,
])