PHPackages                             refatbd/bd-courier-fraud-checker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. refatbd/bd-courier-fraud-checker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

refatbd/bd-courier-fraud-checker
================================

Check for fraudulent customers using Bangladeshi courier data.

1.2.0(1mo ago)06MITPHPPHP ^7.4|^8.0|^8.1|^8.2|^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/refatbd/bd-courier-fraud-checker)[ Packagist](https://packagist.org/packages/refatbd/bd-courier-fraud-checker)[ RSS](/packages/refatbd-bd-courier-fraud-checker/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![BD Courier Fraud Checker](https://camo.githubusercontent.com/39e274ceaedde13388c68c7fbf536dc32d3af5e7fef368fba3350d4ade15e606/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a3030374246462c3130303a303043364646266865696768743d3230302673656374696f6e3d68656164657226746578743d4244253230436f75726965722532304672617564253230436865636b657226666f6e7453697a653d343226666f6e74436f6c6f723d66666666666626616e696d6174696f6e3d66616465496e26666f6e74416c69676e593d333826646573633d53706f742532307269736b79253230637573746f6d6572732532306265666f7265253230796f75253230736869702664657363416c69676e593d3538266465736353697a653d3138)](https://camo.githubusercontent.com/39e274ceaedde13388c68c7fbf536dc32d3af5e7fef368fba3350d4ade15e606/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a3030374246462c3130303a303043364646266865696768743d3230302673656374696f6e3d68656164657226746578743d4244253230436f75726965722532304672617564253230436865636b657226666f6e7453697a653d343226666f6e74436f6c6f723d66666666666626616e696d6174696f6e3d66616465496e26666f6e74416c69676e593d333826646573633d53706f742532307269736b79253230637573746f6d6572732532306265666f7265253230796f75253230736869702664657363416c69676e593d3538266465736353697a653d3138)[ ![Typing SVG](https://camo.githubusercontent.com/d0ae1002908a28ebc7ebcabca3674a9a1d369f479f4b522c4f52f12937120361/68747470733a2f2f726561646d652d747970696e672d7376672e64656d6f6c61622e636f6d3f666f6e743d466972612b436f6465267765696768743d3630302673697a653d3232266475726174696f6e3d333030302670617573653d38303026636f6c6f723d3030374246462663656e7465723d74727565267643656e7465723d747275652677696474683d363030266c696e65733d5374656164666173742b2545322539432539333b50617468616f2b2545322539432539333b526564582b2545322539432539333b43617272796265652b2545322539432539333b4f6e652b4150492e2b466f75722b636f7572696572732e2b5a65726f2b6775657373776f726b2e)](https://github.com/refatbd)
 [![Packagist Version](https://camo.githubusercontent.com/990269762902b16744e4d9665052985eeba6960a4e1c48e19eec7dbb9dc572c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d303037424646266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/990269762902b16744e4d9665052985eeba6960a4e1c48e19eec7dbb9dc572c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d303037424646266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465) [![Downloads](https://camo.githubusercontent.com/09252ab002e254c63356cef15f02323693f5bfa86d017b767f39ccd7b2c6bf1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d303043364646266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/09252ab002e254c63356cef15f02323693f5bfa86d017b767f39ccd7b2c6bf1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d303043364646266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465) [![PHP](https://camo.githubusercontent.com/9ffb718ca2e18c76c3b81c00b623ba600e1f312a310e596beed7c89fdcaf00d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342532302d2d253230382e332d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/9ffb718ca2e18c76c3b81c00b623ba600e1f312a310e596beed7c89fdcaf00d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342532302d2d253230382e332d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![Laravel](https://camo.githubusercontent.com/d30a7da8f530f86e7bf11a1ff4429065b80e99a3c94edb069e40a101a419fc73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d52656164792d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/d30a7da8f530f86e7bf11a1ff4429065b80e99a3c94edb069e40a101a419fc73/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d52656164792d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465) [![License](https://camo.githubusercontent.com/85bb431e1ec8bee6d9d1cd13d2e4ab21db3b219deab7ca6864e3fbc2a200d402/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d323861373435)](https://camo.githubusercontent.com/85bb431e1ec8bee6d9d1cd13d2e4ab21db3b219deab7ca6864e3fbc2a200d402/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726566617462642f62642d636f75726965722d66726175642d636865636b65723f7374796c653d666f722d7468652d626164676526636f6c6f723d323861373435)

Maintained with ❤️ by [**refatbd**](https://github.com/refatbd)

> A **Laravel package** that checks a Bangladeshi phone number against the data of four major couriers — **Steadfast, Pathao, RedX, and Carrybee** — and tells you, in one call, how risky that customer is before you confirm a Cash-on-Delivery order.

```
📞  01XXXXXXXXX  ─────▶  🔎  BdCourierFraudChecker  ─────▶  📊  Success rate · Fraud signals · Complaints

```

---

📑 Table of Contents
-------------------

[](#-table-of-contents)

- [✨ Features](#-features)
- [📦 Installation](#-installation)
- [⚙️ Configuration](#%EF%B8%8F-configuration)
- [🚀 Usage](#-usage)
- [🧾 Response Format](#-response-format)
- [🚚 Supported Couriers](#-supported-couriers)
- [🧠 How the Fraud Signal Works](#-how-the-fraud-signal-works)
- [➕ Adding a New Courier](#-adding-a-new-courier)
- [❓ FAQ](#-faq)
- [📝 Changelog](#-changelog)
- [📄 License](#-license)

---

✨ Features
----------

[](#-features)

FeatureDescription🔁**One call, four couriers**A single `check()` queries Steadfast, Pathao, RedX &amp; Carrybee.📊**Delivery success rate**Delivered / cancelled / total + auto-calculated percentages.🚨**Detailed complaints**Steadfast returns the full complaint list — name, details, date &amp; image.🏷️**Fraud labels**Pathao rating, RedX segment, Carrybee complaint count.⚡**Smart caching**Auth tokens/cookies cached for ~50 min — fewer logins, faster checks.🛡️**Resilient**In-call re-auth on expired sessions, request timeouts, browser-like headers, graceful failures, BD phone validation.🧩**Extensible**Drop in a new courier class and wire it up in minutes.---

📦 Installation
--------------

[](#-installation)

```
composer require refatbd/bd-courier-fraud-checker
```

Publish the config file:

```
php artisan vendor:publish --tag=bdcourierfraudchecker-config
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Add your courier merchant credentials to your `.env` file:

```
# 🟦 Steadfast
STEADFAST_USER=your_email@example.com
STEADFAST_PASSWORD=your_password

# 🟥 Pathao
PATHAO_USER=your_email@example.com
PATHAO_PASSWORD=your_password

# 🟧 RedX
REDX_PHONE=01XXXXXXXXX
REDX_PASSWORD=your_password

# 🟨 Carrybee
CARRYBEE_PHONE=01XXXXXXXXX
CARRYBEE_PASSWORD=your_password
```

> 💡 You only need to configure the couriers you actually use. A courier with missing credentials simply returns `status => false` instead of breaking the whole check.

---

🚀 Usage
-------

[](#-usage)

```
use Refatbd\BdCourierFraudChecker\Facade\BdCourierFraudChecker;

$result = BdCourierFraudChecker::check('01XXXXXXXXX');
```

That's it — `$result` is an array keyed by courier. Loop over it, render it, or feed it into your own risk score.

---

🧾 Response Format
-----------------

[](#-response-format)

```
[
    'steadfast' => [
        'status' => true,
        'message' => 'Successful.',
        'data' => [
            'success'             => 45,
            'cancel'              => 5,
            'total'               => 50,
            'deliveredPercentage' => 90.0,
            'returnPercentage'    => 10.0,
            'fraudReportCount'    => 1,
            'frauds'              => [
                [
                    'name'             => 'Saiyan Ahammd Santo',
                    'phone'            => '01893048178',
                    'details'          => 'পার্সেল রিসিভ করেনা।',
                    'image'            => null,
                    'consignment_id'   => 124581452,
                    'created_at'       => '2025-02-11T14:43:02.000000Z',
                    'created_at_human' => '1 year ago',
                ],
            ],
        ],
    ],
    'pathao' => [
        'status'  => true,
        'message' => 'Successful.',
        'data'    => [
            // Pathao has moved to a rating-based model — most accounts no longer
            // receive numeric counts (showCount: false). See the note below.
            'success'             => null,
            'cancel'              => null,
            'total'               => null,
            'deliveredPercentage' => null,
            'returnPercentage'    => null,
            'customerRating'      => 'excellent_customer', // Pathao's own label
            'riskLevel'           => 'low',                // derived: low | medium | high
            'showCount'           => false,                // did Pathao expose counts?
            'countsAvailable'     => false,                // numeric data usable?
        ],
    ],
    'redx' => [
        'status'  => true,
        'message' => 'Successful.',
        'data'    => [
            'success'             => 30,
            'cancel'              => 5,
            'total'               => 35,
            'deliveredPercentage' => 85.71,
            'returnPercentage'    => 14.29,
            'customerSegment'     => 'Normal Customer', // RedX's own rating label
        ],
    ],
    'carrybee' => [
        'status'  => true,
        'message' => 'Successful.',
        'data'    => [
            'success'             => 18,
            'cancel'              => 2,
            'total'               => 20,
            'deliveredPercentage' => 90.0,
            'returnPercentage'    => 10.0,
            'fraudCount'          => 0, // Carrybee's own complaint counter
        ],
    ],
]
```

> ⚠️ **Always check `status` before reading `data`.** When a courier fails (auth error, no data, etc.) it returns `['status' => false, 'message' => '...']` with **no** `data` key.

> 🟥 **Pathao counts may be `null`.** Pathao migrated to a rating-based model, so most merchant accounts receive **no numeric delivery counts** — `showCount` and `countsAvailable` are `false`, and the count fields are `null` (not `0`, to avoid implying a customer with zero orders). The package **still returns the full numeric breakdown** for any account that *is* entitled to counts (`countsAvailable: true`). **Guard on `countsAvailable` before doing math on Pathao counts.** Steadfast, RedX, and Carrybee continue to return real numeric counts.

---

🚚 Supported Couriers
--------------------

[](#-supported-couriers)

CourierStatusDelivery StatsFraud Signal**Steadfast**✅✅✅ Full complaint list — `frauds[]` (name · details · date · image)**Pathao**✅⚠️ Rating-based¹🏷️ Rating + risk — `customerRating`, `riskLevel`**RedX**✅✅🏷️ Segment label — `customerSegment`**Carrybee**✅✅🔢 Complaint count — `fraudCount`¹ Pathao moved to a rating-based model — most accounts get no numeric counts (`countsAvailable: false`). Numeric counts are still returned for entitled accounts.

> More couriers can be added easily — see [Adding a New Courier](#-adding-a-new-courier).

---

🧠 How the Fraud Signal Works
----------------------------

[](#-how-the-fraud-signal-works)

Each courier exposes risk differently. The package normalizes the **delivery stats** for all of them, and surfaces each courier's **native fraud signal** on top:

CourierFieldExample valuesMeaningSteadfast`frauds[]` + `fraudReportCount`complaint objectsReal merchant-submitted complaints with text, date &amp; imagePathao`customerRating` + `riskLevel``excellent_customer` → `low`, `fraud_customer` → `high`Pathao's internal rating, mapped to a coarse risk levelRedX`customerSegment``Normal Customer`, `High Return Customer`RedX's internal customer tierCarrybee`fraudCount``0`, `3`, …How many complaints Carrybee holds for the number> 🔎 **Only Steadfast** returns the full **who / what / when** complaint text. The others give a single label or count — useful as a quick red flag, but without the details.

**Pathao `customerRating` → `riskLevel` mapping:**

`customerRating``riskLevel``excellent_customer`, `good_customer``low``regular_customer`, `new_customer``medium``fraud_customer``high`unknown / missing`null`---

➕ Adding a New Courier
----------------------

[](#-adding-a-new-courier)

**Click to expand the step-by-step guide**
**1.** Create a new class in `src/Courier/YourCourier.php`:

```
