Browsed by
Category: Web

Today, I created my own marketplace with Stripe

Today, I created my own marketplace with Stripe

Today, I created my own marketplace with Stripe and it was fun!

As part of GitHub’s student developer pack, Stripe comes with a transaction fee waiver for the first 1000$ processed (or so I thought).

Now, I can use this marketplace to sell my stuff to my neighbors at École polytechnique… and they can pay me by credit card!

As a matter of fact it actually is easy to use Stripe’s API: it comes with snippets of code that you can directly use in your application. Even your sandbox keys are pre-filled.

I had a good experience using Trello’s API and using Stripe’s API gave similar satisfaction (much to the contrary of the RATP’s API).

First, encrypt!

The first obstacle I encountered was that Stripe obviously requires TLS encryption. Hopefully, Let’s Encrypt allows that super easily. Like you just install certbot and type certbot certonly and it does the work.

This was very rewarding. As you can see, this blog now uses HTTPS. I will also be able able to use my own server for building a Facebook Messenger Chatbot without using Heroku!

Then, configure the nginx server

I also had some trouble configuring the nginx server just like I wanted: with PHP, TLS and .htpassw. At the end, it looked like this:

server {
        listen 80;
        return 301 https://$server_name$request_uri;

# HTTPS server

server {
    listen 443;
    root /var/www/sold;
    index index.html index.htm index.php;
    client_max_body_size 10M;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    location /admin/ {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/.htpasswd;

        location ~ \.php {
             fastcgi_index index.php;
             fastcgi_pass unix:/var/run/php5-fpm.sock;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;

    location ~ \.php {
         fastcgi_index index.php;
         fastcgi_pass unix:/var/run/php5-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;

(Yeah, sorry I only serve ipv4 for now…)

To generate the .htpsswd file, I simply typed sudo htpasswd -c /etc/nginx/.htpassw varal7 in terminal.

Finally, the coding part

I wanted to do produce the easiest possible code for my MVP. So I used vanilla PHP.

The code is available as a GitHub repository.

End of the day, I don’t think it was the best thing to do, as I had to recode a lot of useful (and therefore existing) functions. I could have used a simple framework like Silex.

Success! Less than 24 hours after starting the project, I had my first customers and will soon cash in some money 🙂

Sadly, as you can see, Stripe does seem to take a transaction fee anyway. I have wrote them an email about that.

Bonus: receiving SMS notification

Stripe doesn’t notify anyone automatically, so you have to do it yourself.

Sadly, I don’t have my own email server yet. But I already have a SMS server ready!

More precisely, I have a Raspberry Pi equipped with a SIM card, connected to the same VPN as my VPS and listening on a certain port for a GET request. If it gets the correct one, it sends me a text with a certain message. I guess this setup could be the subject for another article and it will, when I feel like writing it.

Finally, adding this SMS notification was not difficult and I now have this feature in production 🙂

How to create a chatbot for your Facebook page using Heroku in 10 minutes

How to create a chatbot for your Facebook page using Heroku in 10 minutes

It is now a very popular thing for organizations to own a “Page” on Facebook. Users are now used to communicate directly with a Facebook Page and they expect a quick answer to their questions, 24/7.


Hopefully, since April 2016, Facebook allows us to create messenger bots.
Here’s how.

Note that everything that follows can be found on Facebook’s documentation.

First, create a Facebook Page

This is an easy step. Simply follow the instructions here: Create a page

Then, create a Facebook App

This is another easy step. Follow this link: Create an app
Facebook will want to help you set up your app with “Quick start” steps. Just skip this.

Take note of your App Secret.

On you app Dashboard, under Product Settings, click “Add Product” and select “Messenger.”


Under “Token Generation”, choose your Page to generate a Token. Take note of that Page Access Token.

And keep this tab open. You will need it soon.

Deploy to Facebook’s messenger-platform-samples to Heroku

Because Facebook’API needs an HTTPS callback, you won’t be able to test your app from localhost. One easy way to test your app is to use Heroku.

  1. Create an account on Heroku.
  2. Now download Heroku-CLI from Heroku’sdocumentation
  3. Let’s go

git clone
cd messenger-platform-samples/node
heroku login
heroku create youroriginalnamehere #Replace with your original name
cp config/default.json config/production.json

Now edit the config/production.json file with the App Secret and the Page Access Token you got from last step.

The serverURL is something that should look like

Now, you get to choose your Validation Token. Take note of it, you will need it in a moment.

git add .
git commit -m "Prod"
git push heroku master

Add a Messenger webhook to your app

Back to your App Dashboard. In the Webhooks section, click “Setup Webhooks.”

The URL for your webhook is something like

Enter your Validation Token and select message_deliveries, messages, messaging_optins, and messaging_postbacks under Subscription Fields.

You can now subscribe your App to your Page.


You’re done!

You can now try to chat with your brand new Facebook bot. By default, it will simply echo your message. In development mode, it will only be accessible to admins of the page and testers of the app. Enjoy!