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
15
Merge Requests
15
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
295aff9b
Commit
295aff9b
authored
May 09, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_panel: Factorize and deduplicate the code for payment mode selection
Remove non required code around the topic.
parent
4794734d
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
184 additions
and
79 deletions
+184
-79
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Entity_createPaymentTransaction.py
...kins/slapos_accounting/Entity_createPaymentTransaction.py
+2
-1
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.py
...ortal_skins/slapos_accounting/Person_addDepositPayment.py
+6
-7
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.xml
...rtal_skins/slapos_accounting/Person_addDepositPayment.xml
+1
-1
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5AccountingScenario.py
..._components/test.erp5.testSlapOSERP5AccountingScenario.py
+3
-3
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
...omponents/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+1
-1
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5CRMScenario.py
.../portal_components/test.erp5.testSlapOSERP5CRMScenario.py
+2
-2
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
...mponents/test.erp5.testSlapOSERP5VirtualMasterScenario.py
+3
-3
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
...e_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
+1
-1
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Base_getPaymentModeForCurrency.py
...rtal_skins/slapos_panel/Base_getPaymentModeForCurrency.py
+16
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Base_getPaymentModeForCurrency.xml
...tal_skins/slapos_panel/Base_getPaymentModeForCurrency.xml
+62
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
...createExternalPaymentTransactionFromDepositAndRedirect.py
+13
-30
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.xml
...reateExternalPaymentTransactionFromDepositAndRedirect.xml
+1
-1
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_getVADSUrlDict.py
...l_skins/slapos_panel/PaymentTransaction_getVADSUrlDict.py
+0
-5
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_getVADSUrlDict.xml
..._skins/slapos_panel/PaymentTransaction_getVADSUrlDict.xml
+1
-1
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_redirectToManualPayment.py
...lapos_panel/PaymentTransaction_redirectToManualPayment.py
+6
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_redirectToManualPayment.xml
...apos_panel/PaymentTransaction_redirectToManualPayment.xml
+62
-0
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect.py
..._createExternalPaymentTransactionFromAmountAndRedirect.py
+4
-23
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Entity_createPaymentTransaction.py
View file @
295aff9b
...
@@ -90,7 +90,8 @@ for index, line in enumerate(invoice_list):
...
@@ -90,7 +90,8 @@ for index, line in enumerate(invoice_list):
activate_kw
=
activate_kw
,
activate_kw
=
activate_kw
,
)
)
assert
len
(
payment_transaction
.
checkConsistency
())
==
0
if
len
(
payment_transaction
.
checkConsistency
())
!=
0
:
raise
AssertionError
(
payment_transaction
.
checkConsistency
()[
0
])
payment_transaction
.
start
()
payment_transaction
.
start
()
...
...
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.py
View file @
295aff9b
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Products.ERP5Type.Message
import
translateString
from
Products.ERP5Type.Message
import
translateString
...
@@ -11,7 +15,6 @@ source_section = context
...
@@ -11,7 +15,6 @@ source_section = context
now
=
DateTime
()
now
=
DateTime
()
module
=
portal
.
portal_trash
module
=
portal
.
portal_trash
tmp_sale_order
=
module
.
newContent
(
tmp_sale_order
=
module
.
newContent
(
portal_type
=
'Sale Order'
,
portal_type
=
'Sale Order'
,
temp_object
=
True
,
temp_object
=
True
,
...
@@ -36,7 +39,6 @@ if (tmp_sale_order.getSourceSection(None) == tmp_sale_order.getDestinationSectio
...
@@ -36,7 +39,6 @@ if (tmp_sale_order.getSourceSection(None) == tmp_sale_order.getDestinationSectio
(
tmp_sale_order
.
getSourceSection
(
None
)
is
None
):
(
tmp_sale_order
.
getSourceSection
(
None
)
is
None
):
raise
AssertionError
(
'The trade condition does not generate accounting: %s'
%
tmp_sale_order
.
getSpecialise
())
raise
AssertionError
(
'The trade condition does not generate accounting: %s'
%
tmp_sale_order
.
getSpecialise
())
#######################################################
#######################################################
payment_transaction
=
portal
.
accounting_module
.
newContent
(
payment_transaction
=
portal
.
accounting_module
.
newContent
(
title
=
"reservation payment"
,
title
=
"reservation payment"
,
...
@@ -53,7 +55,7 @@ payment_transaction = portal.accounting_module.newContent(
...
@@ -53,7 +55,7 @@ payment_transaction = portal.accounting_module.newContent(
destination_section
=
tmp_sale_order
.
getDestinationSection
(),
destination_section
=
tmp_sale_order
.
getDestinationSection
(),
destination_decision
=
tmp_sale_order
.
getDestinationDecision
(),
destination_decision
=
tmp_sale_order
.
getDestinationDecision
(),
destination_project
=
tmp_sale_order
.
getDestinationProject
(),
destination_project
=
tmp_sale_order
.
getDestinationProject
(),
payment_mode
=
payment_mode
,
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
resource
=
tmp_sale_order
.
getPriceCurrency
(),
resource
=
tmp_sale_order
.
getPriceCurrency
(),
created_by_builder
=
1
,
# XXX this prevent init script from creating lines.
created_by_builder
=
1
,
# XXX this prevent init script from creating lines.
...
@@ -84,9 +86,6 @@ payment_transaction.newContent(
...
@@ -84,9 +86,6 @@ payment_transaction.newContent(
if
len
(
payment_transaction
.
checkConsistency
())
!=
0
:
if
len
(
payment_transaction
.
checkConsistency
())
!=
0
:
raise
AssertionError
(
payment_transaction
.
checkConsistency
()[
0
])
raise
AssertionError
(
payment_transaction
.
checkConsistency
()[
0
])
#tag = '%s_update' % context.getDestinationReference()
payment_transaction
.
start
(
comment
=
translateString
(
"Deposit payment."
))
comment
=
translateString
(
"Deposit payment."
)
payment_transaction
.
start
(
comment
=
comment
)
return
payment_transaction
return
payment_transaction
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.xml
View file @
295aff9b
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
price, currency_relative_url,
batch=0
</string>
</value>
<value>
<string>
price, currency_relative_url,
payment_mode=None, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5AccountingScenario.py
View file @
295aff9b
...
@@ -34,7 +34,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -34,7 +34,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"submitted"
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"submitted"
)
with
PinnedDateTime
(
self
,
DateTime
(
'2021/04/04'
)):
with
PinnedDateTime
(
self
,
DateTime
(
'2021/04/04'
)):
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
10
,
currency
.
getRelativeUrl
()
,
1
)
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
10
,
currency
.
getRelativeUrl
())
# payzen interface will only stop the payment
# payzen interface will only stop the payment
payment_transaction
.
stop
()
payment_transaction
.
stop
()
self
.
tic
()
self
.
tic
()
...
@@ -209,7 +209,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -209,7 +209,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
# Add deposit
# Add deposit
with
PinnedDateTime
(
self
,
creation_date
+
2
):
with
PinnedDateTime
(
self
,
creation_date
+
2
):
for
person
in
person_list
:
for
person
in
person_list
:
payment_transaction
=
person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
()
,
1
)
payment_transaction
=
person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
())
# payzen interface will only stop the payment
# payzen interface will only stop the payment
payment_transaction
.
stop
()
payment_transaction
.
stop
()
...
@@ -311,7 +311,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -311,7 +311,7 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
##################################################
##################################################
# Add deposit (0.1 to prevent discount generation)
# Add deposit (0.1 to prevent discount generation)
with
PinnedDateTime
(
self
,
creation_date
+
0.1
):
with
PinnedDateTime
(
self
,
creation_date
+
0.1
):
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
()
,
1
)
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
())
# payzen interface will only stop the payment
# payzen interface will only stop the payment
payment_transaction
.
stop
()
payment_transaction
.
stop
()
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
View file @
295aff9b
...
@@ -682,7 +682,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
...
@@ -682,7 +682,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
payment_transaction
=
person
.
Person_restrictMethodAsShadowUser
(
payment_transaction
=
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
shadow_document
=
person
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
person
,
deposit_amount
,
currency
.
getRelativeUrl
()
,
1
])
argument_list
=
[
person
,
deposit_amount
,
currency
.
getRelativeUrl
()])
self
.
tic
()
self
.
tic
()
self
.
logout
()
self
.
logout
()
self
.
login
()
self
.
login
()
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5CRMScenario.py
View file @
295aff9b
...
@@ -56,7 +56,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -56,7 +56,7 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
##################################################
##################################################
# Add deposit
# Add deposit
with
PinnedDateTime
(
self
,
creation_date
):
with
PinnedDateTime
(
self
,
creation_date
):
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
()
,
1
)
payment_transaction
=
owner_person
.
Person_addDepositPayment
(
99
*
100
,
currency
.
getRelativeUrl
())
# payzen interface will only stop the payment
# payzen interface will only stop the payment
payment_transaction
.
stop
()
payment_transaction
.
stop
()
...
@@ -176,4 +176,4 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -176,4 +176,4 @@ class TestSlapOSCRMScenario(TestSlapOSVirtualMasterScenarioMixin):
with
PinnedDateTime
(
self
,
creation_date
+
5
):
with
PinnedDateTime
(
self
,
creation_date
+
5
):
self
.
checkERP5StateBeforeExit
()
self
.
checkERP5StateBeforeExit
()
\ No newline at end of file
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5VirtualMasterScenario.py
View file @
295aff9b
...
@@ -485,7 +485,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -485,7 +485,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
payment_transaction
=
owner_person
.
Person_restrictMethodAsShadowUser
(
payment_transaction
=
owner_person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
owner_person
,
shadow_document
=
owner_person
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
owner_person
,
total_price
,
currency
.
getRelativeUrl
()
,
1
])
argument_list
=
[
owner_person
,
total_price
,
currency
.
getRelativeUrl
()])
self
.
tic
()
self
.
tic
()
self
.
logout
()
self
.
logout
()
self
.
login
()
self
.
login
()
...
@@ -561,7 +561,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -561,7 +561,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self
.
login
()
self
.
login
()
project
=
self
.
portal
.
restrictedTraverse
(
project_relative_url
)
project
=
self
.
portal
.
restrictedTraverse
(
project_relative_url
)
payment_transaction
=
customer_section_organisation
.
Person_addDepositPayment
(
99
*
10
,
currency
.
getRelativeUrl
()
,
1
)
payment_transaction
=
customer_section_organisation
.
Person_addDepositPayment
(
99
*
10
,
currency
.
getRelativeUrl
())
# payzen interface will only stop the payment
# payzen interface will only stop the payment
payment_transaction
.
stop
()
payment_transaction
.
stop
()
self
.
tic
()
self
.
tic
()
...
@@ -869,7 +869,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
...
@@ -869,7 +869,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
payment_transaction
=
project_owner_person
.
Person_restrictMethodAsShadowUser
(
payment_transaction
=
project_owner_person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
project_owner_person
,
shadow_document
=
project_owner_person
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
project_owner_person
,
deposit_amount
,
currency
.
getRelativeUrl
()
,
1
])
argument_list
=
[
project_owner_person
,
deposit_amount
,
currency
.
getRelativeUrl
()])
self
.
tic
()
self
.
tic
()
self
.
logout
()
self
.
logout
()
self
.
login
()
self
.
login
()
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
View file @
295aff9b
...
@@ -20,7 +20,7 @@ for currency_value, secure_service_relative_url in [
...
@@ -20,7 +20,7 @@ for currency_value, secure_service_relative_url in [
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
]:
]:
currency_uid
=
currency_value
.
get
Currency
Uid
()
currency_uid
=
currency_value
.
getUid
()
if
secure_service_relative_url
is
not
None
:
if
secure_service_relative_url
is
not
None
:
# Existing invoices
# Existing invoices
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Base_getPaymentModeForCurrency.py
0 → 100644
View file @
295aff9b
""" XXX This script expects some re-implementation to
rely on panel configuration for handle payment.
"""
portal
=
context
.
getPortalObject
()
payment_mode
=
None
for
accepted_currency_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
(
currency_uid
==
accepted_currency_uid
):
payment_mode
=
accepted_payment_mode
return
payment_mode
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Base_getPaymentModeForCurrency.xml
0 → 100644
View file @
295aff9b
<?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_uid
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_getPaymentModeForCurrency
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
View file @
295aff9b
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
web_site
=
context
.
getWebSiteValue
()
currency_value
=
None
if
currency_reference
:
if
currency_reference
is
not
None
:
currency_value
=
portal
.
portal_catalog
.
getResultValue
(
currency_value
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Currency"
,
portal_type
=
"Currency"
,
reference
=
currency_reference
,
reference
=
currency_reference
,
validation_state
=
"validated"
)
validation_state
=
"validated"
)
if
currency_value
is
None
:
if
currency_value
is
None
:
raise
ValueError
(
"Unknown Currency: %s"
%
currency_reference
)
raise
ValueError
(
"Unknown Currency: %s"
%
currency_reference
)
currency_uid
=
currency_value
.
getUid
()
payment_mode
=
context
.
Base_getPaymentModeForCurrency
(
currency_value
.
getUid
())
assert
payment_mode
is
not
None
assert
web_site
is
not
None
deposit_price
=
context
.
Entity_getOutstandingDepositAmount
(
currency_
uid
)
deposit_price
=
context
.
Entity_getOutstandingDepositAmount
(
currency_
value
.
getUid
()
)
if
0
>=
deposit_price
:
if
0
>=
deposit_price
:
raise
ValueError
(
"Nothing to pay"
)
raise
ValueError
(
"Nothing to pay"
)
payment_mode
=
None
def
wrapWithShadow
(
entity
,
total_amount
,
currency_value
,
payment_mode
):
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
(
return
entity
.
Person_addDepositPayment
(
total_amount
,
total_amount
,
currency_value
.
getRelativeUrl
(),
currency_value
.
getRelativeUrl
(),
batch
=
1
payment_mode
=
payment_mode
)
)
payment_transaction
=
context
.
Person_restrictMethodAsShadowUser
(
payment_transaction
=
context
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
context
,
shadow_document
=
context
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
context
,
deposit_price
,
currency_value
])
argument_list
=
[
context
,
deposit_price
,
currency_value
,
payment_mode
])
if
(
payment_mode
==
"wechat"
):
web_site
=
context
.
getWebSiteValue
()
return
payment_transaction
.
PaymentTransaction_redirectToManualWechatPayment
(
web_site
=
web_site
)
assert
web_site
is
not
None
elif
(
payment_mode
==
"payzen"
):
return
payment_transaction
.
PaymentTransaction_redirectToManualPayment
(
web_site
=
web_site
)
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
View file @
295aff9b
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
currency_reference
=None
</string>
</value>
<value>
<string>
currency_reference
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_getVADSUrlDict.py
View file @
295aff9b
""" Return a dict with vads_urls required for payzen."""
""" Return a dict with vads_urls required for payzen."""
if
web_site
is
None
:
web_site
=
context
.
getWebSiteValue
()
if
web_site
is
None
:
raise
ValueError
(
"This script must be called from a web site"
)
base
=
"%(payment_transaction_url)s/PaymentTransaction_triggerPaymentCheckAlarmAndRedirectToPanel?result=%(result)s"
base
=
"%(payment_transaction_url)s/PaymentTransaction_triggerPaymentCheckAlarmAndRedirectToPanel?result=%(result)s"
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_getVADSUrlDict.xml
View file @
295aff9b
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
web_site
</string>
</value>
<value>
<string></string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_redirectToManualPayment.py
0 → 100644
View file @
295aff9b
if
(
context
.
getPaymentMode
()
==
"wechat"
):
return
context
.
PaymentTransaction_redirectToManualWechatPayment
(
web_site
=
web_site
)
elif
(
context
.
getPaymentMode
()
==
"payzen"
):
return
context
.
PaymentTransaction_redirectToManualPayzenPayment
()
else
:
raise
NotImplementedError
(
'not implemented'
)
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/PaymentTransaction_redirectToManualPayment.xml
0 → 100644
View file @
295aff9b
<?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>
web_site=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
PaymentTransaction_redirectToManualPayment
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect.py
View file @
295aff9b
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
from
DateTime
import
DateTime
date
=
DateTime
()
entity
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
entity
=
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
outstanding_amount
=
context
outstanding_amount
=
context
...
@@ -11,17 +9,10 @@ assert web_site is not None
...
@@ -11,17 +9,10 @@ assert web_site is not None
assert
outstanding_amount
.
getLedgerUid
()
==
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
assert
outstanding_amount
.
getLedgerUid
()
==
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
assert
outstanding_amount
.
getDestinationSectionUid
()
==
entity
.
getUid
()
assert
outstanding_amount
.
getDestinationSectionUid
()
==
entity
.
getUid
()
payment_mode
=
None
payment_mode
=
outstanding_amount
.
Base_getPaymentModeForCurrency
(
outstanding_amount
.
getPriceCurrencyUid
())
resource_uid
=
outstanding_amount
.
getPriceCurrencyUid
()
for
accepted_resource_uid
,
accepted_payment_mode
,
is_activated
in
[
(
portal
.
currency_module
.
EUR
.
getUid
(),
'payzen'
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
]:
if
is_activated
and
(
resource_uid
==
accepted_resource_uid
):
payment_mode
=
accepted_payment_mode
assert
payment_mode
is
not
None
assert
payment_mode
is
not
None
def
wrapWithShadow
(
entity
,
outstanding_amount
):
def
wrapWithShadow
(
entity
,
outstanding_amount
,
payment_mode
):
return
entity
.
Entity_createPaymentTransaction
(
return
entity
.
Entity_createPaymentTransaction
(
entity
.
Entity_getOutstandingAmountList
(
entity
.
Entity_getOutstandingAmountList
(
section_uid
=
outstanding_amount
.
getSourceSectionUid
(),
section_uid
=
outstanding_amount
.
getSourceSectionUid
(),
...
@@ -29,22 +20,12 @@ def wrapWithShadow(entity, outstanding_amount):
...
@@ -29,22 +20,12 @@ def wrapWithShadow(entity, outstanding_amount):
ledger_uid
=
outstanding_amount
.
getLedgerUid
(),
ledger_uid
=
outstanding_amount
.
getLedgerUid
(),
group_by_node
=
False
group_by_node
=
False
),
),
start_date
=
date
,
payment_mode
=
payment_mode
payment_mode
=
payment_mode
)
)
entity
=
outstanding_amount
.
getDestinationSectionValue
(
portal_type
=
"Person"
)
payment_transaction
=
entity
.
Person_restrictMethodAsShadowUser
(
payment_transaction
=
entity
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
entity
,
shadow_document
=
entity
,
callable_object
=
wrapWithShadow
,
callable_object
=
wrapWithShadow
,
argument_list
=
[
entity
,
outstanding_amount
])
argument_list
=
[
entity
,
outstanding_amount
,
payment_mode
])
web_site
=
context
.
getWebSiteValue
()
if
(
payment_mode
==
"wechat"
):
return
payment_transaction
.
PaymentTransaction_redirectToManualPayment
(
web_site
=
web_site
)
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'
)
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