Commit f75f72a4 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Rafael Monnerat

slapos_subscription_request: support Wechat payment

parent 11fc37c3
......@@ -258,6 +258,7 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
'erp5_secure_payment',
'erp5_security_uid_innodb_catalog',
'erp5_payzen_secure_payment',
'erp5_wechat_secure_payment',
'erp5_ooo_import',
'erp5_odt_style',
'erp5_ods_style',
......@@ -324,6 +325,7 @@ class TestSlapOSConfigurator(SlapOSTestCaseMixin):
'slapos_crm',
'slapos_accounting',
'slapos_payzen',
'slapos_wechat',
'slapos_web',
'slapos_web_deploy',
'slapos_erp5',
......
......@@ -13,8 +13,10 @@ error_list = []
preference_method_list = [
"getPreferredHateoasUrl",
"getPreferredPayzenPaymentServiceReference",
"getPreferredPayzenIntegrationSite"
"getPreferredPayzenPaymentServiceReference",
"getPreferredPayzenIntegrationSite",
"getPreferredWechatPaymentServiceReference",
"getPreferredWechatIntegrationSite"
]
for method_id in preference_method_list:
......
......@@ -133,6 +133,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_web_redirect_assist
erp5_km
......@@ -210,6 +211,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -248,6 +250,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -325,6 +328,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -363,6 +367,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -439,6 +444,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -474,6 +480,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -552,6 +559,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -588,6 +596,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_km_theme
......@@ -667,6 +676,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -703,6 +713,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_commerce_multiflex_layout
erp5_km
......@@ -780,6 +791,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -815,6 +827,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_web_download_theme
......@@ -892,6 +905,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -928,6 +942,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -1005,6 +1020,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -1040,6 +1056,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -1117,6 +1134,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -1153,6 +1171,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_rss_style
erp5_km
......@@ -1230,6 +1249,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......@@ -1265,6 +1285,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_web_shacache
erp5_km
......@@ -1343,6 +1364,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -1379,6 +1401,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_web_shadir
erp5_km
......@@ -1457,6 +1480,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
erp5_xhtml_style
external_method
......@@ -1495,6 +1519,7 @@ slapos_payzen
slapos_pdm
slapos_simulation
slapos_slap_tool
slapos_wechat
slapos_configurator
erp5_km
erp5_knowledge_pad
......@@ -1571,6 +1596,7 @@ erp5_web_minimal_theme
erp5_web_renderjs
erp5_web_service
erp5_web_widget_library
erp5_wechat_secure_payment
erp5_workflow
external_method
Images
......
......@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>Base_updateAllLocalRoles</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WechatEvent_edit</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setDestinationSection.*</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Wechat Event</string>
</list>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Payment Transaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_payment/organisation_module/slapos/bank_account</string>
<string>source_section/organisation_module/slapos</string>
<string>price_currency/currency_module/CNY</string>
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
<string>resource/currency_module/CNY</string>
<string>payment_mode/wechat</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_destination_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_wechat_pre_payment_template</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Payment Transaction</string> </value>
</item>
<item>
<key> <string>start_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1533254400.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>stop_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1533313457.88</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Reservation</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Accounting Transaction Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/account_module/payable</string>
<string>source/account_module/receivable</string>
</tuple>
</value>
</item>
<item>
<key> <string>grouping_date</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>grouping_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Accounting Transaction Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>0.0</float> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Accounting Transaction Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>destination/account_module/bank</string>
<string>source/account_module/bank</string>
</tuple>
</value>
</item>
<item>
<key> <string>grouping_date</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>grouping_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>2</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Accounting Transaction Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>0.0</float> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Invoice Transaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_section/organisation_module/slapos</string>
<string>payment_mode/payzen</string>
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
<string>price_currency/currency_module/CNY</string>
<string>resource/currency_module/CNY</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_destination_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_wechat_pre_payment_subscription_sale_invoice_transaction</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Invoice Transaction</string> </value>
</item>
<item>
<key> <string>start_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1325376000.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>stop_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1326582000.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>template_wechat_pre_payment_subscription_sale_invoice_transaction</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Invoice Line" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>use/trade/sale</string>
<string>resource/service_module/slapos_reservation_fee</string>
<string>quantity_unit/unit/piece</string>
<string>base_contribution/base_amount/invoicing</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Invoice Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>188.0</float> </value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>stop_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1326585600.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>movement</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -27,12 +27,16 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request.setDefaultEmailText(email)
target_language = context.getPortalObject().Localizer.get_selected_language()
def wrapWithShadow(subscription_request, amount, subscription_reference):
subscription_request.activate(tag="subscription_condition_%s" % subscription_request.getId()
).SubscriptionRequest_applyCondition(subscription_reference)
return subscription_request.SubscriptionRequest_requestPaymentTransaction(amount=amount,
tag="subscription_%s" % subscription_request.getId())
).SubscriptionRequest_applyCondition(subscription_reference, target_language)
return subscription_request.SubscriptionRequest_requestPaymentTransaction(
amount=amount,
tag="subscription_%s" % subscription_request.getId(),
target_language=target_language
)
payment = person.Person_restrictMethodAsShadowUser(
shadow_document=person,
......@@ -42,8 +46,12 @@ payment = person.Person_restrictMethodAsShadowUser(
if batch_mode:
return {'subscription' : subscription_request.getRelativeUrl(), 'payment': payment.getRelativeUrl() }
def wrapRedirectWithShadow(payment_transaction, web_site):
return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site)
if target_language == "zh": # Wechat payment
def wrapRedirectWithShadow(payment_transaction, web_site):
return payment_transaction.PaymentTransaction_redirectToManualWechatPayment(web_site)
else: # Payzen payment
def wrapRedirectWithShadow(payment_transaction, web_site):
return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site)
return person.Person_restrictMethodAsShadowUser(
shadow_document=person,
......
......@@ -2,12 +2,18 @@ from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
# Set AcceptLanguage in the REQUEST so that getDefaultLanguage() can work
if target_language and context.REQUEST.get('AcceptLanguage'):
context.REQUEST['AcceptLanguage'].set(target_language, 10)
if context.getSimulationState() not in ["draft", "planned"]:
# Don't modify it anymore
return
if subscription_condition_reference is not None:
# It would be better use some clever API here.
if target_language == "zh":
subscription_condition_reference += "_zh"
subscription_condition = context.portal_catalog.getResultValue(
portal_type="Subscription Condition",
reference=subscription_condition_reference,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>subscription_condition_reference=None, REQUEST=None</string> </value>
<value> <string>subscription_condition_reference=None, target_language=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -7,7 +7,10 @@ portal = context.getPortalObject()
current_invoice = context.getCausalityValue()
if current_invoice is None:
invoice_template_path = "accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
if target_language == "zh": # Wechat payment
invoice_template_path = "accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction"
else:
invoice_template_path = "accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
invoice_template = portal.restrictedTraverse(invoice_template_path)
current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>amount, tag, payment, REQUEST=None</string> </value>
<value> <string>amount, tag, payment, target_language, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -8,8 +8,12 @@ current_invoice = context.getCausalityValue()
current_payment = None
if current_invoice is None:
payment_template = portal.restrictedTraverse("accounting_module/slapos_pre_payment_template")
if target_language == "zh": # Wechat payment, reservation fee is 188 CNY
payment_template = portal.restrictedTraverse("accounting_module/slapos_wechat_pre_payment_template")
quantity = int(amount) * 188
else: # Payzen payment, reservation fee is 25 EUR
payment_template = portal.restrictedTraverse("accounting_module/slapos_pre_payment_template")
quantity = int(amount) * 25
current_payment = payment_template.Base_createCloneDocument(batch_mode=1)
current_payment.edit(
......@@ -22,8 +26,7 @@ if current_invoice is None:
stop_date=DateTime()
)
# Hardcoded value for reservation
quantity = int(amount)*25
for line in current_payment.contentValues():
if line.getSource() == "account_module/bank":
line.setQuantity(-1*quantity)
......@@ -39,6 +42,6 @@ if current_invoice is None:
context.reindexObject(activate_kw={'tag': tag})
context.activate(tag=tag).SubscriptionRequest_createRelatedSaleInvoiceTransaction(
amount, tag, current_payment.getRelativeUrl())
amount, tag, current_payment.getRelativeUrl(), target_language)
return current_payment
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>amount, tag, REQUEST=None</string> </value>
<value> <string>amount, tag, target_language, REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
......@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
......@@ -23,7 +23,7 @@ class TestSlapOSSubscriptionChineseScenario(TestSlapOSSubscriptionScenarioMixin)
url_string=self.generateNewSoftwareReleaseUrl(),
root_slave=slave,
price=1888.00,
resource="currency_module/RMB",
resource="currency_module/CNY",
default_source_reference="default",
reference="rapidvm%s" % self.new_id,
# Aggregate and Follow up to web pages for product description and
......
......@@ -252,9 +252,6 @@ class TestSubscriptionRequest_saveTransactionalUser(TestSubscriptionSkinsMixin):
class TestSubscriptionRequest_createUser(TestSubscriptionSkinsMixin):
def test_SubscriptionRequest_createUser_raises_unauthorized(self):
email = "abc%s@nexedi.com" % self.new_id
name = "Cous Cous %s" % self.new_id
self.assertRaises(Unauthorized, self.portal.SubscriptionRequest_createUser, name="a", email="b", REQUEST=self.portal.REQUEST)
def test_SubscriptionRequest_createUser_already_logged_in(self):
......@@ -264,7 +261,6 @@ class TestSubscriptionRequest_createUser(TestSubscriptionSkinsMixin):
def test_SubscriptionRequest_createUser_existing_person(self):
email = "abc%s@nexedi.com" % self.new_id
name = "Cous Cous %s" % self.new_id
person = self.makePerson()
person.setDefaultEmailText(email)
self.tic()
......@@ -273,7 +269,6 @@ class TestSubscriptionRequest_createUser(TestSubscriptionSkinsMixin):
def test_SubscriptionRequest_createUser_existing_login(self):
email = "abc%s@nexedi.com" % self.new_id
name = "Cous Cous %s" % self.new_id
person = self.makePerson()
erp5_login = [i for i in person.searchFolder(portal_type="ERP5 Login")][0]
......@@ -455,8 +450,6 @@ class TestSubscriptionRequest_requestPaymentTransaction(TestSubscriptionSkinsMix
subscription_request = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
price=195.5,
price_currency="currency_module/EUR",
default_email_text="abc%s@nexedi.com" % self.new_id)
invoice_template_path = "accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
......@@ -466,7 +459,7 @@ class TestSubscriptionRequest_requestPaymentTransaction(TestSubscriptionSkinsMix
subscription_request.edit(causality_value=current_invoice)
self.assertEqual(None,
subscription_request.SubscriptionRequest_requestPaymentTransaction("1", "xx"))
subscription_request.SubscriptionRequest_requestPaymentTransaction("1", "xx", "en"))
def _test_request_payment_transaction(self, quantity):
email = "abc%s@nexedi.com" % self.new_id
......@@ -477,11 +470,9 @@ class TestSubscriptionRequest_requestPaymentTransaction(TestSubscriptionSkinsMix
subscription_request = self.newSubscriptionRequest(
quantity=quantity, destination_section_value=person,
price=195.5,
price_currency="currency_module/EUR",
default_email_text="abc%s@nexedi.com" % self.new_id)
current_payment = subscription_request.SubscriptionRequest_requestPaymentTransaction(quantity, "TAG")
current_payment = subscription_request.SubscriptionRequest_requestPaymentTransaction(quantity, "TAG", "en")
self.tic()
self.assertNotEqual(None, current_payment)
self.assertEqual(current_payment.getTitle(), "Payment for Reservation Fee")
......@@ -500,27 +491,76 @@ class TestSubscriptionRequest_requestPaymentTransaction(TestSubscriptionSkinsMix
if line.getSource() == "account_module/receivable":
self.assertEqual(line.getQuantity(), 25*quantity)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, REQUEST=None',"""assert REQUEST == None
def _test_request_payment_transaction_chinese(self, quantity):
email = "abc%s@nexedi.com" % self.new_id
name = "Cous Cous %s" % self.new_id
person, _ = self.portal.SubscriptionRequest_createUser(name=name, email=email)
self.tic()
subscription_request = self.newSubscriptionRequest(
quantity=quantity, destination_section_value=person,
default_email_text="abc%s@nexedi.com" % self.new_id)
current_payment = subscription_request.SubscriptionRequest_requestPaymentTransaction(quantity, "TAG", "zh")
self.tic()
self.assertNotEqual(None, current_payment)
self.assertEqual(current_payment.getTitle(), "Payment for Reservation Fee")
self.assertEqual(current_payment.getSourceValue(), person)
self.assertEqual(current_payment.getDestinationValue(), person)
self.assertEqual(current_payment.getDestinationSectionValue(), person)
self.assertEqual(current_payment.getDestinationDecisionValue(), person)
self.assertEqual(current_payment.getDestinationDecisionValue(), person)
self.assertNotEqual(current_payment.getStartDate(), None)
self.assertNotEqual(current_payment.getStopDate(), None)
self.assertEqual(current_payment.getSimulationState(), "started")
for line in current_payment.contentValues():
if line.getSource() == "account_module/bank":
self.assertEqual(line.getQuantity(), -188*quantity)
if line.getSource() == "account_module/receivable":
self.assertEqual(line.getQuantity(), 188*quantity)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, target_language, REQUEST=None',"""assert REQUEST == None
assert payment
assert amount == 1
assert tag == 'TAG'""")
assert tag == 'TAG'
assert target_language == 'en'""")
def test_request_payment_transaction_q1(self):
self._test_request_payment_transaction(quantity=1)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, REQUEST=None',"""assert REQUEST == None
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, target_language, REQUEST=None',"""assert REQUEST == None
assert payment
assert amount == 2
assert tag == 'TAG'""")
assert tag == 'TAG'
assert target_language == 'en'""")
def test_request_payment_transaction_q2(self):
self._test_request_payment_transaction(quantity=2)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, REQUEST=None',"""assert REQUEST == None
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, target_language, REQUEST=None',"""assert REQUEST == None
assert payment
assert amount == 10
assert tag == 'TAG'""")
assert tag == 'TAG'
assert target_language == 'en'""")
def test_request_payment_transaction_q10(self):
self._test_request_payment_transaction(quantity=10)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, target_language, REQUEST=None',"""assert REQUEST == None
assert payment
assert amount == 1
assert tag == 'TAG'
assert target_language == 'zh'""")
def test_request_payment_transaction_chinese_q1(self):
self._test_request_payment_transaction_chinese(quantity=1)
@simulate('SubscriptionRequest_createRelatedSaleInvoiceTransaction', 'amount, tag, payment, target_language, REQUEST=None',"""assert REQUEST == None
assert payment
assert amount == 10
assert tag == 'TAG'
assert target_language == 'zh'""")
def test_request_payment_transaction_chinese_q10(self):
self._test_request_payment_transaction_chinese(quantity=10)
class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscriptionSkinsMixin):
def test_invoice_already_created(self):
......@@ -532,8 +572,6 @@ class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscripti
subscription_request = self.newSubscriptionRequest(
quantity=1, destination_section_value=person,
price=195.5,
price_currency="currency_module/EUR",
default_email_text="abc%s@nexedi.com" % self.new_id)
invoice_template_path = "accounting_module/template_pre_payment_subscription_sale_invoice_transaction"
......@@ -543,7 +581,7 @@ class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscripti
subscription_request.edit(causality_value=current_invoice)
self.assertEqual(current_invoice,
subscription_request.SubscriptionRequest_createRelatedSaleInvoiceTransaction(1, "xx", "___payment__"))
subscription_request.SubscriptionRequest_createRelatedSaleInvoiceTransaction(1, "xx", "___payment__", "en"))
def _test_creation_of_related_sale_invoice_transaction(self, quantity):
......@@ -555,13 +593,11 @@ class TestSubscriptionRequest_createRelatedSaleInvoiceTransaction(TestSubscripti
subscription_request = self.newSubscriptionRequest(
quantity=quantity, destination_section_value=person,
price=195.5,
price_currency="currency_module/EUR",
default_email_text="abc%s@nexedi.com" % self.new_id)
# The SubscriptionRequest_createRelatedSaleInvoiceTransaction is invoked up, as it proven on
# test TestSubscriptionRequest_requestPaymentTransaction, so let's keep it simple, and just reinvoke
current_payment = subscription_request.SubscriptionRequest_requestPaymentTransaction(quantity, "TAG")
current_payment = subscription_request.SubscriptionRequest_requestPaymentTransaction(quantity, "TAG", "en")
self.tic()
......@@ -612,8 +648,6 @@ class SubscriptionRequest_processRequest(TestSubscriptionSkinsMixin):
<parameter id="zz">yy</parameter>
</instance>""",
root_slave=False,
price=99.9,
price_currency="currency_module/EUR",
source_reference="test_for_test_123")
subscription_request.plan()
subscription_request.order()
......@@ -637,8 +671,6 @@ class SubscriptionRequest_processRequest(TestSubscriptionSkinsMixin):
<parameter id="zz">yy</parameter>
</instance>""",
root_slave=False,
price=99.9,
price_currency="currency_module/EUR",
source_reference="test_for_test_123")
self.tic()
......
......@@ -45,12 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:255, 4: Unused variable \'email\' (unused-variable)</string>
<string>W:256, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:267, 4: Unused variable \'name\' (unused-variable)</string>
<string>W:276, 4: Unused variable \'name\' (unused-variable)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -122,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
......@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
......@@ -124,6 +124,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
......@@ -117,6 +117,7 @@
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
......
erp5_commerce
\ No newline at end of file
erp5_commerce
slapos_payzen
slapos_wechat
\ No newline at end of file
accounting_module/slapos_pre_payment_template
accounting_module/slapos_pre_payment_template/**
accounting_module/slapos_wechat_pre_payment_template
accounting_module/slapos_wechat_pre_payment_template/**
accounting_module/template_pre_payment_subscription_sale_invoice_transaction
accounting_module/template_pre_payment_subscription_sale_invoice_transaction/**
accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction
accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transaction/**
notification_message_module/slapos-free-trial-token
portal_alarms/slapos_subscription_request_process_**
portal_alarms/slapos_trial_process_**
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment