[FIX] website_sale: payment if free
bzr revid: chm@openerp.com-20140128163815-ksds4a7zox84glv8
This commit is contained in:
parent
df38615ea3
commit
b25a34ea94
|
@ -5,7 +5,7 @@
|
||||||
<template id="adyen_acquirer_button">
|
<template id="adyen_acquirer_button">
|
||||||
<form t-if="acquirer.adyen_merchant_account" t-att-action="tx_url" method="post" target="_self">
|
<form t-if="acquirer.adyen_merchant_account" t-att-action="tx_url" method="post" target="_self">
|
||||||
<input type="hidden" name="merchantReference" t-att-value="tx_values['merchantReference']"/>
|
<input type="hidden" name="merchantReference" t-att-value="tx_values['merchantReference']"/>
|
||||||
<input type="hidden" name="paymentAmount" t-att-value="tx_values['paymentAmount']"/>
|
<input type="hidden" name="paymentAmount" t-att-value="tx_values['paymentAmount'] or '0.0'"/>
|
||||||
<input type="hidden" name="currencyCode" t-att-value="tx_values['currencyCode']"/>
|
<input type="hidden" name="currencyCode" t-att-value="tx_values['currencyCode']"/>
|
||||||
<input type="hidden" name="shipBeforeDate" t-att-value="tx_values['shipBeforeDate']"/>
|
<input type="hidden" name="shipBeforeDate" t-att-value="tx_values['shipBeforeDate']"/>
|
||||||
<input type="hidden" name="skinCode" t-att-value="tx_values['skinCode']"/>
|
<input type="hidden" name="skinCode" t-att-value="tx_values['skinCode']"/>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<input type='hidden' name='PSPID' t-att-value='tx_values["PSPID"]'/>
|
<input type='hidden' name='PSPID' t-att-value='tx_values["PSPID"]'/>
|
||||||
<input type='hidden' name='ORDERID' t-att-value='tx_values["ORDERID"]'/>
|
<input type='hidden' name='ORDERID' t-att-value='tx_values["ORDERID"]'/>
|
||||||
<!-- cart -->
|
<!-- cart -->
|
||||||
<input type='hidden' name='AMOUNT' t-att-value='tx_values["AMOUNT"]'/>
|
<input type='hidden' name='AMOUNT' t-att-value='tx_values["AMOUNT"] or "0.0"'/>
|
||||||
<input type='hidden' name='CURRENCY' t-att-value='tx_values["CURRENCY"]'/>
|
<input type='hidden' name='CURRENCY' t-att-value='tx_values["CURRENCY"]'/>
|
||||||
<!-- buyer -->
|
<!-- buyer -->
|
||||||
<input type='hidden' name='LANGUAGE' t-att-value='tx_values["LANGUAGE"]'/>
|
<input type='hidden' name='LANGUAGE' t-att-value='tx_values["LANGUAGE"]'/>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<input type="hidden" name="business" t-att-value="tx_values['business']"/>
|
<input type="hidden" name="business" t-att-value="tx_values['business']"/>
|
||||||
<input type="hidden" name="item_name" t-att-value="tx_values['item_name']"/>
|
<input type="hidden" name="item_name" t-att-value="tx_values['item_name']"/>
|
||||||
<input type="hidden" name="item_number" t-att-value="tx_values['item_number']"/>
|
<input type="hidden" name="item_number" t-att-value="tx_values['item_number']"/>
|
||||||
<input type="hidden" name="amount" t-att-value="tx_values['amount']"/>
|
<input type="hidden" name="amount" t-att-value="tx_values['amount'] or '0.0'"/>
|
||||||
<input t-if="'handling' in tx_values" type="hidden" name="handling"
|
<input t-if="'handling' in tx_values" type="hidden" name="handling"
|
||||||
t-att-value="tx_values.get('handling')"/>
|
t-att-value="tx_values.get('handling')"/>
|
||||||
<input type="hidden" name="currency_code" t-att-value="tx_values['currency_code']"/>
|
<input type="hidden" name="currency_code" t-att-value="tx_values['currency_code']"/>
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
<input type='hidden' name='return_url' t-att-value='tx_values["return_url"]'/>
|
<input type='hidden' name='return_url' t-att-value='tx_values["return_url"]'/>
|
||||||
</t>
|
</t>
|
||||||
<input type='hidden' name='reference' t-att-value='reference'/>
|
<input type='hidden' name='reference' t-att-value='reference'/>
|
||||||
<input type='hidden' name='amount' t-att-value='amount'/>
|
<input type='hidden' name='amount' t-att-value='amount or "0.0"'/>
|
||||||
<input type='hidden' name='currency' t-att-value='currency.name'/>
|
<input type='hidden' name='currency' t-att-value='currency.name'/>
|
||||||
<!-- submit -->
|
<!-- submit -->
|
||||||
<button type="image" name="submit" width="100px"
|
<button name="submit" width="100px"
|
||||||
t-att-class="submit_class">
|
t-att-class="submit_class">
|
||||||
<img t-if="not submit_txt" src="/payment_transfer/static/src/img/transfer_icon.png"/>
|
<img t-if="not submit_txt" src="/payment_transfer/static/src/img/transfer_icon.png"/>
|
||||||
<span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span>
|
<span t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span>
|
||||||
|
|
|
@ -654,27 +654,35 @@ class Ecommerce(http.Controller):
|
||||||
cr, uid, [
|
cr, uid, [
|
||||||
'|', ('sale_order_id', '=', order.id), ('reference', '=', order.name)
|
'|', ('sale_order_id', '=', order.id), ('reference', '=', order.name)
|
||||||
], context=context)
|
], context=context)
|
||||||
|
|
||||||
if not tx_ids:
|
if not tx_ids:
|
||||||
return {
|
if order.amount_total:
|
||||||
'state': 'error',
|
return {
|
||||||
'message': '<p>There seems to be an error with your request.</p>',
|
'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
|
else:
|
||||||
if state == 'done':
|
state = 'done'
|
||||||
message = '<p>Your payment has been received.</p>'
|
message = ""
|
||||||
elif state == 'cancel':
|
validation = None
|
||||||
message = '<p>The payment seems to have been canceled.</p>'
|
|
||||||
elif state == 'pending' and tx.acquirer_id.validation == 'manual':
|
|
||||||
message = '<p>Your transaction is waiting confirmation.</p>'
|
|
||||||
message += tx.acquirer_id.post_msg
|
|
||||||
else:
|
else:
|
||||||
message = '<p>Your transaction is waiting confirmation.</p>'
|
tx = request.registry['payment.transaction'].browse(cr, uid, tx_ids[0], context=context)
|
||||||
|
state = tx.state
|
||||||
|
if state == 'done':
|
||||||
|
message = '<p>Your payment has been received.</p>'
|
||||||
|
elif state == 'cancel':
|
||||||
|
message = '<p>The payment seems to have been canceled.</p>'
|
||||||
|
elif state == 'pending' and tx.acquirer_id.validation == 'manual':
|
||||||
|
message = '<p>Your transaction is waiting confirmation.</p>'
|
||||||
|
message += tx.acquirer_id.post_msg
|
||||||
|
else:
|
||||||
|
message = '<p>Your transaction is waiting confirmation.</p>'
|
||||||
|
validation = tx.acquirer_id.validation
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'state': state,
|
'state': state,
|
||||||
'message': message,
|
'message': message,
|
||||||
'validation': tx.acquirer_id.validation
|
'validation': validation
|
||||||
}
|
}
|
||||||
|
|
||||||
@http.route('/shop/payment/validate/', type='http', auth="public", website=True, multilang=True)
|
@http.route('/shop/payment/validate/', type='http', auth="public", website=True, multilang=True)
|
||||||
|
@ -690,8 +698,6 @@ class Ecommerce(http.Controller):
|
||||||
|
|
||||||
if transaction_id is None:
|
if transaction_id is None:
|
||||||
tx = context.get('website_sale_transaction')
|
tx = context.get('website_sale_transaction')
|
||||||
if not tx:
|
|
||||||
return request.redirect('/shop/')
|
|
||||||
else:
|
else:
|
||||||
tx = request.registry['payment.transaction'].browse(cr, uid, transaction_id, context=context)
|
tx = request.registry['payment.transaction'].browse(cr, uid, transaction_id, context=context)
|
||||||
|
|
||||||
|
@ -701,7 +707,10 @@ class Ecommerce(http.Controller):
|
||||||
order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context)
|
order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context)
|
||||||
assert order.website_session_id == request.httprequest.session['website_session_id']
|
assert order.website_session_id == request.httprequest.session['website_session_id']
|
||||||
|
|
||||||
if tx.state == 'done':
|
if not tx and order.amount_total:
|
||||||
|
return request.redirect('/shop/')
|
||||||
|
|
||||||
|
if not order.amount_total or tx.state == 'done':
|
||||||
# confirm the quotation
|
# confirm the quotation
|
||||||
sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
|
sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
|
||||||
# send by email
|
# send by email
|
||||||
|
|
|
@ -938,7 +938,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="js_payment mb64 row" t-if="acquirers" id="payment_method">
|
<div class="js_payment mb64 row" t-if="acquirers and website_sale_order.amount_total" id="payment_method">
|
||||||
<div class="col-lg-5 col-sm-6">
|
<div class="col-lg-5 col-sm-6">
|
||||||
<h4>Payment Method:</h4>
|
<h4>Payment Method:</h4>
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
|
@ -962,6 +962,15 @@
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="js_payment mb64 row" t-if="not website_sale_order.amount_total" id="payment_method">
|
||||||
|
<div class="col-lg-8 col-sm-8">
|
||||||
|
<form target="_self" action="/shop/payment/validate/" method="post" class="pull-right">
|
||||||
|
<button width="100px" class="btn btn-primary" name="submit">
|
||||||
|
<span>Pay Now <span class="fa fa-long-arrow-right"></span></span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_structure"/>
|
<div class="oe_structure"/>
|
||||||
|
|
Loading…
Reference in New Issue