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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos.core
Commits
d11bb206
Commit
d11bb206
authored
May 02, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_panel: Fixup to allow us to pay deposit
parent
acb86e5c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
19 deletions
+121
-19
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
...Item/portal_components/test.erp5.testSlapOSCodingStyle.py
+1
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
...e_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
+7
-19
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
...createExternalPaymentTransactionFromDepositAndRedirect.py
+51
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.xml
...reateExternalPaymentTransactionFromDepositAndRedirect.xml
+62
-0
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSCodingStyle.py
View file @
d11bb206
...
...
@@ -237,6 +237,7 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_panel/ComputerNetwork_getNewsDict'
,
'slapos_panel/ComputerNetwork_invalidateOnSlaposPanel'
,
'slapos_panel/Document_getNewsDict'
,
'slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect'
,
'slapos_panel/Event_getSafeSourceTitle'
,
'slapos_panel/InstanceNode_addSlapOSAllocationSupply'
,
'slapos_panel/InstanceTreeModule_selectRequestProject'
,
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
View file @
d11bb206
...
...
@@ -16,11 +16,11 @@ entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if
entity
is
None
:
return
'<p>Nothing to pay with your account</p>'
for
currency_
uid
,
secure_service_relative_url
in
[
(
portal
.
currency_module
.
EUR
.
getUid
()
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY
.getUid()
, portal.Base_getWechatServiceRelativeUrl())
for
currency_
value
,
secure_service_relative_url
in
[
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
]:
currency_uid
=
currency_value
.
getCurrencyUid
()
if
secure_service_relative_url
is
not
None
:
# Existing invoices
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
...
...
@@ -36,26 +36,14 @@ for currency_uid, secure_service_relative_url in [
'payment_url'
:
'%s/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect'
%
outstanding_amount
.
absolute_url
()
}
# Existing subscription request
deposit_price
=
0
for
sql_subscription_request
in
portal
.
portal_catalog
(
portal_type
=
"Subscription Request"
,
simulation_state
=
'submitted'
,
destination_section__uid
=
entity
.
getUid
(),
price_currency__uid
=
currency_uid
,
ledger__uid
=
ledger_uid
):
subscription_request
=
sql_subscription_request
.
getObject
()
subscription_request_total_price
=
subscription_request
.
getTotalPrice
()
if
0
<
subscription_request_total_price
:
deposit_price
+=
subscription_request_total_price
deposit_price
=
entity
.
Entity_getOutstandingDepositAmount
(
currency_uid
)
if
0
<
deposit_price
:
html_content
+=
"""
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
'total_price'
:
deposit_price
,
'currency'
:
currency_
uid
,
'payment_url'
:
'%s/
SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect'
%
entity
.
absolute_url
(
)
'currency'
:
currency_
value
.
getReference
()
,
'payment_url'
:
'%s/
Entity_createExternalPaymentTransactionFromDepositAndRedirect?currency_reference=%s'
%
(
entity
.
absolute_url
(),
currency_value
.
getReference
()
)
}
if
html_content
:
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
0 → 100644
View file @
d11bb206
portal
=
context
.
getPortalObject
()
web_site
=
context
.
getWebSiteValue
()
if
currency_reference
is
not
None
:
currency_value
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Currency"
,
reference
=
currency_reference
,
validation_state
=
"validated"
)
if
currency_value
is
None
:
raise
ValueError
(
"Unknown Currency: %s"
%
currency_reference
)
currency_uid
=
currency_value
.
getUid
()
assert
web_site
is
not
None
deposit_price
=
context
.
Entity_getOutstandingDepositAmount
(
currency_uid
)
if
0
>=
deposit_price
:
raise
ValueError
(
"Nothing to pay"
)
payment_mode
=
None
resource_uid
=
currency_uid
for
accepted_resource_uid
,
accepted_payment_mode
,
is_activated
in
[
(
portal
.
currency_module
.
EUR
.
getUid
(),
'payzen'
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY, 'wechat', portal.Base_getWechatServiceRelativeUrl())
]:
if
is_activated
and
(
resource_uid
==
accepted_resource_uid
):
payment_mode
=
accepted_payment_mode
assert
payment_mode
is
not
None
def
wrapWithShadow
(
entity
,
total_amount
,
currency_value
):
return
entity
.
Person_addDepositPayment
(
total_amount
,
currency_value
.
getRelativeUrl
(),
batch
=
1
)
payment_transaction
=
context
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
context
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
context
,
deposit_price
,
currency_value
])
if
(
payment_mode
==
"wechat"
):
return
payment_transaction
.
PaymentTransaction_redirectToManualWechatPayment
(
web_site
=
web_site
)
elif
(
payment_mode
==
"payzen"
):
return
payment_transaction
.
PaymentTransaction_redirectToManualPayzenPayment
(
web_site
=
web_site
)
else
:
raise
NotImplementedError
(
'not implemented'
)
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.xml
0 → 100644
View file @
d11bb206
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
currency_reference=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Entity_createExternalPaymentTransactionFromDepositAndRedirect
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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