Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stripe-checkout
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
stripe-checkout
Commits
0634b52a
Commit
0634b52a
authored
2 months ago
by
Pelle Koster
Browse files
Options
Downloads
Patches
Plain Diff
better exception handling
parent
7300318d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stripe_checkout/stripe_checkout/management/commands/processevents.py
+14
-5
14 additions, 5 deletions
...kout/stripe_checkout/management/commands/processevents.py
stripe_checkout/stripe_checkout/visit.py
+8
-0
8 additions, 0 deletions
stripe_checkout/stripe_checkout/visit.py
with
22 additions
and
5 deletions
stripe_checkout/stripe_checkout/management/commands/processevents.py
+
14
−
5
View file @
0634b52a
...
...
@@ -16,7 +16,7 @@ VALID_EVENTS = [
PAYMENT_INTENT_CANCELED
,
]
RAISE_EXCEPTIONS
=
Tru
e
RAISE_EXCEPTIONS
=
Fals
e
UNPROCESSED_PAYMENT_EMAIL_TEMPLATE
=
"""
\
A payment was made in Stripe that could not be linked to a Visitor. Please process this
...
...
@@ -43,11 +43,11 @@ class Command(BaseCommand):
else
:
msg
=
self
.
style
.
SUCCESS
(
f
"
{
prefix
}
success!
"
)
except
Exception
:
msg
=
self
.
style
.
ERROR
(
f
"
{
prefix
}
error!
"
)
self
.
stdout
.
write
(
self
.
style
.
ERROR
(
f
"
{
prefix
}
error!
"
)
)
if
RAISE_EXCEPTIONS
:
raise
traceback
.
print_exc
()
finally
:
else
:
event
.
handled
=
True
event
.
save
()
self
.
stdout
.
write
(
msg
)
...
...
@@ -77,7 +77,11 @@ class Command(BaseCommand):
if
order
is
None
:
return
self
.
_notify_unprocessed_payment
(
payment_intent
)
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
():
if
item
.
kind
==
ItemKind
.
REGISTRATION_TYPE
:
visitor
.
paid
=
True
...
...
@@ -94,7 +98,12 @@ class Command(BaseCommand):
if
order
is
None
:
return
False
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
api
.
update_visitor
(
visitor
)
order
.
canceled
=
True
...
...
This diff is collapsed.
Click to expand it.
stripe_checkout/stripe_checkout/visit.py
+
8
−
0
View file @
0634b52a
...
...
@@ -76,6 +76,14 @@ class VisitorAPI:
raise
Http404
()
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
(
self
,
visitor
:
Union
[
str
,
Visitor
],
payload
:
Optional
[
dict
]
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment