Files
odoo_source/addons/payment_stripe/controllers/onboarding.py
T
Horacio Tellez f7b8f07501 [IMP] payment: rename of acquirer to provider
Changing the name of model payment.acquirer to payment.provider
and everything that it touches. It is technically incorrect to
use the term "acquirer" for systems that only provide a service
of payment.
After this commit the model payment.acquirer and all related to
it will be renamed to payment.provider.

Task - 2842088

closes odoo/odoo#90899

Related: odoo/upgrade#3542
Related: odoo/documentation#1981
Related: odoo/enterprise#27131
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-09-09 13:38:08 +02:00

46 lines
2.3 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug.urls import url_encode
from odoo import http
from odoo.http import request
class OnboardingController(http.Controller):
_onboarding_return_url = '/payment/stripe/onboarding/return'
_onboarding_refresh_url = '/payment/stripe/onboarding/refresh'
@http.route(_onboarding_return_url, type='http', methods=['GET'], auth='user')
def stripe_return_from_onboarding(self, provider_id, menu_id):
""" Redirect the user to the provider form of the onboarded Stripe account.
The user is redirected to this route by Stripe after or during (if the user clicks on a
dedicated button) the onboarding.
:param str provider_id: The provider linked to the Stripe account being onboarded, as a
`payment.provider` id
:param str menu_id: The menu from which the user started the onboarding step, as an
`ir.ui.menu` id
"""
stripe_provider = request.env['payment.provider'].browse(int(provider_id))
stripe_provider.company_id._mark_payment_onboarding_step_as_done()
action = request.env.ref('payment_stripe.action_payment_provider_onboarding')
get_params_string = url_encode({'action': action.id, 'id': provider_id, 'menu_id': menu_id})
return request.redirect(f'/web?#{get_params_string}')
@http.route(_onboarding_refresh_url, type='http', methods=['GET'], auth='user')
def stripe_refresh_onboarding(self, provider_id, account_id, menu_id):
""" Redirect the user to a new Stripe Connect onboarding link.
The user is redirected to this route by Stripe if the onboarding link they used was expired.
:param str provider_id: The provider linked to the Stripe account being onboarded, as a
`payment.provider` id
:param str account_id: The id of the connected account
:param str menu_id: The menu from which the user started the onboarding step, as an
`ir.ui.menu` id
"""
stripe_provider = request.env['payment.provider'].browse(int(provider_id))
account_link = stripe_provider._stripe_create_account_link(account_id, int(menu_id))
return request.redirect(account_link, local=False)