new command works needs improvement, fix fixtures file thanks for pointing that out @mightyscollins
This commit is contained in:
parent
e5c1e15010
commit
5b223d23cd
|
@ -16,14 +16,16 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
self.style.NOTICE(
|
self.style.NOTICE(
|
||||||
'== Gocardless customers =='))
|
'== Gocardless customer payments =='))
|
||||||
|
|
||||||
Payments.objects.all().delete()
|
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=None,
|
||||||
user_reference=customer.get('user_id'),
|
user_reference=customer.get('user_id'),
|
||||||
user_email=customer.get('email'),
|
user_email=customer.get('email'),
|
||||||
|
@ -31,11 +33,13 @@ class Command(BaseCommand):
|
||||||
amount=customer.get('amount'),
|
amount=customer.get('amount'),
|
||||||
type=Payments.lookup_payment_type(customer.get('payment_type')),
|
type=Payments.lookup_payment_type(customer.get('payment_type')),
|
||||||
date=customer.get('payment_date')
|
date=customer.get('payment_date')
|
||||||
)
|
))
|
||||||
# self.stdout.write(str(customer.email))
|
# self.stdout.write(str(customer.email))
|
||||||
# self.stdout.write(str(dir(customer['email']())))
|
# self.stdout.write(str(dir(customer['email']())))
|
||||||
# self.stdout.write(
|
self.stdout.write(
|
||||||
# self.style.SUCCESS(
|
self.style.SUCCESS(
|
||||||
# '\t{reference} - {payment} - {status} - {email}'.format(**model_to_dict(subscriptions[-1]))))
|
'\t{reference} - {amount} - {type} - {user_email}'.format(**model_to_dict(payment_objects[-1]))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Payments.objects.bulk_create(payment_objects)
|
||||||
|
|
|
@ -56,16 +56,16 @@ class gocardless_provider:
|
||||||
merchant = gocardless.client.merchant()
|
merchant = gocardless.client.merchant()
|
||||||
for customer in merchant.bills():
|
for customer in merchant.bills():
|
||||||
user = customer.user()
|
user = customer.user()
|
||||||
print(dir(customer))
|
# print(dir(customer))
|
||||||
print(dir(customer.reference_fields))
|
# print(dir(customer.reference_fields))
|
||||||
print(customer.reference_fields)
|
# print(customer.reference_fields)
|
||||||
print(customer.payout_id)
|
# print(customer.payout_id)
|
||||||
print(customer.reference_fields.payout_id)
|
# print(customer.reference_fields.payout_id)
|
||||||
result = {
|
result = {
|
||||||
'user_id': user.id,
|
'user_id': user.id,
|
||||||
'email': user.email,
|
'email': user.email,
|
||||||
'status': customer.status,
|
'status': customer.status,
|
||||||
'payment_id': customer.source_id,
|
'payment_id': customer.id,
|
||||||
'payment_type': customer.source_type,
|
'payment_type': customer.source_type,
|
||||||
'payment_date': customer.created_at,
|
'payment_date': customer.created_at,
|
||||||
'amount': customer.amount
|
'amount': customer.amount
|
||||||
|
|
|
@ -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": []}}]
|
|
||||||
|
|
Loading…
Reference in New Issue