Commit 5cd2c351 authored by Romain Courteaud's avatar Romain Courteaud

Add Currency_getIntegrationMapping script.

Prevent duplicated the complex mapping retrieval.
parent 89e8eb83
...@@ -55,7 +55,7 @@ portal.portal_catalog.searchAndActivate(\n ...@@ -55,7 +55,7 @@ portal.portal_catalog.searchAndActivate(\n
portal_type="Payment Transaction", \n portal_type="Payment Transaction", \n
simulation_state=["confirmed"],\n simulation_state=["confirmed"],\n
causality_state=["solved"],\n causality_state=["solved"],\n
method_id=\'PaymentTransaction_updateStatus\',\n method_id=\'PaymentTransaction_startExternalPayment\',\n
packet_size=1, # just one to minimise errors\n packet_size=1, # just one to minimise errors\n
activate_kw={\'tag\': tag}\n activate_kw={\'tag\': tag}\n
)\n )\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
\n
relative_url = context.getRelativeUrl()\n
# Only EUR is supported for now\n
assert relative_url == \'currency_module/EUR\'\n
return integration_site.getMappingFromCategory(\'resource/%s\' % relative_url).split(\'/\', 1)[-1]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Currency_getIntegrationMapping</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n <value> <string>from DateTime import DateTime\n
transaction = context\n transaction = context\n
return None\n
\n
portal = transaction.getPortalObject()\n portal = transaction.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
state_list = portal.getPortalCurrentInventoryStateList()\n state_list = portal.getPortalCurrentInventoryStateList()\n
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
class TestSlapOSCurrency_getIntegrationMapping(testSlapOSMixin):
def beforeTearDown(self):
transaction.abort()
def test_integratedCurrency(self):
currency = self.portal.currency_module.EUR
self.assertEquals(currency.Currency_getIntegrationMapping(), '978')
def test_notIntegratedCurrency(self):
new_id = self.generateNewId()
currency = self.portal.currency_module.newContent(
portal_type='Currency',
title="Currency %s" % new_id,
reference="TESTCUR-%s" % new_id,
)
self.assertRaises(
AssertionError,
currency.Currency_getIntegrationMapping)
...@@ -110,7 +110,7 @@ elif transaction_status in continue_transaction_id_list:\n ...@@ -110,7 +110,7 @@ elif transaction_status in continue_transaction_id_list:\n
if transaction_amount != auth_amount:\n if transaction_amount != auth_amount:\n
payzen_event.confirm(comment=\'Received amount (%r) does not match stored on transaction (%r)\'% (auth_amount, transaction_amount))\n payzen_event.confirm(comment=\'Received amount (%r) does not match stored on transaction (%r)\'% (auth_amount, transaction_amount))\n
return\n return\n
transaction_devise = integration_tool.getMappingFromCategory(\'resource/currency_module/%s\' % transaction.getResourceReference()).split(\'/\')[-1]\n transaction_devise = transaction.getResourceValue().Currency_getIntegrationMapping()\n
if transaction_devise != auth_devise:\n if transaction_devise != auth_devise:\n
payzen_event.confirm(comment=\'Received devise (%r) does not match stored on transaction (%r)\'% (auth_devise, transaction_devise))\n payzen_event.confirm(comment=\'Received devise (%r) does not match stored on transaction (%r)\'% (auth_devise, transaction_devise))\n
return\n return\n
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
In order to not transmit sensitive information the registration is done by looking the newest\n In order to not transmit sensitive information the registration is done by looking the newest\n
payzen related transaction for destination_section and doing its duplicate"""\n payzen related transaction for destination_section and doing its duplicate"""\n
\n \n
raise NotImplementedError\n
\n
from DateTime import DateTime\n from DateTime import DateTime\n
payzen_event = state_change[\'object\']\n payzen_event = state_change[\'object\']\n
transaction = payzen_event.getDestinationValue()\n transaction = payzen_event.getDestinationValue()\n
...@@ -89,7 +91,7 @@ else:\n ...@@ -89,7 +91,7 @@ else:\n
# do causality mapping in integration_site between transaction.getRelativeUrl and today + transaction_id\n # do causality mapping in integration_site between transaction.getRelativeUrl and today + transaction_id\n
payzen_dict = {}\n payzen_dict = {}\n
payzen_dict.update(\n payzen_dict.update(\n
devise=integration_site.getMappingFromCategory(\'resource/currency_module/%s\' % transaction.getResourceReference()).split(\'/\')[-1],\n devise=transaction.getResourceValue().Currency_getIntegrationMapping(),\n
amount=str(int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n amount=str(int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n
presentationDate=transaction.getStartDate().toZone(\'UTC\').asdatetime(),\n presentationDate=transaction.getStartDate().toZone(\'UTC\').asdatetime(),\n
newTransactionId=transaction_id,\n newTransactionId=transaction_id,\n
......
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>payzen_event = state_change[\'object\']\n <value> <string>raise NotImplementedError\n
\n
payzen_event = state_change[\'object\']\n
payment_transaction = payzen_event.getDestinationValue()\n payment_transaction = payzen_event.getDestinationValue()\n
portal = payment_transaction.getPortalObject()\n portal = payment_transaction.getPortalObject()\n
service = portal.portal_secure_payments.find()\n service = portal.portal_secure_payments.find()\n
......
85 87
\ No newline at end of file \ No newline at end of file
testSlapOSPayzenSkins
\ No newline at end of file
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