@payclave/sdk-server 0.1.1 → 0.2.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/CHANGELOG.md +29 -0
- package/README.md +192 -7
- package/dist/index.cjs +826 -14
- package/dist/index.d.cts +660 -8
- package/dist/index.d.ts +660 -8
- package/dist/index.js +826 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,14 +3,27 @@ import { createHmac, timingSafeEqual } from 'crypto';
|
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
5
|
var PAYCLAVE_WEBHOOK_EVENT_TYPES = [
|
|
6
|
+
"invoice.issued",
|
|
6
7
|
"invoice.paid",
|
|
8
|
+
"invoice.partially_paid",
|
|
9
|
+
"invoice.past_due",
|
|
10
|
+
"invoice.overpaid",
|
|
11
|
+
"invoice.voided",
|
|
12
|
+
"invoice.uncollectible",
|
|
13
|
+
"invoice.refund_recorded",
|
|
14
|
+
"invoice.payment_received_after_void",
|
|
15
|
+
"invoice.payment_received_after_uncollectible",
|
|
7
16
|
"invoice.expired",
|
|
17
|
+
"payment_link.completed",
|
|
18
|
+
"payment_link.expired",
|
|
8
19
|
"payment.failed",
|
|
9
20
|
"payment.underpaid",
|
|
10
21
|
"payment.overpaid"
|
|
11
22
|
];
|
|
23
|
+
var PAYCLAVE_RECONCILIATION_SCHEMA_VERSION = "2026-08-29.v1";
|
|
12
24
|
var PAYCLAVE_API_ERROR_CODES = [
|
|
13
25
|
"ACCOUNT_SUSPENDED",
|
|
26
|
+
"ACTIVE_MERCHANT_REQUIRED",
|
|
14
27
|
"API_KEY_FORBIDDEN",
|
|
15
28
|
"API_KEY_REQUIRED",
|
|
16
29
|
"AUTH_FORBIDDEN",
|
|
@@ -23,6 +36,7 @@ var PAYCLAVE_API_ERROR_CODES = [
|
|
|
23
36
|
"GOOGLE_PROFILE_UNAVAILABLE",
|
|
24
37
|
"GOOGLE_AUTH_STATE_INVALID",
|
|
25
38
|
"AUTH_PASSWORD_ALREADY_SET",
|
|
39
|
+
"AUTH_PROXY_UNAUTHORIZED",
|
|
26
40
|
"AUTH_PROVIDER_UNAVAILABLE",
|
|
27
41
|
"AUTH_REQUIRED",
|
|
28
42
|
"USE_SOCIAL_LOGIN",
|
|
@@ -39,22 +53,73 @@ var PAYCLAVE_API_ERROR_CODES = [
|
|
|
39
53
|
"INVALID_WALLET_PAYMENT_ATTEMPT",
|
|
40
54
|
"INVALID_TX_HASH",
|
|
41
55
|
"INVALID_WALLET_ADDRESS",
|
|
56
|
+
"MODE_MISMATCH",
|
|
57
|
+
"MEMBERSHIP_REVOKED",
|
|
58
|
+
"MEMBER_ALREADY_EXISTS",
|
|
59
|
+
"MEMBER_LIMIT_REACHED",
|
|
60
|
+
"LAST_OWNER_REQUIRED",
|
|
61
|
+
"INVITATION_ALREADY_PENDING",
|
|
62
|
+
"INVITATION_ALREADY_USED",
|
|
63
|
+
"INVITATION_EMAIL_MISMATCH",
|
|
64
|
+
"INVITATION_EXPIRED",
|
|
65
|
+
"INVITATION_NOT_FOUND",
|
|
66
|
+
"OWNERSHIP_TRANSFER_REQUIRED",
|
|
42
67
|
"NOT_FOUND",
|
|
68
|
+
"PUBLIC_KEY_FIELD_NOT_ALLOWED",
|
|
69
|
+
"PERMISSION_DENIED",
|
|
43
70
|
"RATE_LIMIT_EXCEEDED",
|
|
71
|
+
"REAUTH_REQUIRED",
|
|
72
|
+
"STEP_UP_REQUIRED",
|
|
44
73
|
"REQUEST_ERROR",
|
|
74
|
+
"REQUEST_TOO_LARGE",
|
|
45
75
|
"SCAN_OR_COPY_UNAVAILABLE",
|
|
46
76
|
"WALLET_PAYMENTS_UNAVAILABLE",
|
|
47
77
|
"UNSUPPORTED_DEFAULT_WALLET",
|
|
48
78
|
"VALIDATION_ERROR",
|
|
49
79
|
"WEBHOOK_DELIVERY_NOT_FOUND",
|
|
80
|
+
"WEBHOOK_ENDPOINT_DISABLED",
|
|
50
81
|
"WEBHOOK_ENDPOINT_NOT_FOUND",
|
|
51
82
|
"WEBHOOK_EVENT_UNSUPPORTED",
|
|
83
|
+
"WEBHOOK_INCIDENT_NOT_FOUND",
|
|
52
84
|
"WEBHOOK_SIGNATURE_INVALID",
|
|
85
|
+
"SECRET_OVERLAP_ACTIVE",
|
|
86
|
+
"SECRET_OVERLAP_EXPIRED",
|
|
53
87
|
"CHECKOUT_SESSION_NOT_PAYABLE",
|
|
88
|
+
"EVENT_TYPE_UNSUPPORTED",
|
|
89
|
+
"EVENT_PAYLOAD_TOO_LARGE",
|
|
90
|
+
"JOURNEY_TOKEN_INVALID",
|
|
91
|
+
"EVENT_DUPLICATE",
|
|
92
|
+
"TIMESTAMP_OUT_OF_RANGE",
|
|
54
93
|
"INVOICE_NOT_FOUND",
|
|
55
94
|
"INVOICE_STATE_MISMATCH",
|
|
56
95
|
"INVOICE_TRANSITION_GUARD_FAILED",
|
|
57
|
-
"
|
|
96
|
+
"INVOICE_NOT_EDITABLE",
|
|
97
|
+
"INVOICE_ALREADY_ISSUED",
|
|
98
|
+
"INVOICE_NOT_PAYABLE",
|
|
99
|
+
"INVOICE_PDF_UNAVAILABLE",
|
|
100
|
+
"INVOICE_VERSION_CONFLICT",
|
|
101
|
+
"CURRENCY_MISMATCH",
|
|
102
|
+
"INVALID_TOTAL",
|
|
103
|
+
"CUSTOMER_EMAIL_REQUIRED",
|
|
104
|
+
"IDEMPOTENCY_KEY_CONFLICT",
|
|
105
|
+
"PAYMENT_LINK_NOT_FOUND",
|
|
106
|
+
"PAYMENT_LINK_VERSION_CONFLICT",
|
|
107
|
+
"LINK_INACTIVE",
|
|
108
|
+
"LINK_EXPIRED",
|
|
109
|
+
"LINK_ALREADY_USED",
|
|
110
|
+
"LINK_RESERVED",
|
|
111
|
+
"AMOUNT_OUT_OF_RANGE",
|
|
112
|
+
"FIELD_REQUIRED",
|
|
113
|
+
"FEATURE_UNAVAILABLE",
|
|
114
|
+
"MODE_UNAVAILABLE",
|
|
115
|
+
"CONFIG_CHANGED",
|
|
116
|
+
"RATE_LIMITED",
|
|
117
|
+
"EXPORT_RANGE_TOO_LARGE",
|
|
118
|
+
"EXPORT_NOT_READY",
|
|
119
|
+
"EXPORT_EXPIRED",
|
|
120
|
+
"EXPORT_CANCELLED",
|
|
121
|
+
"EXPORT_SCHEMA_UNSUPPORTED",
|
|
122
|
+
"EXPORT_TOO_LARGE_FOR_SYNC"
|
|
58
123
|
];
|
|
59
124
|
var PAYCLAVE_SERVER_SDK_ERROR_CODES = [
|
|
60
125
|
"INVALID_SECRET_KEY",
|
|
@@ -113,13 +178,15 @@ var PayclaveError = class extends Error {
|
|
|
113
178
|
}
|
|
114
179
|
};
|
|
115
180
|
var PAYCLAVE_SERVER_SDK_NAME = "payclave-sdk-server";
|
|
116
|
-
var PAYCLAVE_SERVER_SDK_VERSION = "0.
|
|
181
|
+
var PAYCLAVE_SERVER_SDK_VERSION = "0.2.0";
|
|
117
182
|
var defaultApiBaseUrl = "https://api.payclave.com";
|
|
118
183
|
var defaultFetcher = (input, init) => fetch(input, init);
|
|
119
184
|
var secretKeyPattern = /^sk_(test|live)_[A-Za-z0-9_-]+$/;
|
|
120
185
|
var amountPattern = /^(0|[1-9]\d*)(\.\d{1,6})?$/;
|
|
121
186
|
var webhookUrlMessage = "Webhook URL must be a valid http or https URL.";
|
|
187
|
+
var webhookRawBodyGuideUrl = "https://www.payclave.com/developers/docs#webhooks";
|
|
122
188
|
var defaultWebhookToleranceSeconds = 300;
|
|
189
|
+
var defaultTimeoutMs = 3e4;
|
|
123
190
|
var minExpiryMinutes = 5;
|
|
124
191
|
var maxExpiryMinutes = 24 * 60;
|
|
125
192
|
var supportedWebhookEventTypes = new Set(PAYCLAVE_WEBHOOK_EVENT_TYPES);
|
|
@@ -132,6 +199,8 @@ var isPlainObject = (value) => {
|
|
|
132
199
|
return prototype === Object.prototype || prototype === null;
|
|
133
200
|
};
|
|
134
201
|
var isStringOrNull = (value) => typeof value === "string" || value === null;
|
|
202
|
+
var isOptionalString = (value) => value === void 0 || typeof value === "string";
|
|
203
|
+
var isOptionalStringOrNull = (value) => value === void 0 || isStringOrNull(value);
|
|
135
204
|
var isMetadata = (value) => isPlainObject(value);
|
|
136
205
|
var isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
137
206
|
var joinUrl = (baseUrl, path) => `${baseUrl.replace(/\/+$/, "")}${path}`;
|
|
@@ -226,6 +295,79 @@ var assertOptionalMetadata = (metadata) => {
|
|
|
226
295
|
});
|
|
227
296
|
}
|
|
228
297
|
};
|
|
298
|
+
var assertInvoiceDraftFields = (input) => {
|
|
299
|
+
if (!isPlainObject(input.customer) || !Array.isArray(input.lines) || input.lines.length < 1 || input.lines.length > 100) {
|
|
300
|
+
throw new PayclaveError({
|
|
301
|
+
message: "Invoice drafts require a customer object and 1 to 100 lines.",
|
|
302
|
+
code: "INVALID_REQUEST_BODY",
|
|
303
|
+
status: 0
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
assertOptionalMetadata(input.metadata);
|
|
307
|
+
assertOptionalExpiry(input.checkoutExpiresInMinutes);
|
|
308
|
+
};
|
|
309
|
+
var assertInvoiceVersion = (version) => {
|
|
310
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 1) {
|
|
311
|
+
throw new PayclaveError({
|
|
312
|
+
message: "Invoice version must be a positive integer.",
|
|
313
|
+
code: "INVALID_REQUEST_BODY",
|
|
314
|
+
status: 0
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
var assertPaymentLinkFields = (input) => {
|
|
319
|
+
if (!isPlainObject(input) || typeof input.title !== "string" || input.title.trim() === "" || input.mode !== void 0 && input.mode !== "test" && input.mode !== "live" || input.amountType !== "fixed" && input.amountType !== "customer_entered" || input.usageType !== void 0 && input.usageType !== "single_use" && input.usageType !== "reusable" || input.currencyCode !== void 0 && input.currencyCode !== "USDC" && input.currencyCode !== "USDT") {
|
|
320
|
+
throw new PayclaveError({
|
|
321
|
+
message: "Payment link fields are invalid.",
|
|
322
|
+
code: "INVALID_REQUEST_BODY",
|
|
323
|
+
status: 0
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (input.amountType === "fixed") {
|
|
327
|
+
assertAmount(input.amount);
|
|
328
|
+
} else {
|
|
329
|
+
assertAmount(input.minimumAmount);
|
|
330
|
+
if (input.maximumAmount !== void 0 && input.maximumAmount !== "") {
|
|
331
|
+
assertAmount(input.maximumAmount);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (input.collect !== void 0 && (!isPlainObject(input.collect) || Object.values(input.collect).some((value) => typeof value !== "boolean"))) {
|
|
335
|
+
throw new PayclaveError({
|
|
336
|
+
message: "Payment link customer fields must be booleans.",
|
|
337
|
+
code: "INVALID_REQUEST_BODY",
|
|
338
|
+
status: 0
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
assertOptionalMetadata(input.metadata);
|
|
342
|
+
};
|
|
343
|
+
var assertPaymentLinkVersion = (version) => {
|
|
344
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 1) {
|
|
345
|
+
throw new PayclaveError({
|
|
346
|
+
message: "Payment link version must be a positive integer.",
|
|
347
|
+
code: "INVALID_REQUEST_BODY",
|
|
348
|
+
status: 0
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var paymentLinkBody = (input) => compact({
|
|
353
|
+
mode: input.mode,
|
|
354
|
+
title: input.title,
|
|
355
|
+
description: input.description,
|
|
356
|
+
amountType: input.amountType,
|
|
357
|
+
amount: input.amount,
|
|
358
|
+
minimumAmount: input.minimumAmount,
|
|
359
|
+
maximumAmount: input.maximumAmount,
|
|
360
|
+
currencyCode: input.currencyCode,
|
|
361
|
+
usageType: input.usageType,
|
|
362
|
+
activeAt: input.activeAt,
|
|
363
|
+
expiresAt: input.expiresAt,
|
|
364
|
+
collect: input.collect,
|
|
365
|
+
referencePrefix: input.referencePrefix,
|
|
366
|
+
successUrl: input.successUrl,
|
|
367
|
+
cancelUrl: input.cancelUrl,
|
|
368
|
+
successMessage: input.successMessage,
|
|
369
|
+
metadata: input.metadata
|
|
370
|
+
});
|
|
229
371
|
var assertIdempotencyKey = (key) => {
|
|
230
372
|
if (typeof key !== "string" || key.length === 0) {
|
|
231
373
|
throw new PayclaveError({
|
|
@@ -311,6 +453,15 @@ var assertPositiveIntegerLimit = (limit) => {
|
|
|
311
453
|
});
|
|
312
454
|
}
|
|
313
455
|
};
|
|
456
|
+
var assertReconciliationFormat = (format) => {
|
|
457
|
+
if (format !== "csv" && format !== "json") {
|
|
458
|
+
throw new PayclaveError({
|
|
459
|
+
message: "Reconciliation export format must be csv or json.",
|
|
460
|
+
code: "INVALID_REQUEST_BODY",
|
|
461
|
+
status: 0
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
};
|
|
314
465
|
var serializeBody = (body) => {
|
|
315
466
|
try {
|
|
316
467
|
return JSON.stringify(body);
|
|
@@ -363,6 +514,98 @@ var parseResponse = async (response, guard) => {
|
|
|
363
514
|
}
|
|
364
515
|
return body.data;
|
|
365
516
|
};
|
|
517
|
+
var parseInvoicePDFResponse = async (response) => {
|
|
518
|
+
const fallbackRequestId = response.headers.get("X-Request-ID");
|
|
519
|
+
if (!response.ok) {
|
|
520
|
+
const body = await response.json().catch(() => null);
|
|
521
|
+
if (isFailureResponse(body)) {
|
|
522
|
+
throw new PayclaveError({
|
|
523
|
+
message: body.error.message,
|
|
524
|
+
code: body.error.code,
|
|
525
|
+
status: response.status,
|
|
526
|
+
requestId: body.meta?.requestId ?? fallbackRequestId,
|
|
527
|
+
details: body.error.details
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
throw new PayclaveError({
|
|
531
|
+
message: "Payclave returned an invalid response.",
|
|
532
|
+
code: "INVALID_RESPONSE",
|
|
533
|
+
status: response.status,
|
|
534
|
+
requestId: fallbackRequestId
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
if (response.headers.get("content-type")?.split(";", 1)[0].trim() !== "application/pdf") {
|
|
538
|
+
throw new PayclaveError({
|
|
539
|
+
message: "Payclave returned an invalid invoice PDF response.",
|
|
540
|
+
code: "INVALID_RESPONSE",
|
|
541
|
+
status: response.status,
|
|
542
|
+
requestId: fallbackRequestId
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
546
|
+
if (bytes.length < 5 || String.fromCharCode(...bytes.slice(0, 5)) !== "%PDF-") {
|
|
547
|
+
throw new PayclaveError({
|
|
548
|
+
message: "Payclave returned invalid invoice PDF bytes.",
|
|
549
|
+
code: "INVALID_RESPONSE",
|
|
550
|
+
status: response.status,
|
|
551
|
+
requestId: fallbackRequestId
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
const disposition = response.headers.get("content-disposition") ?? "";
|
|
555
|
+
const filenameMatch = disposition.match(
|
|
556
|
+
/filename=(?:"([^"\r\n/\\]+\.pdf)"|([^;\s\r\n/\\]+\.pdf))/i
|
|
557
|
+
);
|
|
558
|
+
const filename = filenameMatch?.[1] ?? filenameMatch?.[2] ?? "payclave-invoice.pdf";
|
|
559
|
+
return {
|
|
560
|
+
bytes,
|
|
561
|
+
contentType: "application/pdf",
|
|
562
|
+
filename,
|
|
563
|
+
requestId: fallbackRequestId
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
var parseReconciliationDownloadResponse = async (response) => {
|
|
567
|
+
const requestId = response.headers.get("X-Request-ID");
|
|
568
|
+
if (!response.ok) {
|
|
569
|
+
const body = await response.json().catch(() => null);
|
|
570
|
+
if (isFailureResponse(body)) {
|
|
571
|
+
throw new PayclaveError({
|
|
572
|
+
message: body.error.message,
|
|
573
|
+
code: body.error.code,
|
|
574
|
+
status: response.status,
|
|
575
|
+
requestId: body.meta?.requestId ?? requestId,
|
|
576
|
+
details: body.error.details
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
throw new PayclaveError({
|
|
580
|
+
message: "Payclave returned an invalid response.",
|
|
581
|
+
code: "INVALID_RESPONSE",
|
|
582
|
+
status: response.status,
|
|
583
|
+
requestId
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
if (response.headers.get("content-type")?.split(";", 1)[0].trim() !== "application/zip" || !response.body) {
|
|
587
|
+
throw new PayclaveError({
|
|
588
|
+
message: "Payclave returned an invalid reconciliation archive response.",
|
|
589
|
+
code: "INVALID_RESPONSE",
|
|
590
|
+
status: response.status,
|
|
591
|
+
requestId
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
const disposition = response.headers.get("content-disposition") ?? "";
|
|
595
|
+
const filenameMatch = disposition.match(
|
|
596
|
+
/filename=(?:"([^"\r\n/\\]+\.zip)"|([^;\s\r\n/\\]+\.zip))/i
|
|
597
|
+
);
|
|
598
|
+
const rawSize = response.headers.get("content-length");
|
|
599
|
+
const parsedSize = rawSize === null ? Number.NaN : Number(rawSize);
|
|
600
|
+
return {
|
|
601
|
+
stream: response.body,
|
|
602
|
+
contentType: "application/zip",
|
|
603
|
+
filename: filenameMatch?.[1] ?? filenameMatch?.[2] ?? "payclave-reconciliation.zip",
|
|
604
|
+
byteSize: Number.isSafeInteger(parsedSize) && parsedSize >= 0 ? parsedSize : null,
|
|
605
|
+
sha256: response.headers.get("X-Payclave-Content-SHA256"),
|
|
606
|
+
requestId
|
|
607
|
+
};
|
|
608
|
+
};
|
|
366
609
|
var runFetch = async ({
|
|
367
610
|
fetcher,
|
|
368
611
|
url,
|
|
@@ -436,32 +679,44 @@ var isCreatedCheckoutSession = (value) => {
|
|
|
436
679
|
if (!isRecord(value)) {
|
|
437
680
|
return false;
|
|
438
681
|
}
|
|
439
|
-
return typeof value.id === "string" && typeof value.checkoutId === "string" && value.object === "checkout_session" && typeof value.mode === "string" && value.status === "pending" && typeof value.invoiceId === "string" && typeof value.invoiceNumber === "string" && typeof value.amountDue === "string" && typeof value.amountReceived === "string" && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenSymbol === "string" && typeof value.tokenContract === "string" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.externalReference) && isStringOrNull(value.customerEmail) && isMetadata(value.metadata) && typeof value.checkoutUrl === "string" && typeof value.expiresAt === "string" && typeof value.createdAt === "string";
|
|
682
|
+
return typeof value.id === "string" && typeof value.checkoutId === "string" && value.object === "checkout_session" && typeof value.mode === "string" && isOptionalString(value.sourceType) && value.status === "pending" && typeof value.collectionState === "string" && typeof value.invoiceId === "string" && typeof value.invoiceNumber === "string" && typeof value.amountDue === "string" && typeof value.amountReceived === "string" && typeof value.total === "string" && typeof value.customerAmountPaid === "string" && typeof value.customerAmountRemaining === "string" && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenSymbol === "string" && typeof value.tokenContract === "string" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.externalReference) && isStringOrNull(value.customerEmail) && isMetadata(value.metadata) && typeof value.checkoutUrl === "string" && typeof value.expiresAt === "string" && typeof value.createdAt === "string";
|
|
440
683
|
};
|
|
441
684
|
var isCheckoutSession = (value) => {
|
|
442
685
|
if (!isRecord(value)) {
|
|
443
686
|
return false;
|
|
444
687
|
}
|
|
445
|
-
return typeof value.id === "string" && typeof value.checkoutId === "string" && value.object === "checkout_session" && typeof value.mode === "string" && typeof value.status === "string" && isStringOrNull(value.invoiceId) && isStringOrNull(value.invoiceNumber) && typeof value.amountDue === "string" && typeof value.amountReceived === "string" && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenSymbol === "string" && typeof value.tokenContract === "string" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.externalReference) && isStringOrNull(value.customerEmail) && isMetadata(value.metadata) && typeof value.checkoutUrl === "string" && typeof value.expiresAt === "string" && isStringOrNull(value.completedAt) && typeof value.createdAt === "string";
|
|
688
|
+
return typeof value.id === "string" && typeof value.checkoutId === "string" && value.object === "checkout_session" && typeof value.mode === "string" && isOptionalString(value.sourceType) && typeof value.status === "string" && typeof value.collectionState === "string" && isStringOrNull(value.invoiceId) && isStringOrNull(value.invoiceNumber) && typeof value.amountDue === "string" && typeof value.amountReceived === "string" && typeof value.total === "string" && typeof value.customerAmountPaid === "string" && typeof value.customerAmountRemaining === "string" && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenSymbol === "string" && typeof value.tokenContract === "string" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.externalReference) && isStringOrNull(value.customerEmail) && isMetadata(value.metadata) && typeof value.checkoutUrl === "string" && typeof value.expiresAt === "string" && isStringOrNull(value.completedAt) && typeof value.createdAt === "string";
|
|
446
689
|
};
|
|
447
690
|
var isInvoice = (value) => {
|
|
448
691
|
if (!isRecord(value)) {
|
|
449
692
|
return false;
|
|
450
693
|
}
|
|
451
|
-
return typeof value.id === "string" && typeof value.
|
|
694
|
+
return typeof value.id === "string" && isStringOrNull(value.invoiceNumber) && value.object === "invoice" && typeof value.mode === "string" && typeof value.status === "string" && typeof value.collectionState === "string" && typeof value.subtotal === "string" && typeof value.discountTotal === "string" && typeof value.taxTotal === "string" && typeof value.total === "string" && typeof value.customerAmountPaid === "string" && typeof value.customerAmountRemaining === "string" && typeof value.expectedMerchantSettlement === "string" && typeof value.merchantAmountSettled === "string" && typeof value.overpaymentAmount === "string" && typeof value.migrationState === "string" && typeof value.amountDue === "string" && typeof value.amountReceived === "string" && typeof value.platformFee === "string" && typeof value.netAmount === "string" && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenContract === "string" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.externalReference) && isMetadata(value.metadata) && isStringOrNull(value.expiresAt) && isStringOrNull(value.paidAt) && isStringOrNull(value.cancelledAt) && isOptionalStringOrNull(value.voidedAt) && isOptionalStringOrNull(value.uncollectibleAt) && typeof value.createdAt === "string" && isOptionalString(value.internalId) && isOptionalString(value.sourceType) && (value.version === void 0 || typeof value.version === "number") && isOptionalString(value.calculationVersion) && (value.customer === void 0 || isRecord(value.customer)) && (value.lines === void 0 || Array.isArray(value.lines)) && (value.discount === void 0 || value.discount === null || isRecord(value.discount)) && (value.taxes === void 0 || Array.isArray(value.taxes)) && isOptionalStringOrNull(value.dueAt) && isOptionalStringOrNull(value.issuedAt) && isOptionalStringOrNull(value.publicToken) && (value.hostedInvoiceEnabled === void 0 || typeof value.hostedInvoiceEnabled === "boolean") && isOptionalStringOrNull(value.hostedInvoiceUrl) && (value.checkoutSessions === void 0 || Array.isArray(value.checkoutSessions)) && (value.payments === void 0 || Array.isArray(value.payments)) && (value.adjustments === void 0 || Array.isArray(value.adjustments)) && (value.deliveries === void 0 || Array.isArray(value.deliveries)) && (value.reminderSchedule === void 0 || isRecord(value.reminderSchedule)) && isOptionalStringOrNull(value.remindersPausedAt) && isOptionalStringOrNull(value.lastReminderAt) && isOptionalStringOrNull(value.nextReminderAt) && isOptionalStringOrNull(value.lastSentAt) && isOptionalString(value.updatedAt) && isOptionalStringOrNull(value.lastActivityAt);
|
|
452
695
|
};
|
|
696
|
+
var isInvoiceCheckoutSessionCreated = (value) => isRecord(value) && typeof value.invoiceId === "string" && typeof value.invoiceNumber === "string" && typeof value.checkoutSessionId === "string" && typeof value.checkoutUrl === "string" && typeof value.amountDue === "string" && typeof value.currencyCode === "string" && typeof value.expiresAt === "string";
|
|
697
|
+
var isRefundReferenceResult = (value) => isRecord(value) && isRecord(value.adjustment) && isInvoice(value.invoice);
|
|
698
|
+
var isInvoiceList = (value) => isRecord(value) && Array.isArray(value.items) && value.items.every(isInvoice) && typeof value.hasMore === "boolean" && isStringOrNull(value.nextCursor);
|
|
699
|
+
var isPaymentLinkCollect = (value) => isRecord(value) && typeof value.email === "boolean" && typeof value.name === "boolean" && typeof value.reference === "boolean";
|
|
700
|
+
var isPaymentLink = (value) => isRecord(value) && typeof value.id === "string" && value.object === "payment_link" && typeof value.publicId === "string" && typeof value.url === "string" && typeof value.merchantId === "string" && typeof value.mode === "string" && typeof value.status === "string" && typeof value.version === "number" && typeof value.title === "string" && typeof value.description === "string" && (value.amountType === "fixed" || value.amountType === "customer_entered") && isStringOrNull(value.amount) && isStringOrNull(value.minimumAmount) && isStringOrNull(value.maximumAmount) && typeof value.currencyCode === "string" && typeof value.chainId === "number" && typeof value.tokenContract === "string" && (value.usageType === "single_use" || value.usageType === "reusable") && typeof value.completedPayments === "number" && typeof value.startedCheckouts === "number" && isStringOrNull(value.activeAt) && isStringOrNull(value.expiresAt) && isStringOrNull(value.pausedAt) && isStringOrNull(value.archivedAt) && isPaymentLinkCollect(value.collect) && typeof value.referencePrefix === "string" && isStringOrNull(value.successUrl) && isStringOrNull(value.cancelUrl) && typeof value.successMessage === "string" && isMetadata(value.metadata) && isStringOrNull(value.reservationInvoiceId) && isStringOrNull(value.reservedAt) && typeof value.createdAt === "string" && typeof value.updatedAt === "string" && isStringOrNull(value.lastCheckoutCreatedAt);
|
|
701
|
+
var isPaymentLinkList = (value) => isRecord(value) && Array.isArray(value.items) && value.items.every(isPaymentLink) && typeof value.hasMore === "boolean" && isStringOrNull(value.nextCursor);
|
|
702
|
+
var isPaymentLinkPayments = (value) => isRecord(value) && Array.isArray(value.items) && value.items.every(isInvoice);
|
|
453
703
|
var isPayment = (value) => {
|
|
454
704
|
if (!isRecord(value)) {
|
|
455
705
|
return false;
|
|
456
706
|
}
|
|
457
|
-
return typeof value.id === "string" && value.object === "payment" && typeof value.invoiceId === "string" && typeof value.invoiceNumber === "string" && isStringOrNull(value.transactionId) && typeof value.mode === "string" && typeof value.status === "string" && typeof value.amountExpected === "string" && typeof value.amountReceived === "string" && typeof value.platformFee === "string" && typeof value.netAmount === "string" && typeof value.chainId === "number" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.failureReason) && isStringOrNull(value.confirmedAt) && typeof value.createdAt === "string";
|
|
707
|
+
return typeof value.id === "string" && value.object === "payment" && typeof value.invoiceId === "string" && typeof value.invoiceNumber === "string" && isStringOrNull(value.transactionId) && typeof value.mode === "string" && typeof value.status === "string" && typeof value.amountExpected === "string" && typeof value.amountReceived === "string" && typeof value.customerAmountTendered === "string" && typeof value.customerAmountCredited === "string" && typeof value.expectedMerchantSettlement === "string" && typeof value.merchantAmountSettled === "string" && typeof value.platformFeeExpected === "string" && typeof value.platformFeeCollected === "string" && typeof value.payerWalletAddress === "string" && typeof value.payerWalletEvidence === "string" && typeof value.creditEvidenceType === "string" && typeof value.migrationState === "string" && typeof value.platformFee === "string" && typeof value.netAmount === "string" && typeof value.chainId === "number" && typeof value.settlementWalletAddress === "string" && isStringOrNull(value.failureReason) && isStringOrNull(value.confirmedAt) && typeof value.createdAt === "string";
|
|
458
708
|
};
|
|
459
709
|
var isWebhookEndpoint = (value) => {
|
|
460
710
|
if (!isRecord(value)) {
|
|
461
711
|
return false;
|
|
462
712
|
}
|
|
463
|
-
return typeof value.id === "string" && value.object === "webhook_endpoint" && typeof value.mode === "string" && typeof value.url === "string" && typeof value.enabled === "boolean" && isStringArray(value.eventTypes) && typeof value.signingSecret === "string" && typeof value.createdAt === "string";
|
|
713
|
+
return typeof value.id === "string" && value.object === "webhook_endpoint" && typeof value.mode === "string" && typeof value.url === "string" && typeof value.enabled === "boolean" && isStringArray(value.eventTypes) && (value.signingSecret === void 0 || typeof value.signingSecret === "string") && (value.copyRequired === void 0 || typeof value.copyRequired === "boolean") && typeof value.currentSecretVersion === "number" && Array.isArray(value.secretVersions) && value.secretVersions.every(isWebhookSecretVersion) && isRecord(value.secretOverlap) && typeof value.secretOverlap.status === "string" && isStringOrNull(value.secretOverlap.expiresAt) && (typeof value.secretOverlap.previousVersion === "number" || value.secretOverlap.previousVersion === null) && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
464
714
|
};
|
|
715
|
+
var isWebhookSecretVersion = (value) => isRecord(value) && typeof value.version === "number" && typeof value.createdAt === "string" && typeof value.activatesAt === "string" && isStringOrNull(value.expiresAt) && isStringOrNull(value.revokedAt) && isStringOrNull(value.testedAt);
|
|
716
|
+
var isWebhookEndpointArray = (value) => Array.isArray(value) && value.every(isWebhookEndpoint);
|
|
717
|
+
var isWebhookEndpointArchive = (value) => isRecord(value) && typeof value.id === "string" && value.object === "webhook_endpoint" && value.archived === true;
|
|
718
|
+
var isWebhookIncident = (value) => isRecord(value) && typeof value.id === "string" && value.object === "webhook_incident" && typeof value.endpointId === "string" && typeof value.mode === "string" && typeof value.status === "string" && typeof value.reasonFamily === "string" && typeof value.failureCount === "number" && typeof value.affectedDeliveryCount === "number" && isStringArray(value.affectedDeliveryIds) && typeof value.firstFailedAt === "string" && typeof value.lastFailedAt === "string" && typeof value.openedAt === "string" && isStringOrNull(value.resolvedAt) && typeof value.lastDeliveryId === "string" && typeof value.lastAttemptId === "string" && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
719
|
+
var isWebhookIncidentArray = (value) => Array.isArray(value) && value.every(isWebhookIncident);
|
|
465
720
|
var isWebhookEvent = (value) => {
|
|
466
721
|
if (!isRecord(value)) {
|
|
467
722
|
return false;
|
|
@@ -472,15 +727,22 @@ var isWebhookDeliveryAttemptSummary = (value) => {
|
|
|
472
727
|
if (!isRecord(value)) {
|
|
473
728
|
return false;
|
|
474
729
|
}
|
|
475
|
-
return (typeof value.responseStatusCode === "number" || value.responseStatusCode === null) && isStringOrNull(value.errorMessage) && typeof value.attemptedAt === "string";
|
|
730
|
+
return (typeof value.responseStatusCode === "number" || value.responseStatusCode === null) && isStringOrNull(value.errorMessage) && (value.errorCategory === void 0 || isStringOrNull(value.errorCategory)) && typeof value.attemptedAt === "string";
|
|
476
731
|
};
|
|
732
|
+
var isWebhookDeliveryAttempt = (value) => isRecord(value) && typeof value.id === "string" && typeof value.attemptNumber === "number" && (typeof value.responseStatusCode === "number" || value.responseStatusCode === null) && isStringOrNull(value.responseBody) && typeof value.responseBodyTruncated === "boolean" && isStringOrNull(value.errorMessage) && (value.errorCategory === void 0 || isStringOrNull(value.errorCategory)) && (value.responseHeaders === void 0 || value.responseHeaders === null || isRecord(value.responseHeaders)) && (value.requestHeaders === void 0 || value.requestHeaders === null || isRecord(value.requestHeaders)) && (value.destinationHost === void 0 || typeof value.destinationHost === "string") && (value.sanitizedAt === void 0 || typeof value.sanitizedAt === "string") && typeof value.attemptedAt === "string" && typeof value.startedAt === "string" && typeof value.completedAt === "string" && typeof value.durationMs === "number";
|
|
477
733
|
var isWebhookDelivery = (value) => {
|
|
478
734
|
if (!isRecord(value)) {
|
|
479
735
|
return false;
|
|
480
736
|
}
|
|
481
|
-
return typeof value.id === "string" && value.object === "webhook_delivery" && typeof value.endpointId === "string" && isStringOrNull(value.invoiceId) && typeof value.eventType === "string" && typeof value.status === "string" && typeof value.idempotencyKey === "string" && isWebhookEvent(value.payload) && typeof value.nextAttemptAt === "string" && isStringOrNull(value.deliveredAt) && typeof value.attemptCount === "number" && (value.latestAttempt === null || isWebhookDeliveryAttemptSummary(value.latestAttempt)) && typeof value.createdAt === "string";
|
|
737
|
+
return typeof value.id === "string" && value.object === "webhook_delivery" && typeof value.endpointId === "string" && isStringOrNull(value.invoiceId) && typeof value.eventId === "string" && typeof value.eventType === "string" && typeof value.status === "string" && typeof value.idempotencyKey === "string" && isWebhookEvent(value.payload) && typeof value.nextAttemptAt === "string" && isStringOrNull(value.deliveredAt) && typeof value.attemptCount === "number" && (value.latestErrorCategory === void 0 || isStringOrNull(value.latestErrorCategory)) && (value.latestAttempt === null || isWebhookDeliveryAttemptSummary(value.latestAttempt)) && isStringOrNull(value.replayOfDeliveryId) && isStringOrNull(value.replayRootDeliveryId) && isStringOrNull(value.replayedBy) && isStringOrNull(value.replayedAt) && typeof value.createdAt === "string";
|
|
482
738
|
};
|
|
739
|
+
var isWebhookDeliveryDetail = (value) => isWebhookDelivery(value) && Array.isArray(value.attempts) && value.attempts.every(isWebhookDeliveryAttempt);
|
|
740
|
+
var isWebhookDeliveryAttemptArray = (value) => Array.isArray(value) && value.every(isWebhookDeliveryAttempt);
|
|
483
741
|
var isWebhookDeliveryArray = (value) => Array.isArray(value) && value.every(isWebhookDelivery);
|
|
742
|
+
var isReconciliationSchema = (value) => isRecord(value) && typeof value.schemaVersion === "string" && Array.isArray(value.formats) && Array.isArray(value.dateBases) && typeof value.maximumRangeDays === "number" && typeof value.rangeEnd === "string" && typeof value.retention === "string" && Array.isArray(value.files) && Array.isArray(value.stateRules);
|
|
743
|
+
var isReconciliationSummary = (value) => isRecord(value) && typeof value.schemaVersion === "string" && typeof value.dateBasis === "string" && typeof value.from === "string" && typeof value.to === "string" && typeof value.cutoffAt === "string" && typeof value.timezone === "string" && isRecord(value.rowCounts) && Array.isArray(value.summaryByToken) && Array.isArray(value.exceptions) && isStringArray(value.warnings);
|
|
744
|
+
var isReconciliationExport = (value) => isRecord(value) && typeof value.id === "string" && typeof value.merchantId === "string" && typeof value.mode === "string" && typeof value.status === "string" && typeof value.format === "string" && typeof value.schemaVersion === "string" && isRecord(value.filters) && typeof value.filters.from === "string" && typeof value.filters.to === "string" && typeof value.dateBasis === "string" && typeof value.timezone === "string" && typeof value.requestedBy === "string" && typeof value.requestedAt === "string" && typeof value.attempts === "number" && typeof value.includePII === "boolean" && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
745
|
+
var isReconciliationExportList = (value) => isRecord(value) && Array.isArray(value.items) && value.items.every(isReconciliationExport) && typeof value.hasMore === "boolean" && (value.nextCursor === void 0 || typeof value.nextCursor === "string");
|
|
484
746
|
var normalizePayloadBytes = (payload) => {
|
|
485
747
|
if (typeof payload === "string") {
|
|
486
748
|
return Buffer.from(payload, "utf8");
|
|
@@ -618,9 +880,10 @@ function assertPayclaveWebhookSignature({
|
|
|
618
880
|
(candidate) => timingSafeHexEqual(candidate, expected)
|
|
619
881
|
)) {
|
|
620
882
|
throw new PayclaveError({
|
|
621
|
-
message:
|
|
883
|
+
message: `Payclave webhook signature is invalid. Verify the signature against the exact raw request body before parsing it. See ${webhookRawBodyGuideUrl}`,
|
|
622
884
|
code: "WEBHOOK_SIGNATURE_INVALID",
|
|
623
|
-
status: 0
|
|
885
|
+
status: 0,
|
|
886
|
+
details: { documentationUrl: webhookRawBodyGuideUrl }
|
|
624
887
|
});
|
|
625
888
|
}
|
|
626
889
|
}
|
|
@@ -658,7 +921,7 @@ function createPayclaveServerClient({
|
|
|
658
921
|
secretKey,
|
|
659
922
|
apiBaseUrl = defaultApiBaseUrl,
|
|
660
923
|
fetcher = defaultFetcher,
|
|
661
|
-
timeoutMs
|
|
924
|
+
timeoutMs = defaultTimeoutMs
|
|
662
925
|
}) {
|
|
663
926
|
assertSecretKey(secretKey);
|
|
664
927
|
assertTimeoutMs(timeoutMs);
|
|
@@ -744,6 +1007,40 @@ function createPayclaveServerClient({
|
|
|
744
1007
|
guard: isInvoice
|
|
745
1008
|
});
|
|
746
1009
|
};
|
|
1010
|
+
const createInvoiceDraft = (input) => {
|
|
1011
|
+
assertInvoiceDraftFields(input);
|
|
1012
|
+
const { signal, idempotencyKey, ...body } = input;
|
|
1013
|
+
return request({
|
|
1014
|
+
method: "POST",
|
|
1015
|
+
path: "/v1/invoices",
|
|
1016
|
+
body,
|
|
1017
|
+
idempotencyKey,
|
|
1018
|
+
signal,
|
|
1019
|
+
guard: isInvoice
|
|
1020
|
+
});
|
|
1021
|
+
};
|
|
1022
|
+
const listInvoices = (input = {}) => {
|
|
1023
|
+
const query = new URLSearchParams();
|
|
1024
|
+
if (input.limit !== void 0) {
|
|
1025
|
+
assertPositiveIntegerLimit(input.limit);
|
|
1026
|
+
query.set("limit", String(input.limit));
|
|
1027
|
+
}
|
|
1028
|
+
if (input.startingAfter !== void 0) {
|
|
1029
|
+
assertIdentifier(input.startingAfter, "Starting invoice id");
|
|
1030
|
+
query.set("startingAfter", input.startingAfter);
|
|
1031
|
+
}
|
|
1032
|
+
if (input.collectionState !== void 0) {
|
|
1033
|
+
assertIdentifier(input.collectionState, "Invoice collection state");
|
|
1034
|
+
query.set("collectionState", input.collectionState);
|
|
1035
|
+
}
|
|
1036
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1037
|
+
return request({
|
|
1038
|
+
method: "GET",
|
|
1039
|
+
path: `/v1/invoices${suffix}`,
|
|
1040
|
+
signal: input.signal,
|
|
1041
|
+
guard: isInvoiceList
|
|
1042
|
+
});
|
|
1043
|
+
};
|
|
747
1044
|
const getInvoice = (id, options = {}) => {
|
|
748
1045
|
assertIdentifier(id, "Invoice id");
|
|
749
1046
|
return request({
|
|
@@ -753,6 +1050,230 @@ function createPayclaveServerClient({
|
|
|
753
1050
|
guard: isInvoice
|
|
754
1051
|
});
|
|
755
1052
|
};
|
|
1053
|
+
const downloadInvoicePDF = async (id, options = {}) => {
|
|
1054
|
+
assertIdentifier(id, "Invoice id");
|
|
1055
|
+
const response = await runFetch({
|
|
1056
|
+
fetcher,
|
|
1057
|
+
url: joinUrl(
|
|
1058
|
+
normalizedApiBaseUrl,
|
|
1059
|
+
`/v1/invoices/${encodePathSegment(id)}/pdf`
|
|
1060
|
+
),
|
|
1061
|
+
init: {
|
|
1062
|
+
method: "GET",
|
|
1063
|
+
headers: {
|
|
1064
|
+
Accept: "application/pdf",
|
|
1065
|
+
Authorization: `Bearer ${secretKey}`,
|
|
1066
|
+
"X-Payclave-Client": buildClientHeader()
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
externalSignal: options.signal,
|
|
1070
|
+
timeoutMs
|
|
1071
|
+
});
|
|
1072
|
+
return parseInvoicePDFResponse(response);
|
|
1073
|
+
};
|
|
1074
|
+
const updateInvoiceDraft = (id, input) => {
|
|
1075
|
+
assertIdentifier(id, "Invoice id");
|
|
1076
|
+
assertInvoiceDraftFields(input);
|
|
1077
|
+
assertInvoiceVersion(input.version);
|
|
1078
|
+
const { signal, idempotencyKey, ...body } = input;
|
|
1079
|
+
return request({
|
|
1080
|
+
method: "PATCH",
|
|
1081
|
+
path: `/v1/invoices/${encodePathSegment(id)}`,
|
|
1082
|
+
body,
|
|
1083
|
+
idempotencyKey,
|
|
1084
|
+
signal,
|
|
1085
|
+
guard: isInvoice
|
|
1086
|
+
});
|
|
1087
|
+
};
|
|
1088
|
+
const issueInvoice = (id, input) => {
|
|
1089
|
+
assertIdentifier(id, "Invoice id");
|
|
1090
|
+
assertInvoiceVersion(input.version);
|
|
1091
|
+
return request({
|
|
1092
|
+
method: "POST",
|
|
1093
|
+
path: `/v1/invoices/${encodePathSegment(id)}/issue`,
|
|
1094
|
+
body: { version: input.version, send: input.send },
|
|
1095
|
+
idempotencyKey: input.idempotencyKey,
|
|
1096
|
+
signal: input.signal,
|
|
1097
|
+
guard: isInvoice
|
|
1098
|
+
});
|
|
1099
|
+
};
|
|
1100
|
+
const createInvoiceCheckoutSession = (id, input = {}) => {
|
|
1101
|
+
assertIdentifier(id, "Invoice id");
|
|
1102
|
+
return request({
|
|
1103
|
+
method: "POST",
|
|
1104
|
+
path: `/v1/invoices/${encodePathSegment(id)}/checkout-sessions`,
|
|
1105
|
+
idempotencyKey: input.idempotencyKey,
|
|
1106
|
+
signal: input.signal,
|
|
1107
|
+
guard: isInvoiceCheckoutSessionCreated
|
|
1108
|
+
});
|
|
1109
|
+
};
|
|
1110
|
+
const sendInvoice = (id, input = {}) => {
|
|
1111
|
+
assertIdentifier(id, "Invoice id");
|
|
1112
|
+
return request({
|
|
1113
|
+
method: "POST",
|
|
1114
|
+
path: `/v1/invoices/${encodePathSegment(id)}/send`,
|
|
1115
|
+
idempotencyKey: input.idempotencyKey,
|
|
1116
|
+
signal: input.signal,
|
|
1117
|
+
guard: isInvoice
|
|
1118
|
+
});
|
|
1119
|
+
};
|
|
1120
|
+
const remindInvoice = (id, input = {}) => {
|
|
1121
|
+
assertIdentifier(id, "Invoice id");
|
|
1122
|
+
return request({
|
|
1123
|
+
method: "POST",
|
|
1124
|
+
path: `/v1/invoices/${encodePathSegment(id)}/remind`,
|
|
1125
|
+
idempotencyKey: input.idempotencyKey,
|
|
1126
|
+
signal: input.signal,
|
|
1127
|
+
guard: isInvoice
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
const invoiceAction = (id, path, input) => {
|
|
1131
|
+
assertIdentifier(id, "Invoice id");
|
|
1132
|
+
return request({
|
|
1133
|
+
method: "POST",
|
|
1134
|
+
path: `/v1/invoices/${encodePathSegment(id)}/${path}`,
|
|
1135
|
+
body: compact({ reason: input.reason }),
|
|
1136
|
+
idempotencyKey: input.idempotencyKey,
|
|
1137
|
+
signal: input.signal,
|
|
1138
|
+
guard: isInvoice
|
|
1139
|
+
});
|
|
1140
|
+
};
|
|
1141
|
+
const voidInvoice = (id, input = {}) => invoiceAction(id, "void", input);
|
|
1142
|
+
const voidInvoiceRemaining = (id, input = {}) => invoiceAction(id, "void-remaining", input);
|
|
1143
|
+
const markInvoiceUncollectible = (id, input = {}) => invoiceAction(id, "mark-uncollectible", input);
|
|
1144
|
+
const duplicateInvoice = (id, input = {}) => {
|
|
1145
|
+
assertIdentifier(id, "Invoice id");
|
|
1146
|
+
return request({
|
|
1147
|
+
method: "POST",
|
|
1148
|
+
path: `/v1/invoices/${encodePathSegment(id)}/duplicate`,
|
|
1149
|
+
idempotencyKey: input.idempotencyKey,
|
|
1150
|
+
signal: input.signal,
|
|
1151
|
+
guard: isInvoice
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
const recordInvoiceRefundReference = (id, input) => {
|
|
1155
|
+
assertIdentifier(id, "Invoice id");
|
|
1156
|
+
assertIdentifier(input.paymentId, "Payment id");
|
|
1157
|
+
assertAmount(input.amount);
|
|
1158
|
+
const { signal, idempotencyKey, ...body } = input;
|
|
1159
|
+
return request({
|
|
1160
|
+
method: "POST",
|
|
1161
|
+
path: `/v1/invoices/${encodePathSegment(id)}/refund-references`,
|
|
1162
|
+
body,
|
|
1163
|
+
idempotencyKey,
|
|
1164
|
+
signal,
|
|
1165
|
+
guard: isRefundReferenceResult
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
const createPaymentLink = (input) => {
|
|
1169
|
+
assertPaymentLinkFields(input);
|
|
1170
|
+
return request({
|
|
1171
|
+
method: "POST",
|
|
1172
|
+
path: "/v1/payment-links",
|
|
1173
|
+
body: paymentLinkBody(input),
|
|
1174
|
+
idempotencyKey: input.idempotencyKey,
|
|
1175
|
+
signal: input.signal,
|
|
1176
|
+
guard: isPaymentLink
|
|
1177
|
+
});
|
|
1178
|
+
};
|
|
1179
|
+
const listPaymentLinks = (input = {}) => {
|
|
1180
|
+
const query = new URLSearchParams();
|
|
1181
|
+
if (input.limit !== void 0) {
|
|
1182
|
+
assertPositiveIntegerLimit(input.limit);
|
|
1183
|
+
query.set("limit", String(input.limit));
|
|
1184
|
+
}
|
|
1185
|
+
for (const [name, value] of [
|
|
1186
|
+
["startingAfter", input.startingAfter],
|
|
1187
|
+
["status", input.status],
|
|
1188
|
+
["amountType", input.amountType],
|
|
1189
|
+
["usageType", input.usageType],
|
|
1190
|
+
["currencyCode", input.currencyCode],
|
|
1191
|
+
["search", input.search],
|
|
1192
|
+
["createdFrom", input.createdFrom],
|
|
1193
|
+
["createdTo", input.createdTo]
|
|
1194
|
+
]) {
|
|
1195
|
+
if (value !== void 0) {
|
|
1196
|
+
assertIdentifier(value, name);
|
|
1197
|
+
query.set(name, value);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1201
|
+
return request({
|
|
1202
|
+
method: "GET",
|
|
1203
|
+
path: `/v1/payment-links${suffix}`,
|
|
1204
|
+
signal: input.signal,
|
|
1205
|
+
guard: isPaymentLinkList
|
|
1206
|
+
});
|
|
1207
|
+
};
|
|
1208
|
+
const getPaymentLink = (id, options = {}) => {
|
|
1209
|
+
assertIdentifier(id, "Payment link id");
|
|
1210
|
+
return request({
|
|
1211
|
+
method: "GET",
|
|
1212
|
+
path: `/v1/payment-links/${encodePathSegment(id)}`,
|
|
1213
|
+
signal: options.signal,
|
|
1214
|
+
guard: isPaymentLink
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
const updatePaymentLink = (id, input) => {
|
|
1218
|
+
assertIdentifier(id, "Payment link id");
|
|
1219
|
+
assertPaymentLinkFields(input);
|
|
1220
|
+
assertPaymentLinkVersion(input.version);
|
|
1221
|
+
return request({
|
|
1222
|
+
method: "PATCH",
|
|
1223
|
+
path: `/v1/payment-links/${encodePathSegment(id)}`,
|
|
1224
|
+
body: { ...paymentLinkBody(input), version: input.version },
|
|
1225
|
+
idempotencyKey: input.idempotencyKey,
|
|
1226
|
+
signal: input.signal,
|
|
1227
|
+
guard: isPaymentLink
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1230
|
+
const paymentLinkAction = (id, action, input = {}) => {
|
|
1231
|
+
assertIdentifier(id, "Payment link id");
|
|
1232
|
+
return request({
|
|
1233
|
+
method: "POST",
|
|
1234
|
+
path: `/v1/payment-links/${encodePathSegment(id)}/${action}`,
|
|
1235
|
+
idempotencyKey: input.idempotencyKey,
|
|
1236
|
+
signal: input.signal,
|
|
1237
|
+
guard: isPaymentLink
|
|
1238
|
+
});
|
|
1239
|
+
};
|
|
1240
|
+
const pausePaymentLink = (id, input = {}) => paymentLinkAction(id, "pause", input);
|
|
1241
|
+
const resumePaymentLink = (id, input = {}) => paymentLinkAction(id, "resume", input);
|
|
1242
|
+
const archivePaymentLink = (id, input = {}) => paymentLinkAction(id, "archive", input);
|
|
1243
|
+
const duplicatePaymentLink = (id, input = {}) => paymentLinkAction(id, "duplicate", input);
|
|
1244
|
+
const releasePaymentLinkReservation = (id, input) => {
|
|
1245
|
+
assertIdentifier(id, "Payment link id");
|
|
1246
|
+
if (input.acknowledgeLatePaymentRisk !== true) {
|
|
1247
|
+
throw new PayclaveError({
|
|
1248
|
+
message: "Payment-link reservation release requires explicit late-payment risk acknowledgement.",
|
|
1249
|
+
code: "INVALID_REQUEST_BODY",
|
|
1250
|
+
status: 0
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
return request({
|
|
1254
|
+
method: "POST",
|
|
1255
|
+
path: `/v1/payment-links/${encodePathSegment(id)}/release-reservation`,
|
|
1256
|
+
body: { acknowledgeLatePaymentRisk: input.acknowledgeLatePaymentRisk },
|
|
1257
|
+
idempotencyKey: input.idempotencyKey,
|
|
1258
|
+
signal: input.signal,
|
|
1259
|
+
guard: isPaymentLink
|
|
1260
|
+
});
|
|
1261
|
+
};
|
|
1262
|
+
const listPaymentLinkPayments = (id, input = {}) => {
|
|
1263
|
+
assertIdentifier(id, "Payment link id");
|
|
1264
|
+
const query = new URLSearchParams();
|
|
1265
|
+
if (input.limit !== void 0) {
|
|
1266
|
+
assertPositiveIntegerLimit(input.limit);
|
|
1267
|
+
query.set("limit", String(input.limit));
|
|
1268
|
+
}
|
|
1269
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1270
|
+
return request({
|
|
1271
|
+
method: "GET",
|
|
1272
|
+
path: `/v1/payment-links/${encodePathSegment(id)}/payments${suffix}`,
|
|
1273
|
+
signal: input.signal,
|
|
1274
|
+
guard: isPaymentLinkPayments
|
|
1275
|
+
});
|
|
1276
|
+
};
|
|
756
1277
|
const getPayment = (id, options = {}) => {
|
|
757
1278
|
assertIdentifier(id, "Payment id");
|
|
758
1279
|
return request({
|
|
@@ -776,6 +1297,75 @@ function createPayclaveServerClient({
|
|
|
776
1297
|
guard: isWebhookEndpoint
|
|
777
1298
|
});
|
|
778
1299
|
};
|
|
1300
|
+
const listWebhookEndpoints = (options = {}) => request({
|
|
1301
|
+
method: "GET",
|
|
1302
|
+
path: "/v1/webhook-endpoints",
|
|
1303
|
+
signal: options.signal,
|
|
1304
|
+
guard: isWebhookEndpointArray
|
|
1305
|
+
});
|
|
1306
|
+
const getWebhookEndpoint = (id, options = {}) => {
|
|
1307
|
+
assertIdentifier(id, "Webhook endpoint id");
|
|
1308
|
+
return request({
|
|
1309
|
+
method: "GET",
|
|
1310
|
+
path: `/v1/webhook-endpoints/${encodePathSegment(id)}`,
|
|
1311
|
+
signal: options.signal,
|
|
1312
|
+
guard: isWebhookEndpoint
|
|
1313
|
+
});
|
|
1314
|
+
};
|
|
1315
|
+
const updateWebhookEndpoint = (id, input) => {
|
|
1316
|
+
assertIdentifier(id, "Webhook endpoint id");
|
|
1317
|
+
const url = input.url === void 0 ? void 0 : normalizeWebhookUrl(input.url);
|
|
1318
|
+
assertWebhookEventTypes(input.eventTypes);
|
|
1319
|
+
if (input.alertThreshold !== void 0 && (!Number.isInteger(input.alertThreshold) || input.alertThreshold < 2 || input.alertThreshold > 10)) {
|
|
1320
|
+
throw new PayclaveError({
|
|
1321
|
+
message: "Webhook alert threshold must be between 2 and 10.",
|
|
1322
|
+
code: "INVALID_ARGUMENT",
|
|
1323
|
+
status: 0
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
const { signal, idempotencyKey, ...rest } = input;
|
|
1327
|
+
const body = { ...rest, ...url === void 0 ? {} : { url } };
|
|
1328
|
+
return request({
|
|
1329
|
+
method: "PATCH",
|
|
1330
|
+
path: `/v1/webhook-endpoints/${encodePathSegment(id)}`,
|
|
1331
|
+
body,
|
|
1332
|
+
idempotencyKey,
|
|
1333
|
+
signal,
|
|
1334
|
+
guard: isWebhookEndpoint
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
const archiveWebhookEndpoint = (id, input) => {
|
|
1338
|
+
assertIdentifier(id, "Webhook endpoint id");
|
|
1339
|
+
return request({
|
|
1340
|
+
method: "DELETE",
|
|
1341
|
+
path: `/v1/webhook-endpoints/${encodePathSegment(id)}`,
|
|
1342
|
+
idempotencyKey: input.idempotencyKey,
|
|
1343
|
+
signal: input.signal,
|
|
1344
|
+
guard: isWebhookEndpointArchive
|
|
1345
|
+
});
|
|
1346
|
+
};
|
|
1347
|
+
const rotateWebhookSecret = (id, input) => {
|
|
1348
|
+
assertIdentifier(id, "Webhook endpoint id");
|
|
1349
|
+
return request({
|
|
1350
|
+
method: "POST",
|
|
1351
|
+
path: `/v1/webhook-endpoints/${encodePathSegment(id)}/rotate-secret`,
|
|
1352
|
+
body: {},
|
|
1353
|
+
idempotencyKey: input.idempotencyKey,
|
|
1354
|
+
signal: input.signal,
|
|
1355
|
+
guard: isWebhookEndpoint
|
|
1356
|
+
});
|
|
1357
|
+
};
|
|
1358
|
+
const endWebhookSecretOverlap = (id, input) => {
|
|
1359
|
+
assertIdentifier(id, "Webhook endpoint id");
|
|
1360
|
+
return request({
|
|
1361
|
+
method: "POST",
|
|
1362
|
+
path: `/v1/webhook-endpoints/${encodePathSegment(id)}/end-secret-overlap`,
|
|
1363
|
+
body: {},
|
|
1364
|
+
idempotencyKey: input.idempotencyKey,
|
|
1365
|
+
signal: input.signal,
|
|
1366
|
+
guard: isWebhookEndpoint
|
|
1367
|
+
});
|
|
1368
|
+
};
|
|
779
1369
|
const createTestWebhook = (input) => {
|
|
780
1370
|
assertIdentifier(input.endpointId, "Webhook endpoint id");
|
|
781
1371
|
assertWebhookEventTypes(
|
|
@@ -797,7 +1387,23 @@ function createPayclaveServerClient({
|
|
|
797
1387
|
if (limit !== void 0) {
|
|
798
1388
|
assertPositiveIntegerLimit(limit);
|
|
799
1389
|
}
|
|
800
|
-
const
|
|
1390
|
+
const params = new URLSearchParams();
|
|
1391
|
+
if (limit !== void 0) params.set("limit", String(limit));
|
|
1392
|
+
for (const [key, value] of [
|
|
1393
|
+
["endpointId", input.endpointId],
|
|
1394
|
+
["eventType", input.eventType],
|
|
1395
|
+
["status", input.status],
|
|
1396
|
+
["createdFrom", input.createdFrom],
|
|
1397
|
+
["createdTo", input.createdTo],
|
|
1398
|
+
["replayStatus", input.replayStatus],
|
|
1399
|
+
["responseFamily", input.responseFamily]
|
|
1400
|
+
]) {
|
|
1401
|
+
if (value !== void 0) {
|
|
1402
|
+
assertIdentifier(value, key);
|
|
1403
|
+
params.set(key, value);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
801
1407
|
return request({
|
|
802
1408
|
method: "GET",
|
|
803
1409
|
path: `/v1/webhook-deliveries${query}`,
|
|
@@ -805,16 +1411,221 @@ function createPayclaveServerClient({
|
|
|
805
1411
|
guard: isWebhookDeliveryArray
|
|
806
1412
|
});
|
|
807
1413
|
};
|
|
1414
|
+
const getWebhookDelivery = (id, options = {}) => {
|
|
1415
|
+
assertIdentifier(id, "Webhook delivery id");
|
|
1416
|
+
return request({
|
|
1417
|
+
method: "GET",
|
|
1418
|
+
path: `/v1/webhook-deliveries/${encodePathSegment(id)}`,
|
|
1419
|
+
signal: options.signal,
|
|
1420
|
+
guard: isWebhookDeliveryDetail
|
|
1421
|
+
});
|
|
1422
|
+
};
|
|
1423
|
+
const listWebhookDeliveryAttempts = (id, options = {}) => {
|
|
1424
|
+
assertIdentifier(id, "Webhook delivery id");
|
|
1425
|
+
return request({
|
|
1426
|
+
method: "GET",
|
|
1427
|
+
path: `/v1/webhook-deliveries/${encodePathSegment(id)}/attempts`,
|
|
1428
|
+
signal: options.signal,
|
|
1429
|
+
guard: isWebhookDeliveryAttemptArray
|
|
1430
|
+
});
|
|
1431
|
+
};
|
|
1432
|
+
const replayWebhookDelivery = (id, input) => {
|
|
1433
|
+
assertIdentifier(id, "Webhook delivery id");
|
|
1434
|
+
return request({
|
|
1435
|
+
method: "POST",
|
|
1436
|
+
path: `/v1/webhook-deliveries/${encodePathSegment(id)}/replay`,
|
|
1437
|
+
idempotencyKey: input.idempotencyKey,
|
|
1438
|
+
signal: input.signal,
|
|
1439
|
+
guard: isWebhookDeliveryDetail
|
|
1440
|
+
});
|
|
1441
|
+
};
|
|
1442
|
+
const listWebhookIncidents = (input = {}) => {
|
|
1443
|
+
const query = input.status ? `?status=${input.status}` : "";
|
|
1444
|
+
return request({
|
|
1445
|
+
method: "GET",
|
|
1446
|
+
path: `/v1/webhook-incidents${query}`,
|
|
1447
|
+
signal: input.signal,
|
|
1448
|
+
guard: isWebhookIncidentArray
|
|
1449
|
+
});
|
|
1450
|
+
};
|
|
1451
|
+
const getWebhookIncident = (id, options = {}) => {
|
|
1452
|
+
assertIdentifier(id, "Webhook incident id");
|
|
1453
|
+
return request({
|
|
1454
|
+
method: "GET",
|
|
1455
|
+
path: `/v1/webhook-incidents/${encodePathSegment(id)}`,
|
|
1456
|
+
signal: options.signal,
|
|
1457
|
+
guard: isWebhookIncident
|
|
1458
|
+
});
|
|
1459
|
+
};
|
|
1460
|
+
const getReconciliationSchema = (version = PAYCLAVE_RECONCILIATION_SCHEMA_VERSION, options = {}) => {
|
|
1461
|
+
assertIdentifier(version, "Reconciliation schema version");
|
|
1462
|
+
return request({
|
|
1463
|
+
method: "GET",
|
|
1464
|
+
path: `/v1/reconciliation/schema/${encodePathSegment(version)}`,
|
|
1465
|
+
signal: options.signal,
|
|
1466
|
+
guard: isReconciliationSchema
|
|
1467
|
+
});
|
|
1468
|
+
};
|
|
1469
|
+
const getReconciliationSummary = (input) => {
|
|
1470
|
+
assertIdentifier(input.dateBasis, "Reconciliation date basis");
|
|
1471
|
+
assertIdentifier(input.from, "Reconciliation from timestamp");
|
|
1472
|
+
assertIdentifier(input.to, "Reconciliation to timestamp");
|
|
1473
|
+
const query = new URLSearchParams({
|
|
1474
|
+
dateBasis: input.dateBasis,
|
|
1475
|
+
from: input.from,
|
|
1476
|
+
to: input.to,
|
|
1477
|
+
timezone: input.timezone ?? "UTC"
|
|
1478
|
+
});
|
|
1479
|
+
if (input.exceptionOnly !== void 0) {
|
|
1480
|
+
query.set("exceptionOnly", String(input.exceptionOnly));
|
|
1481
|
+
}
|
|
1482
|
+
for (const status of input.invoiceStatuses ?? []) {
|
|
1483
|
+
query.append("invoiceStatus", status);
|
|
1484
|
+
}
|
|
1485
|
+
for (const status of input.paymentStatuses ?? []) {
|
|
1486
|
+
query.append("paymentStatus", status);
|
|
1487
|
+
}
|
|
1488
|
+
for (const token of input.settlementTokens ?? []) {
|
|
1489
|
+
query.append("settlementToken", token);
|
|
1490
|
+
}
|
|
1491
|
+
return request({
|
|
1492
|
+
method: "GET",
|
|
1493
|
+
path: `/v1/reconciliation/summary?${query.toString()}`,
|
|
1494
|
+
signal: input.signal,
|
|
1495
|
+
guard: isReconciliationSummary
|
|
1496
|
+
});
|
|
1497
|
+
};
|
|
1498
|
+
const createReconciliationExport = (input) => {
|
|
1499
|
+
assertReconciliationFormat(input.format);
|
|
1500
|
+
assertIdentifier(input.dateBasis, "Reconciliation date basis");
|
|
1501
|
+
assertIdentifier(input.from, "Reconciliation from timestamp");
|
|
1502
|
+
assertIdentifier(input.to, "Reconciliation to timestamp");
|
|
1503
|
+
const { signal, idempotencyKey, ...fields } = input;
|
|
1504
|
+
return request({
|
|
1505
|
+
method: "POST",
|
|
1506
|
+
path: "/v1/reconciliation-exports",
|
|
1507
|
+
body: compact({
|
|
1508
|
+
...fields,
|
|
1509
|
+
mode: input.mode ?? (secretKey.startsWith("sk_live_") ? "live" : "test"),
|
|
1510
|
+
timezone: input.timezone ?? "UTC",
|
|
1511
|
+
exceptionOnly: input.exceptionOnly ?? false,
|
|
1512
|
+
includePII: input.includePII ?? false,
|
|
1513
|
+
schemaVersion: input.schemaVersion ?? PAYCLAVE_RECONCILIATION_SCHEMA_VERSION
|
|
1514
|
+
}),
|
|
1515
|
+
idempotencyKey,
|
|
1516
|
+
signal,
|
|
1517
|
+
guard: isReconciliationExport
|
|
1518
|
+
});
|
|
1519
|
+
};
|
|
1520
|
+
const listReconciliationExports = (input = {}) => {
|
|
1521
|
+
const query = new URLSearchParams();
|
|
1522
|
+
if (input.limit !== void 0) {
|
|
1523
|
+
assertPositiveIntegerLimit(input.limit);
|
|
1524
|
+
query.set("limit", String(input.limit));
|
|
1525
|
+
}
|
|
1526
|
+
if (input.startingAfter !== void 0) {
|
|
1527
|
+
assertIdentifier(input.startingAfter, "Starting reconciliation export id");
|
|
1528
|
+
query.set("startingAfter", input.startingAfter);
|
|
1529
|
+
}
|
|
1530
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1531
|
+
return request({
|
|
1532
|
+
method: "GET",
|
|
1533
|
+
path: `/v1/reconciliation-exports${suffix}`,
|
|
1534
|
+
signal: input.signal,
|
|
1535
|
+
guard: isReconciliationExportList
|
|
1536
|
+
});
|
|
1537
|
+
};
|
|
1538
|
+
const getReconciliationExport = (id, options = {}) => {
|
|
1539
|
+
assertIdentifier(id, "Reconciliation export id");
|
|
1540
|
+
return request({
|
|
1541
|
+
method: "GET",
|
|
1542
|
+
path: `/v1/reconciliation-exports/${encodePathSegment(id)}`,
|
|
1543
|
+
signal: options.signal,
|
|
1544
|
+
guard: isReconciliationExport
|
|
1545
|
+
});
|
|
1546
|
+
};
|
|
1547
|
+
const cancelReconciliationExport = (id, input = {}) => {
|
|
1548
|
+
assertIdentifier(id, "Reconciliation export id");
|
|
1549
|
+
return request({
|
|
1550
|
+
method: "POST",
|
|
1551
|
+
path: `/v1/reconciliation-exports/${encodePathSegment(id)}/cancel`,
|
|
1552
|
+
idempotencyKey: input.idempotencyKey,
|
|
1553
|
+
signal: input.signal,
|
|
1554
|
+
guard: isReconciliationExport
|
|
1555
|
+
});
|
|
1556
|
+
};
|
|
1557
|
+
const downloadReconciliationExport = async (id, options = {}) => {
|
|
1558
|
+
assertIdentifier(id, "Reconciliation export id");
|
|
1559
|
+
const response = await runFetch({
|
|
1560
|
+
fetcher,
|
|
1561
|
+
url: joinUrl(
|
|
1562
|
+
normalizedApiBaseUrl,
|
|
1563
|
+
`/v1/reconciliation-exports/${encodePathSegment(id)}/download`
|
|
1564
|
+
),
|
|
1565
|
+
init: {
|
|
1566
|
+
method: "GET",
|
|
1567
|
+
headers: {
|
|
1568
|
+
Accept: "application/zip",
|
|
1569
|
+
Authorization: `Bearer ${secretKey}`,
|
|
1570
|
+
"X-Payclave-Client": buildClientHeader()
|
|
1571
|
+
}
|
|
1572
|
+
},
|
|
1573
|
+
externalSignal: options.signal,
|
|
1574
|
+
timeoutMs
|
|
1575
|
+
});
|
|
1576
|
+
return parseReconciliationDownloadResponse(response);
|
|
1577
|
+
};
|
|
808
1578
|
return {
|
|
809
1579
|
createCheckoutSession,
|
|
810
1580
|
getCheckoutSession,
|
|
811
1581
|
createInvoice,
|
|
1582
|
+
createInvoiceDraft,
|
|
1583
|
+
listInvoices,
|
|
812
1584
|
getInvoice,
|
|
1585
|
+
downloadInvoicePDF,
|
|
1586
|
+
updateInvoiceDraft,
|
|
1587
|
+
issueInvoice,
|
|
1588
|
+
sendInvoice,
|
|
1589
|
+
remindInvoice,
|
|
1590
|
+
createInvoiceCheckoutSession,
|
|
1591
|
+
voidInvoice,
|
|
1592
|
+
voidInvoiceRemaining,
|
|
1593
|
+
markInvoiceUncollectible,
|
|
1594
|
+
duplicateInvoice,
|
|
1595
|
+
recordInvoiceRefundReference,
|
|
1596
|
+
createPaymentLink,
|
|
1597
|
+
listPaymentLinks,
|
|
1598
|
+
getPaymentLink,
|
|
1599
|
+
updatePaymentLink,
|
|
1600
|
+
pausePaymentLink,
|
|
1601
|
+
resumePaymentLink,
|
|
1602
|
+
archivePaymentLink,
|
|
1603
|
+
duplicatePaymentLink,
|
|
1604
|
+
releasePaymentLinkReservation,
|
|
1605
|
+
listPaymentLinkPayments,
|
|
813
1606
|
getPayment,
|
|
814
1607
|
createWebhookEndpoint,
|
|
1608
|
+
listWebhookEndpoints,
|
|
1609
|
+
getWebhookEndpoint,
|
|
1610
|
+
updateWebhookEndpoint,
|
|
1611
|
+
archiveWebhookEndpoint,
|
|
1612
|
+
rotateWebhookSecret,
|
|
1613
|
+
endWebhookSecretOverlap,
|
|
815
1614
|
createTestWebhook,
|
|
816
|
-
listWebhookDeliveries
|
|
1615
|
+
listWebhookDeliveries,
|
|
1616
|
+
getWebhookDelivery,
|
|
1617
|
+
listWebhookDeliveryAttempts,
|
|
1618
|
+
replayWebhookDelivery,
|
|
1619
|
+
listWebhookIncidents,
|
|
1620
|
+
getWebhookIncident,
|
|
1621
|
+
getReconciliationSchema,
|
|
1622
|
+
getReconciliationSummary,
|
|
1623
|
+
createReconciliationExport,
|
|
1624
|
+
listReconciliationExports,
|
|
1625
|
+
getReconciliationExport,
|
|
1626
|
+
cancelReconciliationExport,
|
|
1627
|
+
downloadReconciliationExport
|
|
817
1628
|
};
|
|
818
1629
|
}
|
|
819
1630
|
|
|
820
|
-
export { PAYCLAVE_API_ERROR_CODES, PAYCLAVE_SERVER_SDK_ERROR_CODES, PAYCLAVE_SERVER_SDK_NAME, PAYCLAVE_SERVER_SDK_VERSION, PAYCLAVE_WEBHOOK_EVENT_TYPES, PAYCLAVE_WEBHOOK_VERIFICATION_ERROR_CODES, PayclaveError, assertPayclaveWebhookSignature, constructPayclaveWebhookEvent, createPayclaveServerClient, verifyPayclaveWebhookSignature };
|
|
1631
|
+
export { PAYCLAVE_API_ERROR_CODES, PAYCLAVE_RECONCILIATION_SCHEMA_VERSION, PAYCLAVE_SERVER_SDK_ERROR_CODES, PAYCLAVE_SERVER_SDK_NAME, PAYCLAVE_SERVER_SDK_VERSION, PAYCLAVE_WEBHOOK_EVENT_TYPES, PAYCLAVE_WEBHOOK_VERIFICATION_ERROR_CODES, PayclaveError, assertPayclaveWebhookSignature, constructPayclaveWebhookEvent, createPayclaveServerClient, verifyPayclaveWebhookSignature };
|