[ADD]:Added Upstream Patch for pos_mercury

This commit is contained in:
Fatemi Lokhandwala 2018-07-10 13:09:12 +05:30
parent c8ce027ecb
commit 79aad71e3f
4 changed files with 13 additions and 6 deletions

View File

@ -5,8 +5,8 @@
<!-- This is a test account for testing with test cards and cannot be used in a live environment -->
<record id="pos_mercury_configuration" model="pos_mercury.configuration">
<field name="name">Mercury Demo</field>
<field name="merchant_id">334160</field>
<field name="merchant_pwd">81303DUR</field>
<field name="merchant_id">755847002</field>
<field name="merchant_pwd">xyz</field>
</record>
</data>
</flectra>

View File

@ -4,6 +4,7 @@
import logging
from flectra import models, fields, api, _
from flectra.tools.float_utils import float_compare
_logger = logging.getLogger(__name__)
@ -71,8 +72,9 @@ class PosOrder(models.Model):
statement_id = super(PosOrder, self).add_payment(data)
statement_lines = self.env['account.bank.statement.line'].search([('statement_id', '=', statement_id),
('pos_statement_id', '=', self.id),
('journal_id', '=', data['journal']),
('amount', '=', data['amount'])])
('journal_id', '=', data['journal'])])
statement_lines = statement_lines.filtered(lambda line: float_compare(line.amount, data['amount'],
precision_rounding=line.journal_currency_id.rounding) == 0)
# we can get multiple statement_lines when there are >1 credit
# card payments with the same amount. In that case it doesn't

View File

@ -61,11 +61,15 @@ class MercuryTransaction(models.Model):
'SOAPAction': 'http://www.mercurypay.com/CreditTransaction',
}
url = 'https://w1.mercurypay.com/ws/ws.asmx'
if self.env['ir.config_parameter'].sudo().get_param('pos_mercury.enable_test_env'):
url = 'https://w1.mercurycert.net/ws/ws.asmx'
try:
r = requests.post('https://w1.mercurypay.com/ws/ws.asmx', data=xml_transaction, headers=headers, timeout=65)
r = requests.post(url, data=xml_transaction, headers=headers, timeout=65)
r.raise_for_status()
response = werkzeug.utils.unescape(r.content.decode())
except:
except Exception:
response = "timeout"
return response

View File

@ -449,6 +449,7 @@ PaymentScreenWidget.include({
order.selected_paymentline.paid = true;
order.selected_paymentline.mercury_swipe_pending = false;
order.selected_paymentline.mercury_amount = response.authorize;
order.selected_paymentline.set_amount(response.authorize);
order.selected_paymentline.mercury_card_number = decodedMagtek['number'];
order.selected_paymentline.mercury_card_brand = response.card_type;
order.selected_paymentline.mercury_card_owner_name = decodedMagtek['name'];