<?php
/**
 * OAuth callback controller.
 */

namespace IPS\makepay\modules\front\oauth;

use IPS\makepay\OAuth\OAuth;

if (!\defined('\IPS\SUITE_UNIQUE_KEY')) {
    exit;
}

class _callback extends \IPS\Dispatcher\Controller
{
    protected function manage(): void
    {
        $code = (string) \IPS\Request::i()->code;
        $state = (string) \IPS\Request::i()->state;

        OAuth::exchangeCode($code, $state);
        \IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=nexus&module=payments&controller=settings', 'admin'));
    }
}
