Commit b7df55aa authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen: Use nice error when integration_site is not configured

parent 6cca1c8d
......@@ -3,7 +3,6 @@ if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())
_, transaction_id = context.PaymentTransaction_getPayzenId()
if transaction_id is not None:
......@@ -13,19 +12,17 @@ if transaction_id is not None:
now = DateTime().toZone('UTC')
today = now.asdatetime().strftime('%Y%m%d')
preferred_integration_site = portal.portal_preferences.getPreferredPayzenIntegrationSite()
integration_site = portal.restrictedTraverse(preferred_integration_site)
if integration_site is None or not preferred_integration_site:
raise ValueError("Integration Site not found or not configured: %s" %
preferred_integration_site)
transaction_id = str(portal.portal_ids.generateNewId(
id_group='%s_%s' % (integration_site.getRelativeUrl(), today),
id_generator='uid')).zfill(6)
mapping_id = '%s_%s' % (today, transaction_id)
# integration_site.Causality[mapping_id].setDestinationReference(context.getRelativeUrl())
# try:
# integration_site.getCategoryFromMapping('Causality/%s' % mapping_id, create_mapping_line=True, create_mapping=True)
# except ValueError:
# mapping = integration_site.Causality[mapping_id]
# mapping.setDestinationReference('%s' % context.getRelativeUrl())
# else:
# raise ValueError, "Payzen transaction_id already exists"
try:
# Init for use later.
......@@ -35,6 +32,8 @@ try:
create_mapping=True)
except ValueError:
pass
mapping_id = '%s_%s' % (today, transaction_id)
integration_site.Causality[context.getId().replace('-', '_')].setDestinationReference(mapping_id)
return context.PaymentTransaction_getPayzenId()
......@@ -3,7 +3,12 @@ if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())
preferred_integration_site = portal.portal_preferences.getPreferredPayzenIntegrationSite()
integration_site = portal.restrictedTraverse(preferred_integration_site)
if integration_site is None or not preferred_integration_site:
raise ValueError("Integration Site not found or not configured: %s" %
preferred_integration_site)
payzen_id = integration_site.getCategoryFromMapping('Causality/%s' % context.getId().replace('-', '_'))
if payzen_id != 'causality/%s' % context.getId().replace('-', '_'):
......
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