diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 8e2cc6452c0..a993c0708bc 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -956,7 +956,6 @@
-
diff --git a/addons/base_import_module/__openerp__.py b/addons/base_import_module/__openerp__.py
index 09ebca9cf41..262e1232278 100644
--- a/addons/base_import_module/__openerp__.py
+++ b/addons/base_import_module/__openerp__.py
@@ -13,7 +13,7 @@ for customization purpose.
'depends': ['web'],
'installable': True,
'auto_install': False,
- 'data': [],
+ 'data': ['views/base_import_module.xml'],
'qweb': [],
'test': [],
}
diff --git a/addons/base_import_module/controllers/main.py b/addons/base_import_module/controllers/main.py
index cbfbd75894b..d97e75ba8b6 100644
--- a/addons/base_import_module/controllers/main.py
+++ b/addons/base_import_module/controllers/main.py
@@ -1,14 +1,8 @@
# -*- coding: utf-8 -*-
import functools
-import os
-import zipfile
-from os.path import join as opj
-
import openerp
from openerp.http import Controller, route, request, Response
-MAX_FILE_SIZE = 100 * 1024 * 1024 # in megabytes
-
def webservice(f):
@functools.wraps(f)
def wrap(*args, **kw):
@@ -42,32 +36,4 @@ class ImportModule(Controller):
@webservice
def upload(self, mod_file=None, **kw):
self.check_user()
- imm = request.registry['ir.module.module']
-
- if not mod_file:
- raise Exception("No file sent.")
- if not zipfile.is_zipfile(mod_file):
- raise Exception("Not a zipfile.")
-
- success = []
- errors = dict()
- with zipfile.ZipFile(mod_file, "r") as z:
- for zf in z.filelist:
- if zf.file_size > MAX_FILE_SIZE:
- raise Exception("File '%s' exceed maximum allowed file size" % zf.filename)
-
- with openerp.tools.osutil.tempdir() as module_dir:
- z.extractall(module_dir)
- dirs = [d for d in os.listdir(module_dir) if os.path.isdir(opj(module_dir, d))]
- for mod_name in dirs:
- try:
- # assert mod_name.startswith('theme_')
- path = opj(module_dir, mod_name)
- imm.import_module(request.cr, request.uid, mod_name, path, context=request.context)
- success.append(mod_name)
- except Exception, e:
- errors[mod_name] = str(e)
- r = ["Successfully imported module '%s'" % mod for mod in success]
- for mod, error in errors.items():
- r.append("Error while importing module '%s': %r" % (mod, error))
- return '\n'.join(r)
+ return request.registry['ir.module.module'].import_zipfile(request.cr, request.uid, mod_file, context=request.context)[0]
diff --git a/addons/base_import_module/models/__init__.py b/addons/base_import_module/models/__init__.py
index a28c82fe5ba..02b8831509a 100644
--- a/addons/base_import_module/models/__init__.py
+++ b/addons/base_import_module/models/__init__.py
@@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
import ir_module
+import base_import_module
diff --git a/addons/base_import_module/models/base_import_module.py b/addons/base_import_module/models/base_import_module.py
new file mode 100644
index 00000000000..36edb5a56f3
--- /dev/null
+++ b/addons/base_import_module/models/base_import_module.py
@@ -0,0 +1,53 @@
+import base64
+from StringIO import StringIO
+from io import BytesIO
+from openerp.osv import osv, fields
+
+class base_import_module(osv.TransientModel):
+ """ Import Module """
+ _name = "base.import.module"
+ _description = "Import Module"
+
+ _columns = {
+ 'module_file': fields.binary('Module .ZIP file', required=True),
+ 'state':fields.selection([('init','init'),('done','done')], 'Status', readonly=True),
+ 'import_message': fields.char('Import message'),
+ }
+
+ _defaults = {
+ 'state': 'init',
+ }
+
+ def import_module(self, cr, uid, ids, context=None):
+ module_obj = self.pool.get('ir.module.module')
+ data = self.browse(cr, uid, ids[0] , context=context)
+ zip_data = base64.decodestring(data.module_file)
+ fp = BytesIO()
+ fp.write(zip_data)
+ res = module_obj.import_zipfile(cr, uid, fp, context=context)
+ self.write(cr, uid, ids, {'state': 'done', 'import_message': res[0]}, context=context)
+ context = dict(context, module_name=res[1])
+ # Return wizard otherwise it will close wizard and will not show result message to user.
+ return {
+ 'name': 'Import Module',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'res_id': ids[0],
+ 'res_model': 'base.import.module',
+ 'type': 'ir.actions.act_window',
+ 'context': context,
+ }
+
+ def action_module_open(self, cr, uid, ids, context):
+ return {
+ 'domain': [('name', 'in', context.get('module_name',[]))],
+ 'name': 'Modules',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'ir.module.module',
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ }
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py
index 18e60f858da..2a0a9ea7fed 100644
--- a/addons/base_import_module/models/ir_module.py
+++ b/addons/base_import_module/models/ir_module.py
@@ -1,14 +1,18 @@
import logging
import os
import sys
+import zipfile
from os.path import join as opj
import openerp
from openerp.osv import osv
from openerp.tools import convert_file
+from openerp.tools.translate import _
_logger = logging.getLogger(__name__)
+MAX_FILE_SIZE = 100 * 1024 * 1024 # in megabytes
+
class view(osv.osv):
_inherit = "ir.module.module"
@@ -22,7 +26,7 @@ class view(osv.osv):
unmet_dependencies = set(terp['depends']).difference(known_mods_names.keys())
if unmet_dependencies:
- raise Exception("Unmet module dependencies: %s" % ', '.join(unmet_dependencies))
+ raise osv.except_osv(_('Error !'), _("Unmet module dependencies: %s" % ', '.join(unmet_dependencies)))
if mod:
self.write(cr, uid, mod.id, values)
@@ -69,3 +73,33 @@ class view(osv.osv):
return True
+ def import_zipfile(self, cr, uid, module_file, context=None):
+ if not module_file:
+ raise Exception("No file sent.")
+ if not zipfile.is_zipfile(module_file):
+ raise osv.except_osv(_('Error !'), _('File is not a zip file!'))
+
+ success = []
+ errors = dict()
+ module_names = []
+ with zipfile.ZipFile(module_file, "r") as z:
+ for zf in z.filelist:
+ if zf.file_size > MAX_FILE_SIZE:
+ raise osv.except_osv(_('Error !'), _("File '%s' exceed maximum allowed file size" % zf.filename))
+
+ with openerp.tools.osutil.tempdir() as module_dir:
+ z.extractall(module_dir)
+ dirs = [d for d in os.listdir(module_dir) if os.path.isdir(opj(module_dir, d))]
+ for mod_name in dirs:
+ module_names.append(mod_name)
+ try:
+ # assert mod_name.startswith('theme_')
+ path = opj(module_dir, mod_name)
+ self.import_module(cr, uid, mod_name, path, context=context)
+ success.append(mod_name)
+ except Exception, e:
+ errors[mod_name] = str(e)
+ r = ["Successfully imported module '%s'" % mod for mod in success]
+ for mod, error in errors.items():
+ r.append("Error while importing module '%s': %r" % (mod, error))
+ return '\n'.join(r), module_names
diff --git a/openerp/addons/base/module/wizard/base_module_import_view.xml b/addons/base_import_module/views/base_import_module.xml
similarity index 55%
rename from openerp/addons/base/module/wizard/base_module_import_view.xml
rename to addons/base_import_module/views/base_import_module.xml
index d9d6bb6ee78..daaa7779c27 100644
--- a/openerp/addons/base/module/wizard/base_module_import_view.xml
+++ b/addons/base_import_module/views/base_import_module.xml
@@ -3,49 +3,51 @@
- Module Import
- base.module.import
+ Import Module
+ base.import.module
- Module Import
+ Import Module
ir.actions.act_window
- base.module.import
+ base.import.module
form
form
new
-
+ sequence="100"/>
+
diff --git a/addons/payment/models/res_config.py b/addons/payment/models/res_config.py
index 70668a296da..a74e595b52e 100644
--- a/addons/payment/models/res_config.py
+++ b/addons/payment/models/res_config.py
@@ -16,4 +16,7 @@ class AccountPaymentConfig(osv.TransientModel):
'module_payment_adyen': fields.boolean(
'Manage Payments Using Adyen',
help='-It installs the module payment_adyen.'),
+ 'module_payment_buckaroo': fields.boolean(
+ 'Manage Payments Using Buckaroo',
+ help='-It installs the module payment_buckaroo.'),
}
diff --git a/addons/payment/views/res_config_view.xml b/addons/payment/views/res_config_view.xml
index 101acb7c9ee..45c0a3d168e 100644
--- a/addons/payment/views/res_config_view.xml
+++ b/addons/payment/views/res_config_view.xml
@@ -20,6 +20,10 @@
+
+
+
+
diff --git a/addons/payment_adyen/views/adyen.xml b/addons/payment_adyen/views/adyen.xml
index 75e166f92fe..79281f43a99 100644
--- a/addons/payment_adyen/views/adyen.xml
+++ b/addons/payment_adyen/views/adyen.xml
@@ -20,7 +20,7 @@
-
]]>
+ dummy
+ dummy
+
+
+
+
diff --git a/addons/payment_buckaroo/models/__init__.py b/addons/payment_buckaroo/models/__init__.py
new file mode 100644
index 00000000000..7e1780a0059
--- /dev/null
+++ b/addons/payment_buckaroo/models/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+import buckaroo
diff --git a/addons/payment_buckaroo/models/buckaroo.py b/addons/payment_buckaroo/models/buckaroo.py
new file mode 100644
index 00000000000..5b576a24c3b
--- /dev/null
+++ b/addons/payment_buckaroo/models/buckaroo.py
@@ -0,0 +1,191 @@
+# -*- coding: utf-'8' "-*-"
+from hashlib import sha1
+import logging
+import urlparse
+
+from openerp.addons.payment.models.payment_acquirer import ValidationError
+from openerp.addons.payment_buckaroo.controllers.main import BuckarooController
+from openerp.osv import osv, fields
+from openerp.tools.float_utils import float_compare
+
+_logger = logging.getLogger(__name__)
+
+
+class AcquirerBuckaroo(osv.Model):
+ _inherit = 'payment.acquirer'
+
+ def _get_buckaroo_urls(self, cr, uid, environment, context=None):
+ """ Buckaroo URLs
+ """
+ if environment == 'prod':
+ return {
+ 'buckaroo_form_url': 'https://checkout.buckaroo.nl/html/',
+ }
+ else:
+ return {
+ 'buckaroo_form_url': 'https://testcheckout.buckaroo.nl/html/',
+ }
+
+ def _get_providers(self, cr, uid, context=None):
+ providers = super(AcquirerBuckaroo, self)._get_providers(cr, uid, context=context)
+ providers.append(['buckaroo', 'Buckaroo'])
+ return providers
+
+ _columns = {
+ 'brq_websitekey': fields.char('WebsiteKey', required_if_provider='buckaroo'),
+ 'brq_secretkey': fields.char('SecretKey', required_if_provider='buckaroo'),
+ }
+
+ def _buckaroo_generate_digital_sign(self, acquirer, inout, values):
+ """ Generate the shasign for incoming or outgoing communications.
+
+ :param browse acquirer: the payment.acquirer browse record. It should
+ have a shakey in shaky out
+ :param string inout: 'in' (openerp contacting buckaroo) or 'out' (buckaroo
+ contacting openerp).
+ :param dict values: transaction values
+
+ :return string: shasign
+ """
+ assert inout in ('in', 'out')
+ assert acquirer.provider == 'buckaroo'
+
+ keys = "add_returndata Brq_amount Brq_culture Brq_currency Brq_invoicenumber Brq_return Brq_returncancel Brq_returnerror Brq_returnreject brq_test Brq_websitekey".split()
+
+ def get_value(key):
+ if values.get(key):
+ return values[key]
+ return ''
+
+ if inout == 'out':
+ if 'BRQ_SIGNATURE' in values:
+ del values['BRQ_SIGNATURE']
+ items = sorted((k.upper(), v) for k, v in values.items())
+ sign = ''.join('%s=%s' % (k, v) for k, v in items)
+ else:
+ sign = ''.join('%s=%s' % (k,get_value(k)) for k in keys)
+ #Add the pre-shared secret key at the end of the signature
+ sign = sign + acquirer.brq_secretkey
+ if isinstance(sign, str):
+ sign = urlparse.parse_qsl(sign)
+ shasign = sha1(sign).hexdigest()
+ return shasign
+
+
+ def buckaroo_form_generate_values(self, cr, uid, id, partner_values, tx_values, context=None):
+ base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
+ acquirer = self.browse(cr, uid, id, context=context)
+ buckaroo_tx_values = dict(tx_values)
+ buckaroo_tx_values.update({
+ 'Brq_websitekey': acquirer.brq_websitekey,
+ 'Brq_amount': tx_values['amount'],
+ 'Brq_currency': tx_values['currency'] and tx_values['currency'].name or '',
+ 'Brq_invoicenumber': tx_values['reference'],
+ 'brq_test' : True,
+ 'Brq_return': '%s' % urlparse.urljoin(base_url, BuckarooController._return_url),
+ 'Brq_returncancel': '%s' % urlparse.urljoin(base_url, BuckarooController._cancel_url),
+ 'Brq_returnerror': '%s' % urlparse.urljoin(base_url, BuckarooController._exception_url),
+ 'Brq_returnreject': '%s' % urlparse.urljoin(base_url, BuckarooController._reject_url),
+ 'Brq_culture': 'en-US',
+ })
+ if buckaroo_tx_values.get('return_url'):
+ buckaroo_tx_values['add_returndata'] = {'return_url': '%s' % buckaroo_tx_values.pop('return_url')}
+ else:
+ buckaroo_tx_values['add_returndata'] = ''
+ buckaroo_tx_values['Brq_signature'] = self._buckaroo_generate_digital_sign(acquirer, 'in', buckaroo_tx_values)
+ return partner_values, buckaroo_tx_values
+
+ def buckaroo_get_form_action_url(self, cr, uid, id, context=None):
+ acquirer = self.browse(cr, uid, id, context=context)
+ return self._get_buckaroo_urls(cr, uid, acquirer.environment, context=context)['buckaroo_form_url']
+
+class TxBuckaroo(osv.Model):
+ _inherit = 'payment.transaction'
+
+ # buckaroo status
+ _buckaroo_valid_tx_status = [190]
+ _buckaroo_pending_tx_status = [790, 791, 792, 793]
+ _buckaroo_cancel_tx_status = [890, 891]
+ _buckaroo_error_tx_status = [490, 491, 492]
+ _buckaroo_reject_tx_status = [690]
+
+ _columns = {
+ 'buckaroo_txnid': fields.char('Transaction ID'),
+ }
+
+
+ # --------------------------------------------------
+ # FORM RELATED METHODS
+ # --------------------------------------------------
+
+ def _buckaroo_form_get_tx_from_data(self, cr, uid, data, context=None):
+ """ Given a data dict coming from buckaroo, verify it and find the related
+ transaction record. """
+ reference, pay_id, shasign = data.get('BRQ_INVOICENUMBER'), data.get('BRQ_PAYMENT'), data.get('BRQ_SIGNATURE')
+ if not reference or not pay_id or not shasign:
+ error_msg = 'Buckaroo: received data with missing reference (%s) or pay_id (%s) or shashign (%s)' % (reference, pay_id, shasign)
+ _logger.error(error_msg)
+ raise ValidationError(error_msg)
+
+ tx_ids = self.search(cr, uid, [('reference', '=', reference)], context=context)
+ if not tx_ids or len(tx_ids) > 1:
+ error_msg = 'Buckaroo: received data for reference %s' % (reference)
+ if not tx_ids:
+ error_msg += '; no order found'
+ else:
+ error_msg += '; multiple order found'
+ _logger.error(error_msg)
+ raise ValidationError(error_msg)
+ tx = self.pool['payment.transaction'].browse(cr, uid, tx_ids[0], context=context)
+
+ #verify shasign
+ shasign_check = self.pool['payment.acquirer']._buckaroo_generate_digital_sign(tx.acquirer_id, 'out' ,data)
+ if shasign_check.upper() != shasign.upper():
+ error_msg = 'Buckaroo: invalid shasign, received %s, computed %s, for data %s' % (shasign, shasign_check, data)
+ _logger.error(error_msg)
+ raise ValidationError(error_msg)
+
+ return tx
+
+ def _buckaroo_form_get_invalid_parameters(self, cr, uid, tx, data, context=None):
+ invalid_parameters = []
+
+ if tx.acquirer_reference and data.get('BRQ_TRANSACTIONS') != tx.acquirer_reference:
+ invalid_parameters.append(('Transaction Id', data.get('BRQ_TRANSACTIONS'), tx.acquirer_reference))
+ # check what is buyed
+ if float_compare(float(data.get('BRQ_AMOUNT', '0.0')), tx.amount, 2) != 0:
+ invalid_parameters.append(('Amount', data.get('BRQ_AMOUNT'), '%.2f' % tx.amount))
+ if data.get('BRQ_CURRENCY') != tx.currency_id.name:
+ invalid_parameters.append(('Currency', data.get('BRQ_CURRENCY'), tx.currency_id.name))
+
+ return invalid_parameters
+
+ def _buckaroo_form_validate(self, cr, uid, tx, data, context=None):
+ status_code = int(data.get('BRQ_STATUSCODE','0'))
+ if status_code in self._buckaroo_valid_tx_status:
+ tx.write({
+ 'state': 'done',
+ 'buckaroo_txnid': data.get('BRQ_TRANSACTIONS'),
+ })
+ return True
+ elif status_code in self._buckaroo_pending_tx_status:
+ tx.write({
+ 'state': 'pending',
+ 'buckaroo_txnid': data.get('BRQ_TRANSACTIONS'),
+ })
+ return True
+ elif status_code in self._buckaroo_cancel_tx_status:
+ tx.write({
+ 'state': 'cancel',
+ 'buckaroo_txnid': data.get('BRQ_TRANSACTIONS'),
+ })
+ return True
+ else:
+ error = 'Buckaroo: feedback error'
+ _logger.info(error)
+ tx.write({
+ 'state': 'error',
+ 'state_message': error,
+ 'buckaroo_txnid': data.get('BRQ_TRANSACTIONS'),
+ })
+ return False
diff --git a/addons/payment_buckaroo/static/description/icon.png b/addons/payment_buckaroo/static/description/icon.png
new file mode 100644
index 00000000000..663fcad1d6d
Binary files /dev/null and b/addons/payment_buckaroo/static/description/icon.png differ
diff --git a/addons/payment_buckaroo/static/src/img/buckaroo_icon.png b/addons/payment_buckaroo/static/src/img/buckaroo_icon.png
new file mode 100644
index 00000000000..819606db730
Binary files /dev/null and b/addons/payment_buckaroo/static/src/img/buckaroo_icon.png differ
diff --git a/addons/payment_buckaroo/static/src/img/logo.png b/addons/payment_buckaroo/static/src/img/logo.png
new file mode 100644
index 00000000000..663fcad1d6d
Binary files /dev/null and b/addons/payment_buckaroo/static/src/img/logo.png differ
diff --git a/addons/payment_buckaroo/tests/__init__.py b/addons/payment_buckaroo/tests/__init__.py
new file mode 100644
index 00000000000..d245ab8339d
--- /dev/null
+++ b/addons/payment_buckaroo/tests/__init__.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+from openerp.addons.payment_buckaroo.tests import test_buckaroo
+
+checks = [
+ test_buckaroo,
+]
diff --git a/addons/payment_buckaroo/tests/test_buckaroo.py b/addons/payment_buckaroo/tests/test_buckaroo.py
new file mode 100644
index 00000000000..b826f3b920e
--- /dev/null
+++ b/addons/payment_buckaroo/tests/test_buckaroo.py
@@ -0,0 +1,178 @@
+# -*- coding: utf-8 -*-
+
+from lxml import objectify
+import urlparse
+
+import openerp
+from openerp.addons.payment.models.payment_acquirer import ValidationError
+from openerp.addons.payment.tests.common import PaymentAcquirerCommon
+from openerp.addons.payment_buckaroo.controllers.main import BuckarooController
+from openerp.tools import mute_logger
+
+
+@openerp.tests.common.at_install(False)
+@openerp.tests.common.post_install(False)
+class BuckarooCommon(PaymentAcquirerCommon):
+
+ def setUp(self):
+ super(BuckarooCommon, self).setUp()
+ cr, uid = self.cr, self.uid
+ self.base_url = self.registry('ir.config_parameter').get_param(cr, uid, 'web.base.url')
+
+ # get the buckaroo account
+ model, self.buckaroo_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'payment_buckaroo', 'payment_acquirer_buckaroo')
+
+
+@openerp.tests.common.at_install(False)
+@openerp.tests.common.post_install(False)
+class BuckarooForm(BuckarooCommon):
+
+ def test_10_Buckaroo_form_render(self):
+ cr, uid, context = self.cr, self.uid, {}
+ # be sure not to do stupid things
+ buckaroo = self.payment_acquirer.browse(self.cr, self.uid, self.buckaroo_id, None)
+ self.assertEqual(buckaroo.environment, 'test', 'test without test environment')
+
+ # ----------------------------------------
+ # Test: button direct rendering
+ # ----------------------------------------
+
+ form_values = {
+ 'add_returndata': None,
+ 'Brq_websitekey': buckaroo.brq_websitekey,
+ 'Brq_amount': '2240.0',
+ 'Brq_currency': 'EUR',
+ 'Brq_invoicenumber': 'SO004',
+ 'Brq_signature': '1b8c10074c622d965272a91a9e88b5b3777d2474', # update me
+ 'brq_test': 'True',
+ 'Brq_return': '%s' % urlparse.urljoin(self.base_url, BuckarooController._return_url),
+ 'Brq_returncancel': '%s' % urlparse.urljoin(self.base_url, BuckarooController._cancel_url),
+ 'Brq_returnerror': '%s' % urlparse.urljoin(self.base_url, BuckarooController._exception_url),
+ 'Brq_returnreject': '%s' % urlparse.urljoin(self.base_url, BuckarooController._reject_url),
+ 'Brq_culture': 'en-US',
+ }
+
+ # render the button
+ res = self.payment_acquirer.render(
+ cr, uid, self.buckaroo_id,
+ 'SO004', 2240.0, self.currency_euro_id,
+ partner_id=None,
+ partner_values=self.buyer_values,
+ context=context)
+
+ # check form result
+ tree = objectify.fromstring(res)
+ self.assertEqual(tree.get('action'), 'https://testcheckout.buckaroo.nl/html/', 'Buckaroo: wrong form POST url')
+ for form_input in tree.input:
+ if form_input.get('name') in ['submit']:
+ continue
+ self.assertEqual(
+ form_input.get('value'),
+ form_values[form_input.get('name')],
+ 'Buckaroo: wrong value for input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')])
+ )
+
+ # ----------------------------------------
+ # Test2: button using tx + validation
+ # ----------------------------------------
+
+ # create a new draft tx
+ tx_id = self.payment_transaction.create(
+ cr, uid, {
+ 'amount': 2240.0,
+ 'acquirer_id': self.buckaroo_id,
+ 'currency_id': self.currency_euro_id,
+ 'reference': 'SO004',
+ 'partner_id': self.buyer_id,
+ }, context=context
+ )
+
+ # render the button
+ res = self.payment_acquirer.render(
+ cr, uid, self.buckaroo_id,
+ 'should_be_erased', 2240.0, self.currency_euro,
+ tx_id=tx_id,
+ partner_id=None,
+ partner_values=self.buyer_values,
+ context=context)
+
+ # check form result
+ tree = objectify.fromstring(res)
+ self.assertEqual(tree.get('action'), 'https://testcheckout.buckaroo.nl/html/', 'Buckaroo: wrong form POST url')
+ for form_input in tree.input:
+ if form_input.get('name') in ['submit']:
+ continue
+ self.assertEqual(
+ form_input.get('value'),
+ form_values[form_input.get('name')],
+ 'Buckaroo: wrong value for form input %s: received %s instead of %s' % (form_input.get('name'), form_input.get('value'), form_values[form_input.get('name')])
+ )
+
+ @mute_logger('openerp.addons.payment_buckaroo.models.buckaroo', 'ValidationError')
+ def test_20_buckaroo_form_management(self):
+ cr, uid, context = self.cr, self.uid, {}
+ # be sure not to do stupid thing
+ buckaroo = self.payment_acquirer.browse(self.cr, self.uid, self.buckaroo_id, None)
+ self.assertEqual(buckaroo.environment, 'test', 'test without test environment')
+
+ # typical data posted by buckaroo after client has successfully paid
+ buckaroo_post_data = {
+ 'BRQ_RETURNDATA': u'',
+ 'BRQ_AMOUNT': u'2240.00',
+ 'BRQ_CURRENCY': u'EUR',
+ 'BRQ_CUSTOMER_NAME': u'Jan de Tester',
+ 'BRQ_INVOICENUMBER': u'SO004',
+ 'BRQ_PAYMENT': u'573311D081B04069BD6336001611DBD4',
+ 'BRQ_PAYMENT_METHOD': u'paypal',
+ 'BRQ_SERVICE_PAYPAL_PAYERCOUNTRY': u'NL',
+ 'BRQ_SERVICE_PAYPAL_PAYEREMAIL': u'fhe@openerp.com',
+ 'BRQ_SERVICE_PAYPAL_PAYERFIRSTNAME': u'Jan',
+ 'BRQ_SERVICE_PAYPAL_PAYERLASTNAME': u'Tester',
+ 'BRQ_SERVICE_PAYPAL_PAYERMIDDLENAME': u'de',
+ 'BRQ_SERVICE_PAYPAL_PAYERSTATUS': u'verified',
+ 'BRQ_SIGNATURE': u'175d82dd53a02bad393fee32cb1eafa3b6fbbd91',
+ 'BRQ_STATUSCODE': u'190',
+ 'BRQ_STATUSCODE_DETAIL': u'S001',
+ 'BRQ_STATUSMESSAGE': u'Transaction successfully processed',
+ 'BRQ_TEST': u'true',
+ 'BRQ_TIMESTAMP': u'2014-05-08 12:41:21',
+ 'BRQ_TRANSACTIONS': u'D6106678E1D54EEB8093F5B3AC42EA7B',
+ 'BRQ_WEBSITEKEY': u'5xTGyGyPyl',
+ }
+
+ # should raise error about unknown tx
+ with self.assertRaises(ValidationError):
+ self.payment_transaction.form_feedback(cr, uid, buckaroo_post_data, 'buckaroo', context=context)
+
+ tx_id = self.payment_transaction.create(
+ cr, uid, {
+ 'amount': 2240.0,
+ 'acquirer_id': self.buckaroo_id,
+ 'currency_id': self.currency_euro_id,
+ 'reference': 'SO004',
+ 'partner_name': 'Norbert Buyer',
+ 'partner_country_id': self.country_france_id,
+ }, context=context
+ )
+ # validate it
+ self.payment_transaction.form_feedback(cr, uid, buckaroo_post_data, 'buckaroo', context=context)
+ # check state
+ tx = self.payment_transaction.browse(cr, uid, tx_id, context=context)
+ self.assertEqual(tx.state, 'done', 'Buckaroo: validation did not put tx into done state')
+ self.assertEqual(tx.buckaroo_txnid, buckaroo_post_data.get('BRQ_TRANSACTIONS'), 'Buckaroo: validation did not update tx payid')
+
+ # reset tx
+ tx.write({'state': 'draft', 'date_validate': False, 'buckaroo_txnid': False})
+
+ # now buckaroo post is ok: try to modify the SHASIGN
+ buckaroo_post_data['BRQ_SIGNATURE'] = '54d928810e343acf5fb0c3ee75fd747ff159ef7a'
+ with self.assertRaises(ValidationError):
+ self.payment_transaction.form_feedback(cr, uid, buckaroo_post_data, 'buckaroo', context=context)
+
+ # simulate an error
+ buckaroo_post_data['BRQ_STATUSCODE'] = 2
+ buckaroo_post_data['BRQ_SIGNATURE'] = '4164b52adb1e6a2221d3d8a39d8c3e18a9ecb90b'
+ self.payment_transaction.form_feedback(cr, uid, buckaroo_post_data, 'buckaroo', context=context)
+ # check state
+ tx = self.payment_transaction.browse(cr, uid, tx_id, context=context)
+ self.assertEqual(tx.state, 'error', 'Buckaroo: erroneous validation did not put tx into error state')
diff --git a/addons/payment_buckaroo/views/buckaroo.xml b/addons/payment_buckaroo/views/buckaroo.xml
new file mode 100644
index 00000000000..567a2691b00
--- /dev/null
+++ b/addons/payment_buckaroo/views/buckaroo.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/payment_buckaroo/views/payment_acquirer.xml b/addons/payment_buckaroo/views/payment_acquirer.xml
new file mode 100644
index 00000000000..4eb294e49c3
--- /dev/null
+++ b/addons/payment_buckaroo/views/payment_acquirer.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+ acquirer.form.buckaroo
+ payment.acquirer
+
+
+
+
+
+
+
+
+
+
+
+
+ acquirer.transaction.form.buckaroo
+ payment.transaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/payment_ogone/views/ogone.xml b/addons/payment_ogone/views/ogone.xml
index be89579c84a..48480da23eb 100644
--- a/addons/payment_ogone/views/ogone.xml
+++ b/addons/payment_ogone/views/ogone.xml
@@ -41,7 +41,7 @@
-