Exytab.CustomsLens 0.1.0

dotnet add package Exytab.CustomsLens --version 0.1.0
                    
NuGet\Install-Package Exytab.CustomsLens -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Exytab.CustomsLens" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Exytab.CustomsLens" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Exytab.CustomsLens" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Exytab.CustomsLens --version 0.1.0
                    
#r "nuget: Exytab.CustomsLens, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Exytab.CustomsLens@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Exytab.CustomsLens&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Exytab.CustomsLens&version=0.1.0
                    
Install as a Cake Tool

CustomsLens

Offline .NET library that determines whether a shipment requires customs clearance — including intra-country cases where both addresses share the same country code but belong to different customs territories.

The problem

Most shipping logic treats countryFrom == countryTo as "domestic, no customs needed." But that's wrong for dozens of real-world routes:

From To Same country? Customs needed?
New York, US Guam, US ✅ ✅
London, GB Belfast, GB ✅ ✅
Madrid, ES Tenerife, ES ✅ ✅
Milan, IT Livigno, IT ✅ ✅
Hamburg, DE Heligoland, DE ✅ ✅

CustomsLens knows about these territories and resolves them by state code or postal/ZIP prefix.

Install

dotnet add package Exytab.CustomsLens

Usage

using CustomsLens;

var from = new ShippingAddress
{
    CountryCode = "US",
    StateCode = "NY",
    PostalCode = "10001"
};

var to = new ShippingAddress
{
    CountryCode = "US",
    StateCode = "GU",
    PostalCode = "96910"
};

var result = CustomsTerritoryResolver.Evaluate(from, to);

result.RequiresCustoms  // true
result.Reason            // IntraCountryCustomsTerritory
result.Description       // "Intra-country customs required: US mainland → Guam. ..."

Northern Ireland (resolved by postal prefix)

var from = new ShippingAddress { CountryCode = "GB", PostalCode = "SW1A 1AA" };
var to   = new ShippingAddress { CountryCode = "GB", PostalCode = "BT1 5GS" };

var result = CustomsTerritoryResolver.Evaluate(from, to);
// RequiresCustoms: true — Windsor Framework applies

Query available zones

var zones = CustomsTerritoryResolver.GetCustomsZones("ES");
// Canary Islands, Ceuta, Melilla

var countries = CustomsTerritoryResolver.GetCountriesWithIntraCustoms();
// US, GB, ES, IT, DE, NO, FI, GR, PT, AU

Covered territories

Country Zones
🇺🇸 US American Samoa, Guam, U.S. Virgin Islands, Northern Mariana Islands
🇬🇧 GB Northern Ireland
🇪🇸 ES Canary Islands, Ceuta, Melilla
🇮🇹 IT Livigno, Campione d'Italia
🇩🇪 DE Heligoland, Büsingen am Hochrhein
🇳🇴 NO Svalbard
🇫🇮 FI Åland Islands
🇬🇷 GR Mount Athos
🇵🇹 PT Azores, Madeira
🇦🇺 AU Norfolk Island

Note: Territories with their own ISO country code (HK, MO, FO, GL, GI, etc.) are already handled as international shipments by the countryFrom != countryTo check. CustomsLens focuses on the tricky cases where the country code is the same.

How it works

  1. Different country codes → InternationalShipment (always requires customs)
  2. Same country code → looks up the address against known customs zones by:
    • State/province code (e.g. GU, VI, AS, MP)
    • Postal/ZIP prefix (e.g. BT for Northern Ireland, 35/38 for Canary Islands)
  3. Both in mainland → DomesticShipment (no customs)
  4. Both in the same zone → SameCustomsZone (no customs)
  5. One in a zone, other in mainland (or different zone) → IntraCountryCustomsTerritory (customs required)

Carrier-agnostic

CustomsLens is not tied to any specific carrier. Use it as a pre-validation step before calling FedEx, UPS, DHL, or any other shipping API.

Contributing

Found a missing territory? PRs welcome! The zone data lives in CustomsTerritoryResolver.Data.cs in the Zones dictionary.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 318 3/17/2026