Integrate Authorize.net Payment Gateway In Laravel 12
Accepting payments on your Laravel application can be overwhelming when you're dealing with third-party gateways. Most tutorials push you toward installing packages—but what if you want full control with no extra baggage?
In this guide, I’ll walk you through integrating the Authorize.Net payment gateway in Laravel 12 without using any package, focusing on test mode to keep things safe for development. You’ll learn how to:
- Build a Bootstrap-powered payment form
- Send transactions directly to Authorize.Net
- Validate payment responses
- Securely verify webhooks from Authorize.Net
Let’s dive right in.
🧠 Why No Package?
Laravel has great community packages for payments, but they often come with extra layers of abstraction. When working with a gateway like Authorize.Net that has a detailed and well-documented API, doing it "barehanded" gives you:
- Full control of request structure
- Better debugging and logging
- No dependency on package updates
- Easier compliance with specific API versions
🛠️ Prerequisites
Before you start, make sure you have the following:
- Laravel 12 installed
- An Authorize.Net sandbox account: https://developer.authorize.net/hello_world/sandbox.html
- Sandbox API Login ID, Transaction Key, and Signature Key
Before moving ahead, you need to create a sandbox account to test the authorize.net, create the account from here https://developer.authorize.net/hello_world/sandbox.html
when you visit the above URL you can see the form like below one, fill the form and get your login details
Then you can login into your account from this link - https://logintest.authorize.net/?cobrand=sandbox
When you logged in you have the dashboard like the below one.
Then click on the account and look for the API keys and credentials
Click on that to get you api_login_id, transaction_key and signature_key
Add them to your .env
file:
🖼️ Step 1: Create the Payment Blade View
Let’s create a simple, clean payment form using Bootstrap 5.
Create a file at resources/views/payment.blade.php
:
This form accepts credit card details and amount, pre-filled for testing with Authorize.Net’s sandbox test card.
📦 Step 2: Create the Controller
Now, let’s write the controller that will handle the charge and webhook logic.
Run:
Then update it with the following code:
Key Takeaways:
- We use Laravel’s built-in HTTP client to send JSON to Authorize.Net.
- No
testRequest
flag is added—sandbox is already handled via the test endpoint. - Webhooks are validated using HMAC SHA-512.
🌐 Step 3: Define Your Routes
Add the following routes in routes/web.php
:
Visit /payment
in your browser to view the payment form.
🌐 Step 4: Testing the integration
Run the below command
after running the above URL you can open the below URL
When you visit this URL, you have the UI like the one below
When click on the pay now payment being received by the authorize.net and you will receive email as for the payment like the one below
🧪 Test Card Details
Use the following test card to simulate payments in Authorize.Net sandbox:
- Card Number:
4111 1111 1111 1111
- Expiration Date: Any future date
- CVV: Any 3 digits
- Amount: Any amount, like
10.00
🔒 Webhook Security
When Authorize.Net sends webhooks (like transaction status updates), you must verify the HMAC signature using your Signature Key. Laravel makes this easy by:
- Reading the
X-ANET-SIGNATURE
header - Computing HMAC with the request body
- Comparing them securely
Pro tip: Log these payloads first in development. Webhooks may contain important data you’ll want to store later.
✅ Benefits of This Approach
- You understand every line of logic
- No third-party abstraction
- Easy debugging via
dd()
orLog::info()
- Readily extendable for subscriptions, refunds, etc.
👨💻 Final Thoughts
Integrating Authorize.Net without a package in Laravel might look a little intimidating, but it’s really just about structuring your JSON payload properly and securing your credentials. Once you get past the first successful payment, the rest becomes straightforward.
Whether you’re building a SaaS platform, eCommerce site, or a donation portal, this method gives you the confidence that your payment logic is truly yours.
💡 Need Help or Customization?
This guide is created by CodeHunger Pvt Ltd, a Laravel development agency helping businesses integrate secure payment solutions without package bloat.
- 🌐 www.codehunger.in
- 📧 hungerforcode@gmail.com
- 📞 +91 9470759951
🧾 Source Code on GitHub
Explore the full working example here:
🔗 https://github.com/codehunger-team/integrate-authorize.net-in-laravel-12
Happy coding—and happy charging! 🚀