summaryrefslogtreecommitdiff
path: root/addons/payment_stripe/controllers/main.py
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2016-11-23 14:03:50 +0100
committerNicolas Martinelli <nim@odoo.com>2016-11-24 12:33:55 +0100
commit7e7205a7bfd5543f05808d71ae7ec8513d910079 (patch)
treecf721070df0664ebeea75d063861e61a144f8114 /addons/payment_stripe/controllers/main.py
parenta6b41186ca88e26be4244e5ecfd606cfc0407b42 (diff)
[FIX] payment_stripe: make it work
The module `payment_stripe` was apparently not designed to work with module `website_payment`, althought the payment method is available. For example: - Go to '/my/home', select "Pay Now" on an invoice - Try to pay with Stripe ==> nothing happens This commit brings the necessary modifications to make it compatible with `website_payment`. Moreover, it prevents the creation of 2 `payment.transactions`, which was not necessary. opw-693421
Diffstat (limited to 'addons/payment_stripe/controllers/main.py')
-rw-r--r--addons/payment_stripe/controllers/main.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/addons/payment_stripe/controllers/main.py b/addons/payment_stripe/controllers/main.py
index f2f2d60b8f5..ceebb17e500 100644
--- a/addons/payment_stripe/controllers/main.py
+++ b/addons/payment_stripe/controllers/main.py
@@ -29,24 +29,9 @@ class StripeController(http.Controller):
""" Create a payment transaction
Expects the result from the user input from checkout.js popup"""
- acquirer = request.env['payment.acquirer'].browse(int(post.get('acquirer_id')))
-
- sale_order_id = int(request.session.get('sale_order_id') or post.get('sale_order_id'))
-
- order = request.env['sale.order'].sudo().browse(sale_order_id)
- tx = request.env['payment.transaction'].sudo().create({
- 'acquirer_id': acquirer.id,
- 'reference': 'STRIPE-%s' % order.id,
- 'amount': float(post.get('amount')),
- 'currency_id': request.env['res.currency'].search([('name', '=', post.get('currency'))], limit=1).id,
- 'partner_id': request.env.user.partner_id.id,
- 'sale_order_id': order.id
- })
- order.write({
- 'payment_acquirer_id': acquirer.id,
- 'payment_tx_id': tx.id
- })
- request.session['sale_transaction_id'] = tx.id
+ tx = request.env['payment.transaction'].sudo().browse(
+ int(request.session.get('sale_transaction_id') or request.session.get('website_payment_tx_id', False))
+ )
response = tx._create_stripe_charge(tokenid=post['tokenid'])
_logger.info('Stripe: entering form_feedback with post data %s', pprint.pformat(response))
if response: