[IMP] payment: distinguish manual from automatic payment acquirers.
Improved validation (manual/automatic) management in ecommerce. bzr revid: tde@openerp.com-20140124144355-6aqhocw0nfo7212a
This commit is contained in:
parent
cc793480fc
commit
aff2b4973f
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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[
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue