Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
9dddb882
Commit
9dddb882
authored
Aug 29, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Stop Payments for Free Reservations automatically
parent
0b8e17fc
Pipeline
#11270
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
..._request/SubscriptionRequest_requestPaymentTransaction.py
+6
-1
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
...al_components/test.erp5.testSlapOSSubscriptionScenario.py
+18
-1
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_requestPaymentTransaction.py
View file @
9dddb882
...
@@ -24,6 +24,7 @@ if current_invoice is None:
...
@@ -24,6 +24,7 @@ if current_invoice is None:
)
)
if
context
.
SubscriptionRequest_testSkippedReservationFree
(
contract
):
if
context
.
SubscriptionRequest_testSkippedReservationFree
(
contract
):
# Reservation is Free
amount
=
0
amount
=
0
for
line
in
current_payment
.
contentValues
():
for
line
in
current_payment
.
contentValues
():
...
@@ -35,7 +36,11 @@ if current_invoice is None:
...
@@ -35,7 +36,11 @@ if current_invoice is None:
comment
=
"Validation payment for subscription request %s"
%
context
.
getRelativeUrl
()
comment
=
"Validation payment for subscription request %s"
%
context
.
getRelativeUrl
()
current_payment
.
confirm
(
comment
=
comment
)
current_payment
.
confirm
(
comment
=
comment
)
current_payment
.
start
(
comment
=
comment
)
current_payment
.
start
(
comment
=
comment
)
current_payment
.
PaymentTransaction_updateStatus
()
if
not
amount
:
current_payment
.
stop
(
comment
=
"%s (Free)"
%
comment
)
elif
target_language
!=
"zh"
:
# Payzen don't require update like this.
current_payment
.
PaymentTransaction_updateStatus
()
current_payment
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
current_payment
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
context
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
View file @
9dddb882
...
@@ -320,6 +320,18 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -320,6 +320,18 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
}
}
payment
.
PaymentTransaction_createPayzenEvent
().
PayzenEvent_processUpdate
(
data_kw
,
True
)
payment
.
PaymentTransaction_createPayzenEvent
().
PayzenEvent_processUpdate
(
data_kw
,
True
)
def
_checkFreeReservationPayment
(
self
,
subscription_request
):
quantity
=
subscription_request
.
getQuantity
()
# Check Payment
payment
=
self
.
_getRelatedPaymentValue
(
subscription_request
)
self
.
assertEqual
(
self
.
expected_price_currency
,
payment
.
getPriceCurrency
())
self
.
assertEqual
(
-
self
.
expected_reservation_fee
*
quantity
,
payment
.
PaymentTransaction_getTotalPayablePrice
())
self
.
assertEqual
(
payment
.
getSimulationState
(),
"stopped"
)
return
payment
def
_payPayment
(
self
,
subscription_request
):
def
_payPayment
(
self
,
subscription_request
):
quantity
=
subscription_request
.
getQuantity
()
quantity
=
subscription_request
.
getQuantity
()
# Check Payment
# Check Payment
...
@@ -353,8 +365,13 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -353,8 +365,13 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
assertEqual
(
invoice
.
getSource
(),
self
.
expected_source
)
self
.
assertEqual
(
invoice
.
getSource
(),
self
.
expected_source
)
self
.
assertEqual
(
invoice
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
invoice
.
getSourceSection
(),
self
.
expected_source_section
)
# Pay Invoice if it is not Free
if
not
self
.
expected_free_reservation
:
payment
=
self
.
_payPayment
(
subscription_request
)
else
:
payment
=
self
.
_checkFreeReservationPayment
(
subscription_request
)
# Check Payment
# Check Payment
payment
=
self
.
_payPayment
(
subscription_request
)
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment