|
| 1 | +--- |
| 2 | +sidebar_position: 9 |
| 3 | +--- |
| 4 | + |
| 5 | +import Tabs from '@theme/Tabs'; |
| 6 | +import TabItem from '@theme/TabItem'; |
| 7 | + |
| 8 | +# Personalización de facturas |
| 9 | + |
| 10 | +Puedes añadir un html customizado mediante el campo de `pdf_custom_section` dentro del request de `invoices`. |
| 11 | + |
| 12 | +## Tags permitidos |
| 13 | + |
| 14 | +| Tag | Allowed Attributes | |
| 15 | +| ------ | ------------------------------ | |
| 16 | +| **h1** | — | |
| 17 | +| **h2** | — | |
| 18 | +| **h3** | — | |
| 19 | +| **h4** | — | |
| 20 | +| **h5** | — | |
| 21 | +| **h6** | — | |
| 22 | +| **div** | — | |
| 23 | +| **a** | `href`, `title`, `target`, `blank` | |
| 24 | +| **p** | — | |
| 25 | +| **span** | — | |
| 26 | +| **small** | — | |
| 27 | +| **br** | — | |
| 28 | +| **b** | — | |
| 29 | +| **i** | — | |
| 30 | +| **ul** | — | |
| 31 | +| **ol** | — | |
| 32 | +| **li** | — | |
| 33 | +| **strong** | — | |
| 34 | +| **table** | — | |
| 35 | +| **thead** | — | |
| 36 | +| **tbody** | — | |
| 37 | +| **tfoot** | — | |
| 38 | +| **tr** | — | |
| 39 | +| **th** | `colspan`, `align` | |
| 40 | +| **td** | `colspan`, `align` | |
| 41 | + |
| 42 | +## Ejemplo |
| 43 | + |
| 44 | +El siguiente ejemplo muestra el envío de `pdf_custom_section` dentro del request de creación `invoice` |
| 45 | + |
| 46 | +<Tabs groupId="codeExamples"> |
| 47 | +<TabItem value="js" label="Node.js" default> |
| 48 | + |
| 49 | +```javascript |
| 50 | +const Facturapi = require('facturapi'); |
| 51 | +const facturapi = new Facturapi('sk_test_API_KEY'); |
| 52 | + |
| 53 | +const invoice = await facturapi.invoices.create({ |
| 54 | + customer: { |
| 55 | + legal_name: 'Dunder Mifflin', |
| 56 | + email: 'email@example.com', |
| 57 | + tax_id: 'ABC101010111', |
| 58 | + tax_system: '601', |
| 59 | + address: { |
| 60 | + zip: '85900' |
| 61 | + } |
| 62 | + }, |
| 63 | + items: [{ |
| 64 | + quantity: 2, |
| 65 | + product: { |
| 66 | + description: 'Ukelele', |
| 67 | + product_key: '60131324', // ClaveProdServ del SAT |
| 68 | + price: 345.60, |
| 69 | + taxes: [ |
| 70 | + { |
| 71 | + type: 'IVA', |
| 72 | + rate: 0.16 |
| 73 | + } |
| 74 | + ] |
| 75 | + } |
| 76 | + }], |
| 77 | + use: 'G01', |
| 78 | + payment_form: "28" // "Tarjeta de débito", |
| 79 | + pdf_custom_section: '<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>' |
| 80 | +}); |
| 81 | +``` |
| 82 | + |
| 83 | +</TabItem> |
| 84 | +<TabItem value="cs" label="C#"> |
| 85 | + |
| 86 | +```csharp |
| 87 | +var facturapi = new FacturapiClient("sk_test_API_KEY"); |
| 88 | + |
| 89 | +var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object> |
| 90 | +{ |
| 91 | + ["customer"] = new Dictionary<string, object> |
| 92 | + { |
| 93 | + ["legal_name"] = "Dunder Mifflin", |
| 94 | + ["email"] = "email@example.com", |
| 95 | + ["tax_id"] = "ABC101010111", |
| 96 | + ["tax_system"] = "601", |
| 97 | + ["address"] = new Dictionary<string, object> |
| 98 | + { |
| 99 | + ["zip"] = "85900" |
| 100 | + } |
| 101 | + }, |
| 102 | + ["items"] = new Dictionary<string, object>[] |
| 103 | + { |
| 104 | + new Dictionary<string, object> |
| 105 | + { |
| 106 | + ["quantity"] = 2, |
| 107 | + ["product"] = new Dictionary<string, object> |
| 108 | + { |
| 109 | + ["description"] = "Ukelele", |
| 110 | + ["product_key"] = "60131324", // ClaveProdServ del SAT |
| 111 | + ["price"] = 345.60, |
| 112 | + ["taxes"] = new Dictionary<string, object>[] |
| 113 | + { |
| 114 | + new Dictionary<string, object> |
| 115 | + { |
| 116 | + ["type"] = "IVA", |
| 117 | + ["rate"] = 0.16 |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + ["product"] = new Dictionary<string, object> |
| 122 | + { |
| 123 | + ["description"] = "Ukelele", |
| 124 | + ["product_key"] = "60131324", // ClaveProdServ del SAT |
| 125 | + ["price"] = 345.60, |
| 126 | + ["taxes"] = new Dictionary<string, object>[] |
| 127 | + { |
| 128 | + new Dictionary<string, object> |
| 129 | + { |
| 130 | + ["type"] = "IVA", |
| 131 | + ["rate"] = 0.16 |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + }, |
| 137 | + ["use"] = "G01", |
| 138 | + ["payment_form"] = "28" // "Tarjeta de débito", |
| 139 | + ["pdf_custom_section"] = "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>" |
| 140 | +}); |
| 141 | +``` |
| 142 | + |
| 143 | +</TabItem> |
| 144 | +<TabItem value="php" label="PHP"> |
| 145 | + |
| 146 | +```php |
| 147 | +$facturapi = new Facturapi( "sk_test_API_KEY" ); |
| 148 | + |
| 149 | +$invoice = $facturapi->Invoices->create([ |
| 150 | + "customer" => [ |
| 151 | + "legal_name" => "Dunder Mifflin", |
| 152 | + "email" => "email@example.com", |
| 153 | + "tax_id" => "ABC101010111", |
| 154 | + "tax_system" => "601", |
| 155 | + "address" => [ |
| 156 | + "zip" => "85900" |
| 157 | + ] |
| 158 | + ], |
| 159 | + "items" => [ |
| 160 | + [ |
| 161 | + "quantity" => 2, |
| 162 | + "product" => [ |
| 163 | + "description" => "Ukelele", |
| 164 | + "product_key" => "60131324", // ClaveProdServ del SAT |
| 165 | + "price" => 345.60, |
| 166 | + "taxes" => [ |
| 167 | + [ |
| 168 | + "type" => "IVA", |
| 169 | + "rate" => 0.16, |
| 170 | + ] |
| 171 | + ] |
| 172 | + ] |
| 173 | + ], |
| 174 | + ], |
| 175 | + "payment_form" => "28" // "Tarjeta de débito" |
| 176 | + "pdf_custom_section" => "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>" |
| 177 | +]); |
| 178 | +``` |
| 179 | + |
| 180 | +</TabItem> |
| 181 | +<TabItem value="curl" label="cURL"> |
| 182 | + |
| 183 | +```bash |
| 184 | +curl https://www.facturapi.io/v2/invoices \ |
| 185 | + -H "Authorization: Bearer sk_test_API_KEY" \ |
| 186 | + -H "Content-Type: application/json" \ |
| 187 | + -d '{ |
| 188 | + "customer": { |
| 189 | + "legal_name": "Dunder Mifflin", |
| 190 | + "email": "email@example.com", |
| 191 | + "tax_id": "ABC101010111", |
| 192 | + "tax_system": "601", |
| 193 | + "address": { |
| 194 | + "zip": "85900" |
| 195 | + } |
| 196 | + }, |
| 197 | + "items": [{ |
| 198 | + "quantity": 2, |
| 199 | + "product": { |
| 200 | + "description": "Ukelele", |
| 201 | + "product_key": "60131324", // ClaveProdServ del SAT |
| 202 | + "price": 345.60, |
| 203 | + "taxes": [ |
| 204 | + { |
| 205 | + "type": "IVA", |
| 206 | + "rate": 0.16 |
| 207 | + } |
| 208 | + ] |
| 209 | + } |
| 210 | + }], |
| 211 | + "use": "G01", |
| 212 | + "payment_form": "28" // "Tarjeta de débito", |
| 213 | + "pdf_custom_section": "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>" |
| 214 | + }' |
| 215 | +``` |
| 216 | + |
| 217 | +</TabItem> |
| 218 | +</Tabs> |
0 commit comments