[IMP] Payment and Payment Gateway compatible for Multi Website

This commit is contained in:
Kaushal Prajappati 2018-01-17 16:10:51 +05:30
parent aba1a60084
commit e5d7434bc1
12 changed files with 52 additions and 2 deletions

View File

@ -115,6 +115,8 @@ class AcquirerAdyen(models.Model):
@api.multi
def adyen_form_generate_values(self, values):
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
import datetime
from dateutil import relativedelta

View File

@ -24,6 +24,8 @@ class AuthorizeController(http.Controller):
request.env['payment.transaction'].sudo().form_feedback(post, 'authorize')
return_url = post.pop('return_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.
# 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.

View File

@ -60,6 +60,8 @@ class PaymentAcquirerAuthorize(models.Model):
def authorize_form_generate_values(self, values):
self.ensure_one()
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)
temp_authorize_tx_values = {
'x_login': self.authorize_login,

View File

@ -84,6 +84,8 @@ class AcquirerBuckaroo(models.Model):
@api.multi
def buckaroo_form_generate_values(self, values):
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.update({
'Brq_websitekey': self.brq_websitekey,

View File

@ -150,6 +150,8 @@ class PaymentAcquirerOgone(models.Model):
def ogone_form_generate_values(self, values):
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)
temp_ogone_tx_values = {
'PSPID': self.ogone_pspid,

View File

@ -92,6 +92,8 @@ class AcquirerPaypal(models.Model):
@api.multi
def paypal_form_generate_values(self, values):
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.update({

View File

@ -56,6 +56,8 @@ class PaymentAcquirerPayumoney(models.Model):
def payumoney_form_generate_values(self, values):
self.ensure_one()
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,
key=self.payumoney_merchant_key,
txnid=values['reference'],

View File

@ -68,6 +68,8 @@ class AcquirerSips(models.Model):
def sips_form_generate_values(self, values):
self.ensure_one()
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_code = CURRENCY_CODES.get(currency.name, False)
if not currency_code:

View File

@ -1 +1,2 @@
from . import payment
from . import website

View 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')

View File

@ -18,5 +18,28 @@
</xpath>
</field>
</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>
</flectra>

View File

@ -254,7 +254,7 @@ class WebsiteSale(http.Controller):
if 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']
parent_category_ids = []
@ -790,7 +790,7 @@ class WebsiteSale(http.Controller):
)
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