Skip to content

Commit c106875

Browse files
authored
Merge pull request #165 from FacturAPI/feature/edit-links
Add customer edit links
2 parents 601e7e3 + 541a9d2 commit c106875

File tree

19 files changed

+534
-16
lines changed

19 files changed

+534
-16
lines changed
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
8+
# Enlaces de edición de datos fiscales
9+
10+
Facturapi te permite crear un enlace temporal para que tus clientes llenen y
11+
guarden sus datos fiscales por sí mismos. Una vez guardados, sus datos fiscales
12+
estarán disponibles en el objeto Customer que utilizaste para crear el enlace.
13+
14+
Un enlace de edición de datos fiscales tiene el siguiente formato:
15+
16+
```
17+
https://auto.facturapi.io/tax-info/<EDIT_SECRET_KEY>
18+
```
19+
20+
El portal web donde tus clientes llenarán sus datos fiscales tendrá el
21+
logotipo y colores de la organización que creó el enlace.
22+
23+
El enlace tendrá una duración de 7 días, con posibilidad de renovarse generando
24+
un nuevo enlace en cualquier momento, sobreescribiendo el anterior.
25+
26+
## Crear un enlace de edición para un nuevo cliente
27+
28+
Para crear un enlace de edición de datos fiscales para un nuevo cliente, simplemente
29+
crea un objeto Customer pasando el query parameter `createEditLink` como `true`.
30+
31+
<Tabs groupId="codeExamples">
32+
<TabItem value="js" label="Node.js" default>
33+
34+
```javascript
35+
const newCustomer = facturapi.customers.create({
36+
email: 'email@example.com'
37+
}, {
38+
createEditLink: true
39+
});
40+
```
41+
42+
</TabItem>
43+
<TabItem value="cs" label="C#">
44+
45+
```csharp
46+
var newCustomer = facturapi.Customer.CreateAsync(new Dictionary<string, object>
47+
{
48+
["email"] = "email@example.com"
49+
}, new Dictionary<string, object>
50+
{
51+
["createEditLink"] = true
52+
});
53+
```
54+
55+
</TabItem>
56+
<TabItem value="php" label="PHP">
57+
58+
```php
59+
$newCustomer = $facturapi->Customers->create([
60+
"email" => "email@example.com"
61+
], [
62+
"createEditLink" => true
63+
]);
64+
```
65+
66+
</TabItem>
67+
<TabItem value="curl" label="cURL">
68+
69+
```bash
70+
curl https://www.facturapi.io/v2/customers?createEditLink=true \
71+
-H "Authorization Bearer sk_test_API_KEY" \
72+
-H "Content-Type: application/json" \
73+
-d '{
74+
"email": "email@example.com"
75+
}'
76+
```
77+
78+
</TabItem>
79+
</Tabs>
80+
81+
Al crear un nuevo cliente con el query parameter `createEditLink` como `true, todos los campos del objeto Customer se vuelven opcionales.
82+
83+
El objeto de respuesta incluirá los siguientes campos:
84+
85+
- `edit_link`: El enlace temporal para que el cliente edite sus datos fiscales.
86+
- `edit_link_expires_at`: La fecha de expiración del enlace. 7 días después de la creación del enlace.
87+
88+
```json
89+
{
90+
"id": "67bf1239b15b44fb9269e6a8",
91+
// ...rest of the customer object
92+
"edit_link": "https://auto.facturapi.io/tax-info/EDIT_SECRET_KEY",
93+
"edit_link_expires_at": "2025-02-26T23:59:59Z"
94+
}
95+
```
96+
97+
Una vez que el cliente haya llenado sus datos fiscales, puedes recuperar el objeto Customer actualizado para acceder a la nueva información.
98+
99+
<Tabs groupId="codeExamples">
100+
<TabItem value="js" label="Node.js" default>
101+
102+
```javascript
103+
const customer = await facturapi.customers.retrieve('67bf1239b15b44fb9269e6a8');
104+
```
105+
106+
</TabItem>
107+
<TabItem value="cs" label="C#">
108+
109+
```csharp
110+
var customer = await facturapi.Customer.RetrieveAsync("67bf1239b15b44fb9269e6a8");
111+
```
112+
113+
</TabItem>
114+
<TabItem value="php" label="PHP">
115+
116+
```php
117+
$customer = $facturapi->Customers->retrieve("67bf1239b15b44fb9269e6a8");
118+
```
119+
120+
</TabItem>
121+
<TabItem value="curl" label="cURL">
122+
123+
```bash
124+
curl https://www.facturapi.io/v2/customers/67bf1239b15b44fb
125+
-H "Authorization Bearer sk_test_API_KEY"
126+
```
127+
128+
</TabItem>
129+
</Tabs>
130+
131+
Respuesta: Objeto Customer actualizado con la nueva información fiscal.
132+
133+
```json
134+
{
135+
"id": "67bf1239b15b44fb9269e6a8",
136+
"legal_name": "Dunder Mifflin",
137+
"tax_id": "ABC101010111",
138+
"tax_system": "601",
139+
"email": "email@example.com",
140+
"address": {
141+
"country": "MEX",
142+
"state": "Sonora",
143+
"city": "Huatabampo",
144+
"zip": "85900"
145+
}
146+
}
147+
```
148+
149+
## Crear un enlace de edición para un cliente existente
150+
151+
Si ya tienes un cliente creado y deseas generar un enlace de edición para que
152+
actualice sus datos fiscales, simplemente actualiza el cliente pasando el query
153+
parameter `createEditLink` como `true`.
154+
155+
Esto también es útil cuando deseas renovar el enlace para un cliente existente,
156+
revocando el enlace anterior.
157+
158+
<Tabs groupId="codeExamples">
159+
<TabItem value="js" label="Node.js" default>
160+
161+
```javascript
162+
const customer = await facturapi.customers.update('67bf1239b15b44fb9269e6a8', {}, {
163+
createEditLink: true
164+
});
165+
```
166+
167+
</TabItem>
168+
<TabItem value="cs" label="C#">
169+
170+
```csharp
171+
var customer = await facturapi.Customer.UpdateAsync("67bf1239b15b44fb9269e6a8", new Dictionary<string, object>(), new Dictionary<string, object>
172+
{
173+
["createEditLink"] = true
174+
});
175+
```
176+
177+
</TabItem>
178+
<TabItem value="php" label="PHP">
179+
180+
```php
181+
$customer = $facturapi->Customers->update("67bf1239b15b44fb9269e6a8", [], [
182+
"createEditLink" => true
183+
]);
184+
```
185+
186+
</TabItem>
187+
<TabItem value="curl" label="cURL">
188+
189+
```bash
190+
curl https://www.facturapi.io/v2/customers/67bf1239b15b44fb9269e6a8?createEditLink=true \
191+
-H "Authorization Bearer sk_test_API_KEY" \
192+
-H "Content-Type: application/json" \
193+
-X PUT
194+
```
195+
196+
</TabItem>
197+
</Tabs>
198+
199+
El objeto de respuesta incluirá el enlace en el campo `edit_link` y la fecha de expiración en `edit_link_expires_at`.
200+
201+
```json
202+
{
203+
"id": "67bf1239b15b44fb9269e6a8",
204+
// ...rest of the customer object
205+
"edit_link": "https://auto.facturapi.io/tax-info/EDIT_SECRET_KEY",
206+
"edit_link_expires_at": "2025-02-26T23:59:59Z"
207+
}
208+
```

website/docs/guides/drafts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 8
2+
sidebar_position: 5
33
---
44

55
import Tabs from '@theme/Tabs';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"position": 3,
2+
"position": 4,
33
"collapsed": false
44
}

website/docs/guides/invoices/async-invoices.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ $invoice = $facturapi->Invoices->create([
144144

145145
```bash
146146
curl https://www.facturapi.io/v2/invoices \
147-
-H "
148-
Authorization Bearer sk_test_API_KEY" \
147+
-H "Authorization Bearer sk_test_API_KEY" \
149148
-H "Content-Type: application/json" \
150149
-d '{
151150
"customer": {

website/docs/guides/organizations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 5
2+
sidebar_position: 6
33
---
44

55
import Tabs from '@theme/Tabs';

website/docs/guides/products.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
---
44

55
import Tabs from '@theme/Tabs';

website/docs/guides/receipts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 7
33
---
44

55
import Tabs from '@theme/Tabs';

website/docs/guides/self-invoice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 7
2+
sidebar_position: 8
33
---
44

55
# Autofactura
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"label": "Guides",
3-
"position": 4
3+
"position": 4,
4+
"collapsed": false
45
}

0 commit comments

Comments
 (0)