Commit 010cd409 authored by Rafael Monnerat's avatar Rafael Monnerat

Make external payment configuration optional

See merge request nexedi/slapos.core!586
parents ed2c746f be8e2565
......@@ -2,15 +2,18 @@
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_url = web_site.absolute_url()
payment_transaction_url = context.getRelativeUrl()
base = web_site.getLayoutProperty("configuration_payment_url_template",
"%(url)s/#/%(payment)s?page=slap_payment_result&result=%(result)s")
"%(url)s/#/%(payment_transaction_url)s?page=slap_payment_result&result=%(result)s")
base_substitution_dict = {
"url" : base_url,
"payment": payment_transaction_url,
"payment_transaction_url": payment_transaction_url,
"result": "__RESULT__"
}
......
""" Return a dict with vads_urls required for payzen."""
if web_site is None:
web_site = context.getWebSiteValue()
if context.PaymentTransaction_getTotalPayablePrice() == 0:
# This script cannot be used if Payment has a value to pay
raise ValueError("Payment Transaction has a non zero total")
base_url = web_site.absolute_url()
payment_transaction_url = context.getRelativeUrl()
base = web_site.getLayoutProperty("configuration_payment_url_template",
"%(url)s/#/%(payment_transaction_url)s?page=slap_payment_result&result=%(result)s")
base_substitution_dict = {
"url" : base_url,
"payment_transaction_url": payment_transaction_url,
"result": "contact_us"
}
redirect_url = base % base_substitution_dict
return context.REQUEST.RESPONSE.redirect(redirect_url)
......@@ -52,9 +52,17 @@
<key> <string>_params</string> </key>
<value> <string>web_site=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_redirectToWechatPayment</string> </value>
<value> <string>PaymentTransaction_redirectToManualContactUsPayment</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -10,11 +10,11 @@ base_url = web_site.absolute_url()
payment_transaction_url = context.getRelativeUrl()
base = web_site.getLayoutProperty("configuration_payment_url_template",
"%(url)s/#/%(payment)s?page=slap_payment_result&result=%(result)s")
"%(url)s/#/%(payment_transaction_url)s?page=slap_payment_result&result=%(result)s")
base_substitution_dict = {
"url" : base_url,
"payment": payment_transaction_url,
"payment_transaction_url": payment_transaction_url,
"result": "free"
}
......
......@@ -13,9 +13,19 @@ payment = entity.Person_restrictMethodAsShadowUser(
if web_site is None:
web_site = context.getWebSiteValue()
total_price = entity.Person_restrictMethodAsShadowUser(
shadow_document=entity,
callable_object=payment.PaymentTransaction_getTotalPayablePrice,
argument_list=[])
if total_price >= 0:
return payment.PaymentTransaction_redirectToManualFreePayment(web_site=web_site)
if payment_mode == "wechat":
if payment.Base_getWechatServiceRelativeUrl():
return payment.PaymentTransaction_redirectToManualWechatPayment(web_site=web_site)
elif payment_mode == "payzen":
if payment.Base_getPayzenServiceRelativeUrl():
return payment.PaymentTransaction_redirectToManualPayzenPayment(web_site=web_site)
raise ValueError("%s isn't an acceptable payment mode" % payment_mode)
return payment.PaymentTransaction_redirectToManualContactUsPayment(web_site=web_site)
......@@ -167,6 +167,8 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_accounting/SaleInvoiceTransaction_isTotalPriceEqualAccounting',
'slapos_accounting/SaleInvoiceTransaction_isTotalPriceMatchingSalePackingList',
'slapos_accounting/SaleInvoiceTransaction_isTradeModelCorrect',
'slapos_accounting/PaymentTransaction_redirectToManualFreePayment',
'slapos_accounting/PaymentTransaction_redirectToManualContactUsPayment',
'slapos_accounting/SalePackingList_jumpToRelatedAggregatedSalePackingList',
'slapos_accounting/SalePackingList_jumpToRelatedGroupedSalePackingList',
'slapos_accounting/SalePackingList_postSlapOSAggregatedDeliveryBuilder',
......@@ -189,7 +191,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_consumption/SoftwareRelease_getAverageConsumedMemory',
'slapos_wechat/Base_queryWechatOrderStatusByTradeNo',
'slapos_wechat/ERP5Site_receiveWechatPaymentCallback',
'slapos_wechat/PaymentTransaction_redirectToWechatPayment',
'slapos_payzen/PayzenEvent_isPaymentExpired',
'slapos_deploy_theme/WebPage_getDeploySubstitutionMappingDict',
'slapos_deploy_theme/WebPage_viewAsWeb',
......@@ -233,7 +234,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_hal_json_style/Organisation_getAssociatedPersonList',
'slapos_hal_json_style/Organisation_hasItem',
'slapos_hal_json_style/PasswordTool_changeUserPassword',
'slapos_hal_json_style/PaymentTransaction_redirectToManualFreePayment',
'slapos_hal_json_style/Person_getAssignmentDestinationList',
'slapos_hal_json_style/Person_getCloudContractRelated',
'slapos_hal_json_style/Person_requestComputeNode',
......
......@@ -59,6 +59,14 @@
page_title = "Payment Unfinished";
message = "You have not finished your payment.";
advice = "Please consider continuing it as soon as possible, otherwise you will be not able to use full functionality.";
} else if (options.result === "free") {
page_title = "This payment is free";
message = "You are trying to pay a Free invoice.";
advice = "Please, contact us by opening a ticket to ask more information.";
} else if (options.result === "contact_us") {
page_title = "Please, contact us";
message = "You are trying to pay an invoice, but the automatic payments are disabled currently.";
advice = "Please contact us by opening a ticket with the invoice information, we will provide you an alternative way to pay.";
} else if (options.result === "already_registered") {
page_title = "Payment already registered";
message = "Your payment had already been registered.";
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.20858.14913.15650</string> </value>
<value> <string>1006.58340.40727.23620</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1668439460.43</float>
<float>1701887958.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -353,6 +353,16 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_payment_url_template</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -446,6 +456,14 @@
<key> <string>configuration_payment_result</string> </key>
<value> <string>slap_payment_result</string> </value>
</item>
<item>
<key> <string>configuration_payment_url_template</string> </key>
<value> <string encoding="cdata"><![CDATA[
%(url)s/#/%(payment_transaction_url)s?page=slap_payment_result&result=%(result)s
]]></string> </value>
</item>
<item>
<key> <string>configuration_precache_manifest_script_list</string> </key>
<value> <string>WebSection_getHostingJSPrecacheManifestList\n
......@@ -708,7 +726,7 @@ WebSection_getJsonEditorPrecacheManifestList</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.52641.3080.21452</string> </value>
<value> <string>1012.36758.49018.20019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -728,7 +746,7 @@ WebSection_getJsonEditorPrecacheManifestList</string> </value>
</tuple>
<state>
<tuple>
<float>1700245844.87</float>
<float>1701890500.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -14,9 +14,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -27,9 +25,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -40,9 +36,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -54,9 +48,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -108,6 +100,12 @@
<none/>
</value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
......@@ -141,4 +139,85 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1702404222.37</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -14,9 +14,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -27,9 +25,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -40,9 +36,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -54,9 +48,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -93,7 +85,9 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
<tuple>
<string>price_currency/currency_module/EUR</string>
</tuple>
</value>
</item>
<item>
......@@ -130,6 +124,12 @@
<none/>
</value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
......@@ -195,4 +195,156 @@
<none/>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAg=</string> </persistent>
</value>
</item>
<item>
<key> <string>validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAk=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="8" aka="AAAAAAAAAAg=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1013.8578.12822.45056</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1702404310.04</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="9" aka="AAAAAAAAAAk=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1702400771.68</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -3,7 +3,16 @@ if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
payment_service = portal.portal_secure_payments.find(
service_reference=portal.portal_preferences.getPreferredPayzenPaymentServiceReference())
service_reference = portal.portal_preferences.getPreferredPayzenPaymentServiceReference()
if not service_reference:
return
try:
payment_service = portal.portal_secure_payments.find(service_reference=service_reference)
except ValueError:
# If service is not found, return None
# this might allow the side handle disabled service configuration.
return
return payment_service.getRelativeUrl()
......@@ -2,9 +2,6 @@ from zExceptions import Unauthorized
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if getattr(context, "PaymentTransaction_getVADSUrlDict", None) is None:
raise ValueError("PaymentTransaction_getVADSUrlDict is missing on this site")
def wrapWithShadow(payment_transaction, web_site, person_relative_url):
vads_url_dict = payment_transaction.PaymentTransaction_getVADSUrlDict(web_site)
......
......@@ -170,6 +170,8 @@ class TestSlapOSPaymentTransaction_createPayzenEvent(SlapOSTestCaseMixinWithAbor
REQUEST={})
def test_createPayzenEvent_newPayment(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("PSERV-Payzen-Test")
self.tic()
payment_transaction = self.createPaymentTransaction()
payzen_event = payment_transaction.PaymentTransaction_createPayzenEvent()
self.assertEqual(payzen_event.getPortalType(), "Payzen Event")
......@@ -178,6 +180,8 @@ class TestSlapOSPaymentTransaction_createPayzenEvent(SlapOSTestCaseMixinWithAbor
self.assertEqual(payzen_event.getDestination(), payment_transaction.getRelativeUrl())
def test_createPayzenEvent_kwParameter(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("PSERV-Payzen-Test")
self.tic()
payment_transaction = self.createPaymentTransaction()
payzen_event = payment_transaction.PaymentTransaction_createPayzenEvent(
title='foo')
......@@ -666,9 +670,18 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAb
REQUEST={})
def test_getPayzenServiceRelativeUrl_default_result(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("PSERV-Payzen-Test")
self.tic()
result = self.portal.Base_getPayzenServiceRelativeUrl()
self.assertEqual(result, 'portal_secure_payments/slapos_payzen_test')
def test_getPayzenServiceRelativeUrl_not_found(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("disabled")
self.tic()
result = self.portal.Base_getPayzenServiceRelativeUrl()
self.assertEqual(result, None)
class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment(
SlapOSTestCaseMixinWithAbort):
......@@ -712,6 +725,8 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self._dropPaymentTransaction_getVADSUrlDict()
def test_PaymentTransaction_redirectToManualPayzenPayment_redirect(self):
self.portal.portal_secure_payments.slapos_payzen_test.setReference("PSERV-Payzen-Test")
self.tic()
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
......
sale_trade_condition_module/payzen_sale_trade_condition
sale_trade_condition_module/slapos_manual_accounting_trade_condition
\ No newline at end of file
......@@ -20,8 +20,6 @@ if email in ["", None]:
)
return context.REQUEST.RESPONSE.redirect(redirect_url)
if token:
error = ""
try:
......@@ -105,14 +103,18 @@ if target_language == "zh": # Wechat payment
def wrapRedirectWithShadow(payment_transaction, web_site):
# getTotalPayble returns a negative value
if payment_transaction.PaymentTransaction_getTotalPayablePrice() < 0:
if payment_transaction.Base_getWechatServiceRelativeUrl():
return payment_transaction.PaymentTransaction_redirectToManualWechatPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualContactUsPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualFreePayment(web_site)
else: # Payzen payment
def wrapRedirectWithShadow(payment_transaction, web_site):
# getTotalPayble returns a negative value
if payment_transaction.PaymentTransaction_getTotalPayablePrice() < 0:
if payment_transaction.Base_getPayzenServiceRelativeUrl():
return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualContactUsPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualFreePayment(web_site)
return person.Person_restrictMethodAsShadowUser(
......
......@@ -3,7 +3,17 @@ if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
payment_service = portal.portal_secure_payments.find(
service_reference=portal.portal_preferences.getPreferredWechatPaymentServiceReference())
service_reference = portal.portal_preferences.getPreferredWechatPaymentServiceReference()
if not service_reference:
return
try:
payment_service = portal.portal_secure_payments.find(
service_reference=service_reference)
except ValueError:
# If service is not found, return None
# this might allow the side handle disabled service configuration.
return
return payment_service.getRelativeUrl()
......@@ -2,9 +2,6 @@ from zExceptions import Unauthorized
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if getattr(context, "PaymentTransaction_getVADSUrlDict", None) is None:
raise ValueError("PaymentTransaction_getVADSUrlDict is missing on this site")
def wrapWithShadow(payment_transaction, web_site, person_relative_url):
vads_url_dict = payment_transaction.PaymentTransaction_getVADSUrlDict(web_site)
......
from zExceptions import Unauthorized
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
def wrapWithShadow(payment_transaction, web_site, person_relative_url):
vads_url_dict = payment_transaction.PaymentTransaction_getVADSUrlDict(web_site)
# ???
#_ , transaction_id = payment_transaction.PaymentTransaction_getWechatId()
# vads_url_already_registered = vads_url_dict.pop('vads_url_already_registered')
# if transaction_id is not None:
# return context.REQUEST.RESPONSE.redirect(vads_url_already_registered)
system_event = payment_transaction.PaymentTransaction_createWechatEvent(
title='User navigation script for %s' % payment_transaction.getTitle(),
destination_section=person_relative_url,
)
# Why I need to login ???
system_event.generateWechatPaymentPage(
**vads_url_dict
)
'''
return system_event.contentValues(
portal_type="Wechat Event Message")[0].getTextContent()
'''
if person is None:
if not portal.portal_membership.isAnonymousUser():
return wrapWithShadow(context, web_site, context.getDestinationSection())
raise Unauthorized("You must be logged in")
return person.Person_restrictMethodAsShadowUser(
shadow_document=person,
callable_object=wrapWithShadow,
argument_list=[context, web_site, person.getRelativeUrl()])
......@@ -169,6 +169,7 @@ class TestSlapOSPaymentTransaction_createWechatEvent(SlapOSTestCaseMixinWithAbor
REQUEST={})
def test_createWechatEvent_newPayment(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
payment_transaction = self.createPaymentTransaction()
wechat_event = payment_transaction.PaymentTransaction_createWechatEvent()
self.assertEqual(wechat_event.getPortalType(), "Wechat Event")
......@@ -177,6 +178,8 @@ class TestSlapOSPaymentTransaction_createWechatEvent(SlapOSTestCaseMixinWithAbor
self.assertEqual(wechat_event.getDestination(), payment_transaction.getRelativeUrl())
def test_createWechatEvent_kwParameter(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
self.tic()
payment_transaction = self.createPaymentTransaction()
wechat_event = payment_transaction.PaymentTransaction_createWechatEvent(
title='foo')
......@@ -523,7 +526,6 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAbort):
def test_getWechatServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises(
Unauthorized,
......@@ -531,9 +533,18 @@ class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAb
REQUEST={})
def test_getWechatServiceRelativeUrl_default_result(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
self.tic()
result = self.portal.Base_getWechatServiceRelativeUrl()
self.assertEqual(result, 'portal_secure_payments/slapos_wechat_test')
def test_getWechatServiceRelativeUrl_not_found(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("disabled")
self.tic()
result = self.portal.Base_getWechatServiceRelativeUrl()
self.assertEqual(result, None)
class TestSlapOSWechatPaymentTransaction_redirectToManualWechatPayment(
SlapOSTestCaseMixinWithAbort):
......@@ -577,6 +588,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self._dropPaymentTransaction_getVADSUrlDict()
def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
......@@ -621,6 +633,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
transaction.abort()
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
person = self.makePerson()
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
......
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