'Json method that creates a payment.transaction, used to create a
transaction when the user clicks on \'pay now\' button. After having
created the transaction, the event continues and the user is redirected
to the acquirer website.
:param int acquirer_id: id of a payment.acquirer record. If not set the
user is redirected to the checkout page'

@http.route(['/quote/<int:order_id>/transaction/<int:acquirer_id>/<token>'], type='json', auth='public', website=True)
def payment_transaction_token(self, acquirer_id, order_id, token):

    PaymentTransaction = request.env['payment.transaction'].sudo()
    Order = request.env['sale.order'].sudo().browse(order_id)
    if ((not Order) or (not Order.order_line) or (acquirer_id is None)):
        return request.redirect(('/quote/%s' % order_id))
    Transaction = PaymentTransaction.search([('reference', '=', Order.name)])
    if Transaction:
        if ((Transaction.sale_order_id != Order) or (Transaction.state in ['error', 'cancel']) or (Transaction.acquirer_id.id != acquirer_id)):
            Transaction = False
        elif (Transaction.state == 'draft'):
            Transaction.write({'amount': Order.amount_total})
    if (not Transaction):
        Transaction = PaymentTransaction.create({'acquirer_id': acquirer_id, 'type': Order._get_payment_type(), 'amount': Order.amount_total, 'currency_id': Order.pricelist_id.currency_id.id, 'partner_id': Order.partner_id.id, 'reference': PaymentTransaction.get_next_reference(Order.name), 'sale_order_id': Order.id, 'callback_eval': 'self.sale_order_id._confirm_online_quote(self)'})
        request.session[('quote_%s_transaction_id' % Order.id)] = Transaction.id
        Order.write({'payment_acquirer_id': acquirer_id, 'payment_tx_id': Transaction.id})
    return Transaction.acquirer_id.with_context(submit_class='btn    btn-primary', submit_txt=_('Pay    &    Confirm')).render(Transaction.reference, Order.amount_total, Order.pricelist_id.currency_id.id, values={'return_url': (('/quote/%s/%s' % (order_id, token)) if token else ('/quote/%s' % order_id)), 'type': Order._get_payment_type(), 'alias_usage': _('If    we    store    your    payment    information    on    our    server,    subscription    payments    will    be    made    automatically.'), 'partner_id': (Order.partner_shipping_id.id or Order.partner_invoice_id.id), 'billing_partner_id': Order.partner_invoice_id.id})
