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
26a6c165
Commit
26a6c165
authored
6 months ago
by
Pelle Koster
Browse files
Options
Downloads
Patches
Plain Diff
read organization from visit company field
parent
f7e0cc96
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
stripe_checkout/stripe_checkout/visit.py
+10
-0
10 additions, 0 deletions
stripe_checkout/stripe_checkout/visit.py
test/test_stripe.py
+14
-2
14 additions, 2 deletions
test/test_stripe.py
with
24 additions
and
2 deletions
stripe_checkout/stripe_checkout/visit.py
+
10
−
0
View file @
26a6c165
...
...
@@ -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
"
]
...
...
This diff is collapsed.
Click to expand it.
test/test_stripe.py
+
14
−
2
View file @
26a6c165
...
...
@@ -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
"
,
}
...
...
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