How to Integrate PayPal Payments in Laravel Without Any SDK or Package (2025 Guide)
Integrating PayPal with Laravel doesn't require third-party SDKs or bloated packages. In this tutorial, we'll use PayPal's REST API and Laravel's built-in Http
client to create and capture orders. This guide supports the latest PayPal v2 Checkout API and works seamlessly in Laravel 8 and above.
So, first of all you need to create a account on Paypal to create a account visit this URL - https://developer.paypal.com/home/
Then after login you have to click on the API credential as shown in the below image
Then you have to click on the create app as show in the below image, to create a new app on Paypal
Then you have the popup like something below just fill the details and create your application
Then after you will receive you client Id and secret as given in below image, save it somewhere as we will use it in our application
Now we will follow step by step guide to implement Paypal payment in the laravel application.
Install Laravel using the below command, if you haven't installed it yet
🚀 Step 1: Create a Controller
Create a controller named PayPalController
:
✍️ Step 2: Implement PayPal Order Creation and Capture
Paste the following code in PayPalController.php
:
🔗 Step 3: Define Routes in web.php
🧪 Step 4: Testing with PayPal Sandbox
- Visit
/paypal/create
to create an order. - You'll receive a PayPal approval link in the response.
- Redirect the user to the link.
- After payment, PayPal will redirect to
/paypal/capture/{orderId}
. - In that route, your app will capture the payment.
🧩 Step 5: Add PayPal API Credentials to .env
To keep your credentials secure and easy to manage across environments (local, staging, production), add the following lines to your .env
file:
🔁 Step 6: Clear Route Cache (if needed)
After making changes to your routes or .env
file, it's good practice to clear cached routes and configuration to avoid unexpected issues.
Run the following Artisan commands:
🌐 Step 7: Test the Integration in Browser
Finally, start your Laravel development server by running:
Now, open your browser and visit:
when you hit the above URL you can see something like below
This will initiate the PayPal order creation process. If everything is set up correctly, you should see a JSON response with the PayPal order details including the approval link where the user can proceed with the payment.
✅ Step 8: Access the Full Source Code
You can download or clone the full working code from our official GitHub repository:
🔗 GitHub Repo: https://github.com/codehunger-team/paypal-payment-integration-in-laravel-12/tree/master
It includes:
- PayPalController with order creation and capture logic
- Routes setup
- Example
.env
configuration - Sample PayPal order payload
- Instructions to run and test it locally
📌 Make sure to place this after Step 7 in your blog article or wherever it makes most sense in your content structure. You could also include it in a dedicated “Source Code” or “GitHub Repository” section near the end of the article. Let me know if you'd like the blog content edited directly for placement.
🧾 Conclusion: Seamless PayPal Integration in Laravel Without SDKs
Integrating PayPal payment gateway in Laravel without relying on third-party packages or SDKs gives developers complete control over the payment flow, API handling, and response customization. By directly communicating with PayPal’s RESTful APIs using Laravel’s robust HTTP client, you ensure a lightweight, efficient, and secure implementation tailored to your specific business logic.
This approach not only eliminates the overhead of external dependencies but also empowers you to fully understand the payment lifecycle — from generating an access token using OAuth 2.0, to creating orders, and finally capturing payments. Whether you're building an eCommerce platform, SaaS product, subscription service, or a donation system, having direct PayPal API integration in your Laravel application enhances flexibility, maintainability, and future scalability.
Here’s a quick recap of what we covered in this tutorial:
- 🛠️ Set up your PayPal sandbox credentials for safe testing
- 🔐 Use Laravel's native HTTP client to handle authentication and authorization
- 🧾 Craft dynamic and detailed purchase units with shipping, item breakdown, and metadata
- 💳 Capture payments using PayPal Order ID securely and efficiently
- 🌐 Test the full flow using Laravel’s local development server and sandbox environment
- ⚙️ Configure your
.env
file and clear your Laravel route & config cache for a fresh start
🚀 Benefits of Raw PayPal API Integration in Laravel
- ✅ No package bloat or hidden dependencies
- ✅ Improved application performance
- ✅ Full API-level control and customization
- ✅ Easier debugging and logging of PayPal interactions
- ✅ Perfect for both monolithic and microservice-based Laravel architectures
By following this comprehensive, step-by-step guide, you are now capable of adding PayPal payment support in any Laravel project — without a single external package.
If you found this tutorial helpful, don’t forget to share it with your fellow developers and bookmark it for your next Laravel + PayPal project. Need a production-ready PayPal module or custom Laravel development? Let’s talk!
Youtube Url: