Commit 0e76d9fb authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request:

* drop not needed condition
* factorize some code
parent 291cfdaa
...@@ -20,6 +20,8 @@ if email in ["", None]: ...@@ -20,6 +20,8 @@ if email in ["", None]:
) )
return context.REQUEST.RESPONSE.redirect(redirect_url) return context.REQUEST.RESPONSE.redirect(redirect_url)
if token: if token:
error = "" error = ""
try: try:
...@@ -99,24 +101,15 @@ if batch_mode: ...@@ -99,24 +101,15 @@ if batch_mode:
return {'subscription' : subscription_request.getRelativeUrl(), return {'subscription' : subscription_request.getRelativeUrl(),
'payment': payment.getRelativeUrl() } 'payment': payment.getRelativeUrl() }
if target_language == "zh": # Wechat payment def wrapRedirectWithShadow(payment_transaction, web_site):
def wrapRedirectWithShadow(payment_transaction, web_site): # getTotalPayble returns a negative value
# getTotalPayble returns a negative value if payment_transaction.PaymentTransaction_getTotalPayablePrice() < 0:
if payment_transaction.PaymentTransaction_getTotalPayablePrice() < 0: if target_language == "zh":
if payment_transaction.Base_getWechatServiceRelativeUrl(): return payment_transaction.PaymentTransaction_redirectToManualWechatPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualWechatPayment(web_site) else:
return payment_transaction.PaymentTransaction_redirectToManualContactUsPayment(web_site) return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site)
return payment_transaction.PaymentTransaction_redirectToManualFreePayment(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( return person.Person_restrictMethodAsShadowUser(
shadow_document=person, shadow_document=person,
callable_object=wrapRedirectWithShadow, callable_object=wrapRedirectWithShadow,
......
...@@ -9,12 +9,12 @@ if contract is None: ...@@ -9,12 +9,12 @@ if contract is None:
return return
if context.SubscriptionRequest_getTransactionalUser() is not None: if context.SubscriptionRequest_getTransactionalUser() is not None:
if contract is not None and contract.getMaximumInvoiceDelay() > 0: if contract.getMaximumInvoiceDelay() > 0:
return True return True
else: else:
person = context.getDestinationSectionValue() person = context.getDestinationSectionValue()
if person.Entity_statSlapOSOutstandingAmount() > 0: if person.Entity_statSlapOSOutstandingAmount() > 0:
return return
if contract is not None and contract.getMaximumInvoiceDelay() > 0: if contract.getMaximumInvoiceDelay() > 0:
return True return True
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