[IMP] Payment and Payment Gateway compatible for Multi Website
This commit is contained in:
parent
aba1a60084
commit
e5d7434bc1
@ -115,6 +115,8 @@ class AcquirerAdyen(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def adyen_form_generate_values(self, values):
|
def adyen_form_generate_values(self, values):
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
# tmp
|
# tmp
|
||||||
import datetime
|
import datetime
|
||||||
from dateutil import relativedelta
|
from dateutil import relativedelta
|
||||||
|
@ -24,6 +24,8 @@ class AuthorizeController(http.Controller):
|
|||||||
request.env['payment.transaction'].sudo().form_feedback(post, 'authorize')
|
request.env['payment.transaction'].sudo().form_feedback(post, 'authorize')
|
||||||
return_url = post.pop('return_url', '/')
|
return_url = post.pop('return_url', '/')
|
||||||
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
# Authorize.Net is expecting a response to the POST sent by their server.
|
# Authorize.Net is expecting a response to the POST sent by their server.
|
||||||
# This response is in the form of a URL that Authorize.Net will pass on to the
|
# This response is in the form of a URL that Authorize.Net will pass on to the
|
||||||
# client's browser to redirect them to the desired location need javascript.
|
# client's browser to redirect them to the desired location need javascript.
|
||||||
|
@ -60,6 +60,8 @@ class PaymentAcquirerAuthorize(models.Model):
|
|||||||
def authorize_form_generate_values(self, values):
|
def authorize_form_generate_values(self, values):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
authorize_tx_values = dict(values)
|
authorize_tx_values = dict(values)
|
||||||
temp_authorize_tx_values = {
|
temp_authorize_tx_values = {
|
||||||
'x_login': self.authorize_login,
|
'x_login': self.authorize_login,
|
||||||
|
@ -84,6 +84,8 @@ class AcquirerBuckaroo(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def buckaroo_form_generate_values(self, values):
|
def buckaroo_form_generate_values(self, values):
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
buckaroo_tx_values = dict(values)
|
buckaroo_tx_values = dict(values)
|
||||||
buckaroo_tx_values.update({
|
buckaroo_tx_values.update({
|
||||||
'Brq_websitekey': self.brq_websitekey,
|
'Brq_websitekey': self.brq_websitekey,
|
||||||
|
@ -150,6 +150,8 @@ class PaymentAcquirerOgone(models.Model):
|
|||||||
|
|
||||||
def ogone_form_generate_values(self, values):
|
def ogone_form_generate_values(self, values):
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
ogone_tx_values = dict(values)
|
ogone_tx_values = dict(values)
|
||||||
temp_ogone_tx_values = {
|
temp_ogone_tx_values = {
|
||||||
'PSPID': self.ogone_pspid,
|
'PSPID': self.ogone_pspid,
|
||||||
|
@ -92,6 +92,8 @@ class AcquirerPaypal(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def paypal_form_generate_values(self, values):
|
def paypal_form_generate_values(self, values):
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
|
|
||||||
paypal_tx_values = dict(values)
|
paypal_tx_values = dict(values)
|
||||||
paypal_tx_values.update({
|
paypal_tx_values.update({
|
||||||
|
@ -56,6 +56,8 @@ class PaymentAcquirerPayumoney(models.Model):
|
|||||||
def payumoney_form_generate_values(self, values):
|
def payumoney_form_generate_values(self, values):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
payumoney_values = dict(values,
|
payumoney_values = dict(values,
|
||||||
key=self.payumoney_merchant_key,
|
key=self.payumoney_merchant_key,
|
||||||
txnid=values['reference'],
|
txnid=values['reference'],
|
||||||
|
@ -68,6 +68,8 @@ class AcquirerSips(models.Model):
|
|||||||
def sips_form_generate_values(self, values):
|
def sips_form_generate_values(self, values):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||||
|
if self.env.ref('base.module_website').state == 'installed':
|
||||||
|
base_url = "http://" + self.env['website'].get_current_website().domain
|
||||||
currency = self.env['res.currency'].sudo().browse(values['currency_id'])
|
currency = self.env['res.currency'].sudo().browse(values['currency_id'])
|
||||||
currency_code = CURRENCY_CODES.get(currency.name, False)
|
currency_code = CURRENCY_CODES.get(currency.name, False)
|
||||||
if not currency_code:
|
if not currency_code:
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
from . import payment
|
||||||
from . import website
|
from . import website
|
||||||
|
10
addons/website_payment/models/payment.py
Normal file
10
addons/website_payment/models/payment.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Part of Flectra. See LICENSE file for full copyright and licensing details.
|
||||||
|
from flectra import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentAcquirer(models.Model):
|
||||||
|
_inherit = "payment.acquirer"
|
||||||
|
|
||||||
|
website_id = fields.Many2many('website', 'website_payment_rel',
|
||||||
|
'website_id', 'payment_id',
|
||||||
|
string='Website')
|
@ -18,5 +18,28 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="website_acquirer_form" model="ir.ui.view">
|
||||||
|
<field name="name">payment.acquirer.form</field>
|
||||||
|
<field name="model">payment.acquirer</field>
|
||||||
|
<field name="inherit_id" ref="payment.acquirer_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='provider']" position='after'>
|
||||||
|
<field name="website_id" widget="many2many_tags"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//group[@name='acquirer_left']" position="after">
|
||||||
|
<group nama="acquirer_right">
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<span>
|
||||||
|
Website is required in order to use payment gateway in e-commerce store.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</flectra>
|
</flectra>
|
||||||
|
@ -254,7 +254,7 @@ class WebsiteSale(http.Controller):
|
|||||||
if attrib_list:
|
if attrib_list:
|
||||||
post['attrib'] = attrib_list
|
post['attrib'] = attrib_list
|
||||||
|
|
||||||
categs = request.env['product.public.category'].search([('parent_id', '=', False), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)])
|
categs = request.env['product.public.category'].search([('parent_id', '=', False), ('website_ids', 'in', request.website.id)])
|
||||||
Product = request.env['product.template']
|
Product = request.env['product.template']
|
||||||
|
|
||||||
parent_category_ids = []
|
parent_category_ids = []
|
||||||
@ -790,7 +790,7 @@ class WebsiteSale(http.Controller):
|
|||||||
)
|
)
|
||||||
|
|
||||||
acquirers = request.env['payment.acquirer'].search(
|
acquirers = request.env['payment.acquirer'].search(
|
||||||
[('website_published', '=', True), ('company_id', '=', order.company_id.id)]
|
[('website_published', '=', True), ('company_id', '=', order.company_id.id), '|', ('website_id', '=', False), ('website_id', '=', request.website.id)]
|
||||||
)
|
)
|
||||||
|
|
||||||
values['access_token'] = order.access_token
|
values['access_token'] = order.access_token
|
||||||
|
Loading…
Reference in New Issue
Block a user