Пример #1
0
def get_or_create_customer():
    """
    Get or create dwolla customer.
    """
    dw = DwollaApi()
    customer = dw.get_customer_by_email(TEST_EMAIL)
    if customer is not None:
        return customer
    customer = CustomerFactory.get_customer(email=TEST_EMAIL)
    Customer.objects.create_dwolla_customer(customer.id)
    customer.refresh_from_db()
    return dw.get_customer(customer.dwolla_id)
Пример #2
0
 def initiate_dwolla_customer(self, id):
     """
     Get data of created, but not initiated yet customer.
     """
     c = self.model.objects.get(id=id)
     if c.dwolla_id is not None and c.created_at is None\
             and not c.user.is_admin:
         dw = DwollaApi()
         d = dw.get_customer(c.dwolla_id)
         if d is not None:
             assert d['id'] == c.dwolla_id
             c.dwolla_type = d['type']
             c.status = d['status']
             c.created_at = d['created']
             c.save()