summaryrefslogtreecommitdiff
path: root/addons/website_payment
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-08-08 15:37:24 +0200
committerThibault Delavallée <tde@odoo.com>2017-08-08 15:38:04 +0200
commit79f362d067fd34f05e7383ab0796bdd7cf325079 (patch)
tree4197017f91c9c402677451c26b5661b78c7d68c9 /addons/website_payment
parent9456c7b332c417c8461ab92abc18b309fb208720 (diff)
[MOV] (website_)payment: move customer portal for payments to payment
Customer portal controller and templates contained in website_payment module are moved to payment. This module now uses the customer portal defined in portal module and most of website_payment code is moved to payment. website_payment now contain code really related to website, such as payment acquirers configuration for website.
Diffstat (limited to 'addons/website_payment')
-rw-r--r--addons/website_payment/__init__.py1
-rw-r--r--addons/website_payment/controllers/__init__.py1
-rw-r--r--addons/website_payment/controllers/main.py114
-rw-r--r--addons/website_payment/static/lib/jquery.payment/jquery.payment.js497
-rw-r--r--addons/website_payment/static/src/css/website_payment.css46
-rw-r--r--addons/website_payment/static/src/css/website_payment.sass41
-rw-r--r--addons/website_payment/static/src/js/payment_acquirer.js117
-rw-r--r--addons/website_payment/static/src/js/payment_transaction.js26
-rw-r--r--addons/website_payment/views/website_payment_templates.xml171
9 files changed, 11 insertions, 1003 deletions
diff --git a/addons/website_payment/__init__.py b/addons/website_payment/__init__.py
index 8c67f893b37..dc5e6b693d1 100644
--- a/addons/website_payment/__init__.py
+++ b/addons/website_payment/__init__.py
@@ -2,4 +2,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
-from . import controllers
diff --git a/addons/website_payment/controllers/__init__.py b/addons/website_payment/controllers/__init__.py
deleted file mode 100644
index 12a7e529b67..00000000000
--- a/addons/website_payment/controllers/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from . import main
diff --git a/addons/website_payment/controllers/main.py b/addons/website_payment/controllers/main.py
deleted file mode 100644
index f3548e9090f..00000000000
--- a/addons/website_payment/controllers/main.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# -*- coding: utf-8 -*-
-# Part of Odoo. See LICENSE file for full copyright and licensing details.
-
-from odoo import http, _
-from odoo.http import request
-
-
-class WebsitePayment(http.Controller):
- @http.route(['/my/payment_method'], type='http', auth="user", website=True)
- def payment_method(self, **kwargs):
- acquirers = list(request.env['payment.acquirer'].search([('website_published', '=', True), ('registration_view_template_id', '!=', False)]))
- partner = request.env.user.partner_id
- payment_tokens = partner.payment_token_ids
- payment_tokens |= partner.commercial_partner_id.sudo().payment_token_ids
- values = {
- 'pms': payment_tokens,
- 'acquirers': acquirers
- }
- return_url = request.params.get('redirect', '/my/payment_method')
- for acquirer in acquirers:
- acquirer.form = acquirer.sudo()._registration_render(request.env.user.partner_id.id, {'error': {}, 'error_message': [], 'return_url': return_url, 'json': False, 'bootstrap_formatting': True, 'verify_validity': True})
- return request.render("website_payment.pay_methods", values)
-
- @http.route(['/website_payment/delete/'], methods=['POST'], type='http', auth="user", website=True)
- def delete(self, delete_pm_id=None):
- if delete_pm_id:
- pay_meth = request.env['payment.token'].browse(int(delete_pm_id))
- pay_meth.unlink()
- return request.redirect('/my/payment_method')
-
- @http.route(['/website_payment/pay'], type='http', auth='public', website=True)
- def pay(self, reference='', amount=False, currency_id=None, acquirer_id=None, **kw):
- env = request.env
- user = env.user.sudo()
-
- currency_id = currency_id and int(currency_id) or user.company_id.currency_id.id
- currency = env['res.currency'].browse(currency_id)
-
- # Try default one then fallback on first
- acquirer_id = acquirer_id and int(acquirer_id) or \
- env['ir.values'].get_default('payment.transaction', 'acquirer_id', company_id=user.company_id.id) or \
- env['payment.acquirer'].search([('website_published', '=', True), ('company_id', '=', user.company_id.id)])[0].id
-
- acquirer = env['payment.acquirer'].with_context(submit_class='btn btn-primary pull-right',
- submit_txt=_('Pay Now')).browse(acquirer_id)
- # auto-increment reference with a number suffix if the reference already exists
- reference = request.env['payment.transaction'].get_next_reference(reference)
-
- partner_id = user.partner_id.id if user.partner_id.id != request.website.partner_id.id else False
-
- payment_form = acquirer.sudo().render(reference, float(amount), currency.id, values={'return_url': '/website_payment/confirm', 'partner_id': partner_id})
- values = {
- 'reference': reference,
- 'acquirer': acquirer,
- 'currency': currency,
- 'amount': float(amount),
- 'payment_form': payment_form,
- }
- return request.render('website_payment.pay', values)
-
- @http.route(['/website_payment/transaction'], type='json', auth="public", website=True)
- def transaction(self, reference, amount, currency_id, acquirer_id):
- partner_id = request.env.user.partner_id.id if request.env.user.partner_id != request.website.partner_id else False
- values = {
- 'acquirer_id': int(acquirer_id),
- 'reference': reference,
- 'amount': float(amount),
- 'currency_id': int(currency_id),
- 'partner_id': partner_id,
- }
-
- tx = request.env['payment.transaction'].sudo().create(values)
- request.session['website_payment_tx_id'] = tx.id
- return tx.id
-
- @http.route(['/website_payment/confirm'], type='http', auth='public', website=True)
- def confirm(self, **kw):
- tx_id = request.session.pop('website_payment_tx_id', False)
- if tx_id:
- tx = request.env['payment.transaction'].browse(tx_id)
- if tx.state == 'done':
- status = 'success'
- message = tx.acquirer_id.done_msg
- elif tx.state == 'pending':
- status = 'warning'
- message = tx.acquirer_id.pending_msg
- else:
- status = 'danger'
- message = tx.acquirer_id.error_msg
- return request.render('website_payment.confirm', {'tx': tx, 'status': status, 'message': message})
- else:
- return request.redirect('/my/home')
-
- @http.route(['/website_payment/get_linked_records'], type='json', auth='user', website=True)
- def get_linked_records(self, payment_token_id):
- payment_token_id = int(payment_token_id)
-
- res = []
- token = request.env['payment.token'].search([('id','=',payment_token_id)])
- # if the payment token is valid
- if token:
- # then we retrieve the description for the model sale.subscription
- subscription_description = request.env['sale.subscription']._description
- # we retrieve all the linked records for the token
- records = token._get_linked_records()
- # transform the list of tuple into a dict so we can search easily
- records = dict(records[payment_token_id])
- # if there's subscriptions linked to that token
- if records.get(subscription_description):
- subscriptions = records[subscription_description]
- # we create our json with all the info needed
- for r in subscriptions:
- res.append({'id': r.id, 'name': r.name})
- return res \ No newline at end of file
diff --git a/addons/website_payment/static/lib/jquery.payment/jquery.payment.js b/addons/website_payment/static/lib/jquery.payment/jquery.payment.js
deleted file mode 100644
index c81c6e00d81..00000000000
--- a/addons/website_payment/static/lib/jquery.payment/jquery.payment.js
+++ /dev/null
@@ -1,497 +0,0 @@
-// Generated by CoffeeScript 1.4.0
-(function() {
- var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType,
- __slice = [].slice,
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
- _this = this;
-
- $ = jQuery;
-
- $.payment = {};
-
- $.payment.fn = {};
-
- $.fn.payment = function() {
- var args, method;
- method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- return $.payment.fn[method].apply(this, args);
- };
-
- defaultFormat = /(\d{1,4})/g;
-
- cards = [
- {
- type: 'maestro',
- pattern: /^(5018|5020|5038|6304|6759|676[1-3])/,
- format: defaultFormat,
- length: [12, 13, 14, 15, 16, 17, 18, 19],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'dinersclub',
- pattern: /^(36|38|30[0-5])/,
- format: defaultFormat,
- length: [14],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'laser',
- pattern: /^(6706|6771|6709)/,
- format: defaultFormat,
- length: [16, 17, 18, 19],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'jcb',
- pattern: /^35/,
- format: defaultFormat,
- length: [16],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'unionpay',
- pattern: /^62/,
- format: defaultFormat,
- length: [16, 17, 18, 19],
- cvcLength: [3],
- luhn: false
- }, {
- type: 'discover',
- pattern: /^(6011|65|64[4-9]|622)/,
- format: defaultFormat,
- length: [16],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'mastercard',
- pattern: /^5[1-5]/,
- format: defaultFormat,
- length: [16],
- cvcLength: [3],
- luhn: true
- }, {
- type: 'amex',
- pattern: /^3[47]/,
- format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
- length: [15],
- cvcLength: [3, 4],
- luhn: true
- }, {
- type: 'visa',
- pattern: /^4/,
- format: defaultFormat,
- length: [13, 14, 15, 16],
- cvcLength: [3],
- luhn: true
- }
- ];
-
- cardFromNumber = function(num) {
- var card, _i, _len;
- num = (num + '').replace(/\D/g, '');
- for (_i = 0, _len = cards.length; _i < _len; _i++) {
- card = cards[_i];
- if (card.pattern.test(num)) {
- return card;
- }
- }
- };
-
- cardFromType = function(type) {
- var card, _i, _len;
- for (_i = 0, _len = cards.length; _i < _len; _i++) {
- card = cards[_i];
- if (card.type === type) {
- return card;
- }
- }
- };
-
- luhnCheck = function(num) {
- var digit, digits, odd, sum, _i, _len;
- odd = true;
- sum = 0;
- digits = (num + '').split('').reverse();
- for (_i = 0, _len = digits.length; _i < _len; _i++) {
- digit = digits[_i];
- digit = parseInt(digit, 10);
- if ((odd = !odd)) {
- digit *= 2;
- }
- if (digit > 9) {
- digit -= 9;
- }
- sum += digit;
- }
- return sum % 10 === 0;
- };
-
- hasTextSelected = function($target) {
- var _ref;
- if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
- return true;
- }
- if (typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? typeof _ref.createRange === "function" ? _ref.createRange().text : void 0 : void 0 : void 0) {
- return true;
- }
- return false;
- };
-
- reFormatCardNumber = function(e) {
- var _this = this;
- return setTimeout(function() {
- var $target, value;
- $target = $(e.currentTarget);
- value = $target.val();
- value = $.payment.formatCardNumber(value);
- return $target.val(value);
- });
- };
-
- formatCardNumber = function(e) {
- var $target, card, digit, length, re, upperLength, value;
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- $target = $(e.currentTarget);
- value = $target.val();
- card = cardFromNumber(value + digit);
- length = (value.replace(/\D/g, '') + digit).length;
- upperLength = 16;
- if (card) {
- upperLength = card.length[card.length.length - 1];
- }
- if (length >= upperLength) {
- return;
- }
- if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
- return;
- }
- if (card && card.type === 'amex') {
- re = /^(\d{4}|\d{4}\s\d{6})$/;
- } else {
- re = /(?:^|\s)(\d{4})$/;
- }
- if (re.test(value)) {
- e.preventDefault();
- return $target.val(value + ' ' + digit);
- } else if (re.test(value + digit)) {
- e.preventDefault();
- return $target.val(value + digit + ' ');
- }
- };
-
- formatBackCardNumber = function(e) {
- var $target, value;
- $target = $(e.currentTarget);
- value = $target.val();
- if (e.meta) {
- return;
- }
- if (e.which !== 8) {
- return;
- }
- if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
- return;
- }
- if (/\d\s$/.test(value)) {
- e.preventDefault();
- return $target.val(value.replace(/\d\s$/, ''));
- } else if (/\s\d?$/.test(value)) {
- e.preventDefault();
- return $target.val(value.replace(/\s\d?$/, ''));
- }
- };
-
- formatExpiry = function(e) {
- var $target, digit, val;
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- $target = $(e.currentTarget);
- val = $target.val() + digit;
- if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
- e.preventDefault();
- return $target.val("0" + val + " / ");
- } else if (/^\d\d$/.test(val)) {
- e.preventDefault();
- return $target.val("" + val + " / ");
- }
- };
-
- formatForwardExpiry = function(e) {
- var $target, digit, val;
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- $target = $(e.currentTarget);
- val = $target.val();
- if (/^\d\d$/.test(val)) {
- return $target.val("" + val + " / ");
- }
- };
-
- formatForwardSlash = function(e) {
- var $target, slash, val;
- slash = String.fromCharCode(e.which);
- if (slash !== '/') {
- return;
- }
- $target = $(e.currentTarget);
- val = $target.val();
- if (/^\d$/.test(val) && val !== '0') {
- return $target.val("0" + val + " / ");
- }
- };
-
- formatBackExpiry = function(e) {
- var $target, value;
- if (e.meta) {
- return;
- }
- $target = $(e.currentTarget);
- value = $target.val();
- if (e.which !== 8) {
- return;
- }
- if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
- return;
- }
- if (/\d(\s|\/)+$/.test(value)) {
- e.preventDefault();
- return $target.val(value.replace(/\d(\s|\/)*$/, ''));
- } else if (/\s\/\s?\d?$/.test(value)) {
- e.preventDefault();
- return $target.val(value.replace(/\s\/\s?\d?$/, ''));
- }
- };
-
- restrictNumeric = function(e) {
- var input;
- if (e.metaKey || e.ctrlKey) {
- return true;
- }
- if (e.which === 32) {
- return false;
- }
- if (e.which === 0) {
- return true;
- }
- if (e.which < 33) {
- return true;
- }
- input = String.fromCharCode(e.which);
- return !!/[\d\s]/.test(input);
- };
-
- restrictCardNumber = function(e) {
- var $target, card, digit, value;
- $target = $(e.currentTarget);
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- if (hasTextSelected($target)) {
- return;
- }
- value = ($target.val() + digit).replace(/\D/g, '');
- card = cardFromNumber(value);
- if (card) {
- return value.length <= card.length[card.length.length - 1];
- } else {
- return value.length <= 16;
- }
- };
-
- restrictExpiry = function(e) {
- var $target, digit, value;
- $target = $(e.currentTarget);
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- if (hasTextSelected($target)) {
- return;
- }
- value = $target.val() + digit;
- value = value.replace(/\D/g, '');
- if (value.length > 6) {
- return false;
- }
- };
-
- restrictCVC = function(e) {
- var $target, digit, val;
- $target = $(e.currentTarget);
- digit = String.fromCharCode(e.which);
- if (!/^\d+$/.test(digit)) {
- return;
- }
- val = $target.val() + digit;
- return val.length <= 4;
- };
-
- setCardType = function(e) {
- var $target, allTypes, card, cardType, val;
- $target = $(e.currentTarget);
- val = $target.val();
- cardType = $.payment.cardType(val) || 'unknown';
- if (!$target.hasClass(cardType)) {
- allTypes = (function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = cards.length; _i < _len; _i++) {
- card = cards[_i];
- _results.push(card.type);
- }
- return _results;
- })();
- $target.removeClass('unknown');
- $target.removeClass(allTypes.join(' '));
- $target.addClass(cardType);
- $target.toggleClass('identified', cardType !== 'unknown');
- return $target.trigger('payment.cardType', cardType);
- }
- };
-
- $.payment.fn.formatCardCVC = function() {
- this.payment('restrictNumeric');
- this.on('keypress', restrictCVC);
- return this;
- };
-
- $.payment.fn.formatCardExpiry = function() {
- this.payment('restrictNumeric');
- this.on('keypress', restrictExpiry);
- this.on('keypress', formatExpiry);
- this.on('keypress', formatForwardSlash);
- this.on('keypress', formatForwardExpiry);
- this.on('keydown', formatBackExpiry);
- return this;
- };
-
- $.payment.fn.formatCardNumber = function() {
- this.payment('restrictNumeric');
- this.on('keypress', restrictCardNumber);
- this.on('keypress', formatCardNumber);
- this.on('keydown', formatBackCardNumber);
- this.on('keyup', setCardType);
- this.on('paste', reFormatCardNumber);
- return this;
- };
-
- $.payment.fn.restrictNumeric = function() {
- this.on('keypress', restrictNumeric);
- return this;
- };
-
- $.payment.fn.cardExpiryVal = function() {
- return $.payment.cardExpiryVal($(this).val());
- };
-
- $.payment.cardExpiryVal = function(value) {
- var month, prefix, year, _ref;
- value = value.replace(/\s/g, '');
- _ref = value.split('/', 2), month = _ref[0], year = _ref[1];
- if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
- prefix = (new Date).getFullYear();
- prefix = prefix.toString().slice(0, 2);
- year = prefix + year;
- }
- month = parseInt(month, 10);
- year = parseInt(year, 10);
- return {
- month: month,
- year: year
- };
- };
-
- $.payment.validateCardNumber = function(num) {
- var card, _ref;
- num = (num + '').replace(/\s+|-/g, '');
- if (!/^\d+$/.test(num)) {
- return false;
- }
- card = cardFromNumber(num);
- if (!card) {
- return false;
- }
- return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
- };
-
- $.payment.validateCardExpiry = function(month, year) {
- var currentTime, expiry, prefix, _ref;
- if (typeof month === 'object' && 'month' in month) {
- _ref = month, month = _ref.month, year = _ref.year;
- }
- if (!(month && year)) {
- return false;
- }
- month = $.trim(month);
- year = $.trim(year);
- if (!/^\d+$/.test(month)) {
- return false;
- }
- if (!/^\d+$/.test(year)) {
- return false;
- }
- if (!(parseInt(month, 10) <= 12)) {
- return false;
- }
- if (year.length === 2) {
- prefix = (new Date).getFullYear();
- prefix = prefix.toString().slice(0, 2);
- year = prefix + year;
- }
- expiry = new Date(year, month);
- currentTime = new Date;
- expiry.setMonth(expiry.getMonth() - 1);
- expiry.setMonth(expiry.getMonth() + 1, 1);
- return expiry > currentTime;
- };
-
- $.payment.validateCardCVC = function(cvc, type) {
- var _ref, _ref1;
- cvc = $.trim(cvc);
- if (!/^\d+$/.test(cvc)) {
- return false;
- }
- if (type) {
- return _ref = cvc.length, __indexOf.call((_ref1 = cardFromType(type)) != null ? _ref1.cvcLength : void 0, _ref) >= 0;
- } else {
- return cvc.length >= 3 && cvc.length <= 4;
- }
- };
-
- $.payment.cardType = function(num) {
- var _ref;
- if (!num) {
- return null;
- }
- return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
- };
-
- $.payment.formatCardNumber = function(num) {
- var card, groups, upperLength, _ref;
- card = cardFromNumber(num);
- if (!card) {
- return num;
- }
- upperLength = card.length[card.length.length - 1];
- num = num.replace(/\D/g, '');
- num = num.slice(0, +upperLength + 1 || 9e9);
- if (card.format.global) {
- return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
- } else {
- groups = card.format.exec(num);
- if (groups != null) {
- groups.shift();
- }
- return groups != null ? groups.join(' ') : void 0;
- }
- };
-
-}).call(this);
diff --git a/addons/website_payment/static/src/css/website_payment.css b/addons/website_payment/static/src/css/website_payment.css
deleted file mode 100644
index 1892700fdd0..00000000000
--- a/addons/website_payment/static/src/css/website_payment.css
+++ /dev/null
@@ -1,46 +0,0 @@
-input#cc_number {
- background-repeat: no-repeat;
- background-position: 14px 14px; }
-
-div.card_placeholder {
- background-image: url("/website_payment/static/src/img/placeholder.png");
- background-repeat: no-repeat;
- width: 32px;
- height: 20px;
- position: absolute;
- top: 34px;
- right: 20px;
- -webkit-transition: 0.4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
- transition: 0.4s cubic-bezier(0.455, 0.03, 0.515, 0.955);
- pointer-events: none; }
-
-div.amex {
- background-image: url("/website_payment/static/src/img/amex.png");
- background-repeat: no-repeat; }
-
-div.diners {
- background-image: url("/website_payment/static/src/img/diners.png");
- background-repeat: no-repeat; }
-
-div.discover {
- background-image: url("/website_payment/static/src/img/discover.png");
- background-repeat: no-repeat; }
-
-div.jcb {
- background-image: url("/website_payment/static/src/img/jcb.png");
- background-repeat: no-repeat; }
-
-div.mastercard {
- background-image: url("/website_payment/static/src/img/mastercard.png");
- background-repeat: no-repeat; }
-
-div.visa {
- background-image: url("/website_payment/static/src/img/visa.png");
- background-repeat: no-repeat; }
-
-/*# sourceMappingURL=website_payment.css.map */
-
-ul.payment_method_list img.img-rounded {
- max-width: 100px;
- max-height: 40px;
-}
diff --git a/addons/website_payment/static/src/css/website_payment.sass b/addons/website_payment/static/src/css/website_payment.sass
deleted file mode 100644
index a396bae99c1..00000000000
--- a/addons/website_payment/static/src/css/website_payment.sass
+++ /dev/null
@@ -1,41 +0,0 @@
-@charset "utf-8"
-
-input#cc_number
- background-repeat: no-repeat
- background-position: 14px 14px
-
-div.card_placeholder
- background-image: url('/website_payment/static/src/img/placeholder.png')
- background-repeat: no-repeat
- width: 32px
- height: 20px
- position: absolute
- top: 34px
- right: 20px
- -webkit-transition: .4s cubic-bezier(0.455,0.03,0.515,0.955)
- transition: .4s cubic-bezier(0.455,0.03,0.515,0.955)
- pointer-events: none
-
-div.amex
- background-image: url('/website_payment/static/src/img/amex.png')
- background-repeat: no-repeat
-
-div.diners
- background-image: url('/website_payment/static/src/img/diners.png')
- background-repeat: no-repeat
-
-div.discover
- background-image: url('/website_payment/static/src/img/discover.png')
- background-repeat: no-repeat
-
-div.jcb
- background-image: url('/website_payment/static/src/img/jcb.png')
- background-repeat: no-repeat
-
-div.mastercard
- background-image: url('/website_payment/static/src/img/mastercard.png')
- background-repeat: no-repeat
-
-div.visa
- background-image: url('/website_payment/static/src/img/visa.png')
- background-repeat: no-repeat
diff --git a/addons/website_payment/static/src/js/payment_acquirer.js b/addons/website_payment/static/src/js/payment_acquirer.js
deleted file mode 100644
index 357159ea17b..00000000000
--- a/addons/website_payment/static/src/js/payment_acquirer.js
+++ /dev/null
@@ -1,117 +0,0 @@
-$(document).ready(function () {
-
- $('input#cc_number').payment('formatCardNumber');
- $('input#cc_cvc').payment('formatCardCVC');
- $('input#cc_expiry').payment('formatCardExpiry')
-
- $('input#cc_number').on('focusout', function (e) {
- var valid_value = $.payment.validateCardNumber(this.value);
- var card_type = $.payment.cardType(this.value);
- if (card_type) {
- $(this).parent('.form-group').children('.card_placeholder').removeClass().addClass('card_placeholder ' + card_type);
- $(this).parent('.form-group').children('input[name="cc_brand"]').val(card_type)
- }
- else {
- $(this).parent('.form-group').children('.card_placeholder').removeClass().addClass('card_placeholder');
- }
- if (valid_value) {
- $(this).parent('.form-group').addClass('has-success');
- $(this).parent('.form-group').removeClass('has-error');
- }
- else {
- $(this).parent('.form-group').addClass('has-error');
- $(this).parent('.form-group').removeClass('has-success');
- }
- });
-
- $('input#cc_cvc').on('focusout', function (e) {
- var cc_nbr = $(this).parents('.oe_cc').find('#cc_number').val();
- var card_type = $.payment.cardType(cc_nbr);
- var valid_value = $.payment.validateCardCVC(this.value, card_type);
- if (valid_value) {
- $(this).parent('.form-group').addClass('has-success');
- $(this).parent('.form-group').removeClass('has-error');
- }
- else {
- $(this).parent('.form-group').addClass('has-error');
- $(this).parent('.form-group').removeClass('has-success');
- }
- });
-
- $('input#cc_expiry').on('focusout', function (e) {
- var expiry_value = $.payment.cardExpiryVal(this.value);
- var month = expiry_value.month || '';
- var year = expiry_value.year || '';
- var valid_value = $.payment.validateCardExpiry(month, year);
- if (valid_value) {
- $(this).parent('.form-group').addClass('has-success');
- $(this).parent('.form-group').removeClass('has-error');
- }
- else {
- $(this).parent('.form-group').addClass('has-error');
- $(this).parent('.form-group').removeClass('has-success');
- }
- });
-
- $('select[name="pm_acquirer_id"]').on('change', function() {
- var acquirer_id = $(this).val();
- $('.acquirer').addClass('hidden');
- $('.acquirer[data-acquirer-id="'+acquirer_id+'"]').removeClass('hidden');
- });
-
-});
-
-
-odoo.define('website_payment.payment_acquirer', function (require) {
-"use strict";
-
-var ajax = require('web.ajax');
-var Dialog = require('web.Dialog');
-var website = require('website.website');
-
- var payment_methods = $('#payment_tokens_list');
-
- payment_methods.find('button[name="delete_pm_id"]').on('click', function(ev){
- ev.stopPropagation();
- ev.preventDefault();
- var self = this;
-
- // we retrieve the selected payment method id
- var payment_method_id = ev.target.value;
-
- var Delete = function()
- {
- payment_methods.find('button[name="delete_pm_id"]').off("click");
- ev.target.click();
- };
-
- ajax.jsonRpc('/website_payment/get_linked_records', 'call', {
- 'payment_token_id': payment_method_id,
- }).done(function (response) {
- // if there's records linked to the payment method we're trying to delete
- if(response.length > 0)
- {
- var content = '';
-
- response.forEach(function(sub) {
- content += '<p><a href="/my/subscription/' + sub.id + '">' + sub.name + '</a><p/>';
- });
-
- content = $('<div>').html('<p>This card is currently linked to the following records:<p/>' + content);
- // Then we display the list of the records and ask the user if he really want to remove the ppayment method.
- new Dialog(self, {
- title: 'Warning!',
- size: 'medium',
- $content: content,
- buttons: [
- {text: 'Confirm Deletion', classes: 'btn-primary', close: true, click: Delete},
- {text: 'Cancel', close: true}]}).open();
- }
- // otherwise if the user has no records linked to this payment method, then we just delete it.
- else
- {
- Delete();
- }
- });
- });
-});
diff --git a/addons/website_payment/static/src/js/payment_transaction.js b/addons/website_payment/static/src/js/payment_transaction.js
deleted file mode 100644
index 79e6584f515..00000000000
--- a/addons/website_payment/static/src/js/payment_transaction.js
+++ /dev/null
@@ -1,26 +0,0 @@
-odoo.define('website_payment.website_payment', function (require) {
-"use strict";
-
-var ajax = require('web.ajax');
-var website = require('website.website');
-
-if(!$('.o_website_payment').length) {
- return $.Deferred().reject("DOM doesn't contain '.o_website_payment'");
-}
-
-// When clicking on payment button: create the tx using json then continue to the acquirer
-var $payment = $(".o_website_payment_form");
-$payment.on("click", 'button[type="submit"],button[name="submit"]', function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- $(ev.currentTarget).attr('disabled', true);
- $(ev.currentTarget).prepend('<i class="fa fa-refresh fa-spin"></i> ');
- var $form = $(ev.currentTarget).parents('form');
- var data =$("div[class~='o_website_payment_new_payment']").data();
- console.log(data);
- ajax.jsonRpc('/website_payment/transaction/', 'call', data).then(function (result) {
- $form.submit();
- });
-});
-
-});
diff --git a/addons/website_payment/views/website_payment_templates.xml b/addons/website_payment/views/website_payment_templates.xml
index ba012478c79..9b7a784ac28 100644
--- a/addons/website_payment/views/website_payment_templates.xml
+++ b/addons/website_payment/views/website_payment_templates.xml
@@ -1,164 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
- <data>
- <template id="header_footer_custom_payment" inherit_id="website.footer_default" customize_show="True" active="False" name="Payment Acquirers">
- <xpath expr="//div[@id='info']" position="inside">
- <h4 class="payment_method_title">Payment Acquirer</h4>
- <ul class="payment_method_list list-inline">
- <t t-foreach="request.website.payment_acquirers()" t-as="acquirer">
- <li>
- <span t-field="acquirer.image_small" t-options='{"widget": "image", "alt-field": "name"}' />
- </li>
- </t>
- </ul>
- </xpath>
- </template>
-
- <template id="assets_frontend" inherit_id="website.assets_frontend" name="Payment Frontend assets">
- <xpath expr="." position="inside">
-
- <link rel='stylesheet' href='/website_payment/static/src/css/website_payment.css'/>
- <script type="text/javascript" src="/website_payment/static/src/js/payment_acquirer.js"></script>
- <script type="text/javascript" src="/website_payment/static/lib/jquery.payment/jquery.payment.js"></script>
- <script type="text/javascript" src="/website_payment/static/src/js/payment_transaction.js"></script>
- </xpath>
- </template>
-
- <template id="pay_methods" name="Payment Acquirers">
- <t t-call="website.layout">
- <t t-set="additional_title">Payment Acquirers</t>
- <div class="wrap">
- <div class="container">
- <div class="row">
- <div class="col-sm-6">
- <ol class="breadcrumb mt8">
- <li><a href="/my/home"><i class="fa fa-home"/></a></li>
- <li>Payment Acquirers</li>
- </ol>
- </div>
- </div>
- <h1>Payment Acquirers</h1>
- <h4 t-if="acquirers">Add a new payment acquirer:</h4>
- <div t-if="acquirers" class="row">
- <div class="col-sm-8">
- <div t-if="error_message" class="alert alert-danger">
- <t t-foreach="error_message" t-as="err"><t t-esc="err"/><br /></t>
- </div>
- <div t-if='len(acquirers)&gt;1'>
- <label class="control-label" for="pm_acquirer_id">Acquirer</label>
- <select name="pm_acquirer_id" class="form-control">
- <t t-foreach="acquirers" t-as="acquirer">
- <option t-att-value="acquirer.id" t-esc="acquirer.name"/>
- </t>
- </select>
- </div>
- <t t-foreach="acquirers" t-as="acquirer">
- <div t-raw="acquirer.form" t-att-data-acquirer-id="acquirer.id" t-attf-class="acquirer #{'hidden' if acquirer!=acquirers[0] else ''}"/>
- </t>
- </div>
- </div>
- <div t-if="pms" class="clearfix">
- <h4>Your payment Methods</h4>
- <t t-set="show_delete" t-value="True"/>
- <t t-set="form_action" t-value="'/website_payment/delete/'"/>
- <div class="col-sm-8">
- <t t-call="payment.payment_tokens_list"/>
- </div>
- </div>
- </div>
- </div>
- </t>
- </template>
-
- <template id="pay_meth_link" inherit_id="portal.portal_layout" customize_show="True">
- <xpath expr="//div[@class='o_portal_my_details']" position="inside">
- <t t-if="request.env['payment.acquirer'].search([('website_published', '=', True), ('registration_view_template_id', '!=', False)])">
- <div class='manage_payment_method mt16'><a href="/my/payment_method">Manage your payment acquirers</a></div>
- </t>
+ <template id="header_footer_custom_payment" inherit_id="website.footer_default" customize_show="True" active="False" name="Payment Acquirers">
+ <xpath expr="//div[@id='info']" position="inside">
+ <h4 class="payment_method_title">Payment Acquirer</h4>
+ <ul class="payment_method_list list-inline">
+ <t t-foreach="request.website.payment_acquirers()" t-as="acquirer">
+ <li>
+ <span t-field="acquirer.image_small" t-options='{"widget": "image", "alt-field": "name"}' />
+ </li>
+ </t>
+ </ul>
</xpath>
</template>
-
- <template id="pay">
- <t t-call="website.layout">
- <t t-set="additional_title">Payment</t>
- <div class="wrap">
- <div class="container o_website_payment">
- <h1>Payment</h1>
- <div class="row">
- <div class="col-md-6">
- <div class="oe_structure"></div>
- <div>
- <div class="form-horizontal row o_website_payment_new_payment" t-att-data-acquirer_id="acquirer.id" t-att-data-currency_id="currency.id" t-att-data-reference="reference" t-att-data-amount="amount">
- <div class="form-group">
- <label for="form_reference" class="col-sm-3 control-label">Reference</label>
- <div class="col-sm-9">
- <span name="form_reference" class="form-control" t-esc="reference"/>
- </div>
- </div>
- <div class="form-group">
- <label for="form_amount" class="col-sm-3 control-label">Amount</label>
- <div class="col-sm-9">
- <span name="form_amount" class="form-control" t-esc="amount" t-options="{'widget': 'monetary', 'display_currency': currency}"/>
- </div>
- </div>
- <div class="col-sm-9 col-sm-offset-3 text-muted mt16" t-raw="acquirer.pre_msg"/>
- <div class="col-sm-12 o_website_payment_form" t-raw="payment_form"/>
- <div class="col-sm-6 col-sm-offset-6 text-muted mt16">
- <img alt="payment_provider_logo" class="pull-right ml8" t-att-src="website.image_url(acquirer, 'image_small')"/>
- <span>This transaction will be processed by <t t-esc="acquirer.name"/>.</span>
- </div>
- </div>
- </div>
- <div class="oe_structure"/>
- </div>
- </div>
- </div>
- </div>
- </t>
- </template>
-
- <template id="confirm">
- <t t-call="website.layout">
- <t t-set="additional_title">Payment</t>
- <div class="wrap">
- <div class="container o_website_payment">
- <h1>Payment</h1>
- <div class="row">
- <div class="col-md-6">
- <div class="form-horizontal">
- <div t-attf-class="alert alert-#{status}" t-raw="message"/>
- <div class="form-group">
- <label for="form_partner_name" class="col-sm-3 control-label">From</label>
- <div class="col-sm-9">
- <span name="form_partner_name" class="form-control" t-esc="tx.partner_name"/>
- </div>
- </div>
- <div class="form-group">
- <label for="form_reference" class="col-sm-3 control-label">Reference</label>
- <div class="col-sm-9">
- <span name="form_reference" class="form-control" t-esc="tx.reference"/>
- </div>
- </div>
- <div class="form-group">
- <label for="form_amount" class="col-sm-3 control-label">Amount</label>
- <div class="col-sm-9">
- <span name="form_amount" class="form-control" t-esc="tx.amount" t-options="{'widget': 'monetary', 'display_currency': tx.currency_id}"/>
- </div>
- </div>
- <div class="col-sm-12">
- <a t-attf-class="btn btn-#{status} pull-right" href="/my/home"><i class="fa fa-arrow-circle-right"/> Back to My Account</a>
- </div>
- <div class="col-sm-6 col-sm-offset-6 text-muted mt16">
- <img alt="payment_provider_logo" class="pull-right ml8" t-att-src="website.image_url(tx.acquirer_id, 'image_small')"/>
- <span>Payment processed by <t t-esc="tx.acquirer_id.name"/>.</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </t>
- </template>
-
- </data>
-</odoo>
+</odoo> \ No newline at end of file