Documentation Topics
C# Code Samples of Clearing Api - Documentation
About These Samples- Sample 01
This page demonstrates various ZATCA simplified invoice clearing scenarios with ready-to-use JSON samples. Additionally, we provided c# code to implement each scenario
Basic Simplified Invoice
A minimal simplified invoice with one standard-rated item (15% VAT).
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-000532",
"DocType": "TAXINVOICE",
"DocForm": "INVOICE",
"IssueDate": "2025-08-16",
"IssueTime": "20:26:00",
"DocCurrency": "SAR",
"PaymentMethod": "Cash",
"CustomerName": "B2B Customer",
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Laptop Dell Precision 7560",
"Quantity": 1,
"UnitCode": "NOS",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 4500,
"Currency": "SAR"
}
]
}
Invoice with Document-Level Allowances-Sample 02
An invoice with document-level discounts and charges applied to the total amount.
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-2023-532",
"DocType": "TAXINVOICE",
"DocForm": "INVOICE",
"Note": "Standard invoice with document-level allowances",
"IssueDate": "2025-08-16",
"IssueTime": "20:30:00",
"DocCurrency": "SAR",
"PaymentMethod": "CreditCard",
"CustomerName": "B2B Customer",
"AllowanceCharges": [
{
"Type": "ALLOWANCE",
"Reason": "Corporate Discount",
"Amount": 200.00,
"TaxRate": 15.00,
"TaxCategory": "S"
},
{
"Type": "CHARGE",
"Reason": "Installation Fee",
"Amount": 150.00,
"TaxRate": 15.00,
"TaxCategory": "S"
}
],
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Workstation PC",
"Quantity": 3,
"UnitCode": "NOS",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 3500,
"Currency": "SAR"
}
]
}
Mixed Tax Categories Invoice- Sample 03
An invoice containing items with different tax categories (Standard, Zero-rated, and Exempt).
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-2023-523",
"DocType": "TAXINVOICE",
"DocForm": "INVOICE",
"IssueDate": "2025-08-16",
"IssueTime": "20:35:00",
"DocCurrency": "SAR",
"PaymentMethod": "BankTransfer",
"CustomerName": "B2B Customer",
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "IT Consulting Services",
"Quantity": 40,
"UnitCode": "HUR",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 250,
"Currency": "SAR"
},
{
"LineNo": 2,
"ItemName": "International Shipping",
"Quantity": 5,
"UnitCode": "BOX",
"TaxCategory": "Z",
"TaxRate": 0,
"ItemPrice": 750,
"Currency": "SAR",
"VatExemptionCode": "VATEX-SA-34-4",
"VatExemptionReason": "International transport services"
},
{
"LineNo": 3,
"ItemName": "Medical Equipment",
"Quantity": 8,
"UnitCode": "PCE",
"TaxCategory": "E",
"TaxRate": 0,
"ItemPrice": 1200,
"Currency": "SAR",
"VatExemptionCode": "VATEX-SA-MED",
"VatExemptionReason": "Medical equipment exempt under VAT regulations"
}
]
}
Credit Note with Reference - Sample 04
A credit note referencing the original invoice being credited.
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-CN-2023-524",
"DocType": "TAXINVOICE",
"DocForm": "CREDITNOTE",
"Note": "Return of defective equipment",
"IssueDate": "2025-08-16",
"IssueTime": "20:40:00",
"DocCurrency": "SAR",
"PaymentMethod": "Credit",
"CustomerName": "B2B Customer",
"PreviousInvoiceRef": "STD-INV-2023-045",
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Defective Server Rack",
"Quantity": 1,
"UnitCode": "PCE",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 8500,
"Currency": "SAR"
}
]
}
Debit Note with Reference - Sample 05
A debit note referencing the original invoice being debited.
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-DN-2023-525",
"DocType": "TAXINVOICE",
"DocForm": "DEBITNOTE",
"Note": "Additional services rendered",
"IssueDate": "2025-08-16",
"IssueTime": "20:45:00",
"DocCurrency": "SAR",
"PaymentMethod": "DebitTransfer",
"CustomerName": "B2B Customer",
"PreviousInvoiceRef": "STD-INV-2023-045",
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Additional Support Hours",
"Quantity": 10,
"UnitCode": "HUR",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 200,
"Currency": "SAR"
}
]
}
Invoice with Line-Level Allowances - Sample 06
An invoice with discounts applied at the line-item level.
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-2023-526",
"DocType": "TAXINVOICE",
"DocForm": "INVOICE",
"IssueDate": "2025-08-16",
"IssueTime": "20:50:00",
"DocCurrency": "SAR",
"PaymentMethod": "Cash",
"CustomerName": "B2B Customer",
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Conference Table",
"Quantity": 3,
"UnitCode": "PCE",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 1200,
"Currency": "SAR",
"AllowanceCharges": [
{
"Type": "ALLOWANCE",
"Reason": "Corporate discount",
"Amount": 150
},
{
"Type": "ALLOWANCE",
"Reason": "Early payment discount",
"Amount": 75
}
]
}
]
}
Sample with full json attrbutes set - Sample 07
This sample was not implemented in code. given here for your reference only
{
"UnitId": "TST-C22FF20EFD-DIANA152",
"InvoiceNo": "STD-000101",
"DocType": "TAXINVOICE",
"DocForm": "INVOICE",
"Note": "Corporate customer sale with prepayments",
"IssueDate": "2025-07-17",
"IssueTime": "03:06:14",
"DocCurrency": "SAR",
"ActualDelivery": "2025-07-17",
"LatestDelivery": "2025-07-17",
"PaymentMethod": "BankTransfer",
"CustomerName": "B2B Customer",
"PreviousInvoiceRef": "STD-INV-00020",
"AllowanceCharges": [
{
"Type": "ALLOWANCE",
"Reason": "Annual Contract Discount",
"Amount": 500.00,
"TaxRate": 15.00,
"TaxCategory": "S"
},
{
"Type": "CHARGE",
"Reason": "Emergency Service Fee",
"Amount": 300.00,
"TaxRate": 15.00,
"TaxCategory": "S"
}
],
"InvoiceLines": [
{
"LineNo": 1,
"ItemName": "Annual Software License",
"Quantity": 1,
"UnitCode": "LIC",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 15000,
"Currency": "SAR",
"BaseQuantity": 1,
"BaseUnitCode": "LIC",
"AllowanceCharges": [
{
"Type": "ALLOWANCE",
"Reason": "Multi-year commitment",
"Amount": 1500
}
]
},
{
"LineNo": 2,
"ItemName": "Premium Support Package",
"Quantity": 1,
"UnitCode": "PKG",
"TaxCategory": "S",
"TaxRate": 15,
"ItemPrice": 5000,
"Currency": "SAR",
"BaseQuantity": 1,
"BaseUnitCode": "PKG"
}
],
"PrePayments": [
{
"Amount": 7500,
"Quantity": 1,
"UnitCode": "PCE",
"ItemName": "Initial Deposit",
"TaxCategory": "S",
"Rate": "15",
"Currency": "SAR",
"BaseQuantity": 1,
"BaseUnit": "PCE",
"PrePaidInvoiceNo": "STD-PP-000454",
"PrePaidInvoiceIssueDate": "2025-07-10",
"PrePaidInvoiceIssueTime": "06:08:14"
}
]
}
C# Code samples
Input and Output Data Objects
Samples provide all neccessary classes to implement invoice objects
public class StandardInvoiceDto
{
public string UnitId { get; set; }
public string InvoiceNo { get; set; }
public string DocType { get; set; }
public string DocForm { get; set; }
public string Note { get; set; }
public string IssueDate { get; set; }
public string IssueTime { get; set; }
public string DocCurrency { get; set; }
public string ActualDelivery { get; set; }
public string LatestDelivery { get; set; }
public string PaymentMethod { get; set; }
public string CustomerName { get; set; }
public string PreviousInvoiceRef { get; set; }
public List AllowanceCharges { get; set; } = new List();
public List InvoiceLines { get; set; } = new List();
public List PrePayments { get; set; } = new List();
}
public class StandardInvoiceAllowanceChargeDto
{
public string Type { get; set; } // "ALLOWANCE" or "CHARGE"
public string Reason { get; set; }
public decimal Amount { get; set; }
public decimal TaxRate { get; set; }
public string TaxCategory { get; set; } // "S", "Z", "E", etc.
}
public class StandardInvoiceLineDto
{
public int LineNo { get; set; }
public string ItemName { get; set; }
public decimal Quantity { get; set; }
public string UnitCode { get; set; }
public string TaxCategory { get; set; }
public decimal TaxRate { get; set; }
public decimal ItemPrice { get; set; }
public string Currency { get; set; }
public decimal BaseQuantity { get; set; }
public string BaseUnitCode { get; set; }
public string VatExemptionCode { get; set; }
public string VatExemptionReason { get; set; }
public List AllowanceCharges { get; set; } = new List();
}
public class StandardInvoiceLineAllowanceChargeDto
{
public string Type { get; set; } // "ALLOWANCE" or "CHARGE"
public string Reason { get; set; }
public decimal Amount { get; set; }
}
public class StandardPrePaymentsDto
{
public decimal Amount { get; set; }
public decimal Quantity { get; set; }
public string UnitCode { get; set; }
public string ItemName { get; set; }
public string TaxCategory { get; set; }
public string Rate { get; set; }
public string Currency { get; set; }
public decimal BaseQuantity { get; set; }
public string BaseUnit { get; set; }
public string PrePaidInvoiceNo { get; set; }
public string PrePaidInvoiceIssueDate { get; set; }
public string PrePaidInvoiceIssueTime { get; set; }
}
// The ZatcaApiResponse can remain the same as it's generic for both simplified and standard invoices
public class ZatcaApiResponse
{
public string Status { get; set; }
public string Message { get; set; }
public string Icv { get; set; }
public string Hash { get; set; }
public string Uuid { get; set; }
public string QrCodeValue { get; set; }
}
Sample code of creating Invoice objects in each scenario
Samples provide all neccessary classes to implement invoice objects
public class ZatcaStandardInvoiceApiClient
{
private readonly HttpClient _httpClient;
private readonly string _baseUrl;
private readonly string _jwtToken;
public ZatcaStandardInvoiceApiClient(string baseUrl, string jwtToken)
{
_baseUrl = baseUrl ?? throw new ArgumentNullException(nameof(baseUrl));
_jwtToken = jwtToken ?? throw new ArgumentNullException(nameof(jwtToken));
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _jwtToken);
}
public async Task ClearStandardInvoice(StandardInvoiceDto invoice)
{
var endpoint = $"{_baseUrl}/api/ZatcaIntegration/ClearInvoice";
var jsonContent = JsonConvert.SerializeObject(invoice);
var httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync(endpoint, httpContent);
if (!response.IsSuccessStatusCode)
{
var errorContent = await response.Content.ReadAsStringAsync();
throw new HttpRequestException($"API call failed with status code {response.StatusCode}. Response: {errorContent}");
}
var responseContent = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject(responseContent);
}
// Sample invoice creation methods – Sample 01
public StandardInvoiceDto CreateBasicStandardInvoice()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-000532",
DocType = "TAXINVOICE",
DocForm = "INVOICE",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "Cash",
CustomerName = "B2B Customer",
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Laptop Dell Precision 7560",
Quantity = 1,
UnitCode = "NOS",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 4500,
Currency = "SAR"
}
}
};
}
// Sample invoice creation methods – Sample 02
public StandardInvoiceDto CreateStandardInvoiceWithDocumentAllowances()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-2023-532",
DocType = "TAXINVOICE",
DocForm = "INVOICE",
Note = "Standard invoice with document-level allowances",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "CreditCard",
CustomerName = "B2B Customer",
AllowanceCharges = new List
{
new StandardInvoiceAllowanceChargeDto
{
Type = "ALLOWANCE",
Reason = "Corporate Discount",
Amount = 200.00m,
TaxRate = 15.00m,
TaxCategory = "S"
},
new StandardInvoiceAllowanceChargeDto
{
Type = "CHARGE",
Reason = "Installation Fee",
Amount = 150.00m,
TaxRate = 15.00m,
TaxCategory = "S"
}
},
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Workstation PC",
Quantity = 3,
UnitCode = "NOS",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 3500,
Currency = "SAR"
}
}
};
}
// Sample invoice creation methods – Sample 03
public StandardInvoiceDto CreateMixedTaxStandardInvoice()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-2023-523",
DocType = "TAXINVOICE",
DocForm = "INVOICE",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "BankTransfer",
CustomerName = "B2B Customer",
InvoiceLines = new List
{
new StandardInvoiceLineDto // Standard rated
{
LineNo = 1,
ItemName = "IT Consulting Services",
Quantity = 40,
UnitCode = "HUR",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 250,
Currency = "SAR"
},
new StandardInvoiceLineDto // Zero-rated
{
LineNo = 2,
ItemName = "International Shipping",
Quantity = 5,
UnitCode = "BOX",
TaxCategory = "Z",
TaxRate = 0,
ItemPrice = 750,
Currency = "SAR",
VatExemptionCode = "VATEX-SA-34-4",
VatExemptionReason = "International transport services"
},
new StandardInvoiceLineDto // Exempt
{
LineNo = 3,
ItemName = "Medical Equipment",
Quantity = 8,
UnitCode = "PCE",
TaxCategory = "E",
TaxRate = 0,
ItemPrice = 1200,
Currency = "SAR",
VatExemptionCode = "VATEX-SA-MED",
VatExemptionReason = "Medical equipment exempt under VAT regulations"
}
}
};
}
// Sample invoice creation methods – Sample 04
public StandardInvoiceDto CreateStandardCreditNote()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-CN-2023-524",
DocType = "TAXINVOICE",
DocForm = "CREDITNOTE",
Note = "Return of defective equipment",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "Credit",
CustomerName = "B2B Customer",
PreviousInvoiceRef = "STD-INV-2023-045",
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Defective Server Rack",
Quantity = 1,
UnitCode = "PCE",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 8500,
Currency = "SAR"
}
}
};
}
// Sample invoice creation methods – Sample 05
public StandardInvoiceDto CreateStandardDebitNote()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-DN-2023-525",
DocType = "TAXINVOICE",
DocForm = "DEBITNOTE",
Note = "Additional services rendered",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "DebitTransfer",
CustomerName = "B2B Customer",
PreviousInvoiceRef = "STD-INV-2023-045",
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Additional Support Hours",
Quantity = 10,
UnitCode = "HUR",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 200,
Currency = "SAR"
}
}
};
}
// Sample invoice creation methods – Sample 06
public StandardInvoiceDto CreateStandardInvoiceWithLineAllowances()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-2023-526",
DocType = "TAXINVOICE",
DocForm = "INVOICE",
IssueDate = DateTime.Now.ToString("yyyy-MM-dd"),
IssueTime = DateTime.Now.ToString("HH:mm:ss"),
DocCurrency = "SAR",
PaymentMethod = "Cash",
CustomerName = "B2B Customer",
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Conference Table",
Quantity = 3,
UnitCode = "PCE",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 1200,
Currency = "SAR",
AllowanceCharges = new List
{
new StandardInvoiceLineAllowanceChargeDto
{
Type = "ALLOWANCE",
Reason = "Corporate discount",
Amount = 150
},
new StandardInvoiceLineAllowanceChargeDto
{
Type = "ALLOWANCE",
Reason = "Early payment discount",
Amount = 75
}
}
}
}
};
}
// Sample invoice creation methods – Sample 07
public StandardInvoiceDto CreateStandardInvoiceWithPrePaymentsAndMixedItems()
{
return new StandardInvoiceDto
{
UnitId = "TST-C22FF20EFD-DIANA152",
InvoiceNo = "STD-000101",
DocType = "TAXINVOICE",
DocForm = "INVOICE",
Note = "Corporate customer sale with prepayments",
IssueDate = "2025-07-17",
IssueTime = "03:06:14",
DocCurrency = "SAR",
ActualDelivery = "2025-07-17",
LatestDelivery = "2025-07-17",
PaymentMethod = "BankTransfer",
CustomerName = "B2B Customer",
PreviousInvoiceRef = "STD-INV-00020",
AllowanceCharges = new List
{
new StandardInvoiceAllowanceChargeDto
{
Type = "ALLOWANCE",
Reason = "Annual Contract Discount",
Amount = 500.00m,
TaxRate = 15.00m,
TaxCategory = "S"
},
new StandardInvoiceAllowanceChargeDto
{
Type = "CHARGE",
Reason = "Emergency Service Fee",
Amount = 300.00m,
TaxRate = 15.00m,
TaxCategory = "S"
}
},
InvoiceLines = new List
{
new StandardInvoiceLineDto
{
LineNo = 1,
ItemName = "Annual Software License",
Quantity = 1,
UnitCode = "LIC",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 15000,
Currency = "SAR",
BaseQuantity = 1,
BaseUnitCode = "LIC",
AllowanceCharges = new List
{
new StandardInvoiceLineAllowanceChargeDto
{
Type = "ALLOWANCE",
Reason = "Multi-year commitment",
Amount = 1500
}
}
},
new StandardInvoiceLineDto
{
LineNo = 2,
ItemName = "Premium Support Package",
Quantity = 1,
UnitCode = "PKG",
TaxCategory = "S",
TaxRate = 15,
ItemPrice = 5000,
Currency = "SAR",
BaseQuantity = 1,
BaseUnitCode = "PKG"
}
},
PrePayments = new List
{
new StandardPrePaymentsDto
{
Amount = 7500,
Quantity = 1,
UnitCode = "PCE",
ItemName = "Initial Deposit",
TaxCategory = "S",
Rate = "15",
Currency = "SAR",
BaseQuantity = 1,
BaseUnit = "PCE",
PrePaidInvoiceNo = "STD-PP-000454",
PrePaidInvoiceIssueDate = "2025-07-10",
PrePaidInvoiceIssueTime = "06:08:14"
}
}
};
}
}
Code samples of calling Simplified invoice reporting API's'
Samples provides Consple applicate code to run API
public class Program
{
public static async Task Main(string[] args)
{
const string apiBaseUrl = "https://www.pristineinvoice.com";
const string jwtToken = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImRpYW5hZ3VuYXdhcmRhbmEiLCJuYW1laWQiOiI5YzcxMzk1YS03ODBjLTQwOWYtYmYxNy01MDhlMzFkMDEwM2UiLCJlbWFpbCI6ImRpYW5hZ3VuYXdhcmRhbmFAZ21haWwuY29tIiwiVGVuYW50SWQiOiJDMjJGRjIwRUZEIiwiUHJvZHVjdCI6IlN1YnNjcmlwdGlvbiIsIm5iZiI6MTc1NTMyOTAzMiwiZXhwIjoxNzU4MDA3NDMyLCJpYXQiOjE3NTUzMjkwMzIsImlzcyI6Imh0dHBzOi8vd3d3LnByaXN0aW5laW52b2ljZS5jb20iLCJhdWQiOiJodHRwczovL3d3dy5wcmlzdGluZWludm9pY2UuY29tIn0.igAGuZTCPcuA3SD-2fFUeNOfrdANPJsBze25wABuj6R4xZzjd1fWIbtbWSSVyClMECu9HNyyvQXOfMtyIs4QZg";
var zatcaClient = new ZatcaStandardInvoiceApiClient(apiBaseUrl, jwtToken);
try
{
// Example 1: Basic standard invoice
var basicInvoice = zatcaClient.CreateBasicStandardInvoice();
var basicResponse = await zatcaClient.ClearStandardInvoice(basicInvoice);
Console.WriteLine($"Basic standard invoice reported. UUID: {basicResponse.Uuid}\nMessage: {basicResponse.Message}");
// Example 2: Standard invoice with document allowances
var allowanceInvoice = zatcaClient.CreateStandardInvoiceWithDocumentAllowances();
var allowanceResponse = await zatcaClient.ClearStandardInvoice(allowanceInvoice);
Console.WriteLine($"\nAllowance standard invoice reported. QR Code: {allowanceResponse.QrCodeValue}\nHash: {allowanceResponse.Hash}\nMessage: {basicResponse.Message}");
// Example 3: Mixed tax standard invoice
var mixedTaxInvoice = zatcaClient.CreateMixedTaxStandardInvoice();
var mixedTaxResponse = await zatcaClient.ClearStandardInvoice(mixedTaxInvoice);
Console.WriteLine($"\nMixed tax standard invoice reported. ICV: {mixedTaxResponse.Icv}\nMessage: {mixedTaxResponse.Message}");
// Example 4: Standard credit note
var creditNote = zatcaClient.CreateStandardCreditNote();
var creditNoteResponse = await zatcaClient.ClearStandardInvoice(creditNote);
Console.WriteLine($"\nStandard credit note reported. Status: {creditNoteResponse.Status}\nUUID: {creditNoteResponse.Uuid}\nMessage: {basicResponse.Message}");
// Example 5: Standard debit note
var debitNote = zatcaClient.CreateStandardDebitNote();
var debitNoteResponse = await zatcaClient.ClearStandardInvoice(debitNote);
Console.WriteLine($"\nStandard debit note reported. ICV: {debitNoteResponse.Icv}\nQR Code: {debitNoteResponse.QrCodeValue}\nMessage: {basicResponse.Message}");
// Example 6: Standard invoice with line allowances
var lineAllowanceInvoice = zatcaClient.CreateStandardInvoiceWithLineAllowances();
var lineAllowanceResponse = await zatcaClient.ClearStandardInvoice(lineAllowanceInvoice);
Console.WriteLine($"\nLine allowance standard invoice reported. Status: {lineAllowanceResponse.Status}\nHash: {lineAllowanceResponse.Hash}\nMessage: {basicResponse.Message}");
Console.WriteLine("\nAll standard invoice examples completed successfully.");
}
catch (HttpRequestException httpEx)
{
Console.WriteLine($"\nHTTP Error: {httpEx.Message}");
if (httpEx.Data.Contains("ResponseContent"))
{
Console.WriteLine($"Server response: {httpEx.Data["ResponseContent"]}");
}
}
catch (Exception ex)
{
Console.WriteLine($"\nUnexpected error: {ex.Message}");
Console.WriteLine($"Stack trace: {ex.StackTrace}");
}
}
}
Download Standard invoice sample
This console application project developed in c# contains complete source code