new command works needs improvement, fix fixtures file thanks for pointing that out @mightyscollins

This commit is contained in:
Oliver Marks 2017-01-30 22:39:15 +00:00
parent e5c1e15010
commit 5b223d23cd
3 changed files with 20 additions and 17 deletions

View File

@ -16,14 +16,16 @@ class Command(BaseCommand):
self.stdout.write(
self.style.NOTICE(
'== Gocardless customers =='))
'== Gocardless customer payments =='))
Payments.objects.all().delete()
for customer in provider.fetch_customers():
self.stdout.write(str(dir(customer)))
self.stdout.write(str(customer))
Payments.objects.create(
payment_objects = []
for customer in provider.fetch_customers():
# self.stdout.write(str(dir(customer)))
# self.stdout.write(str(customer))
payment_objects.append(Payments(
user=None,
user_reference=customer.get('user_id'),
user_email=customer.get('email'),
@ -31,11 +33,13 @@ class Command(BaseCommand):
amount=customer.get('amount'),
type=Payments.lookup_payment_type(customer.get('payment_type')),
date=customer.get('payment_date')
)
))
# self.stdout.write(str(customer.email))
# self.stdout.write(str(dir(customer['email']())))
# self.stdout.write(
# self.style.SUCCESS(
# '\t{reference} - {payment} - {status} - {email}'.format(**model_to_dict(subscriptions[-1]))))
self.stdout.write(
self.style.SUCCESS(
'\t{reference} - {amount} - {type} - {user_email}'.format(**model_to_dict(payment_objects[-1]))))
Payments.objects.bulk_create(payment_objects)

View File

@ -56,16 +56,16 @@ class gocardless_provider:
merchant = gocardless.client.merchant()
for customer in merchant.bills():
user = customer.user()
print(dir(customer))
print(dir(customer.reference_fields))
print(customer.reference_fields)
print(customer.payout_id)
print(customer.reference_fields.payout_id)
# print(dir(customer))
# print(dir(customer.reference_fields))
# print(customer.reference_fields)
# print(customer.payout_id)
# print(customer.reference_fields.payout_id)
result = {
'user_id': user.id,
'email': user.email,
'status': customer.status,
'payment_id': customer.source_id,
'payment_id': customer.id,
'payment_type': customer.source_type,
'payment_date': customer.created_at,
'amount': customer.amount

View File

@ -1,2 +1 @@
Postgres is up - continuing...
[{"model": "auth.group", "pk": 1, "fields": {"name": "members", "permissions": []}}]
[{"model": "auth.group", "pk": 1, "fields": {"name": "members", "permissions": []}}]