Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Excel Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Excel) Create XAdES Facturae 3.2 Signed Invoice

Demonstrates how to create a factura electrónica XAdES digital signature for Gobierno de España

Note: This example requires Chilkat v9.5.0.75 or greater.

Download Excel Class Modules

Chilkat Excel Class Modules

'  ----------------------------------------------------------------------
'  IMPORTANT: This generated example requires Chilkat v9.5.0.75 or later.
'  Contact support@chilkatsoft.com for a pre-release.
'  ----------------------------------------------------------------------

'  ---
'  The following source code can be generated from sample XML using the XML Signature Code Generator at chilkat.io
'  ---

'  Create the XML to be signed...
Dim xmlToSign As Chilkat.Xml
Set xmlToSign = Chilkat.NewXml
xmlToSign.Tag = "fe:Facturae"
Dim success As Boolean
success = xmlToSign.AddAttribute("xmlns:ds","http://www.w3.org/2000/09/xmldsig#")
success = xmlToSign.AddAttribute("xmlns:fe","http://www.facturae.es/Facturae/2009/v3.2/Facturae")
xmlToSign.UpdateChildContent "FileHeader|SchemaVersion","3.2"
xmlToSign.UpdateChildContent "FileHeader|Modality","I"
xmlToSign.UpdateChildContent "FileHeader|InvoiceIssuerType","EM"
xmlToSign.UpdateChildContent "FileHeader|Batch|BatchIdentifier","0000000000B2Emit-"
xmlToSign.UpdateChildContent "FileHeader|Batch|InvoicesCount","1"
xmlToSign.UpdateChildContent "FileHeader|Batch|TotalInvoicesAmount|TotalAmount","63.13"
xmlToSign.UpdateChildContent "FileHeader|Batch|TotalOutstandingAmount|TotalAmount","63.13"
xmlToSign.UpdateChildContent "FileHeader|Batch|TotalExecutableAmount|TotalAmount","63.13"
xmlToSign.UpdateChildContent "FileHeader|Batch|InvoiceCurrencyCode","EUR"
xmlToSign.UpdateChildContent "Parties|SellerParty|TaxIdentification|PersonTypeCode","J"
xmlToSign.UpdateChildContent "Parties|SellerParty|TaxIdentification|ResidenceTypeCode","R"
xmlToSign.UpdateChildContent "Parties|SellerParty|TaxIdentification|TaxIdentificationNumber","A82735122"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|CorporateName","Company Comp SA"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|TradeName","Comp"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|Book","1"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|RegisterOfCompaniesLocation","12AP22"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|Sheet","3"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|Folio","15"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|Section","2"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|Volume","12"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|RegistrationData|AdditionalRegistrationData","Sin datos"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|AddressInSpain|Address","C/ Mayour 33 15 E"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|AddressInSpain|PostCode","28001"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|AddressInSpain|Town","Argamasilla de Alba"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|AddressInSpain|Province","Ciudad Real"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|AddressInSpain|CountryCode","ESP"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|Telephone","917776665"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|TeleFax","917776666"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|WebAddress","www.facturae.es"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|ElectronicMail","facturae@mityc.es"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|ContactPersons","Fernando"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|CnoCnae","28000"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|INETownCode","2134AAB"
xmlToSign.UpdateChildContent "Parties|SellerParty|LegalEntity|ContactDetails|AdditionalContactDetails","Otros datos"
xmlToSign.UpdateChildContent "Parties|BuyerParty|TaxIdentification|PersonTypeCode","F"
xmlToSign.UpdateChildContent "Parties|BuyerParty|TaxIdentification|ResidenceTypeCode","E"
xmlToSign.UpdateChildContent "Parties|BuyerParty|TaxIdentification|TaxIdentificationNumber","0000000000B"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreCode","1"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|RoleTypeCode","02"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|Name","Ruth"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|FirstSurname","Mauripo"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Address","Armenia 1922"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|PostCodeAndTown","00000 Buenos Aires"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Province","Capital Federal"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|CountryCode","ARG"
xmlToSign.UpdateChildContent "Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreDescription","Centro principal de recepcion"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|Name","Juana"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|FirstSurname","Mauripo"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|OverseasAddress|Address","Juncal 1315"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|OverseasAddress|PostCodeAndTown","00000 Buenos Aires"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|OverseasAddress|Province","Capital Federal"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|OverseasAddress|CountryCode","ARG"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|ContactDetails|Telephone","00547775554"
xmlToSign.UpdateChildContent "Parties|BuyerParty|Individual|ContactDetails|TeleFax","00547775555"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceHeader|InvoiceNumber","2"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceHeader|InvoiceSeriesCode","Emit-"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceHeader|InvoiceDocumentType","FC"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceHeader|InvoiceClass","OO"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|IssueDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|OperationDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PostCode","00000"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PlaceOfIssueDescription","Regalos"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|StartDate","2010-03-09"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|EndDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|InvoiceCurrencyCode","EUR"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|TaxCurrencyCode","EUR"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceIssueData|LanguageName","es"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|TaxTypeCode","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|TaxRate","16.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|TaxableBase|TotalAmount","26.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|TaxAmount|TotalAmount","4.16"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurcharge","1.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount","0.26"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax[1]|TaxTypeCode","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax[1]|TaxRate","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesOutputs|Tax[1]|TaxableBase|TotalAmount","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesWithheld|Tax|TaxTypeCode","05"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesWithheld|Tax|TaxRate","4.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesWithheld|Tax|TaxableBase|TotalAmount","26.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|TaxesWithheld|Tax|TaxAmount|TotalAmount","1.04"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalGrossAmount","59.75"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalGeneralDiscounts","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalGeneralSurcharges","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalGrossAmountBeforeTaxes","59.75"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalTaxOutputs","4.42"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalTaxesWithheld","1.04"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|InvoiceTotal","63.13"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalOutstandingAmount","63.13"
xmlToSign.UpdateChildContent "Invoices|Invoice|InvoiceTotals|TotalExecutableAmount","63.13"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|IssuerContractReference","A9938281"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|IssuerContractDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|IssuerTransactionReference","A9938282"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|IssuerTransactionDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ReceiverContractReference","BBBH-38271"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ReceiverContractDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionReference","BBBH-38272"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|FileReference","000298172"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|FileDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|SequenceNumber","1.0"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteNumber","132413842"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteNumber","987673211"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteDate","2010-03-09"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ItemDescription","Flores"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|Quantity","1.0"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|UnitOfMeasure","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|UnitPriceWithoutTax","25.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|TotalCost","25.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountReason","Descuento"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountRate","5.0000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountAmount","1.250000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeReason","Cargo"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeAmount","10.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|GrossAmount","33.750000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxTypeCode","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxRate","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxableBase|TotalAmount","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxAmount|TotalAmount","0.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|AdditionalLineItemInformation","Contacto en Neuquen: Paulita"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventCode","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventReason","Concepto exento por el motivo aqu definido"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine|ArticleCode","142"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|IssuerContractDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|IssuerTransactionDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|ReceiverContractDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|ReceiverTransactionDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|FileDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|SequenceNumber","2.0"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|ItemDescription","Mate"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|Quantity","2.0"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|UnitOfMeasure","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|UnitPriceWithoutTax","13.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TotalCost","26.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|GrossAmount","26.000000"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxTypeCode","05"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxRate","4.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxableBase|TotalAmount","26.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxAmount|TotalAmount","1.04"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxTypeCode","01"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxRate","16.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxableBase|TotalAmount","26.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxAmount|TotalAmount","4.16"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurcharge","1.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount","0.26"
xmlToSign.UpdateChildContent "Invoices|Invoice|Items|InvoiceLine[1]|ArticleCode","122"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|InstallmentDueDate","2010-03-10"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|InstallmentAmount","25.00"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|PaymentMeans","19"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|IBAN","4322 3432 22 1341234212"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BankCode","4322"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BranchCode","3432"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Address","Juncal 1423 8 Z"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|PostCodeAndTown","01115 Capital Federal"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Province","Buenos Aires"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|CountryCode","ARG"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|PaymentReconciliationReference","12223"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|IBAN","1234 4312 22 33212341212314"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BankCode","1234"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BranchCode","4312"
xmlToSign.UpdateChildContent "Invoices|Invoice|PaymentDetails|Installment|DebitReconciliationReference","12223"

Dim gen As Chilkat.XmlDSigGen
Set gen = Chilkat.NewXmlDSigGen

success = True

gen.SigLocation = "fe:Facturae"
gen.SigId = "Signature869123"
success = gen.AddSignatureNamespace("etsi","http://uri.etsi.org/01903/v1.3.2#")
gen.SignedInfoId = "Signature-SignedInfo241096"
gen.SignedInfoCanonAlg = "C14N"
gen.SignedInfoDigestMethod = "sha1"

'  Create an Object to be added to the Signature.
Dim object1 As Chilkat.Xml
Set object1 = Chilkat.NewXml
object1.Tag = "etsi:QualifyingProperties"
success = object1.AddAttribute("Target","#Signature869123")
success = object1.UpdateAttrAt("etsi:SignedProperties",True,"Id","Signature869123-SignedProperties787205")
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SigningTime","TO BE GENERATED BY CHILKAT"
success = object1.UpdateAttrAt("etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SigningCertificate|etsi:Cert|etsi:CertDigest|ds:DigestMethod",True,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1")
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SigningCertificate|etsi:Cert|etsi:CertDigest|ds:DigestValue","TO BE GENERATED BY CHILKAT"
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SigningCertificate|etsi:Cert|etsi:IssuerSerial|ds:X509IssuerName","TO BE GENERATED BY CHILKAT"
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SigningCertificate|etsi:Cert|etsi:IssuerSerial|ds:X509SerialNumber","TO BE GENERATED BY CHILKAT"
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SignaturePolicyIdentifier|etsi:SignaturePolicyId|etsi:SigPolicyId|etsi:Identifier","http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf"
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SignaturePolicyIdentifier|etsi:SignaturePolicyId|etsi:SigPolicyId|etsi:Description","Poltica de Firma FacturaE v3.1"
success = object1.UpdateAttrAt("etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SignaturePolicyIdentifier|etsi:SignaturePolicyId|etsi:SigPolicyHash|ds:DigestMethod",True,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1")
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SignaturePolicyIdentifier|etsi:SignaturePolicyId|etsi:SigPolicyHash|ds:DigestValue","Ohixl6upD6av8N7pEvDABhEL6hM="
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedSignatureProperties|etsi:SignerRole|etsi:ClaimedRoles|etsi:ClaimedRole","emisor"
success = object1.UpdateAttrAt("etsi:SignedProperties|etsi:SignedDataObjectProperties|etsi:DataObjectFormat",True,"ObjectReference","#Reference-ID-670821")
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedDataObjectProperties|etsi:DataObjectFormat|etsi:Description","Factura electrnica"
object1.UpdateChildContent "etsi:SignedProperties|etsi:SignedDataObjectProperties|etsi:DataObjectFormat|etsi:MimeType","text/xml"

success = gen.AddObject("Signature869123-Object629337",object1.GetXml(),"","")

success = gen.AddObjectRef("Signature869123-SignedProperties787205","sha1","","","http://uri.etsi.org/01903#SignedProperties")
success = gen.SetRefIdAttr("Signature869123-SignedProperties787205","SignedPropertiesID459347")

gen.KeyInfoId = "Certificate1570061"
success = gen.AddSameDocRef("Certificate1570061","sha1","","","")

success = gen.AddSameDocRef("","sha1","","","")
success = gen.SetRefIdAttr("","Reference-ID-670821")

'  Provide a certificate + private key. (PFX password is test123)
Dim cert As Chilkat.Cert
Set cert = Chilkat.NewCert
success = cert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
If (success <> True) Then
    Debug.Print cert.LastErrorText
    Exit Sub
End If

success = gen.SetX509Cert(cert,True)
gen.KeyInfoType = "X509Data+KeyValue"
gen.X509Type = "Certificate"

'  Load XML to be signed...
Dim sbXml As Chilkat.StringBuilder
Set sbXml = Chilkat.NewStringBuilder
success = xmlToSign.GetXmlSb(sbXml)

gen.Behaviors = "CompactSignedXml"

'  Sign the XML...
success = gen.CreateXmlDSigSb(sbXml)
If (success <> True) Then
    Debug.Print gen.LastErrorText
    Exit Sub
End If

'  Save the signed XMl to a file.
success = sbXml.WriteFile("qa_output/signedXml.xml","utf-8",False)

Debug.Print sbXml.GetAsString()

 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.