'Payment step. This page proposes several payment means based on available
payment.acquirer. State at this point :
- a draft sale order with lines; otherwise, clean context / session and
back to the shop
- no transaction in context / session, or only a draft one, if the customer
did go to a payment.acquirer website but closed the tab without
paying / canceling'

@http.route(['/shop/payment'], type='http', auth='public', website=True)
def payment(self, **post):

    SaleOrder = request.env['sale.order']
    order = request.website.sale_get_order()
    redirection = self.checkout_redirection(order)
    if redirection:
        return redirection
    shipping_partner_id = False
    if order:
        if order.partner_shipping_id.id:
            shipping_partner_id = order.partner_shipping_id.id
        else:
            shipping_partner_id = order.partner_invoice_id.id
    values = {'website_sale_order': order}
    values['errors'] = SaleOrder._get_errors(order)
    values.update(SaleOrder._get_website_data(order))
    if (not values['errors']):
        acquirers = request.env['payment.acquirer'].search([('website_published', '=', True), ('company_id', '=', order.company_id.id)])
        values['acquirers'] = []
        for acquirer in acquirers:
            acquirer_button = acquirer.with_context(submit_class='btn    btn-primary', submit_txt=_('Pay    Now')).sudo().render('/', order.amount_total, order.pricelist_id.currency_id.id, values={'return_url': '/shop/payment/validate', 'partner_id': shipping_partner_id, 'billing_partner_id': order.partner_invoice_id.id})
            acquirer.button = acquirer_button
            values['acquirers'].append(acquirer)
        values['tokens'] = request.env['payment.token'].search([('partner_id', '=', order.partner_id.id), ('acquirer_id', 'in', acquirers.ids)])
    return request.render('website_sale.payment', values)
