Skip to content
Snippets Groups Projects
Commit 26a6c165 authored by Pelle Koster's avatar Pelle Koster
Browse files

read organization from visit company field

parent f7e0cc96
No related branches found
No related tags found
No related merge requests found
......@@ -88,8 +88,18 @@ class Visitor(dict):
return addr
return {}
@property
def company(self):
return self["contact"].get("company", "")
@company.setter
def company(self, value):
self["contact"]["company"] = value
@property
def organization(self):
if company := self.company:
return company
for question in self.get("questions", []):
if question["id"] == VISIT_ORGANIZATION_QUESTION_ID:
answers = question["answers"]
......
......@@ -62,17 +62,29 @@ def test_adds_organization_to_billing_address(create_visitor, mock_stripe):
assert full_result["line1"] == "some_organization"
def test_adds_company_to_billing_address(create_visitor, mock_stripe):
visitor = create_visitor(organization="some_organization")
visitor.company = "some_company"
stripe.Customer.search.return_value = {"data": []}
get_or_create_customer(visitor)
assert stripe.Customer.create.call_count == 1
full_result = stripe.Customer.create.call_args.kwargs["address"]
assert full_result["line1"] == "some_company"
def test_updates_customer_metadata(create_visitor, mock_stripe):
stripe.Customer.search.return_value = {
"data": [{"id": "stripe-cus-id", "metadata": {"key": "value"}}]
}
visitor = create_visitor(organization="some_organization")
visitor = create_visitor()
visitor.company = "some_company"
get_or_create_customer(visitor)
metadata = stripe.Customer.modify.call_args.kwargs["metadata"]
assert metadata == {
"key": "value",
"TNC25": "yes",
"organization": "some_organization",
"organization": "some_company",
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment