Kasir

Kasir

Kasir is an open-source Laravel package for integrating with Midtrans, a popular Indonesian payment gateway. Designed with developer ergonomics in mind, it simplifies the process of handling transactions by providing a clean Laravel-style API for calling Midtrans’ HTTP endpoints directly.

⚠️ This project is no longer maintained.

Motivation

I created Kasir to reduce repetitive code when working with Midtrans in Laravel projects. Rather than wrapping the official SDK, Kasir interacts with the Midtrans web API directly using Guzzle, offering a simpler and more flexible integration tailored to Laravel conventions.

Features

  • Direct integration with Midtrans Snap and Core API via HTTP
  • Simple configuration via Laravel’s service provider system
  • Laravel-style syntax and facades
  • Focus on code readability and automated testing

Design

Kasir follows Laravel conventions closely: it uses facades for clean and expressive API calls, service classes for each Midtrans feature (like SnapService and TransactionService), and a centralized config for environment-specific settings. This modular structure makes it easy to test, extend, or replace components individually.

It also adopts the Builder Pattern with a fluent interface, allowing developers to configure a payment step-by-step using method chaining. This improves readability and aligns with Laravel’s expressive style.

$user = auth()->user();

// Server key, isProduction, isSanitized, is3ds,
// and appendNotificationUrl is configured in the config file.
// at config/kasir.php

$kasir = Kasir::make()
    ->customerDetails($user)
    ->itemDetails($user->cart()->items());

if ($request->get('payment_method') === 'credit_card') {
    $kasir->creditCard($request->get('token_id'), true);
} elseif ($request->get('payment_method') === 'qris') {
    $kasir->qris('gopay');
}

return $kasir->charge();

View the full source or fork it on GitHub.