Commit 3eb3f76c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen&wechat: Change payment_mode if invoice/payment price is zero

   It isn't possible to pay on payzen zero amount invoices, so just update payment_mode to skip the payment from the search (to prevent bloat activities by relaunching activities that will never change the state of the object).
parent 8f40dd92
Pipeline #16100 running with stage
in 0 seconds
...@@ -3,20 +3,11 @@ from DateTime import DateTime ...@@ -3,20 +3,11 @@ from DateTime import DateTime
state = context.getSimulationState() state = context.getSimulationState()
transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2)) transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2))
if (state != 'confirmed') or (context.getPaymentMode() != 'payzen') or (transaction_amount == 0): if (state != 'confirmed') or (context.getPaymentMode() != 'payzen') or (transaction_amount == 0):
if (transaction_amount == 0):
invoice = context.getCausalityValue(portal_types="Sale Invoice Transaction")
if invoice is not None and round(invoice.getTotalPrice(), 2) == 0:
context.edit(payment_mode="wire_transfer")
return return
else: else:
# Request manual payment # Request manual payment
context.start(comment='Requested manual payment') context.start(comment='Requested manual payment')
# raise NotImplementedError
# if context.PaymentTransaction_getPreviousPayzenId() is not None:
# # there is previous payment
# context.setStartDate(DateTime())
# context.updateCausalityState()
# portal.system_event_module.newContent(
# title='Transaction %s Payzen registration' % context.getTitle(),
# portal_type='Payzen Event',
# source_value=service,
# destination_value=context).registerPayzen()
# comment='Automatically duplicated in payzen.'
# else:
...@@ -3,6 +3,10 @@ from DateTime import DateTime ...@@ -3,6 +3,10 @@ from DateTime import DateTime
state = context.getSimulationState() state = context.getSimulationState()
transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2)) transaction_amount = int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 2))
if (state != 'confirmed') or (context.getPaymentMode() != 'wechat') or (transaction_amount == 0): if (state != 'confirmed') or (context.getPaymentMode() != 'wechat') or (transaction_amount == 0):
if (transaction_amount == 0):
invoice = context.getCausalityValue(portal_types="Sale Invoice Transaction")
if invoice is not None and round(invoice.getTotalPrice(), 2) == 0:
context.edit(payment_mode="wire_transfer")
return return
else: else:
# Request manual payment # Request manual payment
......
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