This course is archived!

This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.

> Dev Tools >

Course Overview

Stripe: Killer Payment Processing + ??? = Profit

  • 959 students
  • EN Captions
  • EN Script
  • Certificate of Completion

Your Guides

About this course

This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=5.5.9, <7.4",
        "symfony/symfony": "3.1.*", // v3.1.10
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.6.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
        "symfony/swiftmailer-bundle": "^2.3", // v2.3.11
        "symfony/monolog-bundle": "^2.8", // 2.11.1
        "symfony/polyfill-apcu": "^1.0", // v1.2.0
        "sensio/distribution-bundle": "^5.0", // v5.0.22
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.2
        "friendsofsymfony/user-bundle": "~2.0.1", // v2.0.1
        "stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
        "stripe/stripe-php": "^3.15", // v3.23.0
        "doctrine/doctrine-migrations-bundle": "^1.1", // 1.1.1
        "twig/twig": "^1.24.1", // v1.35.2
        "composer/package-versions-deprecated": "^1.11" // 1.11.99
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.0.7
        "symfony/phpunit-bridge": "^3.0", // v3.1.2
        "hautelook/alice-bundle": "^1.3", // v1.3.1
        "doctrine/data-fixtures": "^1.2" // v1.2.1
    }
}

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=5.5.9, <7.4",
        "symfony/symfony": "3.1.*", // v3.1.10
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.6.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
        "symfony/swiftmailer-bundle": "^2.3", // v2.3.11
        "symfony/monolog-bundle": "^2.8", // 2.11.1
        "symfony/polyfill-apcu": "^1.0", // v1.2.0
        "sensio/distribution-bundle": "^5.0", // v5.0.22
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.2
        "friendsofsymfony/user-bundle": "~2.0.1", // v2.0.1
        "stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
        "stripe/stripe-php": "^3.15", // v3.23.0
        "doctrine/doctrine-migrations-bundle": "^1.1", // 1.1.1
        "twig/twig": "^1.24.1", // v1.35.2
        "composer/package-versions-deprecated": "^1.11" // 1.11.99
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.0.7
        "symfony/phpunit-bridge": "^3.0", // v3.1.2
        "hautelook/alice-bundle": "^1.3", // v1.3.1
        "doctrine/data-fixtures": "^1.2" // v1.2.1
    }
}

You've already got the unstoppably amazing product, you just need to get out there and sell it! Knowing that almost every payment-processor ever is a huge pain you choose Stripe (you're so wise).

In this tutorial, we'll build a full checkout system for our awesome product and learn all about:

  • Handling the Stripe.js checkout & token process
  • Associating cards and creating Charge objects
  • Creating Stripe customers and connecting them with users
  • Building an embedded and a completely customer checkout form
  • Formatting your card & expiration fields like a pro
  • Being super graceful when things go wrong
  • Organizing everything with Stripe invoices

In Part 2, we'll handle subscriptions, webhooks, discount and more!

Next courses in the Dev Tools: E-Commerce & Payment section of the Dev Tools Track!

38 Comments

Sort By
Login or Register to join the conversation
Default user avatar Shairyar Baig 5 years ago

Could not stop watching it, great job. Can't wait for the next part. You made the integration seem so easy.

2 | Reply |
Default user avatar Christophe Lablancherie 5 years ago

This tutorial was so handsome !

1 | Reply |
Nizar avatar Nizar 3 years ago

Hello,
I would like to give the possibility to my customers to make apay in multiple times (not a single payment) on my website using stripe.
knowing that my website offers several products, is this possible?
How should I proceed?
Thanks for your help

| Reply |

Hi Nizar!

Hmm. I don't think it changes much in Stripe... if you're buying some products, there is no problem with "checking out" multiple times with multiple amounts. Is there some specific doubt or problem you're running into?

Cheers!

| Reply |

I do not know how to do?
What mechanism should I use in stripe?

| Reply |

Hey Nizar!

That's a pretty big question, unfortunately. We have the tutorial to help, but I don't think I can answer such a large inquiry. If you have some specific questions, please definitely let me know.

Good luck!

| Reply |

Hi ryan ,
Thanks you for your response.
To pay in multiple times on my website, I thought of this following solution:
I create the customer via stripe during his first payment, then I store his id in my database and I charge the customer later by using his Id.
(by using a cron to automate this task)

what do you think of this solution ?

| Reply |

Hey Nizar!

This is a great idea - we do something similar on SymfonyCasts (creating the customer via Stripe on first payment and saving that in the database). About the cron, that should work fine - if you need to, sort of, "schedule" when the next payment should happen (but it's not a recurring subscription), you could have a table in the database - e.g. scheduled_payments - that you query during this cron job. For example, that table might have charge_amount and charge_at (a date time column). The cron would then query the table for all rows where charge_at is < NOW().

Anyways, it seems like you are, indeed, in the right path. Here is some info about this topic - https://stripe.com/docs/pay...

Btw, much of the Stripe API has evolved and changed since this API - so check their docs thoroughly - this course is getting out of date.

Cheers!

| Reply |

Ryan,
Thank you very much for his useful information
Have a nice week end

| Reply |

Thanks for this tutorial, with your help, I was able to set up my payment system (single payment) with Symfony 4 and the new version of Stripe. So I thank you very much. Your tutorial is worth gold.

Do you know if it is possible to translate Stripe's message errors?

Thank you.

| Reply |

Hey Camille,

Agree with Diego. But along with error messages Stripe also provides you error codes, you can check them here: https://stripe.com/docs/err... - thought not sure if it's the full list of possible errors or no - most probably it's full, at least for now. So, instead of translating full strings - better to translate error codes because there's much less chance that they will be changed, though Stipe may tweak error messages.

So, for example, instead of translating "The card has expired. Check the expiration date or use a different card" translate this "expired_card".

I hope this helps!

Cheers!

2 | Reply |

Thank you victor !

| Reply |

Thanks for your kind words ojtouch :)

I think you can do something similar as we do with security messages. Just get the full string (stripe message) and add a translation, but don't forget to actually translate the text before rendering it

Cheers!

| Reply |

Thank you MolloKhan !

| Reply |

Hello, is this tutorial outdated?

| Reply |

Hey ojtouch

Not really, although Stripe already re-designed his dashboard but everything been taught in this tutorial is still relevant and useful

Cheers!

| Reply |

Thanks !

| Reply |
Default user avatar Rodolfo Velasco 5 years ago

I have a question here, can I combine the content of this course with symfony 2.8 in order to create payment method in my site?

| Reply |

Hey Rodolfo!

Absolutely :). I don't think I used any features that are new in Symfony 3.1 for this tutorial, so everything should work fine. The "newest" feature I use is service autowiring... which is optional anyways (there are a few minor things with autowiring that were improved in 3.1, so it's possible that autowiring may not work in some cases... but it probably will). The biggest difference will be to translate the different directory structure from Symfony3 to Symfony2 - most importantly that bin/console in Symfony3 is app/console in Symfony2, var/cache is app/cache and a few other minor things.

So yea, get to it! If you have questions along the way, just let us know.

Cheers!

1 | Reply |
Default user avatar Rodolfo Velasco weaverryan 5 years ago

So as I'm understanding right now, every course in this site is built on top of symfony framework? I'm telling you this because in the course description you don't mention anything about symfony, so I'm deducting that It's because of every course here is built with symfony

| Reply |

Yes and no :). Our courses mostly fall into 3 different categories

1) Courses about Symfony where we're teaching Symfony (e.g. anything on http://knpuniversity.com/tr...
2) Courses about some topic (REST, Stripe, Behat). We *often* use Symfony in these, but we try to keep the information as "agnostic" of Symfony as possible, trying to use only the more basic features of Symfony so that someone who doesn't know Symfony well can learn the topic.
3) Beginner courses that are not built on any framework (e.g. http://knpuniversity.com/tr... and http://knpuniversity.com/tr....

So, the trickiest ones are category (2) - it's not very realistic to build real application without a framework... but you also don't want the framework to be a barrier to entry. So, we do our best :).

Cheers!

| Reply |
Default user avatar Shairyar Baig 5 years ago

If I download the source code of chapter 13 in this series, will that include the code of all above chapters as well?

| Reply |

Hey Shairyar,

Yes, it will. Actually, the downloaded course code always contains 2 directories: the "start/" directory holds initial data at the start of course, so you could easily start coding from there when you start a course. The "finish/" directory holds the code of all chapters, i.e. the code after the latest chapter in the course.

Cheers!

| Reply |
Default user avatar Shairyar Baig Victor 5 years ago

Thanks Victor

| Reply |
Default user avatar Garfieldmypet 5 years ago

Hi, there,

Will this tutorial be available soon? Can I also suggest that we have a tutorial on how to integrate with PayPal.

| Reply |

Hey!

We'll release this tutorial this week! And I've added PayPal to our list of ideas - we actually integrate with both Stripe and PayPal (via Braintree) here on KnpU - and it was a bit difficult to support both - and interesting topic!

Cheers!

2 | Reply |
Default user avatar Garfieldmypet weaverryan 5 years ago

Thank you so much for the reply! Would be great to have PayPal integration too as many of us still use PayPal along with other payment processor such as PayPal Express Checkout. I do really appreciate you putting up the Stripe tutorial, as we are planning to add Stripe support soon.

1 | Reply |

Awesome! Yes, we use PayPal here on KnpU (in addition to Stripe) - via Braintree. It's not *quite* as smooth as using Stripe, but it makes life much easier than working with PayPal directly. We've had someone else already ask about PayPal as well, so it's on our list!

Cheers!

1 | Reply |

PayPal would be great! Any idea when this would be coming?

1 | Reply |

Unfortunately, it's not on the schedule for any time too soon :/. I'll add a vote for you on that topic - which always helps! But we've got some other tutorials we need to get out first before considering it. But definitely, Braintree makes it *somewhat* simple - it's similar to Stripe in many ways. If you do start implementing Braintree and have any questions, feel free to ask.

Cheers!

| Reply |
Default user avatar garfieldmypet weaverryan 5 years ago

If we have braintree tutorials, it would be excellent! I am looking to implement braintree and after reading the documentation, I am still lost! Please do update us if there are any progress yet. Really in love with your videos!! and thank you so much for your effort.

1 | Reply |

Sorry - no progress to report - it's not one of our highest priorities! I *can* tell you that our Braintree setup is very similar to our Stripe setup: we have all the same webhooks and all the same flow (creating customers, subscriptions, etc). The biggest difference is just learning the differences between the API's themselves. If you have some specific questions, we can do our best to help - we do have a wealth of knoweldge on this... but won't be able to publish anything too soon about it!

Cheers!

| Reply |
Jovan P. avatar Jovan P. 5 years ago

This was sweet. :) Can't wait for future videos :)

| Reply |

Hey Jovan,

More videos should be in 1-2 weeks. Stay tuned! :)

1 | Reply |

And part 1 is all up! Next up: https://knpuniversity.com/s... - video already recorded. It's big and fun :D

1 | Reply |
Default user avatar Isaak Ordoñez 5 years ago

Hello, This was a great tutorial.

| Reply |

Awesome - thanks for the nice message :). We're already recording part 2 about subscriptions. And it's big!

1 | Reply |
Default user avatar Dan Costinel 5 years ago

Life saviour.

| Reply |

Delete comment?

Share this comment

astronaut with balloons in space

"Houston: no signs of life"
Start the conversation!