Commit 67df0515 authored by Rafael Monnerat's avatar Rafael Monnerat

WIP slapos_panel: Use specific script for deposit

parent c3c004e4
......@@ -55,7 +55,7 @@ for currency_uid, secure_service_relative_url in [
""" % {
'total_price': deposit_price,
'currency': currency_uid,
'payment_url': '%s/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect' % subscription_request.absolute_url()
'payment_url': '%s/Entity_createExternalPaymentTransactionFromDepositAndRedirect?currency_uid=%s' % (entity.absolute_url(), currency_uid)
}
if html_content:
......
portal = context.getPortalObject()
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
web_site = context.getWebSiteValue()
ledger_uid = portal.portal_categories.ledger.automated.getUid()
currency_uid = portal.currency_module.EUR.getUid()
if currency_uid == None:
currency_uid = portal.currency_module.EUR.getUid()
assert web_site is not None
assert web_site.getLayoutProperty("configuration_payment_url_template", None) is not None
assert entity.getUid() == context.getUid()
deposit_price = 0
for sql_subscription_request in portal.portal_catalog(
portal_type="Subscription Request",
simulation_state='submitted',
destination_section__uid=entity.getUid(),
price_currency__uid=currency_uid,
ledger__uid=ledger_uid
):
subscription_request = sql_subscription_request.getObject()
subscription_request_total_price = subscription_request.getTotalPrice()
if 0 < subscription_request_total_price:
deposit_price += subscription_request_total_price
if 0 >= deposit_price:
raise ValueError("Nothing to pay")
payment_mode = None
resource_uid = currency_uid
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
def wrapWithShadow(entity, total_amount, currency_uid):
currency_value = portal.portal_catalog.getObject(uid=currency_uid)
if currency_value is None:
raise ValueError("Currency not found")
return entity.Person_addDepositPayment(
total_amount,
currency_value.getRelativeUrl(),
batch=1
)
payment_transaction = entity.Person_restrictMethodAsShadowUser(
shadow_document=entity,
callable_object=wrapWithShadow,
argument_list=[entity, deposit_price, currency_uid])
web_site = context.getWebSiteValue()
if (payment_mode == "wechat"):
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')
<?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=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Entity_createExternalPaymentTransactionFromDepositAndRedirect</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -23,13 +23,6 @@ for accepted_resource_uid, accepted_payment_mode, is_activated in [
assert payment_mode is not None
def wrapWithShadow(entity, outstanding_amount):
# In case of "Subscription Request"
if outstanding_amount.getPortalType() == 'Subscription Request':
return entity.Person_addDepositPayment(
outstanding_amount.getTotalPrice(),
outstanding_amount.getPriceCurrency(),
batch=1
)
return entity.Entity_createPaymentTransaction(
entity.Entity_getOutstandingAmountList(
section_uid=outstanding_amount.getSourceSectionUid(),
......
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