| Server IP : 188.114.97.2 / Your IP : 104.23.197.230 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/sms.formationlangues.be/application/libraries/stripe-php-master/lib/ |
Upload File : |
<?php
namespace Stripe;
abstract class OAuth
{
/**
* Generates a URL to Stripe's OAuth form.
*
* @param array|null $params
* @param array|null $opts
*
* @return string The URL to Stripe's OAuth form.
*/
public static function authorizeUrl($params = null, $opts = null)
{
$params = $params ?: [];
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
$params['client_id'] = self::_getClientId($params);
if (!array_key_exists('response_type', $params)) {
$params['response_type'] = 'code';
}
$query = Util\Util::encodeParameters($params);
return $base . '/oauth/authorize?' . $query;
}
/**
* Use an authoriztion code to connect an account to your platform and
* fetch the user's credentials.
*
* @param array|null $params
* @param array|null $opts
*
* @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails
*
* @return StripeObject Object containing the response from the API.
*/
public static function token($params = null, $opts = null)
{
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
$requestor = new ApiRequestor(null, $base);
list($response, $apiKey) = $requestor->request(
'post',
'/oauth/token',
$params,
null
);
return Util\Util::convertToStripeObject($response->json, $opts);
}
/**
* Disconnects an account from your platform.
*
* @param array|null $params
* @param array|null $opts
*
* @throws \Stripe\Exception\OAuth\OAuthErrorException if the request fails
*
* @return StripeObject Object containing the response from the API.
*/
public static function deauthorize($params = null, $opts = null)
{
$params = $params ?: [];
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
$requestor = new ApiRequestor(null, $base);
$params['client_id'] = self::_getClientId($params);
list($response, $apiKey) = $requestor->request(
'post',
'/oauth/deauthorize',
$params,
null
);
return Util\Util::convertToStripeObject($response->json, $opts);
}
private static function _getClientId($params = null)
{
$clientId = ($params && array_key_exists('client_id', $params)) ? $params['client_id'] : null;
if ($clientId === null) {
$clientId = Stripe::getClientId();
}
if ($clientId === null) {
$msg = 'No client_id provided. (HINT: set your client_id using '
. '"Stripe::setClientId(<CLIENT-ID>)". You can find your client_ids '
. 'in your Stripe dashboard at '
. 'https://dashboard.stripe.com/account/applications/settings, '
. 'after registering your account as a platform. See '
. 'https://stripe.com/docs/connect/standard-accounts for details, '
. 'or email [email protected] if you have any questions.';
throw new Exception\AuthenticationException($msg);
}
return $clientId;
}
}