diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-01-24 15:43:55 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-01-24 15:43:55 +0100 |
| commit | aff2b4973f538ad3b4e2182ad2512fcfb74f0a58 (patch) | |
| tree | ed596e894dc9d1d2e7cf46cb5d8c62e4ed65a303 /addons | |
| parent | cc793480fcabc5036461e125452ae2905080def0 (diff) | |
[IMP] payment: distinguish manual from automatic payment acquirers.
Improved validation (manual/automatic) management in ecommerce.
bzr revid: tde@openerp.com-20140124144355-6aqhocw0nfo7212a
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 6 | ||||
| -rw-r--r-- | addons/payment_adyen/data/adyen.xml | 3 | ||||
| -rw-r--r-- | addons/payment_ogone/data/ogone.xml | 3 | ||||
| -rw-r--r-- | addons/payment_transfer/data/transfer.xml | 2 | ||||
| -rw-r--r-- | addons/website_sale/controllers/main.py | 19 | ||||
| -rw-r--r-- | addons/website_sale/static/src/js/website_sale_validate.js | 15 | ||||
| -rw-r--r-- | addons/website_sale/views/website_sale.xml | 5 |
7 files changed, 36 insertions, 17 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 1ddca499af7..5c0a9c89eb7 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -57,8 +57,8 @@ class PaymentAcquirer(osv.Model): 'company_id': fields.many2one('res.company', 'Company', required=True), 'pre_msg': fields.html('Message', help='Message displayed to explain and help the payment process.'), 'post_msg': fields.html('Thanks Message', help='Message displayed after having done the payment process.'), - 'process': fields.selection( - [('static', 'Static'), ('dynamic', 'Dynamic')], + 'validation': fields.selection( + [('manual', 'Manual'), ('automatic', 'Automatic')], string='Process Method', help='Static payments are payments like transfer, that require manual steps.'), 'view_template_id': fields.many2one('ir.ui.view', 'Form Button Template', required=True), @@ -79,7 +79,7 @@ class PaymentAcquirer(osv.Model): _defaults = { 'company_id': lambda self, cr, uid, obj, ctx=None: self.pool['res.users'].browse(cr, uid, uid).company_id.id, 'env': 'test', - 'process': 'dynamic', + 'validation': 'dynamic', 'website_published': True, } diff --git a/addons/payment_adyen/data/adyen.xml b/addons/payment_adyen/data/adyen.xml index 92b0cf178b5..8f6e7e218e4 100644 --- a/addons/payment_adyen/data/adyen.xml +++ b/addons/payment_adyen/data/adyen.xml @@ -4,8 +4,11 @@ <record id="payment_acquirer_adyen" model="payment.acquirer"> <field name="name">adyen</field> + <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="adyen_acquirer_button"/> <field name="env">test</field> + <field name="pre_msg"><![CDATA[ +<p>You will be redirected to the Adyen website after cliking on the payment button.</p>]]></field> <field name="adyen_merchant_account">dummy</field> <field name="adyen_skin_code">dummy</field> <field name="adyen_skin_hmac_key">dummy</field> diff --git a/addons/payment_ogone/data/ogone.xml b/addons/payment_ogone/data/ogone.xml index 2c57a361ef6..e94276ba3e1 100644 --- a/addons/payment_ogone/data/ogone.xml +++ b/addons/payment_ogone/data/ogone.xml @@ -4,8 +4,11 @@ <record id="payment_acquirer_ogone" model="payment.acquirer"> <field name="name">ogone</field> + <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="ogone_acquirer_button"/> <field name="env">test</field> + <field name="pre_msg"><![CDATA[ +<p>You will be redirected to the Ogone website after cliking on the payment button.</p>]]></field> <field name='ogone_pspid'>dummy</field> <field name='ogone_userid'>dummy</field> <field name='ogone_password'>dummy</field> diff --git a/addons/payment_transfer/data/transfer.xml b/addons/payment_transfer/data/transfer.xml index 78aae757181..c2863971d34 100644 --- a/addons/payment_transfer/data/transfer.xml +++ b/addons/payment_transfer/data/transfer.xml @@ -4,7 +4,9 @@ <record id="payment_acquirer_transfer" model="payment.acquirer"> <field name="name">transfer</field> + <field name="company_id" ref="base.main_company"/> <field name="view_template_id" ref="transfer_acquirer_button"/> + <field name="validation">manual</field> <field name="env">test</field> <field name="website_published" eval="True"/> <field name="pre_msg"><![CDATA[ diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index f45da77b80d..ed26f90f364 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -635,6 +635,7 @@ class Ecommerce(http.Controller): if not order: return { 'state': 'error', + 'message': '<p>There seems to be an error with your request.</p>', } tx_ids = request.registry['payment.transaction'].search( @@ -643,11 +644,25 @@ class Ecommerce(http.Controller): ], context=context) if not tx_ids: return { - 'state': 'error' + 'state': 'error', + 'message': '<p>There seems to be an error with your request.</p>', } tx = request.registry['payment.transaction'].browse(cr, uid, tx_ids[0], context=context) + state = tx.state + if state == 'done': + message = '<h3>Your payment has been received.</h3>' + elif state == 'cancel': + message = '<h3>The payment seems to have been canceled.</h3>' + elif state == 'pending' and tx.validation == 'manual': + message = '<h3>Your transaction is waiting confirmation.</h3>' + message += tx.post_msg + else: + message = '<h3>Your transaction is waiting confirmation.</h3>' + return { - 'state': tx.state, + 'state': state, + 'message': message, + 'validation': tx.validation } @http.route('/shop/payment/validate/', type='http', auth="public", website=True, multilang=True) diff --git a/addons/website_sale/static/src/js/website_sale_validate.js b/addons/website_sale/static/src/js/website_sale_validate.js index 2543d2e3c55..da917eb1298 100644 --- a/addons/website_sale/static/src/js/website_sale_validate.js +++ b/addons/website_sale/static/src/js/website_sale_validate.js @@ -11,22 +11,15 @@ $(document).ready(function () { return openerp.jsonRpc('/shop/payment/get_status/' + order_id, 'call', { }).then(function (result) { var tx_node = $('div.oe_website_sale_tx_status'); - var txt = '<h3>Your transaction is waiting confirmation.</h3>'; _poll_nbr += 1; - if (result.state == 'pending' && _poll_nbr <= 5) { - txt = "<h3>Your transaction is waiting confirmation.</h3>"; + if (result.state == 'pending' && result.validation == 'automatic' && _poll_nbr <= 5) { + var txt = result.mesage; setTimeout(function () { payment_transaction_poll_status(); }, 1000); } - else if (result.state == 'done') { - txt = "<h3>Your payment has been received.</h3>"; - } - else if (result.state == 'pending') { - txt = "<h3>Your transaction is waiting confirmation. You may try to refresh this page.</h3>"; - } - else if (result.state == 'cancel') { - txt = "<h3>The payment seems to have been canceled.</h3>"; + else { + var txt = result.message; } tx_node.html(txt); }); diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 1d522f53aca..6e1112a57f4 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -960,7 +960,10 @@ </div> <div class="col-lg-3 col-sm-3"> <t t-foreach="acquirers or []" t-as="acquirer"> - <div t-att-data-id="acquirer.id" t-raw="acquirer.button" class="oe_sale_acquirer_button hidden pull-right"/> + <div t-att-data-id="acquirer.id" class="oe_sale_acquirer_button hidden pull-right"> + <div t-raw="acquirer.button"/> + <div t-field="acquirer.pre_msg"/> + </div> </t> </div> </div> |
