PHPackages                             akara/bagisto-rajaongkir - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. akara/bagisto-rajaongkir

ActiveLibrary[HTTP &amp; Networking](/categories/http)

akara/bagisto-rajaongkir
========================

High-reliability RajaOngkir shipping integration for Bagisto.

v1.0.0(5mo ago)015MITPHPPHP ^8.1

Since Nov 18Pushed 5mo agoCompare

[ Source](https://github.com/Nxx1/bagisto-rajaongkir)[ Packagist](https://packagist.org/packages/akara/bagisto-rajaongkir)[ RSS](/packages/akara-bagisto-rajaongkir/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

RajaOngkir Shipping Integration for Bagisto
===========================================

[](#rajaongkir-shipping-integration-for-bagisto)

High-reliability RajaOngkir API client and Bagisto shipping method package with full caching, dedupe, retry, cooldown protection, and deterministic rate optimization.

Overview
--------

[](#overview)

This package provides a fully production-grade RajaOngkir shipping integration for Bagisto. It includes:

- Optimized RajaOngkir API client
- Automatic cost caching (15m)
- Destination caching (24h)
- Lifecycle request dedupe - Retry + exponential backoff
- Upstream cooldown protection
- Normalized rate sorting (cheapest-first or ETA-first logic)
- Bagisto-compatible shipping method service
- Comprehensive logging with trace IDs

Features
--------

[](#features)

### 1. Reliable Client

[](#1-reliable-client)

- HTTP retry with incremental delay
- 429/5xx cooldown enforcement
- Fail-soft mode during cooldown
- Structured logging (request, success, failure, exception)
- Normalized request validation
- Deterministic caching
- Lifecycle dedupe to prevent duplicate processing

### 2. Shipping Rate Optimizer

[](#2-shipping-rate-optimizer)

- Remove duplicate courier services by ETA bracket
- Select lowest price per ETA per courier
- Global sort (cheapest → ETA → deterministic tie-breaker)

### 3. Bagisto Integration

[](#3-bagisto-integration)

- Drop-in service provider
- Configurable API key
- Shipping method class with pre-validation + exception-safe rate fetching
- Production-safe calculate() wrapper
- Full logging

Requirements
============

[](#requirements)

- PHP 8.1+
- Laravel 10+
- Bagisto 2.x

Installation
============

[](#installation)

```
composer require akara/bagisto-rajaongkir

```

Usage
-----

[](#usage)

After installing and configuring the RajaOngkir shipping package, follow these steps to enable and use it in Bagisto.

### 1. Enable Shipping Method in Admin Panel

[](#1-enable-shipping-method-in-admin-panel)

1. Log in to your Bagisto admin panel.
2. Navigate to **Configure → Sales → Shipping Methods**.
3. Locate **RajaOngkir Shipping** in the list.
4. Set **Status** to `Active`.
5. Configure additional options:
    - **Origin City** – the shipping origin for your store.
    - **Enabled Couriers** – select couriers supported by RajaOngkir.
    - **Rate Sorting** – choose `Cheapest First` or `Fastest ETA First`.
6. Save changes.

### 2. Checkout Usage

[](#2-checkout-usage)

Once enabled, RajaOngkir shipping rates will automatically appear on the checkout page for eligible destinations. Calculation is automatic and based on:

- Cart Contents: weights and quantities of items in the cart.
- Origin &amp; Destination: origin city from admin config, destination from customer shipping address.
- RajaOngkir API: fetches live rates.
- Optimization: deduplication, caching, and global rate sorting.

Rates are:

- Cached for 15 minutes (costs) and 24 hours (destination info).
- Deduplicated by courier and ETA.
- Sorted according to the selected rate optimization logic.

### 3. Logs &amp; Troubleshooting

[](#3-logs--troubleshooting)

All API requests are logged with structured trace IDs:

Additionnal Information
=======================

[](#additionnal-information)

Rate Optimization Logic
-----------------------

[](#rate-optimization-logic)

### Step 1: Normalize ETA window

[](#step-1-normalize-eta-window)

### Step 2: Deduplicate per Courier

[](#step-2-deduplicate-per-courier)

### Step 3: Global Sort

[](#step-3-global-sort)

- Cheapest price
- Fastest ETA
- Deterministic fallback by courier code

Logging
-------

[](#logging)

All requests include structured logs.

Caching &amp; Dedupe
--------------------

[](#caching--dedupe)

- Destination cache: 24h
- Cost cache: 15m
- API cooldown: 60s

License
=======

[](#license)

MIT License

Copyright (c) 2025 N.Pratama

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/642e147595e2935027b5dbfccbb1644393f5271e51d1feb0f77813acc566a86d?d=identicon)[Akara](/maintainers/Akara)

---

Top Contributors

[![Nxx1](https://avatars.githubusercontent.com/u/20744855?v=4)](https://github.com/Nxx1 "Nxx1 (3 commits)")

### Embed Badge

![Health badge](/badges/akara-bagisto-rajaongkir/health.svg)

```
[![Health](https://phpackages.com/badges/akara-bagisto-rajaongkir/health.svg)](https://phpackages.com/packages/akara-bagisto-rajaongkir)
```

###  Alternatives

[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
