[ADD]:Added Upstream patch for payment_authorize
This commit is contained in:
parent
7a27960d56
commit
f26524e7dd
@ -3,3 +3,4 @@
|
||||
|
||||
from . import models
|
||||
from . import controllers
|
||||
from flectra.addons.payment.models.payment_acquirer import create_missing_journal_for_acquirers
|
||||
|
@ -14,4 +14,5 @@
|
||||
'data/payment_acquirer_data.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'post_init_hook': 'create_missing_journal_for_acquirers',
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import time
|
||||
from flectra import _, api, fields, models
|
||||
from flectra.addons.payment.models.payment_acquirer import ValidationError
|
||||
from flectra.addons.payment_authorize.controllers.main import AuthorizeController
|
||||
from flectra.tools.float_utils import float_compare
|
||||
from flectra.tools.float_utils import float_compare, float_repr
|
||||
from flectra.tools.safe_eval import safe_eval
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@ -59,12 +59,21 @@ class PaymentAcquirerAuthorize(models.Model):
|
||||
@api.multi
|
||||
def authorize_form_generate_values(self, values):
|
||||
self.ensure_one()
|
||||
# State code is only supported in US, use state name by default
|
||||
# See https://developer.authorize.net/api/reference/
|
||||
state = values['partner_state'].name if values.get('partner_state') else ''
|
||||
if values.get('partner_country') and values.get('partner_country') == self.env.ref('base.us', False):
|
||||
state = values['partner_state'].code if values.get('partner_state') else ''
|
||||
billing_state = values['billing_partner_state'].name if values.get('billing_partner_state') else ''
|
||||
if values.get('billing_partner_country') and values.get('billing_partner_country') == self.env.ref('base.us', False):
|
||||
billing_state = values['billing_partner_state'].code if values.get('billing_partner_state') else ''
|
||||
|
||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||
authorize_tx_values = dict(values)
|
||||
temp_authorize_tx_values = {
|
||||
'x_login': self.authorize_login,
|
||||
'x_trans_key': self.authorize_transaction_key,
|
||||
'x_amount': str(values['amount']),
|
||||
'x_amount': float_repr(values['amount'], values['currency'].decimal_places if values['currency'] else 2),
|
||||
'x_show_form': 'PAYMENT_FORM',
|
||||
'x_type': 'AUTH_CAPTURE' if not self.capture_manually else 'AUTH_ONLY',
|
||||
'x_method': 'CC',
|
||||
@ -83,7 +92,7 @@ class PaymentAcquirerAuthorize(models.Model):
|
||||
'first_name': values.get('partner_first_name'),
|
||||
'last_name': values.get('partner_last_name'),
|
||||
'phone': values.get('partner_phone'),
|
||||
'state': values.get('partner_state') and values['partner_state'].code or '',
|
||||
'state': state,
|
||||
'billing_address': values.get('billing_partner_address'),
|
||||
'billing_city': values.get('billing_partner_city'),
|
||||
'billing_country': values.get('billing_partner_country') and values.get('billing_partner_country').name or '',
|
||||
@ -92,7 +101,7 @@ class PaymentAcquirerAuthorize(models.Model):
|
||||
'billing_first_name': values.get('billing_partner_first_name'),
|
||||
'billing_last_name': values.get('billing_partner_last_name'),
|
||||
'billing_phone': values.get('billing_partner_phone'),
|
||||
'billing_state': values.get('billing_partner_state') and values['billing_partner_state'].code or '',
|
||||
'billing_state': billing_state,
|
||||
}
|
||||
temp_authorize_tx_values['returndata'] = authorize_tx_values.pop('return_url', '')
|
||||
temp_authorize_tx_values['x_fp_hash'] = self._authorize_generate_hashing(temp_authorize_tx_values)
|
||||
|
@ -51,7 +51,7 @@ class AuthorizeForm(AuthorizeCommon):
|
||||
form_values = {
|
||||
'x_login': self.authorize.authorize_login,
|
||||
'x_trans_key': self.authorize.authorize_transaction_key,
|
||||
'x_amount': '320.0',
|
||||
'x_amount': '56.16',
|
||||
'x_show_form': 'PAYMENT_FORM',
|
||||
'x_type': 'AUTH_CAPTURE',
|
||||
'x_method': 'CC',
|
||||
@ -87,7 +87,7 @@ class AuthorizeForm(AuthorizeCommon):
|
||||
|
||||
form_values['x_fp_hash'] = self._authorize_generate_hashing(form_values)
|
||||
# render the button
|
||||
res = self.authorize.render('SO004', 320.0, self.currency_usd.id, values=self.buyer_values)
|
||||
res = self.authorize.render('SO004', 56.16, self.currency_usd.id, values=self.buyer_values)
|
||||
# check form result
|
||||
tree = objectify.fromstring(res)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user