MCP Agent feature is now added to StorefrontLearn more →

Iranian Tax Authority E-Invoicing via Kaysan TSP (سامانه مودیان) Guide

September 20, 2026


Comprehensive Iranian Tax Authority (Moadian) E-Invoicing Guide via Keysun TSP

The enactment of the Law of POS Terminals and Taxpayer System (قانون پایانه‌های فروشگاهی و سامانه مودیان) represents the most significant tax compliance transformation in Iran in decades. All registered businesses, corporations, and e-commerce stores are legally mandated to transmit standardized electronic sales invoices with a 22-digit unique Tax ID (TaxID) to the National Tax Administration (سازمان امور مالیاتی کشور - INTA / tp.tax.gov.ir).

Direct integration with INTA's central servers presents severe technical hurdles (mandatory RSA private keys, CSR generation, asymmetric JWS signing, AES packet encryption, and frequent gateway timeouts). To solve this, the Tax Authority officially certified Type-1 Tax Service Providers (TSP).

Keysun Data Processing (keysuntsp.com) is Iran's premier certified Type-1 TSP. The Webito moadian-kaysan plugin automates 100% of fiscal invoice generation, Verhoeff checksum calculation, and e-invoice transmission with zero hardware tokens required on your server.


1. Direct INTA Connection vs. Keysun TSP in Webito

Requirement / ChallengeDirect Tax Authority ConnectionWebito via Keysun TSP
Hardware Token / RSA Private KeyMandatory on server (High Risk)Not Required (Keysun Digital Seal)
22-Digit TaxID with Verhoeff ChecksumComplex manual math by developer100% Automated by Webito
Tax Authority Server Downtime HandlingFrequent 504 errors & failed invoicesAutomated Retry Queuing by Keysun
Error Diagnosis & Rejection FeedbackOpaque numerical error codesClear Persian / English Diagnostics
Technical Support HotlineNo dedicated INTA support lineCorporate Keysun Support (021-91009610)

2. Anatomy of the 22-Digit Tax ID (TaxID)

Webito implements the exact INTA mathematical specification in moadian-tax-id.util.ts:

$$\text{TaxID (22 chars)} = \underbrace{\text{A12BC3}}{\text{Fiscal Memory (6)}} + \underbrace{\text{20716}}{\text{Julian Day (5)}} + \underbrace{\text{0000000101}}{\text{Invoice Serial (10)}} + \underbrace{\text{5}}{\text{Verhoeff Check Digit (1)}}$$

  1. Fiscal Memory ID (6 characters): Unique terminal identifier issued in your my.tax.gov.ir portal.
  2. Julian Day Number (5 digits): Elapsed days since epoch (1970-01-01) corresponding to invoice issuance date.
  3. Internal Invoice Serial (10 digits): Sequential decimal number unique per fiscal memory terminal.
  4. Verhoeff Checksum (1 digit): Computed using dihedral group $D_5$ permutations preventing typographical fraud.

3. Type-1 (B2B) vs. Type-2 (B2C) Invoice Patterns

  • Pattern 1 (B2B Commercial Sales): For wholesale and corporate sales. Requires buyer Economic Code (tinb), National ID (bid), and 10-digit postal code (bpc). Buyers can claim input VAT tax credits.
  • Pattern 2 (B2C Consumer Retail): Standard consumer e-commerce sales. Does not require buyer economic codes or postal validation.

4. Configuration Parameters

Parameter in WebitoDescriptionExample
Kaysan API KeyDedicated REST API Key from keysuntsp.com dashboardkys_live_apikey_9988
Fiscal Memory ID6-character terminal memory code from my.tax.gov.irA12BC3
Seller Economic CodeMerchant 11 or 14-digit National Economic/Tax ID14001234567
Default PatternPattern 1 (B2B) or Pattern 2 (B2C Retail)2
Default Commodity Code13-digit standard code from stuffid.tax.gov.ir2720000114913
Custom API URLOptional dedicated enterprise endpoint overridehttps://api.keysuntsp.com/v1

5. Troubleshooting Tax Authority Rejections

Rejection ReasonCauseResolution in Webito
Invalid Commodity Code13-digit code not registered in stuffid.tax.gov.irUse general registered code 2720000114913.
Buyer Postal Code MismatchBuyer postal code does not match post databaseCorrect buyer address in Webito order details.
VAT Calculation DiscrepancyRounding mismatch in 10% VAT calculationWebito enforces exact integer Rial rounding.
Duplicate Tax IDInvoice with same serial already transmittedWebito automatically increments serial sequence.