Files
odoo_source/addons/payment_stripe/controllers/main.py
T
jev-odoo 013831b176 [FIX] payment_stripe: Request error handling with automatic flow
PR https://github.com/odoo/odoo/pull/49964 fixed manual payment flow
but broke automatic payment flow.

This commit should allow both by raising the exception only for
manual flow, giving only an error for automatic flows.

FW-PORT of https://github.com/odoo/odoo/pull/50908/commits/46e977a21743644a2e98344e3491f0dd6fcbe892

closes odoo/odoo#52151

X-original-commit: a40089d67b66b593a09b0fa4c4cd24f6ce5fcc71
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
2020-05-29 09:36:02 +00:00

55 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
import logging
import werkzeug
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class StripeController(http.Controller):
_success_url = '/payment/stripe/success'
_cancel_url = '/payment/stripe/cancel'
@http.route(['/payment/stripe/success', '/payment/stripe/cancel'], type='http', auth='public')
def stripe_success(self, **kwargs):
request.env['payment.transaction'].sudo().form_feedback(kwargs, 'stripe')
return werkzeug.utils.redirect('/payment/process')
@http.route(['/payment/stripe/s2s/create_json_3ds'], type='json', auth='public', csrf=False)
def stripe_s2s_create_json_3ds(self, verify_validity=False, **kwargs):
if not kwargs.get('partner_id'):
kwargs = dict(kwargs, partner_id=request.env.user.partner_id.id)
token = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id'))).with_context(stripe_manual_payment=True).s2s_process(kwargs)
if not token:
res = {
'result': False,
}
return res
res = {
'result': True,
'id': token.id,
'short_name': token.short_name,
'3d_secure': False,
'verified': False,
}
if verify_validity != False:
token.validate()
res['verified'] = token.verified
return res
@http.route('/payment/stripe/s2s/create_setup_intent', type='json', auth='public', csrf=False)
def stripe_s2s_create_setup_intent(self, acquirer_id, **kwargs):
acquirer = request.env['payment.acquirer'].browse(int(acquirer_id))
res = acquirer.with_context(stripe_manual_payment=True)._create_setup_intent(kwargs)
return res.get('client_secret')
@http.route('/payment/stripe/s2s/process_payment_intent', type='json', auth='public', csrf=False)
def stripe_s2s_process_payment_intent(self, **post):
return request.env['payment.transaction'].sudo().form_feedback(post, 'stripe')