diff options
| author | tbe-odoo <tbe@odoo.com> | 2017-07-28 15:52:34 +0200 |
|---|---|---|
| committer | Damien Bouvy <dbo@odoo.com> | 2017-08-14 08:30:59 +0200 |
| commit | 2df9c22d80be82b4ed7ffcd79f858e46c34e6479 (patch) | |
| tree | 5f3d7d68c4fc4e461e1a3f235266b14c23d0340a /addons/website_payment/controllers/main.py | |
| parent | c089d39a668fa6ab1f5d7867747da19d0b75f035 (diff) | |
[IMP] Payments & subscriptions: Improved Payments
- When registering a payment token, validating it using a payment of a small amount (~1.50€) followed by a refund allows ensuring
that the payment method is valid (i.e. checksumming the card number simple ensure the number is valid but not that the card exists).
This commit introduces a generic approach that must be implemented for each acquirer that has tokenization support.
This commit also introduces a generic payment token registration/usage template that can be adapted according to one's need.
- Introducing a new payment form that handles payment, deletion and adding payment method (only for server2server for the moment).
- On /my/payment_method, changed strings 'Payment Acquirers' to 'Payment Methods' which is more clear.
- Stripe can now be used to pay subscriptions.
Diffstat (limited to 'addons/website_payment/controllers/main.py')
| -rw-r--r-- | addons/website_payment/controllers/main.py | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/addons/website_payment/controllers/main.py b/addons/website_payment/controllers/main.py index f3548e9090f..2dad4025b47 100644 --- a/addons/website_payment/controllers/main.py +++ b/addons/website_payment/controllers/main.py @@ -18,16 +18,9 @@ class WebsitePayment(http.Controller): } 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}) + acquirer.form = acquirer.sudo()._registration_render(request.env.user.partner_id.id, {'error': {}, 'error_message': [], 'return_url': return_url, 'json': False, 'bootstrap_formatting': 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 @@ -90,25 +83,3 @@ class WebsitePayment(http.Controller): 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 |
