3neti/merchant

Merchant and vendor-alias helper utilities for x-change

Maintainers

Package info

github.com/3neti/merchant

pkg:composer/3neti/merchant

Statistics

Installs: 23

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-04-12 16:23 UTC

This package is auto-updated.

Last update: 2026-04-12 16:24:41 UTC


README

A lightweight Merchant and Vendor Alias management package designed to support the x-change financial workflow platform.

๐Ÿงญ Overview

3neti/merchant provides a minimal, focused domain layer for:

  • Merchant management
  • Vendor alias assignment and validation
  • Reserved alias protection
  • Clean integration with Laravel applications

It is intentionally small, strict, and domain-focused, making it ideal as a supporting package in larger financial systems like x-change.

๐ŸŽฏ Core Concepts

Merchant

Represents a business entity that can:

  • Own vendor aliases
  • Act as a payable / routing identity
  • Be linked to a user

Vendor Alias

A short, human-readable identifier used for:

  • Payment routing
  • Merchant identification
  • External references

Example:

GCASH
SHOP123
VNDR01

โš™๏ธ Features

โœ… Merchant Model

  • Eloquent model with factory support
  • Basic fillable attributes
  • User โ†” Merchant relationship support

โœ… Vendor Alias Service

Handles:

Normalization

$alias = $service->normalize(' shop1 ');
// SHOP1

Validation Rules

  • ASCII only
  • Must start with a letter (Aโ€“Z)
  • Length: 3โ€“8 characters
  • Uppercase letters and digits only
$service->validate('SHOP1'); // true
$service->validate('shop');  // false

Availability Checks

  • Prevents duplicate aliases
  • Prevents use of reserved aliases
$service->isAvailable('SHOP1');

โœ… Validation Rule: ValidVendorAlias

Laravel validation rule enforcing:

  • Strict format validation (no auto-correction)
  • Reserved alias protection
  • Configurable length limits
use LBHurtado\Merchant\Rules\ValidVendorAlias;

$request->validate([
    'alias' => ['required', new ValidVendorAlias],
]);

๐Ÿ”’ Design Philosophy

1. Strict Input Validation

Aliases are not auto-corrected.

  • shop โŒ invalid
  • SHOP โœ… valid

This ensures:

  • Predictability
  • Consistency
  • Financial safety

2. Separation of Concerns

Responsibility Layer
Normalization Service
Validation Rule
Persistence Database
Business logic Application

3. Financial-System Ready

Designed for:

  • Payment routing
  • Payable identities
  • Voucher / Pay Code systems

๐Ÿงช Test Coverage

All tests passing:

Tests: 25 passed (58 assertions)

Covered Areas

  • Merchant model
  • User โ†” Merchant relationship
  • Alias normalization
  • Alias validation (valid + invalid cases)
  • ASCII enforcement
  • Length constraints
  • Reserved alias handling
  • Error messaging

๐Ÿงฑ Database Tables

vendor_aliases

Stores assigned aliases.

reserved_vendor_aliases

Stores protected aliases (e.g. system, EMI, brands).

Example:

alias reason
ADMIN System
ROOT System
GCASH EMI

โš™๏ธ Configuration

// config/merchant.php

'alias' => [
    'min_length' => 3,
    'max_length' => 8,
    'pattern' => '^[A-Z][A-Z0-9]{2,7}$',
],

๐Ÿš€ Usage

Assign Alias

$service = new VendorAliasService;

if ($service->isAvailable('SHOP1')) {
    // assign alias
}

Validate Input

$request->validate([
    'alias' => ['required', new ValidVendorAlias],
]);

๐Ÿงญ Role in x-change

In the x-change architecture, this package provides:

  • Merchant identity layer
  • Vendor alias routing key
  • Integration point for payable flows

Flow:

User โ†’ Merchant โ†’ Vendor Alias โ†’ Voucher / Pay Code โ†’ Disbursement

๐Ÿ“Œ Key Takeaways

  • This package is intentionally simple and strict
  • It enforces clean, uppercase, deterministic identifiers
  • It is built for financial-grade systems, not loose UX inputs

๐Ÿ”ฅ Future Enhancements (Optional)

  • Alias assignment actions
  • Merchant profile DTOs
  • Alias โ†’ Merchant resolver service
  • Integration with voucher payable specifications

๐Ÿ“„ License

Proprietary / Internal Use