25 require
'../../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/includes/OAuth/bootstrap.php';
27 use OAuth\Common\Storage\DoliStorage;
28 use OAuth\Common\Consumer\Credentials;
29 use OAuth\OAuth2\Service\GitHub;
32 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
33 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
38 $action =
GETPOST(
'action',
'aZ09');
39 $backtourl =
GETPOST(
'backtourl',
'alpha');
48 $currentUri =
$uriFactory->createFromAbsolute($urlwithroot.
'/core/modules/oauth/stripetest_oauthcallback.php');
56 $serviceFactory = new \OAuth\ServiceFactory();
57 $httpClient = new \OAuth\Common\Http\Client\CurlClient();
61 $serviceFactory->setHttpClient($httpClient);
64 $storage =
new DoliStorage($db, $conf);
67 $credentials =
new Credentials(
68 $conf->global->OAUTH_STRIPE_TEST_ID,
69 $conf->global->STRIPE_TEST_SECRET_KEY,
70 $currentUri->getAbsoluteUri()
73 $requestedpermissionsarray = array();
74 if (
GETPOST(
'state')) $requestedpermissionsarray = explode(
',',
GETPOST(
'state'));
85 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"oauth_token set service='StripeTest', entity=".$conf->entity;
91 $langs->load(
"oauth");
99 if ($action ==
'delete')
101 $storage->clearToken(
'StripeTest');
105 header(
'Location: '.$backtourl);
109 if (!empty($_GET[
'code']))
114 dol_syslog(
"We are coming from the oauth provider page");
122 $state = isset($_GET[
'state']) ? $_GET[
'state'] : null;
132 $token = $apiService->requestAccessToken($_GET[
'code']);
140 $backtourl = $_SESSION[
"backtourlsavedbeforeoauthjump"];
141 unset($_SESSION[
"backtourlsavedbeforeoauthjump"]);
143 header(
'Location: '.$backtourl);
146 print $e->getMessage();
150 $_SESSION[
"backtourlsavedbeforeoauthjump"] = $backtourl;
156 $url = $apiService->getAuthorizationUri(array(
'state'=>
GETPOST(
'state')));
160 $url =
'https://connect.stripe.com/oauth/authorize?response_type=code&client_id='.$conf->global->OAUTH_STRIPE_TEST_ID.
'&scope=read_write';
164 header(
'Location: '.$url);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
$uriFactory
Create a new instance of the URI class with the current URI, stripping the query string.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.