Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Midtrans

Laravel Midtrans Laravel Package

sawirricardo/laravel-midtrans

A Laravel package for integrating Midtrans payments. Configure credentials, create Snap transactions, handle callbacks and webhooks, and support common payment flows from your Laravel app with a simple, framework-friendly API.

View on GitHub
Deep Wiki
Context7

Supercharge your Laravel App with Midtrans 🚀

Frequently asked questions about Laravel Midtrans
How do I install laravel-midtrans in a Laravel app?
Install it with Composer using composer require sawirricardo/laravel-midtrans. The package ships a service provider and facade that are auto-discovered, so no manual registration is normally needed. After installing, publish the config file with the vendor:publish command and set your Midtrans server key, client key, and production flag. Then confirm your app has the curl, openssl, and json PHP extensions available, since the underlying Midtrans SDK depends on them.
Which Laravel and PHP versions does laravel-midtrans support?
The latest release dates from February 2023, which means the package was built around Laravel 8, 9, and 10 and PHP 8.0 and 8.1 conventions. The exact constraints for php, laravel/framework, and midtrans/midtrans-php are defined in the package's composer.json, so check those before committing. Run composer why-not in a scratch install against your target versions to see whether anything blocks resolution. If your application is on PHP 8.2 or newer, verify compatibility explicitly rather than assuming it.
Does laravel-midtrans work with Laravel 11 and Laravel 12?
That is not confirmed. The last release predates both Laravel 11 and Laravel 12, so compatibility is unknown without inspecting the composer.json version constraints. The fastest way to find out is a throwaway Laravel 11 or 12 project and a composer require attempt, followed by composer why-not if it fails. Because the package is a thin wrapper around the official Midtrans PHP SDK, a small constraint bump is often all a fork would need.
Which Midtrans features does this package wrap — Snap, Core API, or both?
It is a thin Laravel service-provider wrapper around the official midtrans/midtrans-php SDK, exposing convenience bindings for both the Snap and Core API surfaces. That means Snap token creation and Core API calls such as virtual account or e-wallet charges are reachable through the facade. Disbursement and Iris functionality are not clearly documented as wrapped, so verify against the source if you need payouts. Substantive request logic still originates from the upstream SDK, not the wrapper.
How do I configure Midtrans server key, client key, and sandbox mode?
Publish the package config file and map the keys to environment variables in your .env, typically MIDTRANS_SERVER_KEY, MIDTRANS_CLIENT_KEY, and MIDTRANS_IS_PRODUCTION. Make sure the server key used for server-side calls matches the environment, since sandbox and production keys are not interchangeable. Also confirm settings such as isSanitized and is3ds align with what is enabled in your Midtrans merchant dashboard. Never commit production server keys; keep them in your environment or a secrets manager.
How do I create a Snap transaction and get a Snap token?
Build a transaction payload with transaction_details, item_details, and customer_details, then call the Snap create transaction method through the package facade. The response includes a token and usually a redirect URL, which you pass to Midtrans Snap.js on the frontend to open the payment popup. Do not trust amounts or order statuses coming from the browser; recompute totals server-side before requesting the token. Persist the returned token or order ID so you can reconcile it against later notifications.
How do I handle Midtrans webhook notifications in Laravel?
Create a public POST route for Midtrans HTTP notifications, point the notification URL in your Midtrans dashboard at it, and exclude that route from CSRF verification in your middleware configuration. Midtrans sends asynchronous payment confirmations, so your handler should verify the signature, then re-query transaction status via the API before fulfilling an order. Always respond with a 200 quickly and push heavy work like emails or provisioning to a queue. Make the handler idempotent, since notifications can be retried.
Does laravel-midtrans verify Midtrans notification signatures for me?
Signature verification originates from the upstream midtrans/midtrans-php SDK, and the wrapper's own value is limited to dependency injection and configuration wiring. Whether the package surfaces a convenient verification helper is not documented, so inspect the source before relying on it. In practice you should implement verification yourself regardless: compute the SHA512 hash of order_id, status_code, gross_amount, and your server key, then compare it to the signature_key field. Treat any notification that fails that check as untrusted.
Is laravel-midtrans production ready and actively maintained?
The package is architecturally low risk because it is thin, does not touch Eloquent models or framework internals, and is easy to remove or replace. The bigger concern is lifecycle: the last release was in February 2023, it has roughly 12 stars, the bus factor is effectively one, and CI or test coverage is not visible externally. For production, wrap it behind your own PaymentGateway interface so you can swap to the raw SDK or a fork without changing domain code. Because it is MIT licensed and small, vendoring a fork is cheap if the maintainer goes quiet.
What are the alternatives to laravel-midtrans for Midtrans payments in Laravel?
The most direct alternative is using the official midtrans/midtrans-php SDK yourself with a small service class and a config file, which removes a dependency layer entirely. You can also fork this package and bump its Laravel and PHP constraints, since its surface area is small and the license permits it. If you expect to support multiple gateways such as Stripe, Xendit, and Midtrans, define a gateway-agnostic interface and treat this package as one implementation behind it. That keeps you from coupling your domain code to a single-maintainer wrapper.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect