'authorization_code', 'code' => $code, ]); } catch (\Stripe\Error\OAuth\OAuthBase $e) { exit("Error: " . $e->getMessage()); } $accountId = $resp->stripe_user_id; echo "

Success! Account $accountId is connected.

\n"; echo "

Click here to disconnect the account.

\n"; } elseif (isset($_GET['error'])) { // The user was redirect back from the OAuth form with an error. $error = $_GET['error']; $error_description = $_GET['error_description']; echo "

Error: code=" . htmlspecialchars($error, ENT_QUOTES) . ", description=" . htmlspecialchars($error_description, ENT_QUOTES) . "

\n"; echo "

Click here to restart the OAuth flow.

\n"; } elseif (isset($_GET['deauth'])) { // Deauthorization request $accountId = $_GET['deauth']; try { \Stripe\OAuth::deauthorize([ 'stripe_user_id' => $accountId, ]); } catch (\Stripe\Error\OAuth\OAuthBase $e) { exit("Error: " . $e->getMessage()); } echo "

Success! Account " . htmlspecialchars($accountId, ENT_QUOTES) . " is disconnected.

\n"; echo "

Click here to restart the OAuth flow.

\n"; } else { $url = \Stripe\OAuth::authorizeUrl([ 'scope' => 'read_only', ]); echo "Connect with Stripe\n"; }