How to set up Stripe Connect Express (the easy way!)

How to set up Stripe Connect Express (the easy way!)

When needing to set up Stripe Connect for my startup Vizo, it turned out to be a much more extenuating task than I reckoned. Since I finally got it figured out, I wanted to share my solution with others who might be grasping at straws like I was!

This tutorial is most suitable for Express accounts, as most of the work is covered by Stripe. So… let’s get started!

First of all, you want to make sure you have a host that can execute PHP files (the first one I used didn’t and it took me hours to realize). You then want to create a PHP file and input the following:

<?php


if (isset($_GET['code'])) { // Redirect w/ code
$code = $_GET['code'];
}
else
{
echo "Error"; exit;
}

$ch = curl_init();


curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "client_secret=STRIPE_SECRET_KEY=".$code."&grant_type=authorization_code");
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_URL, " https://connect.stripe.com/oauth/token ");curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, "client_secret=STRIPE_SECRET_KEY=".$code."&grant_type=authorization_code");curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);


header('location:
if (curl_errno($ch)) {
}
curl_close ($ch);


?>

$result = curl_exec($ch);header('location: https://LINK_TO_PAGE_OR_WEBSITE_YOU_SEND_USERS_TO_AFTER_AUTHENTICATION' );if (curl_errno($ch)) {curl_close ($ch);?>

Replace STRIPE_SECRET_KEY with your secret api key which can be found here (NOT YOUR CONNECT CLIENT ID).

And then replace LINK_TO_PAGE_OR_WEBSITE_YOU_SEND_USERS_TO_AFTER_AUTHENTICATION to another page either on your website or wherever you please; in my case it is a “success” page, letting the users know their Connect account has been created (see below).

You’re almost done!

After that, make sure to do the following. Add the link to your PHP file in your Stripe Connect settings as the default ‘redirect_uri’. Do it here.

Lastly, set up the link you’ll give your users for on-boarding/sign-up. This is the format Stripe requires: https://connect.stripe.com/express/oauth/authorize?redirect_uri=https://LINK_TO_PHP_FILE&client_id=YOUR_CLIENT_ID&state=111

You can find your client ID here.

That’s it! You’re done!

The code is meant to prevent visitors to access the PHP file and see your API keys. However, always check with your web host what’s the most secure option to prevent such from happening.

You can find this PHP file on GitHub at https://github.com/dekple/Stripe-Connect-Express-Example (You can name it however you please by the way 🙂

If you have any questions, feel free to contact me at [email protected]

Enjoy!