8 * Generates a URL to Stripe's OAuth form.
10 * @param array|null $params
11 * @param array|null $opts
13 * @return string The URL to Stripe's OAuth form.
15 public static function authorizeUrl($params = null, $opts = null)
21 $base = ($opts && array_key_exists('connect_base', $opts)) ?
$opts['connect_base'] : Stripe
::$connectBase;
23 $params['client_id'] = self
::_getClientId($params);
24 if (!array_key_exists('response_type', $params)) {
25 $params['response_type'] = 'code';
27 $query = Util\Util
::urlEncode($params);
29 return $base . '/oauth/authorize?' . $query;
33 * Use an authoriztion code to connect an account to your platform and
34 * fetch the user's credentials.
36 * @param array|null $params
37 * @param array|null $opts
39 * @return StripeObject Object containing the response from the API.
41 public static function token($params = null, $opts = null)
43 $base = ($opts && array_key_exists('connect_base', $opts)) ?
$opts['connect_base'] : Stripe
::$connectBase;
44 $requestor = new ApiRequestor(null, $base);
45 list($response, $apiKey) = $requestor->request(
51 return Util\Util
::convertToStripeObject($response->json
, $opts);
55 * Disconnects an account from your platform.
57 * @param array|null $params
58 * @param array|null $opts
60 * @return StripeObject Object containing the response from the API.
62 public static function deauthorize($params = null, $opts = null)
68 $base = ($opts && array_key_exists('connect_base', $opts)) ?
$opts['connect_base'] : Stripe
::$connectBase;
69 $requestor = new ApiRequestor(null, $base);
70 $params['client_id'] = self
::_getClientId($params);
71 list($response, $apiKey) = $requestor->request(
77 return Util\Util
::convertToStripeObject($response->json
, $opts);
80 private static function _getClientId($params = null)
82 $clientId = ($params && array_key_exists('client_id', $params)) ?
$params['client_id'] : null;
83 if ($clientId === null) {
84 $clientId = Stripe
::getClientId();
86 if ($clientId === null) {
87 $msg = 'No client_id provided. (HINT: set your client_id using '
88 . '"Stripe::setClientId(<CLIENT-ID>)". You can find your client_ids '
89 . 'in your Stripe dashboard at '
90 . 'https://dashboard.stripe.com/account/applications/settings, '
91 . 'after registering your account as a platform. See '
92 . 'https://stripe.com/docs/connect/standard-accounts for details, '
93 . 'or email support@stripe.com if you have any questions.';
94 throw new Error\
Authentication($msg);