Courses

Laravel HTTP Client and 3rd-Party APIs

Stripe: Use Direct API or PHP/Laravel Package?

You're reading a FREE PREVIEW of a PREMIUM course.

Video Version of the Lesson

[Only for premium members]

Link to the repository

[Only for premium members]

When integrating 3rd-party APIs, you will be lucky if they have a specific PHP/Laravel package. In this lesson, I will show you an example of exactly that.

We will try to integrate Stripe payments with Laravel by building a water park ticket purchasing page.

Water Park Payment Form

We'll explore both approaches: using Laravel's HTTP Client directly with Stripe's API and using their official PHP package.

Let me be honest right away: an official package is almost always a better choice than manually using APIs. In this lesson, I will try to demonstrate why.


What You'll Learn

By the end of this lesson, you will understand how to:

  • Compare HTTP Client approach vs official PHP packages
  • Handle Bearer token authentication in API headers
  • Manage dual API keys (public and private) for payment systems
  • Implement proper exception handling for payment APIs

Structure of Stripe Payment Intent API

Stripe's Payment Intent API is the modern way to handle payments. Here's what a typical request looks like:

Stripe API Documentation

As a result, we should get an object containing the client_secret, which we need to put inside the form for further submission.

Again, we can call this API directly with...

The full lesson is only for Premium Members.
Want to access all 7 video+text lessons of this course? (50 min)

You also get:

  • 83 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord