Skip to content

Invoice Signing

Signing helpers and signature metadata.

InvoiceSigner / Signer

from_pem

Create signer from PEM

Create a signer from PEM-encoded certificate and private key.

InvoiceSigner::from_pem(cert_pem: &str, key_pem: &str) -> Result<InvoiceSigner, SigningError>
Signer.from_pem(cert_pem: str, key_pem: str) -> Signer
FfiResult_FfiSigner fatoora_signer_from_pem(const char* cert_pem, const char* key_pem);

from_der

Create signer from DER

Create a signer from DER-encoded certificate and private key.

InvoiceSigner::from_der(cert_der: &[u8], key_der: &[u8]) -> Result<InvoiceSigner, SigningError>
Signer.from_der(cert_der: bytes, key_der: bytes) -> Signer
FfiResult_FfiSigner fatoora_signer_from_der(const uint8_t* cert_der, uintptr_t cert_len, const uint8_t* key_der, uintptr_t key_len);

certificate_pem

Read signer certificate as PEM
Signer.certificate_pem() -> str
FfiResult_FfiString fatoora_signer_certificate_pem(FfiSigner* signer);

certificate_der

Read signer certificate as DER
Signer.certificate_der() -> bytes
FfiResult_FfiBytes fatoora_signer_certificate_der(FfiSigner* signer);

FinalizedInvoice

sign

Sign finalized invoice

Sign finalized invoice XML and return a signed invoice.

FinalizedInvoice::sign(self, signer: &InvoiceSigner) -> Result<SignedInvoice, SigningError>
FinalizedInvoice.sign(signer: Signer) -> SignedInvoice
FfiResult_FfiSignedInvoice fatoora_invoice_sign(FfiFinalizedInvoice* invoice, FfiSigner* signer);

SignedInvoice

xml

Get signed XML
SignedInvoice::xml(&self) -> &str
SignedInvoice.xml() -> str
FfiResult_FfiString fatoora_signed_invoice_xml(FfiSignedInvoice* signed);

to_xml_base64

Get signed XML as Base64
SignedInvoice::to_xml_base64(&self) -> String
SignedInvoice.to_xml_base64() -> str
FfiResult_FfiString fatoora_signed_invoice_to_xml_base64(FfiSignedInvoice* signed);

qr_code

Get QR payload
SignedInvoice::qr_code(&self) -> &str
SignedInvoice.qr_code() -> str
FfiResult_FfiString fatoora_signed_invoice_qr_code(FfiSignedInvoice* signed);

invoice_hash

Get invoice hash
SignedInvoice::invoice_hash(&self) -> &str
SignedInvoice.invoice_hash() -> str
FfiResult_FfiString fatoora_signed_invoice_hash(FfiSignedInvoice* signed);

hash_base64

Get invoice hash as Base64
SignedInvoice::hash_base64(&self) -> Result<String, SigningError>
SignedInvoice.hash_base64() -> str
FfiResult_FfiString fatoora_signed_invoice_hash_base64(FfiSignedInvoice* signed);

signature

Get signature value
SignedInvoice::signature(&self) -> &str
SignedInvoice.signature() -> str
FfiResult_FfiString fatoora_signed_invoice_signature(FfiSignedInvoice* signed);

public_key

Get public key
SignedInvoice::public_key(&self) -> &str
SignedInvoice.public_key() -> str
FfiResult_FfiString fatoora_signed_invoice_public_key(FfiSignedInvoice* signed);

zatca_key_signature

Get optional ZATCA key signature
SignedInvoice::zatca_key_signature(&self) -> Option<&str>
SignedInvoice.zatca_key_signature() -> Optional[str]
FfiResult_FfiString fatoora_signed_invoice_zatca_key_signature(FfiSignedInvoice* signed);

signed_props_hash

Get signed properties hash
SignedProperties::signed_props_hash(&self) -> &str
SignedInvoice.signed_props_hash() -> str
FfiResult_FfiString fatoora_signed_invoice_signed_props_hash(FfiSignedInvoice* signed);

cert_hash

Get certificate hash
SignedInvoice.cert_hash() -> str
FfiResult_FfiString fatoora_signed_invoice_cert_hash(FfiSignedInvoice* signed);

signing_time

Get signing timestamp
SignedInvoice.signing_time() -> str
FfiResult_FfiString fatoora_signed_invoice_signing_time(FfiSignedInvoice* signed);

issuer

Get certificate issuer from signed properties
SignedProperties::issuer(&self) -> &str
SignedInvoice.issuer() -> str
FfiResult_FfiString fatoora_signed_invoice_issuer(FfiSignedInvoice* signed);

serial

Get certificate serial from signed properties
SignedProperties::serial(&self) -> &str
SignedInvoice.serial() -> str
FfiResult_FfiString fatoora_signed_invoice_serial(FfiSignedInvoice* signed);

invoice_hash_base64_from_xml_str

hash from XML

Compute invoice hash (Base64)

Compute invoice hash from XML and return it as Base64.

invoice_hash_base64_from_xml_str(xml: &str) -> Result<String, SigningError>

Errors

Errors

  • SigningError covers XML parsing, canonicalization, and certificate/key errors.

Notes

Notes

  • SignedProperties::signing_time uses YYYY-MM-DDTHH:MM:SS format (UTC).
  • Invoice hashes are computed from canonicalized XML excluding signature fields.

See also: Invoice Signing Guide