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

Finished release 0.15.

parents a6ec1791 0634b52a
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages ...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="stripe-checkout", name="stripe-checkout",
version="0.14", version="0.15",
author="GEANT", author="GEANT",
author_email="swd@geant.org", author_email="swd@geant.org",
description="Stripe custom checkout support service", description="Stripe custom checkout support service",
......
...@@ -16,7 +16,7 @@ VALID_EVENTS = [ ...@@ -16,7 +16,7 @@ VALID_EVENTS = [
PAYMENT_INTENT_CANCELED, PAYMENT_INTENT_CANCELED,
] ]
RAISE_EXCEPTIONS = True RAISE_EXCEPTIONS = False
UNPROCESSED_PAYMENT_EMAIL_TEMPLATE = """\ UNPROCESSED_PAYMENT_EMAIL_TEMPLATE = """\
A payment was made in Stripe that could not be linked to a Visitor. Please process this A payment was made in Stripe that could not be linked to a Visitor. Please process this
...@@ -43,11 +43,11 @@ class Command(BaseCommand): ...@@ -43,11 +43,11 @@ class Command(BaseCommand):
else: else:
msg = self.style.SUCCESS(f"{prefix} success!") msg = self.style.SUCCESS(f"{prefix} success!")
except Exception: except Exception:
msg = self.style.ERROR(f"{prefix} error!") self.stdout.write(self.style.ERROR(f"{prefix} error!"))
if RAISE_EXCEPTIONS: if RAISE_EXCEPTIONS:
raise raise
traceback.print_exc() traceback.print_exc()
finally: else:
event.handled = True event.handled = True
event.save() event.save()
self.stdout.write(msg) self.stdout.write(msg)
...@@ -77,7 +77,11 @@ class Command(BaseCommand): ...@@ -77,7 +77,11 @@ class Command(BaseCommand):
if order is None: if order is None:
return self._notify_unprocessed_payment(payment_intent) return self._notify_unprocessed_payment(payment_intent)
api = VisitorAPI() api = VisitorAPI()
visitor = api.get_visitor(order.visitor_id) visitor = api.get_visitor_or_none(order.visitor_id)
if visitor is None:
self.stdout.write(self.style.ERROR("Visitor not found!"))
return self._notify_unprocessed_payment(payment_intent)
for item in order.items.all(): for item in order.items.all():
if item.kind == ItemKind.REGISTRATION_TYPE: if item.kind == ItemKind.REGISTRATION_TYPE:
visitor.paid = True visitor.paid = True
...@@ -94,7 +98,12 @@ class Command(BaseCommand): ...@@ -94,7 +98,12 @@ class Command(BaseCommand):
if order is None: if order is None:
return False return False
api = VisitorAPI() api = VisitorAPI()
visitor = api.get_visitor(order.visitor_id) visitor = api.get_visitor_or_none(order.visitor_id)
if visitor is None:
self.stdout.write(
self.style.ERROR("Visitor not found! Not processing cancellation")
)
return
visitor.canceled = True visitor.canceled = True
api.update_visitor(visitor) api.update_visitor(visitor)
order.canceled = True order.canceled = True
......
...@@ -76,6 +76,14 @@ class VisitorAPI: ...@@ -76,6 +76,14 @@ class VisitorAPI:
raise Http404() raise Http404()
return Visitor.from_api(result) return Visitor.from_api(result)
def get_visitor_or_none(
self, visitor_id: str, allow_deleted=False
) -> Optional[Visitor]:
try:
return self.get_visitor(visitor_id, allow_deleted)
except Http404:
return None
def update_visitor( def update_visitor(
self, visitor: Union[str, Visitor], payload: Optional[dict] = None self, visitor: Union[str, Visitor], payload: Optional[dict] = None
): ):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment