Skip to content
Snippets Groups Projects
Commit bfa0f89e authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 0.8.

parents f8d0ea7d 26a6c165
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="stripe-checkout",
version="0.7",
version="0.8",
author="GEANT",
author_email="swd@geant.org",
description="Stripe custom checkout support service",
......
......@@ -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