factuplan 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,6 +129,27 @@ const { url } = await factuplan.invoices.downloadXml('invoice-id');
|
|
|
129
129
|
const { url } = await factuplan.invoices.downloadPdf('invoice-id');
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
### Importar factura ya autorizada por el SRI
|
|
133
|
+
|
|
134
|
+
Si tienes una factura que ya fue autorizada directamente por el SRI (no a través de Factuplan), puedes importarla para almacenarla en tu cuenta y generar el PDF (RIDE):
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const result = await factuplan.invoices.importByAccessKey({
|
|
138
|
+
accessKey: '1512202501095019440700120010020000000116488711218',
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
console.log(result.id); // ID interno del comprobante
|
|
142
|
+
console.log(result.accessKey); // Clave de acceso SRI
|
|
143
|
+
console.log(result.sequential); // Número secuencial
|
|
144
|
+
console.log(result.status); // 'AUTHORIZED'
|
|
145
|
+
console.log(result.total); // Total del comprobante
|
|
146
|
+
|
|
147
|
+
// El PDF se genera automáticamente. Descárgalo una vez listo:
|
|
148
|
+
const { url } = await factuplan.invoices.downloadPdf(result.id);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> **Nota:** Este método no envía el comprobante al SRI ni envía correo al cliente. Solo importa y genera el PDF.
|
|
152
|
+
|
|
132
153
|
### Firmar y autorizar XML (Modo B)
|
|
133
154
|
|
|
134
155
|
Si ya tienes tu XML generado (sin firmar), puedes enviarlo para que Factuplan lo firme con tu certificado y lo autorice ante el SRI:
|
package/dist/index.d.mts
CHANGED
|
@@ -115,6 +115,10 @@ interface CreateInvoiceInput {
|
|
|
115
115
|
paymentMethod?: string;
|
|
116
116
|
additionalInfo?: Record<string, string>;
|
|
117
117
|
}
|
|
118
|
+
interface ImportByAccessKeyInput {
|
|
119
|
+
/** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
|
|
120
|
+
accessKey: string;
|
|
121
|
+
}
|
|
118
122
|
interface Invoice {
|
|
119
123
|
id: string;
|
|
120
124
|
accessKey: string;
|
|
@@ -130,8 +134,13 @@ interface InvoiceStatus {
|
|
|
130
134
|
authorizationDate?: string;
|
|
131
135
|
}
|
|
132
136
|
interface DownloadUrlResponse {
|
|
137
|
+
/** URL pre-firmada de S3 — expira en 5 minutos */
|
|
133
138
|
url: string;
|
|
134
|
-
|
|
139
|
+
/**
|
|
140
|
+
* URL permanente de visualización del comprobante en Factuplan.
|
|
141
|
+
* No expira. Formato: https://app.factuplan.com.ec/verify?clave={accessKey}
|
|
142
|
+
*/
|
|
143
|
+
previewUrl?: string;
|
|
135
144
|
}
|
|
136
145
|
interface SignAndAuthorizeInput {
|
|
137
146
|
/** Unsigned XML string */
|
|
@@ -201,7 +210,7 @@ interface WebhookReceiptData {
|
|
|
201
210
|
customerIdentification: string;
|
|
202
211
|
}
|
|
203
212
|
interface FactuplanOptions {
|
|
204
|
-
/** Base URL of the API (default: https://api.factuplan.com/
|
|
213
|
+
/** Base URL of the API (default: https://api-rest.factuplan.com.ec/v1) */
|
|
205
214
|
baseUrl?: string;
|
|
206
215
|
/** Request timeout in milliseconds (default: 30000) */
|
|
207
216
|
timeout?: number;
|
|
@@ -231,6 +240,7 @@ declare class InvoicesResource {
|
|
|
231
240
|
getStatus(id: string): Promise<InvoiceStatus>;
|
|
232
241
|
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
233
242
|
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
243
|
+
importByAccessKey(input: ImportByAccessKeyInput): Promise<Invoice>;
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
@@ -286,4 +296,4 @@ declare class RateLimitError extends FactuplanError {
|
|
|
286
296
|
constructor(message?: string);
|
|
287
297
|
}
|
|
288
298
|
|
|
289
|
-
export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
|
|
299
|
+
export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
|
package/dist/index.d.ts
CHANGED
|
@@ -115,6 +115,10 @@ interface CreateInvoiceInput {
|
|
|
115
115
|
paymentMethod?: string;
|
|
116
116
|
additionalInfo?: Record<string, string>;
|
|
117
117
|
}
|
|
118
|
+
interface ImportByAccessKeyInput {
|
|
119
|
+
/** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
|
|
120
|
+
accessKey: string;
|
|
121
|
+
}
|
|
118
122
|
interface Invoice {
|
|
119
123
|
id: string;
|
|
120
124
|
accessKey: string;
|
|
@@ -130,8 +134,13 @@ interface InvoiceStatus {
|
|
|
130
134
|
authorizationDate?: string;
|
|
131
135
|
}
|
|
132
136
|
interface DownloadUrlResponse {
|
|
137
|
+
/** URL pre-firmada de S3 — expira en 5 minutos */
|
|
133
138
|
url: string;
|
|
134
|
-
|
|
139
|
+
/**
|
|
140
|
+
* URL permanente de visualización del comprobante en Factuplan.
|
|
141
|
+
* No expira. Formato: https://app.factuplan.com.ec/verify?clave={accessKey}
|
|
142
|
+
*/
|
|
143
|
+
previewUrl?: string;
|
|
135
144
|
}
|
|
136
145
|
interface SignAndAuthorizeInput {
|
|
137
146
|
/** Unsigned XML string */
|
|
@@ -201,7 +210,7 @@ interface WebhookReceiptData {
|
|
|
201
210
|
customerIdentification: string;
|
|
202
211
|
}
|
|
203
212
|
interface FactuplanOptions {
|
|
204
|
-
/** Base URL of the API (default: https://api.factuplan.com/
|
|
213
|
+
/** Base URL of the API (default: https://api-rest.factuplan.com.ec/v1) */
|
|
205
214
|
baseUrl?: string;
|
|
206
215
|
/** Request timeout in milliseconds (default: 30000) */
|
|
207
216
|
timeout?: number;
|
|
@@ -231,6 +240,7 @@ declare class InvoicesResource {
|
|
|
231
240
|
getStatus(id: string): Promise<InvoiceStatus>;
|
|
232
241
|
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
233
242
|
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
243
|
+
importByAccessKey(input: ImportByAccessKeyInput): Promise<Invoice>;
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
@@ -286,4 +296,4 @@ declare class RateLimitError extends FactuplanError {
|
|
|
286
296
|
constructor(message?: string);
|
|
287
297
|
}
|
|
288
298
|
|
|
289
|
-
export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
|
|
299
|
+
export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type WebhookEvent, type WebhookReceiptData };
|
package/dist/index.js
CHANGED
|
@@ -104,6 +104,9 @@ var InvoicesResource = class {
|
|
|
104
104
|
async downloadPdf(id) {
|
|
105
105
|
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
106
106
|
}
|
|
107
|
+
async importByAccessKey(input) {
|
|
108
|
+
return this.request("POST", "/developer/invoices/import", input);
|
|
109
|
+
}
|
|
107
110
|
};
|
|
108
111
|
|
|
109
112
|
// src/resources/products.ts
|
|
@@ -151,7 +154,7 @@ var WebhooksResource = class {
|
|
|
151
154
|
};
|
|
152
155
|
|
|
153
156
|
// src/client.ts
|
|
154
|
-
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/
|
|
157
|
+
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/v1";
|
|
155
158
|
var DEFAULT_TIMEOUT = 3e4;
|
|
156
159
|
var Factuplan = class {
|
|
157
160
|
constructor(apiKey, options) {
|
package/dist/index.mjs
CHANGED
|
@@ -75,6 +75,9 @@ var InvoicesResource = class {
|
|
|
75
75
|
async downloadPdf(id) {
|
|
76
76
|
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
77
77
|
}
|
|
78
|
+
async importByAccessKey(input) {
|
|
79
|
+
return this.request("POST", "/developer/invoices/import", input);
|
|
80
|
+
}
|
|
78
81
|
};
|
|
79
82
|
|
|
80
83
|
// src/resources/products.ts
|
|
@@ -122,7 +125,7 @@ var WebhooksResource = class {
|
|
|
122
125
|
};
|
|
123
126
|
|
|
124
127
|
// src/client.ts
|
|
125
|
-
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/
|
|
128
|
+
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/v1";
|
|
126
129
|
var DEFAULT_TIMEOUT = 3e4;
|
|
127
130
|
var Factuplan = class {
|
|
128
131
|
constructor(apiKey, options) {
|
package/package.json
CHANGED