Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active August 27, 2016 20:46
Show Gist options
  • Save adamjstevenson/0e36b125e4146c52df41236cb71623e5 to your computer and use it in GitHub Desktop.
Save adamjstevenson/0e36b125e4146c52df41236cb71623e5 to your computer and use it in GitHub Desktop.
Basic Stripe managed account creation with PHP
<?php
// Not using composer
require_once('stripe-php/init.php');
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
try {
$account = \Stripe\Account::create(array(
"managed" => true,
"country" => "US",
"email" => "[email protected]",
));
echo "Account $account->id created!";
} catch (\Stripe\Error\RateLimit $e) {
// Rate limited
echo $e->getmessage();
} catch (\Stripe\Error\InvalidRequest $e) {
// Invalid parameters were supplied to Stripe's API
echo $e->getmessage();
} catch (\Stripe\Error\Authentication $e) {
// Authentication with Stripe's API failed
// (maybe you changed API keys recently)
echo $e->getmessage();
} catch (\Stripe\Error\ApiConnection $e) {
// Network communication with Stripe failed
echo $e->getmessage();
} catch (\Stripe\Error\Base $e) {
// Display a very generic error to the user, and maybe send
// yourself an email
echo $e->getmessage();
} catch (Exception $e) {
// Something else happened, completely unrelated to Stripe
echo $e->getmessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment