Class: FactPulse::InvoiceProcessingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/factpulse/api/invoice_processing_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ InvoiceProcessingApi

Returns a new instance of InvoiceProcessingApi.



19
20
21
# File 'lib/factpulse/api/invoice_processing_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



17
18
19
# File 'lib/factpulse/api/invoice_processing_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#generate_invoice_api_v1_processing_generate_invoice_post(invoice_data, opts = {}) ⇒ TaskResponse

Generate a Factur-X invoice Generates an electronic invoice in Factur-X format compliant with European standards. ## Applied Standards - Factur-X (France): FNFE-MPE standard (Forum National de la Facture Électronique) - ZUGFeRD (Germany): German format compatible with Factur-X - EN 16931: European semantic standard for electronic invoicing - ISO 19005-3 (PDF/A-3): Long-term electronic archiving - Cross Industry Invoice (CII): UN/CEFACT XML syntax ## 🆕 New: Simplified format with auto-enrichment (P0.1) You can now create an invoice by providing only: - An invoice number - A supplier SIRET + IBAN (required) - A recipient SIRET - Invoice lines (description, quantity, net price) Simplified format example: json { \"number\": \"FACT-2025-001\", \"supplier\": { \"siret\": \"92019522900017\", \"iban\": \"FR7630001007941234567890185\" }, \"recipient\": {\"siret\": \"35600000000048\"}, \"lines\": [ {\"description\": \"Service\", \"quantity\": 10, \"unitPrice\": 100.00, \"vatRate\": 20.0} ] } ⚠️ Required fields (simplified format): - number: Unique invoice number - supplier.siret: Supplier's SIRET (14 digits) - supplier.iban: Bank account IBAN (no public API to retrieve it) - recipient.siret: Recipient's SIRET - lines[]: At least one invoice line What happens automatically with auto_enrich=True: - ✅ Name enrichment from Chorus Pro API - ✅ Address enrichment from Business Search API (free, public) - ✅ Automatic intra-EU VAT calculation (FR + key + SIREN) - ✅ Chorus Pro ID retrieval for electronic invoicing - ✅ Net/VAT/Gross totals calculation - ✅ Date generation (today + 30-day due date) - ✅ Multi-rate VAT handling Supported identifiers: - SIRET (14 digits): Specific establishment ⭐ Recommended - SIREN (9 digits): Company (auto-selection of headquarters) - Special types: UE_HORS_FRANCE, RIDET, TAHITI, etc. ## Checks performed during generation ### 1. Data validation (Pydantic) - Data types (amounts as Decimal, ISO 8601 dates) - Formats (14-digit SIRET, 9-digit SIREN, IBAN) - Required fields per profile - Amount consistency (Net + VAT = Gross) ### 2. CII-compliant XML generation - Serialization according to Cross Industry Invoice XSD schema - Correct UN/CEFACT namespaces - Hierarchical structure respected - UTF-8 encoding without BOM ### 3. Schematron validation - Business rules for selected profile (MINIMUM, BASIC, EN16931, EXTENDED) - Element cardinality (required, optional, repeatable) - Calculation rules (totals, VAT, discounts) - European EN 16931 compliance ### 4. PDF/A-3 conversion (if output_format='pdf') - Source PDF conversion to PDF/A-3 via Ghostscript - Factur-X XML embedding in PDF - Compliant XMP metadata - ICC sRGB color profile - Removal of forbidden elements (JavaScript, forms) ## How it works 1. Submission: Invoice is queued in Celery for asynchronous processing 2. Immediate return: You receive a task_id (HTTP 202 Accepted) 3. Tracking: Use the /tasks/{task_id}/status endpoint to track progress ## Webhook notification (recommended) Instead of polling, you can receive a webhook notification when the task completes: callback_url=https://your-server.com/webhook The webhook will POST a JSON payload with: - event_type: generation.completed or generation.failed - data.task_id: The Celery task ID - data.content_b64 or data.xml_content: The generated content - X-Webhook-Signature header for HMAC verification See /docs/WEBHOOKS.md for full documentation. ## Output formats - xml: Generates only Factur-X XML (recommended for testing) - pdf: Generates PDF/A-3 with embedded XML (requires source_pdf) ## Factur-X profiles - MINIMUM: Minimal data (simplified invoice) - BASIC: Basic information (SMEs) - EN16931: European standard (recommended, compliant with directive 2014/55/EU) - EXTENDED: All available data (large accounts) ## What you get After successful processing (status completed): - XML only: Base64-encoded Factur-X compliant XML file - PDF/A-3: PDF with embedded XML, ready for sending/archiving - Metadata: Profile, Factur-X version, file size - Validation: Schematron compliance confirmation ## Validation Data is automatically validated according to detected format. On error, a 422 status is returned with invalid field details.

Parameters:

  • invoice_data (String) —

    Invoice data in JSON format. Two formats accepted: 1. Classic format: Complete FacturXInvoice structure (all fields) 2. Simplified format (🆕 P0.1): Minimal structure with auto-enrichment Format is detected automatically!

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile) —

    Factur-X profile: MINIMUM, BASIC, EN16931 or EXTENDED.

  • :output_format (OutputFormat) —

    Output format: 'xml' (XML only) or 'pdf' (Factur-X PDF with embedded XML).

  • :auto_enrich (Boolean) —

    🆕 Enable auto-enrichment from SIRET/SIREN (simplified format only) (default to true)

  • :source_pdf (File)
  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

  • :skip_br_fr (Boolean)

Returns:



34
35
36
37
# File 'lib/factpulse/api/invoice_processing_api.rb', line 34

def generate_invoice_api_v1_processing_generate_invoice_post(invoice_data, opts = {})
  data, _status_code, _headers = generate_invoice_api_v1_processing_generate_invoice_post_with_http_info(invoice_data, opts)
  data
end

#generate_invoice_api_v1_processing_generate_invoice_post_with_http_info(invoice_data, opts = {}) ⇒ Array<(TaskResponse, Integer, Hash)>

Generate a Factur-X invoice Generates an electronic invoice in Factur-X format compliant with European standards. ## Applied Standards - Factur-X (France): FNFE-MPE standard (Forum National de la Facture Électronique) - ZUGFeRD (Germany): German format compatible with Factur-X - EN 16931: European semantic standard for electronic invoicing - ISO 19005-3 (PDF/A-3): Long-term electronic archiving - Cross Industry Invoice (CII): UN/CEFACT XML syntax ## 🆕 New: Simplified format with auto-enrichment (P0.1) You can now create an invoice by providing only: - An invoice number - A supplier SIRET + IBAN (required) - A recipient SIRET - Invoice lines (description, quantity, net price) Simplified format example: ```json { &quot;number&quot;: &quot;FACT-2025-001&quot;, &quot;supplier&quot;: { &quot;siret&quot;: &quot;92019522900017&quot;, &quot;iban&quot;: &quot;FR7630001007941234567890185&quot; }, &quot;recipient&quot;: \"35600000000048\", &quot;lines&quot;: [ \"Service\", \"quantity\": 10, \"unitPrice\": 100.00, \"vatRate\": 20.0 ] } ``` ⚠️ Required fields (simplified format): - `number`: Unique invoice number - `supplier.siret`: Supplier's SIRET (14 digits) - `supplier.iban`: Bank account IBAN (no public API to retrieve it) - `recipient.siret`: Recipient's SIRET - `lines`: At least one invoice line What happens automatically with `auto_enrich=True`: - ✅ Name enrichment from Chorus Pro API - ✅ Address enrichment from Business Search API (free, public) - ✅ Automatic intra-EU VAT calculation (FR + key + SIREN) - ✅ Chorus Pro ID retrieval for electronic invoicing - ✅ Net/VAT/Gross totals calculation - ✅ Date generation (today + 30-day due date) - ✅ Multi-rate VAT handling Supported identifiers: - SIRET (14 digits): Specific establishment ⭐ Recommended - SIREN (9 digits): Company (auto-selection of headquarters) - Special types: UE_HORS_FRANCE, RIDET, TAHITI, etc. ## Checks performed during generation ### 1. Data validation (Pydantic) - Data types (amounts as Decimal, ISO 8601 dates) - Formats (14-digit SIRET, 9-digit SIREN, IBAN) - Required fields per profile - Amount consistency (Net + VAT = Gross) ### 2. CII-compliant XML generation - Serialization according to Cross Industry Invoice XSD schema - Correct UN/CEFACT namespaces - Hierarchical structure respected - UTF-8 encoding without BOM ### 3. Schematron validation - Business rules for selected profile (MINIMUM, BASIC, EN16931, EXTENDED) - Element cardinality (required, optional, repeatable) - Calculation rules (totals, VAT, discounts) - European EN 16931 compliance ### 4. PDF/A-3 conversion (if output_format='pdf') - Source PDF conversion to PDF/A-3 via Ghostscript - Factur-X XML embedding in PDF - Compliant XMP metadata - ICC sRGB color profile - Removal of forbidden elements (JavaScript, forms) ## How it works 1. Submission: Invoice is queued in Celery for asynchronous processing 2. Immediate return: You receive a `task_id` (HTTP 202 Accepted) 3. Tracking: Use the `/tasks/task_id/status` endpoint to track progress ## Webhook notification (recommended) Instead of polling, you can receive a webhook notification when the task completes: ``` callback_url=https://your-server.com/webhook ``` The webhook will POST a JSON payload with: - `event_type`: `generation.completed` or `generation.failed` - `data.task_id`: The Celery task ID - `data.content_b64` or `data.xml_content`: The generated content - `X-Webhook-Signature` header for HMAC verification See `/docs/WEBHOOKS.md` for full documentation. ## Output formats - xml: Generates only Factur-X XML (recommended for testing) - pdf: Generates PDF/A-3 with embedded XML (requires `source_pdf`) ## Factur-X profiles - MINIMUM: Minimal data (simplified invoice) - BASIC: Basic information (SMEs) - EN16931: European standard (recommended, compliant with directive 2014/55/EU) - EXTENDED: All available data (large accounts) ## What you get After successful processing (status `completed`): - XML only: Base64-encoded Factur-X compliant XML file - PDF/A-3: PDF with embedded XML, ready for sending/archiving - Metadata: Profile, Factur-X version, file size - Validation: Schematron compliance confirmation ## Validation Data is automatically validated according to detected format. On error, a 422 status is returned with invalid field details.

Parameters:

  • invoice_data (String) —

    Invoice data in JSON format. Two formats accepted: 1. Classic format: Complete FacturXInvoice structure (all fields) 2. Simplified format (🆕 P0.1): Minimal structure with auto-enrichment Format is detected automatically!

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile) —

    Factur-X profile: MINIMUM, BASIC, EN16931 or EXTENDED.

  • :output_format (OutputFormat) —

    Output format: 'xml' (XML only) or 'pdf' (Factur-X PDF with embedded XML).

  • :auto_enrich (Boolean) —

    🆕 Enable auto-enrichment from SIRET/SIREN (simplified format only) (default to true)

  • :source_pdf (File)
  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

  • :skip_br_fr (Boolean)

Returns:

  • (Array<(TaskResponse, Integer, Hash)>) —

    TaskResponse data, response status code and response headers



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/factpulse/api/invoice_processing_api.rb', line 51

def generate_invoice_api_v1_processing_generate_invoice_post_with_http_info(invoice_data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.generate_invoice_api_v1_processing_generate_invoice_post ...'
  end
  # verify the required parameter 'invoice_data' is set
  if @api_client.config.client_side_validation && invoice_data.nil?
    fail ArgumentError, "Missing the required parameter 'invoice_data' when calling InvoiceProcessingApi.generate_invoice_api_v1_processing_generate_invoice_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/generate-invoice'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['invoice_data'] = invoice_data
  form_params['profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  form_params['output_format'] = opts[:'output_format'] if !opts[:'output_format'].nil?
  form_params['auto_enrich'] = opts[:'auto_enrich'] if !opts[:'auto_enrich'].nil?
  form_params['source_pdf'] = opts[:'source_pdf'] if !opts[:'source_pdf'].nil?
  form_params['callback_url'] = opts[:'callback_url'] if !opts[:'callback_url'].nil?
  form_params['webhook_mode'] = opts[:'webhook_mode'] if !opts[:'webhook_mode'].nil?
  form_params['skip_br_fr'] = opts[:'skip_br_fr'] if !opts[:'skip_br_fr'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TaskResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.generate_invoice_api_v1_processing_generate_invoice_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#generate_invoice_api_v1_processing_generate_invoice_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#generate_test_certificate_api_v1_processing_generate_test_certificate_post(generate_certificate_request, opts = {}) ⇒ GenerateCertificateResponse

Generate a self-signed X.509 test certificate Generates a self-signed X.509 certificate for PDF electronic signature testing. ⚠️ WARNING: TEST certificate only! This certificate is: - ✅ Suitable for testing and development - ✅ Compatible with PDF signing (PAdES) - ✅ Compliant with eIDAS SES level (Simple Electronic Signature) - ❌ NEVER usable in production - ❌ Not recognized by browsers and PDF readers - ❌ No legal value ## eIDAS levels - SES (Simple): Self-signed certificate ← Generated by this endpoint - AdES (Advanced): Commercial CA certificate (Let's Encrypt, etc.) - QES (Qualified): Qualified certificate from QTSP (CertEurope, Universign, etc.) ## Usage Once generated, the certificate can be: 1. Saved in Django (recommended): - Django Admin > Signing Certificates - Upload certificate_pem and private_key_pem 2. Used directly: - Sign a PDF with /sign-pdf - The certificate will be automatically used ## Example call bash curl -X POST \"https://factpulse.fr/api/v1/processing/generate-test-certificate\" \\ -H \"Authorization: Bearer eyJ0eXAi...\" \\ -H \"Content-Type: application/json\" \\ -d '{ \"cn\": \"Test Client XYZ\", \"organization\": \"Client XYZ Ltd\", \"email\": \"[email protected]\", \"validity_days\": 365 }' ## Use cases - PDF signature testing in development - Electronic signature POC - Training and demos - Automated integration tests ## Technical compliance Certificate generated with: - RSA key 2048 or 4096 bits - SHA-256 algorithm - Key Usage extensions: digitalSignature, contentCommitment (non-repudiation) - Extended Key Usage extensions: codeSigning, emailProtection - Validity: 1 day to 10 years (configurable) - Format: PEM (certificate and key) - Optional: PKCS#12 (.p12)

Parameters:

Returns:



117
118
119
120
# File 'lib/factpulse/api/invoice_processing_api.rb', line 117

def generate_test_certificate_api_v1_processing_generate_test_certificate_post(generate_certificate_request, opts = {})
  data, _status_code, _headers = generate_test_certificate_api_v1_processing_generate_test_certificate_post_with_http_info(generate_certificate_request, opts)
  data
end

#generate_test_certificate_api_v1_processing_generate_test_certificate_post_with_http_info(generate_certificate_request, opts = {}) ⇒ Array<(GenerateCertificateResponse, Integer, Hash)>

Generate a self-signed X.509 test certificate Generates a self-signed X.509 certificate for PDF electronic signature testing. ⚠️ WARNING: TEST certificate only! This certificate is: - ✅ Suitable for testing and development - ✅ Compatible with PDF signing (PAdES) - ✅ Compliant with eIDAS SES level (Simple Electronic Signature) - ❌ NEVER usable in production - ❌ Not recognized by browsers and PDF readers - ❌ No legal value ## eIDAS levels - SES (Simple): Self-signed certificate ← Generated by this endpoint - AdES (Advanced): Commercial CA certificate (Let's Encrypt, etc.) - QES (Qualified): Qualified certificate from QTSP (CertEurope, Universign, etc.) ## Usage Once generated, the certificate can be: 1. Saved in Django (recommended): - Django Admin > Signing Certificates - Upload `certificate_pem` and `private_key_pem` 2. Used directly: - Sign a PDF with `/sign-pdf` - The certificate will be automatically used ## Example call ```bash curl -X POST &quot;https://factpulse.fr/api/v1/processing/generate-test-certificate&quot; \ -H &quot;Authorization: Bearer eyJ0eXAi...&quot; \ -H &quot;Content-Type: application/json&quot; \ -d '{ &quot;cn&quot;: &quot;Test Client XYZ&quot;, &quot;organization&quot;: &quot;Client XYZ Ltd&quot;, &quot;email&quot;: &quot;[email protected]&quot;, &quot;validity_days&quot;: 365 }' ``` ## Use cases - PDF signature testing in development - Electronic signature POC - Training and demos - Automated integration tests ## Technical compliance Certificate generated with: - RSA key 2048 or 4096 bits - SHA-256 algorithm - Key Usage extensions: `digitalSignature`, `contentCommitment` (non-repudiation) - Extended Key Usage extensions: `codeSigning`, `emailProtection` - Validity: 1 day to 10 years (configurable) - Format: PEM (certificate and key) - Optional: PKCS#12 (.p12)

Parameters:

Returns:

  • (Array<(GenerateCertificateResponse, Integer, Hash)>) —

    GenerateCertificateResponse data, response status code and response headers



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/factpulse/api/invoice_processing_api.rb', line 127

def generate_test_certificate_api_v1_processing_generate_test_certificate_post_with_http_info(generate_certificate_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.generate_test_certificate_api_v1_processing_generate_test_certificate_post ...'
  end
  # verify the required parameter 'generate_certificate_request' is set
  if @api_client.config.client_side_validation && generate_certificate_request.nil?
    fail ArgumentError, "Missing the required parameter 'generate_certificate_request' when calling InvoiceProcessingApi.generate_test_certificate_api_v1_processing_generate_test_certificate_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/generate-test-certificate'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(generate_certificate_request)

  # return_type
  return_type = opts[:debug_return_type] || 'GenerateCertificateResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.generate_test_certificate_api_v1_processing_generate_test_certificate_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#generate_test_certificate_api_v1_processing_generate_test_certificate_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_task_status_api_v1_processing_tasks_task_id_status_get(task_id, opts = {}) ⇒ AsyncTaskStatus

Get task generation status Retrieves the progress status of an invoice generation task. ## Possible states The status field uses the CeleryStatus enum with values: - PENDING, STARTED, SUCCESS, FAILURE, RETRY See the CeleryStatus schema documentation for details. ## Business result When status=\"SUCCESS\", the result field contains: - status: "SUCCESS" or "ERROR" (business result) - content_b64: Base64 encoded content (if success) - errorCode, errorMessage, details: AFNOR format (if business error) ## Usage Poll this endpoint every 2-3 seconds until status is SUCCESS or FAILURE.

Parameters:

  • task_id (String) —

    Celery task ID returned by async endpoints (UUID format)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:



185
186
187
188
# File 'lib/factpulse/api/invoice_processing_api.rb', line 185

def get_task_status_api_v1_processing_tasks_task_id_status_get(task_id, opts = {})
  data, _status_code, _headers = get_task_status_api_v1_processing_tasks_task_id_status_get_with_http_info(task_id, opts)
  data
end

#get_task_status_api_v1_processing_tasks_task_id_status_get_with_http_info(task_id, opts = {}) ⇒ Array<(AsyncTaskStatus, Integer, Hash)>

Get task generation status Retrieves the progress status of an invoice generation task. ## Possible states The `status` field uses the `CeleryStatus` enum with values: - PENDING, STARTED, SUCCESS, FAILURE, RETRY See the `CeleryStatus` schema documentation for details. ## Business result When `status=&quot;SUCCESS&quot;`, the `result` field contains: - `status`: &quot;SUCCESS&quot; or &quot;ERROR&quot; (business result) - `content_b64`: Base64 encoded content (if success) - `errorCode`, `errorMessage`, `details`: AFNOR format (if business error) ## Usage Poll this endpoint every 2-3 seconds until `status` is `SUCCESS` or `FAILURE`.

Parameters:

  • task_id (String) —

    Celery task ID returned by async endpoints (UUID format)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:

  • (Array<(AsyncTaskStatus, Integer, Hash)>) —

    AsyncTaskStatus data, response status code and response headers



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/factpulse/api/invoice_processing_api.rb', line 195

def get_task_status_api_v1_processing_tasks_task_id_status_get_with_http_info(task_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.get_task_status_api_v1_processing_tasks_task_id_status_get ...'
  end
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    fail ArgumentError, "Missing the required parameter 'task_id' when calling InvoiceProcessingApi.get_task_status_api_v1_processing_tasks_task_id_status_get"
  end
  # resource path
  local_var_path = '/api/v1/processing/tasks/{task_id}/status'.sub('{' + 'task_id' + '}', CGI.escape(task_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'AsyncTaskStatus'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.get_task_status_api_v1_processing_tasks_task_id_status_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#get_task_status_api_v1_processing_tasks_task_id_status_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#sign_pdf_api_v1_processing_sign_pdf_post(pdf_file, opts = {}) ⇒ Object

Sign a PDF with client's certificate (PAdES-B-LT) Signs an uploaded PDF with the electronic certificate configured for the client (via client_uid from JWT). Supported standards: PAdES-B-B, PAdES-B-T (timestamping), PAdES-B-LT (long-term archiving). eIDAS levels: SES (self-signed), AdES (commercial CA), QES (PSCO - out of scope). Security: Double authentication X-Internal-Secret + JWT Bearer to retrieve the certificate. ⚠️ Legal disclaimer: Generated signatures are electronic seals as defined by the eIDAS regulation. The level of legal validity depends on the certificate used (SES/AdES/QES). FactPulse does not provide QES qualified certificates - you must obtain a certificate from a PSCO (qualified Trust Service Provider) for maximum legal validity.

Parameters:

  • pdf_file (File) —

    PDF file to sign (will be processed and returned signed in base64)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :reason (String)
  • :location (String)
  • :contact (String)
  • :field_name (String) —

    PDF signature field name (default to 'FactPulseSignature')

  • :use_pades_lt (Boolean) —

    Enable PAdES-B-LT (long-term archiving with embedded validation data). REQUIRES a certificate with OCSP/CRL access. (default to false)

  • :use_timestamp (Boolean) —

    Enable RFC 3161 timestamping with FreeTSA (PAdES-B-T) (default to true)

Returns:

  • (Object)


254
255
256
257
# File 'lib/factpulse/api/invoice_processing_api.rb', line 254

def sign_pdf_api_v1_processing_sign_pdf_post(pdf_file, opts = {})
  data, _status_code, _headers = sign_pdf_api_v1_processing_sign_pdf_post_with_http_info(pdf_file, opts)
  data
end

#sign_pdf_api_v1_processing_sign_pdf_post_with_http_info(pdf_file, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Sign a PDF with client's certificate (PAdES-B-LT) Signs an uploaded PDF with the electronic certificate configured for the client (via client_uid from JWT). Supported standards: PAdES-B-B, PAdES-B-T (timestamping), PAdES-B-LT (long-term archiving). eIDAS levels: SES (self-signed), AdES (commercial CA), QES (PSCO - out of scope). Security: Double authentication X-Internal-Secret + JWT Bearer to retrieve the certificate. ⚠️ Legal disclaimer: Generated signatures are electronic seals as defined by the eIDAS regulation. The level of legal validity depends on the certificate used (SES/AdES/QES). FactPulse does not provide QES qualified certificates - you must obtain a certificate from a PSCO (qualified Trust Service Provider) for maximum legal validity.

Parameters:

  • pdf_file (File) —

    PDF file to sign (will be processed and returned signed in base64)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :reason (String)
  • :location (String)
  • :contact (String)
  • :field_name (String) —

    PDF signature field name (default to 'FactPulseSignature')

  • :use_pades_lt (Boolean) —

    Enable PAdES-B-LT (long-term archiving with embedded validation data). REQUIRES a certificate with OCSP/CRL access. (default to false)

  • :use_timestamp (Boolean) —

    Enable RFC 3161 timestamping with FreeTSA (PAdES-B-T) (default to true)

Returns:

  • (Array<(Object, Integer, Hash)>) —

    Object data, response status code and response headers



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/factpulse/api/invoice_processing_api.rb', line 270

def sign_pdf_api_v1_processing_sign_pdf_post_with_http_info(pdf_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.sign_pdf_api_v1_processing_sign_pdf_post ...'
  end
  # verify the required parameter 'pdf_file' is set
  if @api_client.config.client_side_validation && pdf_file.nil?
    fail ArgumentError, "Missing the required parameter 'pdf_file' when calling InvoiceProcessingApi.sign_pdf_api_v1_processing_sign_pdf_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/sign-pdf'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['pdf_file'] = pdf_file
  form_params['reason'] = opts[:'reason'] if !opts[:'reason'].nil?
  form_params['location'] = opts[:'location'] if !opts[:'location'].nil?
  form_params['contact'] = opts[:'contact'] if !opts[:'contact'].nil?
  form_params['field_name'] = opts[:'field_name'] if !opts[:'field_name'].nil?
  form_params['use_pades_lt'] = opts[:'use_pades_lt'] if !opts[:'use_pades_lt'].nil?
  form_params['use_timestamp'] = opts[:'use_timestamp'] if !opts[:'use_timestamp'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.sign_pdf_api_v1_processing_sign_pdf_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#sign_pdf_api_v1_processing_sign_pdf_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#sign_pdf_async_api_v1_processing_sign_pdf_async_post(pdf_file, opts = {}) ⇒ Object

Sign a PDF asynchronously (Celery) Signs an uploaded PDF asynchronously via a Celery task. Difference with /sign-pdf: - /sign-pdf: Synchronous signature (blocking until completion) - /sign-pdf-async: Asynchronous signature (returns immediately with task_id) Async advantages: - No timeout for large files - No blocking of FastAPI worker - Progress tracking via task_id - Ideal for batch processing Supported standards: PAdES-B-B, PAdES-B-T (timestamping), PAdES-B-LT (long-term archiving). ⚠️ Legal disclaimer: Same as /sign-pdf (see that endpoint's documentation).

Parameters:

  • pdf_file (File) —

    PDF file to sign (processed asynchronously)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

  • :reason (String)
  • :location (String)
  • :contact (String)
  • :field_name (String) —

    PDF signature field name (default to 'FactPulseSignature')

  • :use_pades_lt (Boolean) —

    Enable PAdES-B-LT (long-term archiving with embedded validation data). REQUIRES a certificate with OCSP/CRL access. (default to false)

  • :use_timestamp (Boolean) —

    Enable RFC 3161 timestamping with FreeTSA (PAdES-B-T) (default to true)

Returns:

  • (Object)


343
344
345
346
# File 'lib/factpulse/api/invoice_processing_api.rb', line 343

def sign_pdf_async_api_v1_processing_sign_pdf_async_post(pdf_file, opts = {})
  data, _status_code, _headers = sign_pdf_async_api_v1_processing_sign_pdf_async_post_with_http_info(pdf_file, opts)
  data
end

#sign_pdf_async_api_v1_processing_sign_pdf_async_post_with_http_info(pdf_file, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Sign a PDF asynchronously (Celery) Signs an uploaded PDF asynchronously via a Celery task. Difference with /sign-pdf: - `/sign-pdf`: Synchronous signature (blocking until completion) - `/sign-pdf-async`: Asynchronous signature (returns immediately with task_id) Async advantages: - No timeout for large files - No blocking of FastAPI worker - Progress tracking via task_id - Ideal for batch processing Supported standards: PAdES-B-B, PAdES-B-T (timestamping), PAdES-B-LT (long-term archiving). ⚠️ Legal disclaimer: Same as /sign-pdf (see that endpoint's documentation).

Parameters:

  • pdf_file (File) —

    PDF file to sign (processed asynchronously)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

  • :reason (String)
  • :location (String)
  • :contact (String)
  • :field_name (String) —

    PDF signature field name (default to 'FactPulseSignature')

  • :use_pades_lt (Boolean) —

    Enable PAdES-B-LT (long-term archiving with embedded validation data). REQUIRES a certificate with OCSP/CRL access. (default to false)

  • :use_timestamp (Boolean) —

    Enable RFC 3161 timestamping with FreeTSA (PAdES-B-T) (default to true)

Returns:

  • (Array<(Object, Integer, Hash)>) —

    Object data, response status code and response headers



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/factpulse/api/invoice_processing_api.rb', line 361

def sign_pdf_async_api_v1_processing_sign_pdf_async_post_with_http_info(pdf_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.sign_pdf_async_api_v1_processing_sign_pdf_async_post ...'
  end
  # verify the required parameter 'pdf_file' is set
  if @api_client.config.client_side_validation && pdf_file.nil?
    fail ArgumentError, "Missing the required parameter 'pdf_file' when calling InvoiceProcessingApi.sign_pdf_async_api_v1_processing_sign_pdf_async_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/sign-pdf-async'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['pdf_file'] = pdf_file
  form_params['callback_url'] = opts[:'callback_url'] if !opts[:'callback_url'].nil?
  form_params['webhook_mode'] = opts[:'webhook_mode'] if !opts[:'webhook_mode'].nil?
  form_params['reason'] = opts[:'reason'] if !opts[:'reason'].nil?
  form_params['location'] = opts[:'location'] if !opts[:'location'].nil?
  form_params['contact'] = opts[:'contact'] if !opts[:'contact'].nil?
  form_params['field_name'] = opts[:'field_name'] if !opts[:'field_name'].nil?
  form_params['use_pades_lt'] = opts[:'use_pades_lt'] if !opts[:'use_pades_lt'].nil?
  form_params['use_timestamp'] = opts[:'use_timestamp'] if !opts[:'use_timestamp'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.sign_pdf_async_api_v1_processing_sign_pdf_async_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#sign_pdf_async_api_v1_processing_sign_pdf_async_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#submit_complete_invoice_api_v1_processing_invoices_submit_complete_post(submit_complete_invoice_request, opts = {}) ⇒ SubmitCompleteInvoiceResponse

Submit a complete invoice (generation + signature + submission) Unified endpoint to submit a complete invoice to different destinations. Automated workflow: 1. Auto-enrichment (optional): retrieves data via public APIs and Chorus Pro/AFNOR 2. Factur-X PDF generation: creates a PDF/A-3 with embedded XML 3. Electronic signature (optional): signs the PDF with a certificate 4. Submission: sends to the chosen destination (Chorus Pro or AFNOR PDP) Supported destinations: - Chorus Pro: French B2G platform (invoices to public sector) - AFNOR PDP: Partner Dematerialization Platforms Destination credentials - 2 modes available: Mode 1 - Retrieval via JWT (recommended): - Credentials are retrieved automatically via the JWT client_uid - Do not provide the credentials field in destination - Zero-trust architecture: no secrets in the payload - Example: \"destination\": {\"type\": \"chorus_pro\"} Mode 2 - Credentials in the payload: - Provide credentials directly in the payload - Useful for tests or third-party integrations - Example: \"destination\": {\"type\": \"chorus_pro\", \"credentials\": {...}} Electronic signature (optional) - 2 modes available: Mode 1 - Stored certificate (recommended): - Certificate is retrieved automatically via the JWT client_uid - No key to provide in the payload - PAdES-B-LT signature with timestamp (eIDAS compliant) - Example: \"signature\": {\"reason\": \"Factur-X compliance\"} Mode 2 - Keys in the payload (for tests): - Provide key_pem and cert_pem directly - PEM format accepted: raw or base64 - Useful for tests or special cases without stored certificate - Example: \"signature\": {\"key_pem\": \"-----BEGIN...\", \"cert_pem\": \"-----BEGIN...\"} If key_pem and cert_pem are provided → Mode 2 Otherwise → Mode 1 (certificate retrieved via client_uid)

Parameters:

Returns:



428
429
430
431
# File 'lib/factpulse/api/invoice_processing_api.rb', line 428

def submit_complete_invoice_api_v1_processing_invoices_submit_complete_post(submit_complete_invoice_request, opts = {})
  data, _status_code, _headers = submit_complete_invoice_api_v1_processing_invoices_submit_complete_post_with_http_info(submit_complete_invoice_request, opts)
  data
end

#submit_complete_invoice_api_v1_processing_invoices_submit_complete_post_with_http_info(submit_complete_invoice_request, opts = {}) ⇒ Array<(SubmitCompleteInvoiceResponse, Integer, Hash)>

Submit a complete invoice (generation + signature + submission) Unified endpoint to submit a complete invoice to different destinations. Automated workflow: 1. Auto-enrichment (optional): retrieves data via public APIs and Chorus Pro/AFNOR 2. Factur-X PDF generation: creates a PDF/A-3 with embedded XML 3. Electronic signature (optional): signs the PDF with a certificate 4. Submission: sends to the chosen destination (Chorus Pro or AFNOR PDP) Supported destinations: - Chorus Pro: French B2G platform (invoices to public sector) - AFNOR PDP: Partner Dematerialization Platforms Destination credentials - 2 modes available: Mode 1 - Retrieval via JWT (recommended): - Credentials are retrieved automatically via the JWT `client_uid` - Do not provide the `credentials` field in `destination` - Zero-trust architecture: no secrets in the payload - Example: `&quot;destination&quot;: \"chorus_pro\"` Mode 2 - Credentials in the payload: - Provide credentials directly in the payload - Useful for tests or third-party integrations - Example: `&quot;destination&quot;: \"chorus_pro\", \"credentials\": {...}` Electronic signature (optional) - 2 modes available: Mode 1 - Stored certificate (recommended): - Certificate is retrieved automatically via the JWT `client_uid` - No key to provide in the payload - PAdES-B-LT signature with timestamp (eIDAS compliant) - Example: `&quot;signature&quot;: \"Factur-X compliance\"` Mode 2 - Keys in the payload (for tests): - Provide `key_pem` and `cert_pem` directly - PEM format accepted: raw or base64 - Useful for tests or special cases without stored certificate - Example: `&quot;signature&quot;: \"-----BEGIN...\", \"cert_pem\": \"-----BEGIN...\"` If `key_pem` and `cert_pem` are provided → Mode 2 Otherwise → Mode 1 (certificate retrieved via `client_uid`)

Parameters:

Returns:



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/factpulse/api/invoice_processing_api.rb', line 438

def submit_complete_invoice_api_v1_processing_invoices_submit_complete_post_with_http_info(submit_complete_invoice_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.submit_complete_invoice_api_v1_processing_invoices_submit_complete_post ...'
  end
  # verify the required parameter 'submit_complete_invoice_request' is set
  if @api_client.config.client_side_validation && submit_complete_invoice_request.nil?
    fail ArgumentError, "Missing the required parameter 'submit_complete_invoice_request' when calling InvoiceProcessingApi.submit_complete_invoice_api_v1_processing_invoices_submit_complete_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/invoices/submit-complete'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(submit_complete_invoice_request)

  # return_type
  return_type = opts[:debug_return_type] || 'SubmitCompleteInvoiceResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.submit_complete_invoice_api_v1_processing_invoices_submit_complete_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#submit_complete_invoice_api_v1_processing_invoices_submit_complete_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post(submit_complete_invoice_request, opts = {}) ⇒ TaskResponse

Submit a complete invoice (asynchronous with Celery) Asynchronous version of the /invoices/submit-complete endpoint using Celery for background processing. Automated workflow (same as synchronous version): 1. Auto-enrichment (optional): retrieves data via public APIs and Chorus Pro/AFNOR 2. Factur-X PDF generation: creates a PDF/A-3 with embedded XML 3. Electronic signature (optional): signs the PDF with a certificate 4. Submission: sends to the chosen destination (Chorus Pro or AFNOR PDP) Supported destinations: - Chorus Pro: French B2G platform (invoices to public sector) - AFNOR PDP: Partner Dematerialization Platforms Differences with synchronous version: - ✅ Non-blocking: Returns immediately with a task_id (HTTP 202 Accepted) - ✅ Background processing: Invoice is processed by a Celery worker - ✅ Progress tracking: Use /tasks/{task_id}/status to track status - ✅ Ideal for high volumes: Allows processing many invoices in parallel How to use: 1. Submission: Call this endpoint with your invoice data 2. Immediate return: You receive a task_id (e.g., "abc123-def456") 3. Tracking: Call /tasks/{task_id}/status to check progress 4. Result: When status = \"SUCCESS\", the result field contains the complete response Webhook notification (recommended): Instead of polling, add ?callback_url=https://your-server.com/webhook to receive automatic notification: - event_type: submission.completed, submission.failed, or submission.partial - data.submission_result: Complete submission result - X-Webhook-Signature header for HMAC verification Credentials and signature: Same modes as the synchronous version (JWT or payload).

Parameters:

Options Hash (opts):

  • :callback_url (String) —

    Webhook URL for async notification when submission completes.

  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

Returns:



498
499
500
501
# File 'lib/factpulse/api/invoice_processing_api.rb', line 498

def submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post(submit_complete_invoice_request, opts = {})
  data, _status_code, _headers = submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post_with_http_info(submit_complete_invoice_request, opts)
  data
end

#submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post_with_http_info(submit_complete_invoice_request, opts = {}) ⇒ Array<(TaskResponse, Integer, Hash)>

Submit a complete invoice (asynchronous with Celery) Asynchronous version of the `/invoices/submit-complete` endpoint using Celery for background processing. Automated workflow (same as synchronous version): 1. Auto-enrichment (optional): retrieves data via public APIs and Chorus Pro/AFNOR 2. Factur-X PDF generation: creates a PDF/A-3 with embedded XML 3. Electronic signature (optional): signs the PDF with a certificate 4. Submission: sends to the chosen destination (Chorus Pro or AFNOR PDP) Supported destinations: - Chorus Pro: French B2G platform (invoices to public sector) - AFNOR PDP: Partner Dematerialization Platforms Differences with synchronous version: - ✅ Non-blocking: Returns immediately with a `task_id` (HTTP 202 Accepted) - ✅ Background processing: Invoice is processed by a Celery worker - ✅ Progress tracking: Use `/tasks/task_id/status` to track status - ✅ Ideal for high volumes: Allows processing many invoices in parallel How to use: 1. Submission: Call this endpoint with your invoice data 2. Immediate return: You receive a `task_id` (e.g., &quot;abc123-def456&quot;) 3. Tracking: Call `/tasks/task_id/status` to check progress 4. Result: When `status = &quot;SUCCESS&quot;`, the `result` field contains the complete response Webhook notification (recommended): Instead of polling, add `?callback_url=https://your-server.com/webhook` to receive automatic notification: - `event_type`: `submission.completed`, `submission.failed`, or `submission.partial` - `data.submission_result`: Complete submission result - `X-Webhook-Signature` header for HMAC verification Credentials and signature: Same modes as the synchronous version (JWT or payload).

Parameters:

Options Hash (opts):

  • :callback_url (String) —

    Webhook URL for async notification when submission completes.

  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

Returns:

  • (Array<(TaskResponse, Integer, Hash)>) —

    TaskResponse data, response status code and response headers



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/factpulse/api/invoice_processing_api.rb', line 510

def submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post_with_http_info(submit_complete_invoice_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post ...'
  end
  # verify the required parameter 'submit_complete_invoice_request' is set
  if @api_client.config.client_side_validation && submit_complete_invoice_request.nil?
    fail ArgumentError, "Missing the required parameter 'submit_complete_invoice_request' when calling InvoiceProcessingApi.submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/invoices/submit-complete-async'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'callback_url'] = opts[:'callback_url'] if !opts[:'callback_url'].nil?
  query_params[:'webhook_mode'] = opts[:'webhook_mode'] if !opts[:'webhook_mode'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(submit_complete_invoice_request)

  # return_type
  return_type = opts[:debug_return_type] || 'TaskResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#submit_complete_invoice_async_api_v1_processing_invoices_submit_complete_async_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post(pdf_file, opts = {}) ⇒ PDFValidationResultAPI

Validate a complete Factur-X PDF Validates a complete Factur-X PDF according to European and French standards. ## Applied validation standards - EN 16931: European semantic standard (directive 2014/55/EU) - ISO 19005-3 (PDF/A-3): Long-term electronic archiving - Factur-X / ZUGFeRD: Franco-German specification - Schematron: XML business rules validation - eIDAS: European regulation on electronic identification (signatures) ## Checks performed ### 1. Factur-X XML extraction and validation Checks performed: - Presence of embedded XML file (factur-x.xml or zugferd-invoice.xml) - Automatic profile detection (MINIMUM, BASIC, EN16931, EXTENDED) - XML parsing with UTF-8 validation - GuidelineSpecifiedDocumentContextParameter/ID extraction Schematron validation: - Business rules for detected profile (MINIMUM: 45 rules, EN16931: 178 rules) - Cardinality of required elements - Calculation consistency (net, VAT, gross amounts, discounts) - Identifier formats (SIRET, intra-EU VAT, IBAN) - Standardized codes (ISO country codes, UN/ECE units, VAT codes) What is verified: - ✅ XML structure conforming to Cross Industry Invoice XSD - ✅ Correct UN/CEFACT namespace - ✅ European business rules (BR-xx) - ✅ French-specific rules (FR-xx) ### 2. PDF/A-3 compliance Basic validation (metadata): - Presence of /Type field set to Catalog - Metadata pdfaid:part = 3 (PDF/A-3) - Metadata pdfaid:conformance = B or U - PDF version >= 1.4 Strict VeraPDF validation (if use_verapdf=True): - 146+ ISO 19005-3 rules (PDF/A-3B) - Absence of forbidden content (JavaScript, multimedia, dynamic forms) - Correctly embedded fonts and subsets - Compliant color spaces (sRGB, DeviceGray) - Valid file structure (cross-reference table) - XMP metadata conforming to ISO 16684-1 What is verified: - ✅ Long-term archivable file (20+ years) - ✅ Guaranteed readability (embedded fonts) - ✅ Legal compliance (France, Germany, EU) ### 3. XMP metadata (eXtensible Metadata Platform) Checks performed: - Presence of <?xpacket> block with XMP metadata - fx: namespace for Factur-X: urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0# - Required Factur-X fields: - fx:ConformanceLevel: Profile (MINIMUM, BASIC, EN16931, EXTENDED) - fx:DocumentFileName: Embedded XML name - fx:DocumentType: "INVOICE" - fx:Version: Factur-X version (1.0.07) What is verified: - ✅ Metadata conforming to ISO 16684-1 - ✅ Correct declared Factur-X profile - ✅ Supported Factur-X version ### 4. Electronic signatures Detection and analysis: - Presence of /Sig dictionaries in PDF - Signature type: PAdES (PDF Advanced Electronic Signature) - Information extraction: - Signer name (/Name) - Signing date (/M) - Signature reason (/Reason) - Signature location (/Location) - Signature type (approval, certification) What is verified: - ✅ Presence of signatures or seals - ✅ Number of signatures (single or multi-signature) - ℹ️ No cryptographic verification (requires certificates) ## Parameters - pdf_file (required): The Factur-X PDF file to validate - profile (optional): Expected profile. If absent, auto-detected from XML - use_verapdf (optional, default=false): Enable strict PDF/A validation with VeraPDF - false: Fast metadata validation (2-3 seconds) - true: Complete ISO 19005-3 validation (15-30 seconds, recommended for production) ## Detailed response json { \"isCompliant\": true, \"xml\": { \"present\": true, \"compliant\": true, \"profile\": \"EN16931\", \"errors\": [] }, \"pdfa\": { \"compliant\": true, \"version\": \"PDF/A-3B\", \"method\": \"verapdf\", \"errors\": [] }, \"xmp\": { \"present\": true, \"compliant\": true, \"metadata\": {...} }, \"signatures\": { \"present\": true, \"count\": 1, \"details\": [...] } } ## Use cases - Before sending: Validate generated invoice before transmission to client - On reception: Verify compliance of invoice received from supplier - Audit: Check quality of invoice batches - Legal compliance: Ensure B2B/B2G obligations are met in France - Debugging: Identify issues in generation process - Archiving: Guarantee long-term validity (PDF/A-3) ## Processing time - Basic validation: 2-3 seconds - VeraPDF validation: 15-30 seconds (depends on PDF size)

Parameters:

  • pdf_file (File) —

    Factur-X PDF file to validate (.pdf format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile)
  • :use_verapdf (Boolean) —

    Enable strict PDF/A validation with VeraPDF (recommended for production). If False, uses basic metadata validation. (default to false)

  • :skip_br_fr (Boolean)

Returns:



573
574
575
576
# File 'lib/factpulse/api/invoice_processing_api.rb', line 573

def validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post(pdf_file, opts = {})
  data, _status_code, _headers = validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post_with_http_info(pdf_file, opts)
  data
end

#validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post_with_http_info(pdf_file, opts = {}) ⇒ Array<(PDFValidationResultAPI, Integer, Hash)>

Validate a complete Factur-X PDF Validates a complete Factur-X PDF according to European and French standards. ## Applied validation standards - EN 16931: European semantic standard (directive 2014/55/EU) - ISO 19005-3 (PDF/A-3): Long-term electronic archiving - Factur-X / ZUGFeRD: Franco-German specification - Schematron: XML business rules validation - eIDAS: European regulation on electronic identification (signatures) ## Checks performed ### 1. Factur-X XML extraction and validation Checks performed: - Presence of embedded XML file (`factur-x.xml` or `zugferd-invoice.xml`) - Automatic profile detection (MINIMUM, BASIC, EN16931, EXTENDED) - XML parsing with UTF-8 validation - GuidelineSpecifiedDocumentContextParameter/ID extraction Schematron validation: - Business rules for detected profile (MINIMUM: 45 rules, EN16931: 178 rules) - Cardinality of required elements - Calculation consistency (net, VAT, gross amounts, discounts) - Identifier formats (SIRET, intra-EU VAT, IBAN) - Standardized codes (ISO country codes, UN/ECE units, VAT codes) What is verified: - ✅ XML structure conforming to Cross Industry Invoice XSD - ✅ Correct UN/CEFACT namespace - ✅ European business rules (BR-xx) - ✅ French-specific rules (FR-xx) ### 2. PDF/A-3 compliance Basic validation (metadata): - Presence of `/Type` field set to `Catalog` - Metadata `pdfaid:part` = 3 (PDF/A-3) - Metadata `pdfaid:conformance` = B or U - PDF version >= 1.4 Strict VeraPDF validation (if use_verapdf=True): - 146+ ISO 19005-3 rules (PDF/A-3B) - Absence of forbidden content (JavaScript, multimedia, dynamic forms) - Correctly embedded fonts and subsets - Compliant color spaces (sRGB, DeviceGray) - Valid file structure (cross-reference table) - XMP metadata conforming to ISO 16684-1 What is verified: - ✅ Long-term archivable file (20+ years) - ✅ Guaranteed readability (embedded fonts) - ✅ Legal compliance (France, Germany, EU) ### 3. XMP metadata (eXtensible Metadata Platform) Checks performed: - Presence of `<?xpacket>` block with XMP metadata - `fx:` namespace for Factur-X: `urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#` - Required Factur-X fields: - `fx:ConformanceLevel`: Profile (MINIMUM, BASIC, EN16931, EXTENDED) - `fx:DocumentFileName`: Embedded XML name - `fx:DocumentType`: &quot;INVOICE&quot; - `fx:Version`: Factur-X version (1.0.07) What is verified: - ✅ Metadata conforming to ISO 16684-1 - ✅ Correct declared Factur-X profile - ✅ Supported Factur-X version ### 4. Electronic signatures Detection and analysis: - Presence of `/Sig` dictionaries in PDF - Signature type: PAdES (PDF Advanced Electronic Signature) - Information extraction: - Signer name (`/Name`) - Signing date (`/M`) - Signature reason (`/Reason`) - Signature location (`/Location`) - Signature type (approval, certification) What is verified: - ✅ Presence of signatures or seals - ✅ Number of signatures (single or multi-signature) - ℹ️ No cryptographic verification (requires certificates) ## Parameters - pdf_file (required): The Factur-X PDF file to validate - profile (optional): Expected profile. If absent, auto-detected from XML - use_verapdf (optional, default=false): Enable strict PDF/A validation with VeraPDF - `false`: Fast metadata validation (2-3 seconds) - `true`: Complete ISO 19005-3 validation (15-30 seconds, recommended for production) ## Detailed response ```json { &quot;isCompliant&quot;: true, &quot;xml&quot;: { &quot;present&quot;: true, &quot;compliant&quot;: true, &quot;profile&quot;: &quot;EN16931&quot;, &quot;errors&quot;: [] }, &quot;pdfa&quot;: { &quot;compliant&quot;: true, &quot;version&quot;: &quot;PDF/A-3B&quot;, &quot;method&quot;: &quot;verapdf&quot;, &quot;errors&quot;: [] }, &quot;xmp&quot;: { &quot;present&quot;: true, &quot;compliant&quot;: true, &quot;metadata&quot;: ... }, &quot;signatures&quot;: { &quot;present&quot;: true, &quot;count&quot;: 1, &quot;details&quot;: [...] } } ``` ## Use cases - Before sending: Validate generated invoice before transmission to client - On reception: Verify compliance of invoice received from supplier - Audit: Check quality of invoice batches - Legal compliance: Ensure B2B/B2G obligations are met in France - Debugging: Identify issues in generation process - Archiving: Guarantee long-term validity (PDF/A-3) ## Processing time - Basic validation: 2-3 seconds - VeraPDF validation: 15-30 seconds (depends on PDF size)

Parameters:

  • pdf_file (File) —

    Factur-X PDF file to validate (.pdf format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile)
  • :use_verapdf (Boolean) —

    Enable strict PDF/A validation with VeraPDF (recommended for production). If False, uses basic metadata validation. (default to false)

  • :skip_br_fr (Boolean)

Returns:

  • (Array<(PDFValidationResultAPI, Integer, Hash)>) —

    PDFValidationResultAPI data, response status code and response headers



586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
# File 'lib/factpulse/api/invoice_processing_api.rb', line 586

def validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post_with_http_info(pdf_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post ...'
  end
  # verify the required parameter 'pdf_file' is set
  if @api_client.config.client_side_validation && pdf_file.nil?
    fail ArgumentError, "Missing the required parameter 'pdf_file' when calling InvoiceProcessingApi.validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/validate-facturx-pdf'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['pdf_file'] = pdf_file
  form_params['profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  form_params['use_verapdf'] = opts[:'use_verapdf'] if !opts[:'use_verapdf'].nil?
  form_params['skip_br_fr'] = opts[:'skip_br_fr'] if !opts[:'skip_br_fr'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PDFValidationResultAPI'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#validate_facturx_pdf_api_v1_processing_validate_facturx_pdf_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post(pdf_file, opts = {}) ⇒ TaskResponse

Validate a Factur-X PDF (asynchronous with polling) Validates a Factur-X PDF asynchronously with polling system. ## How it works 1. Submission: PDF is queued for asynchronous validation 2. Immediate return: You receive a task_id (HTTP 202) 3. Tracking: Use the /tasks/{task_id}/status endpoint to track progress ## Advantages of asynchronous mode - No timeout: Ideal for large PDFs or VeraPDF validation (which can take several seconds) - Scalability: Validations are processed by dedicated Celery workers - Status tracking: Allows you to monitor validation progress - Non-blocking: Your client doesn't wait during validation ## Webhook notification (recommended) Instead of polling, you can receive a webhook notification when validation completes: callback_url=https://your-server.com/webhook webhook_mode=download_url # Optional: get download URL instead of base64 The webhook will POST a JSON payload with: - event_type: validation.completed or validation.failed - data.is_compliant: Whether the PDF is Factur-X compliant - data.detected_profile: The detected Factur-X profile - X-Webhook-Signature header for HMAC verification ## When to use this mode? - VeraPDF validation enabled (use_verapdf=True): Strict validation can take 2-10 seconds - Large PDF files: PDFs > 1 MB - Batch processing: Validating multiple invoices in parallel - Asynchronous integration: Your system supports polling ## Checks performed ### 1. Factur-X XML extraction and validation - Verifies presence of Factur-X compliant embedded XML file - Automatically detects profile used (MINIMUM, BASIC, EN16931, EXTENDED) - Validates XML against detected profile's Schematron rules ### 2. PDF/A compliance - Without VeraPDF: Basic metadata validation (fast, ~100ms) - With VeraPDF: Strict ISO 19005 validation (146+ rules, 2-10s) - Detects PDF/A version (PDF/A-1, PDF/A-3, etc.) - Detailed non-compliance reports ### 3. XMP metadata - Verifies presence of XMP metadata in PDF - Validates Factur-X metadata compliance (profile, version) - Extracts all available XMP metadata ### 4. Electronic signatures - Detects presence of electronic signatures or seals - Extracts information about each signature (signer, date, reason) - Counts number of signatures present ## Parameters - pdf_file: The Factur-X PDF file to validate - profile: Expected Factur-X profile (optional). If not specified, profile will be auto-detected from embedded XML file. - use_verapdf: Enable strict PDF/A validation with VeraPDF. ⚠️ Warning: VeraPDF can take 2-10 seconds depending on PDF size. Recommended only in asynchronous mode to avoid timeouts. ## Retrieving results After submission, use GET /tasks/{task_id}/status endpoint to retrieve the result. Polling example: python import requests import time # 1. Submit task response = requests.post(\"/validate-facturx-async\", files={\"pdf_file\": pdf_file}) task_id = response.json()[\"taskId\"] # 2. Poll every 2 seconds while True: status_response = requests.get(f\"/tasks/{task_id}/status\") status = status_response.json() if status[\"status\"] == \"SUCCESS\": result = status[\"result\"][\"validation_result\"] print(f\"Compliant: {result['is_compliant']}\") break elif status[\"status\"] == \"FAILURE\": print(f\"Error: {status['result']['errorMessage']}\") break time.sleep(2) # Wait 2 seconds before next check ## Use cases - Validate invoices before sending with VeraPDF (strict validation) - Process invoice batches in parallel - Integrate validation into an asynchronous pipeline - Validate large PDFs without timeout risk

Parameters:

  • pdf_file (File) —

    Factur-X PDF file to validate (.pdf format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile)
  • :use_verapdf (Boolean) —

    Enable strict PDF/A validation with VeraPDF (recommended for production). May take several seconds. (default to false)

  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

Returns:



652
653
654
655
# File 'lib/factpulse/api/invoice_processing_api.rb', line 652

def validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post(pdf_file, opts = {})
  data, _status_code, _headers = validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post_with_http_info(pdf_file, opts)
  data
end

#validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post_with_http_info(pdf_file, opts = {}) ⇒ Array<(TaskResponse, Integer, Hash)>

Validate a Factur-X PDF (asynchronous with polling) Validates a Factur-X PDF asynchronously with polling system. ## How it works 1. Submission: PDF is queued for asynchronous validation 2. Immediate return: You receive a `task_id` (HTTP 202) 3. Tracking: Use the `/tasks/task_id/status` endpoint to track progress ## Advantages of asynchronous mode - No timeout: Ideal for large PDFs or VeraPDF validation (which can take several seconds) - Scalability: Validations are processed by dedicated Celery workers - Status tracking: Allows you to monitor validation progress - Non-blocking: Your client doesn't wait during validation ## Webhook notification (recommended) Instead of polling, you can receive a webhook notification when validation completes: ``` callback_url=https://your-server.com/webhook webhook_mode=download_url # Optional: get download URL instead of base64 ``` The webhook will POST a JSON payload with: - `event_type`: `validation.completed` or `validation.failed` - `data.is_compliant`: Whether the PDF is Factur-X compliant - `data.detected_profile`: The detected Factur-X profile - `X-Webhook-Signature` header for HMAC verification ## When to use this mode? - VeraPDF validation enabled (`use_verapdf=True`): Strict validation can take 2-10 seconds - Large PDF files: PDFs > 1 MB - Batch processing: Validating multiple invoices in parallel - Asynchronous integration: Your system supports polling ## Checks performed ### 1. Factur-X XML extraction and validation - Verifies presence of Factur-X compliant embedded XML file - Automatically detects profile used (MINIMUM, BASIC, EN16931, EXTENDED) - Validates XML against detected profile's Schematron rules ### 2. PDF/A compliance - Without VeraPDF: Basic metadata validation (fast, ~100ms) - With VeraPDF: Strict ISO 19005 validation (146+ rules, 2-10s) - Detects PDF/A version (PDF/A-1, PDF/A-3, etc.) - Detailed non-compliance reports ### 3. XMP metadata - Verifies presence of XMP metadata in PDF - Validates Factur-X metadata compliance (profile, version) - Extracts all available XMP metadata ### 4. Electronic signatures - Detects presence of electronic signatures or seals - Extracts information about each signature (signer, date, reason) - Counts number of signatures present ## Parameters - pdf_file: The Factur-X PDF file to validate - profile: Expected Factur-X profile (optional). If not specified, profile will be auto-detected from embedded XML file. - use_verapdf: Enable strict PDF/A validation with VeraPDF. ⚠️ Warning: VeraPDF can take 2-10 seconds depending on PDF size. Recommended only in asynchronous mode to avoid timeouts. ## Retrieving results After submission, use `GET /tasks/task_id/status` endpoint to retrieve the result. Polling example: ```python import requests import time # 1. Submit task response = requests.post(&quot;/validate-facturx-async&quot;, files=pdf_file) task_id = response.json()[&quot;taskId&quot;] # 2. Poll every 2 seconds while True: status_response = requests.get(f&quot;/tasks/task_id/status&quot;) status = status_response.json() if status[&quot;status&quot;] == &quot;SUCCESS&quot;: result = status[&quot;result&quot;][&quot;validation_result&quot;] print(f&quot;Compliant: result['is_compliant']&quot;) break elif status[&quot;status&quot;] == &quot;FAILURE&quot;: print(f&quot;Error: status['result']['errorMessage']&quot;) break time.sleep(2) # Wait 2 seconds before next check ``` ## Use cases - Validate invoices before sending with VeraPDF (strict validation) - Process invoice batches in parallel - Integrate validation into an asynchronous pipeline - Validate large PDFs without timeout risk

Parameters:

  • pdf_file (File) —

    Factur-X PDF file to validate (.pdf format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile)
  • :use_verapdf (Boolean) —

    Enable strict PDF/A validation with VeraPDF (recommended for production). May take several seconds. (default to false)

  • :callback_url (String)
  • :webhook_mode (String) —

    Webhook content delivery: 'inline' (base64 in payload) or 'download_url' (temporary URL, 1h TTL) (default to 'inline')

Returns:

  • (Array<(TaskResponse, Integer, Hash)>) —

    TaskResponse data, response status code and response headers



666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
# File 'lib/factpulse/api/invoice_processing_api.rb', line 666

def validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post_with_http_info(pdf_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post ...'
  end
  # verify the required parameter 'pdf_file' is set
  if @api_client.config.client_side_validation && pdf_file.nil?
    fail ArgumentError, "Missing the required parameter 'pdf_file' when calling InvoiceProcessingApi.validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/validate-facturx-async'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['pdf_file'] = pdf_file
  form_params['profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  form_params['use_verapdf'] = opts[:'use_verapdf'] if !opts[:'use_verapdf'].nil?
  form_params['callback_url'] = opts[:'callback_url'] if !opts[:'callback_url'].nil?
  form_params['webhook_mode'] = opts[:'webhook_mode'] if !opts[:'webhook_mode'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TaskResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#validate_facturx_pdf_async_api_v1_processing_validate_facturx_async_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post(pdf_file, opts = {}) ⇒ Object

Validate electronic signatures of a PDF Validates electronic signatures present in an uploaded PDF. Verifications performed: - Presence of signatures - Document integrity (not modified since signing) - Certificate validity - Chain of trust (if available) - Presence of timestamp (PAdES-B-T) - Validation data (PAdES-B-LT) Supported standards: PAdES-B-B, PAdES-B-T, PAdES-B-LT, ISO 32000-2. ⚠️ Note: This validation is technical (cryptographic integrity). Legal validity depends on the eIDAS level of the certificate (SES/AdES/QES) and the context of use.

Parameters:

  • pdf_file (File) —

    PDF file to validate (will be analyzed to detect and validate signatures)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:

  • (Object)


729
730
731
732
# File 'lib/factpulse/api/invoice_processing_api.rb', line 729

def validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post(pdf_file, opts = {})
  data, _status_code, _headers = validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post_with_http_info(pdf_file, opts)
  data
end

#validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post_with_http_info(pdf_file, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Validate electronic signatures of a PDF Validates electronic signatures present in an uploaded PDF. Verifications performed: - Presence of signatures - Document integrity (not modified since signing) - Certificate validity - Chain of trust (if available) - Presence of timestamp (PAdES-B-T) - Validation data (PAdES-B-LT) Supported standards: PAdES-B-B, PAdES-B-T, PAdES-B-LT, ISO 32000-2. ⚠️ Note: This validation is technical (cryptographic integrity). Legal validity depends on the eIDAS level of the certificate (SES/AdES/QES) and the context of use.

Parameters:

  • pdf_file (File) —

    PDF file to validate (will be analyzed to detect and validate signatures)

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>) —

    Object data, response status code and response headers



739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'lib/factpulse/api/invoice_processing_api.rb', line 739

def validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post_with_http_info(pdf_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post ...'
  end
  # verify the required parameter 'pdf_file' is set
  if @api_client.config.client_side_validation && pdf_file.nil?
    fail ArgumentError, "Missing the required parameter 'pdf_file' when calling InvoiceProcessingApi.validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/validate-pdf-signature'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['pdf_file'] = pdf_file

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#validate_pdf_signature_endpoint_api_v1_processing_validate_pdf_signature_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#validate_xml_api_v1_processing_validate_xml_post(xml_file, opts = {}) ⇒ ValidationSuccessResponse

Validate an existing Factur-X XML Validates a Factur-X XML file against Schematron business rules according to EN 16931 standard. ## Applied Standard Schematron ISO/IEC 19757-3: Business rules validation language for XML - Semantic validation (beyond XSD syntax) - European EN 16931 business rules - French-specific Factur-X rules - Arithmetic calculations and data consistency ## Profiles and validated rules ### MINIMUM (45 rules) - Unique invoice identifier - Dates (issue, due date) - Party identifiers (SIRET/SIREN) - Total gross amount ### BASIC (102 rules) - All MINIMUM rules - Detailed invoice lines - Basic VAT calculations - Payment methods - References (order, contract) ### EN16931 (178 rules) - All BASIC rules - European rules (BR-xx): 81 business rules - French rules (FR-xx): 12 France-specific rules - Advanced calculations (CR-xx): 32 calculation rules - Standardized codes (CL-xx): 52 code lists ### EXTENDED (210+ rules) - All EN16931 rules - Logistics information - Advanced accounting data - Multiple external references ## Checks performed ### 1. Syntax validation - Correct XML parsing (UTF-8, well-formed) - UN/CEFACT namespaces present - Hierarchical structure respected ### 2. Business rules (BR-xx) Examples: - BR-1: Invoice total must equal sum of line totals + document-level amounts - BR-CO-10: Sum of VAT base amounts must equal invoice net total - BR-16: Invoice currency code must be in ISO 4217 list ### 3. French rules (FR-xx) Examples: - FR-1: Supplier SIRET must have 14 digits - FR-2: Customer SIRET must have 14 digits (if present) - FR-5: Intra-EU VAT number must be in format FRxx999999999 ### 4. Calculation rules (CR-xx) - Net + VAT = Gross amounts - Sum of lines = Document total - Discounts and surcharges correctly applied - Compliant rounding (2 decimals for amounts) ### 5. Standardized codes (CL-xx) - ISO 3166-1 alpha-2 country codes - ISO 4217 currency codes - UN/ECE Rec 20 measurement units - VAT codes (types, categories, exemptions) - SchemeID for identifiers (0002=SIREN, 0009=SIRET, etc.) ## Validation process 1. XSLT loading: Schematron file converted to XSLT (Saxon-HE) 2. Transformation: Rules applied to XML 3. Results analysis: Extraction of errors (failed-assert) and warnings (successful-report) 4. Report: Structured list of non-conformities ## Responses 200 OK: Compliant XML json { \"message\": \"XML is compliant with EN16931 profile\" } 400 Bad Request: Non-compliant XML json { \"detail\": [ \"[BR-1] Invoice total (120.00) does not match calculated sum (100.00 + 20.00)\", \"[FR-1] Supplier SIRET must contain exactly 14 digits\" ] } ## Use cases - Pre-validation: Verify XML before PDF/A integration - Debugging: Precisely identify generation errors - Testing: Validate test or example XMLs - Compliance: Ensure European and French rules are met - Development: Quick testing without PDF generation ## Processing time - MINIMUM profile: ~0.5 second - EN16931 profile: ~1-2 seconds - EXTENDED profile: ~2-3 seconds

Parameters:

  • xml_file (File) —

    Factur-X XML file to validate (.xml format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile) —

    Validation profile (MINIMUM, BASIC, EN16931, EXTENDED).

  • :skip_br_fr (Boolean)

Returns:



800
801
802
803
# File 'lib/factpulse/api/invoice_processing_api.rb', line 800

def validate_xml_api_v1_processing_validate_xml_post(xml_file, opts = {})
  data, _status_code, _headers = validate_xml_api_v1_processing_validate_xml_post_with_http_info(xml_file, opts)
  data
end

#validate_xml_api_v1_processing_validate_xml_post_with_http_info(xml_file, opts = {}) ⇒ Array<(ValidationSuccessResponse, Integer, Hash)>

Validate an existing Factur-X XML Validates a Factur-X XML file against Schematron business rules according to EN 16931 standard. ## Applied Standard Schematron ISO/IEC 19757-3: Business rules validation language for XML - Semantic validation (beyond XSD syntax) - European EN 16931 business rules - French-specific Factur-X rules - Arithmetic calculations and data consistency ## Profiles and validated rules ### MINIMUM (45 rules) - Unique invoice identifier - Dates (issue, due date) - Party identifiers (SIRET/SIREN) - Total gross amount ### BASIC (102 rules) - All MINIMUM rules - Detailed invoice lines - Basic VAT calculations - Payment methods - References (order, contract) ### EN16931 (178 rules) - All BASIC rules - European rules (BR-xx): 81 business rules - French rules (FR-xx): 12 France-specific rules - Advanced calculations (CR-xx): 32 calculation rules - Standardized codes (CL-xx): 52 code lists ### EXTENDED (210+ rules) - All EN16931 rules - Logistics information - Advanced accounting data - Multiple external references ## Checks performed ### 1. Syntax validation - Correct XML parsing (UTF-8, well-formed) - UN/CEFACT namespaces present - Hierarchical structure respected ### 2. Business rules (BR-xx) Examples: - `BR-1`: Invoice total must equal sum of line totals + document-level amounts - `BR-CO-10`: Sum of VAT base amounts must equal invoice net total - `BR-16`: Invoice currency code must be in ISO 4217 list ### 3. French rules (FR-xx) Examples: - `FR-1`: Supplier SIRET must have 14 digits - `FR-2`: Customer SIRET must have 14 digits (if present) - `FR-5`: Intra-EU VAT number must be in format FRxx999999999 ### 4. Calculation rules (CR-xx) - Net + VAT = Gross amounts - Sum of lines = Document total - Discounts and surcharges correctly applied - Compliant rounding (2 decimals for amounts) ### 5. Standardized codes (CL-xx) - ISO 3166-1 alpha-2 country codes - ISO 4217 currency codes - UN/ECE Rec 20 measurement units - VAT codes (types, categories, exemptions) - SchemeID for identifiers (0002=SIREN, 0009=SIRET, etc.) ## Validation process 1. XSLT loading: Schematron file converted to XSLT (Saxon-HE) 2. Transformation: Rules applied to XML 3. Results analysis: Extraction of errors (`failed-assert`) and warnings (`successful-report`) 4. Report: Structured list of non-conformities ## Responses 200 OK: Compliant XML ```json { &quot;message&quot;: &quot;XML is compliant with EN16931 profile&quot; } ``` 400 Bad Request: Non-compliant XML ```json { &quot;detail&quot;: [ &quot;[BR-1] Invoice total (120.00) does not match calculated sum (100.00 + 20.00)&quot;, &quot;[FR-1] Supplier SIRET must contain exactly 14 digits&quot; ] } ``` ## Use cases - Pre-validation: Verify XML before PDF/A integration - Debugging: Precisely identify generation errors - Testing: Validate test or example XMLs - Compliance: Ensure European and French rules are met - Development: Quick testing without PDF generation ## Processing time - MINIMUM profile: ~0.5 second - EN16931 profile: ~1-2 seconds - EXTENDED profile: ~2-3 seconds

Parameters:

  • xml_file (File) —

    Factur-X XML file to validate (.xml format).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :profile (APIProfile) —

    Validation profile (MINIMUM, BASIC, EN16931, EXTENDED).

  • :skip_br_fr (Boolean)

Returns:

  • (Array<(ValidationSuccessResponse, Integer, Hash)>) —

    ValidationSuccessResponse data, response status code and response headers



812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
# File 'lib/factpulse/api/invoice_processing_api.rb', line 812

def validate_xml_api_v1_processing_validate_xml_post_with_http_info(xml_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: InvoiceProcessingApi.validate_xml_api_v1_processing_validate_xml_post ...'
  end
  # verify the required parameter 'xml_file' is set
  if @api_client.config.client_side_validation && xml_file.nil?
    fail ArgumentError, "Missing the required parameter 'xml_file' when calling InvoiceProcessingApi.validate_xml_api_v1_processing_validate_xml_post"
  end
  # resource path
  local_var_path = '/api/v1/processing/validate-xml'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['xml_file'] = xml_file
  form_params['profile'] = opts[:'profile'] if !opts[:'profile'].nil?
  form_params['skip_br_fr'] = opts[:'skip_br_fr'] if !opts[:'skip_br_fr'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ValidationSuccessResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"InvoiceProcessingApi.validate_xml_api_v1_processing_validate_xml_post",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: InvoiceProcessingApi#validate_xml_api_v1_processing_validate_xml_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end