@klappay/types 2.0.4 → 3.0.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/dist/index.d.mts +70 -10
- package/dist/index.d.ts +70 -10
- package/dist/index.js +95 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -32,9 +32,11 @@ type ErrorPayload = z.infer<typeof ErrorPayloadSchema>;
|
|
|
32
32
|
declare const EnvironmentSchema: z.ZodEnum<["live", "test"]>;
|
|
33
33
|
type Environment = z.infer<typeof EnvironmentSchema>;
|
|
34
34
|
|
|
35
|
-
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger"]>;
|
|
35
|
+
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"]>;
|
|
36
36
|
type ApiKeyScope = z.infer<typeof ApiKeyScopeSchema>;
|
|
37
|
-
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger"];
|
|
37
|
+
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"];
|
|
38
|
+
declare const CONFLICTING_SCOPE_PAIRS: ReadonlyArray<readonly [ApiKeyScope, ApiKeyScope]>;
|
|
39
|
+
declare function findConflictingScopes(scopes: readonly ApiKeyScope[]): readonly [ApiKeyScope, ApiKeyScope] | null;
|
|
38
40
|
|
|
39
41
|
declare const NetworkSchema: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
40
42
|
type Network = z.infer<typeof NetworkSchema>;
|
|
@@ -112,6 +114,20 @@ declare const SplitRecipientSchema: z.ZodObject<{
|
|
|
112
114
|
label?: string | undefined;
|
|
113
115
|
}>;
|
|
114
116
|
type SplitRecipient = z.infer<typeof SplitRecipientSchema>;
|
|
117
|
+
declare const SplitRecipientInputSchema: z.ZodObject<{
|
|
118
|
+
recipientId: z.ZodString;
|
|
119
|
+
percent: z.ZodNumber;
|
|
120
|
+
label: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
percent: number;
|
|
123
|
+
recipientId: string;
|
|
124
|
+
label?: string | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
percent: number;
|
|
127
|
+
recipientId: string;
|
|
128
|
+
label?: string | undefined;
|
|
129
|
+
}>;
|
|
130
|
+
type SplitRecipientInput = z.infer<typeof SplitRecipientInputSchema>;
|
|
115
131
|
declare const CHARGE_AMOUNT_MAX = 999999999999;
|
|
116
132
|
declare const CreateChargeSchema: z.ZodObject<{
|
|
117
133
|
amount: z.ZodNumber;
|
|
@@ -223,24 +239,24 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
223
239
|
}, z.ZodUnknown, "strip">>>;
|
|
224
240
|
redirectUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
225
241
|
splitRecipients: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
226
|
-
|
|
242
|
+
recipientId: z.ZodString;
|
|
227
243
|
percent: z.ZodNumber;
|
|
228
244
|
label: z.ZodOptional<z.ZodString>;
|
|
229
245
|
}, "strip", z.ZodTypeAny, {
|
|
230
|
-
address: string;
|
|
231
246
|
percent: number;
|
|
247
|
+
recipientId: string;
|
|
232
248
|
label?: string | undefined;
|
|
233
249
|
}, {
|
|
234
|
-
address: string;
|
|
235
250
|
percent: number;
|
|
251
|
+
recipientId: string;
|
|
236
252
|
label?: string | undefined;
|
|
237
253
|
}>, "many">, {
|
|
238
|
-
address: string;
|
|
239
254
|
percent: number;
|
|
255
|
+
recipientId: string;
|
|
240
256
|
label?: string | undefined;
|
|
241
257
|
}[], {
|
|
242
|
-
address: string;
|
|
243
258
|
percent: number;
|
|
259
|
+
recipientId: string;
|
|
244
260
|
label?: string | undefined;
|
|
245
261
|
}[]>>;
|
|
246
262
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -285,8 +301,8 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
285
301
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
286
302
|
redirectUrl?: string | undefined;
|
|
287
303
|
splitRecipients?: {
|
|
288
|
-
address: string;
|
|
289
304
|
percent: number;
|
|
305
|
+
recipientId: string;
|
|
290
306
|
label?: string | undefined;
|
|
291
307
|
}[] | undefined;
|
|
292
308
|
}, {
|
|
@@ -331,8 +347,8 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
331
347
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
332
348
|
redirectUrl?: string | undefined;
|
|
333
349
|
splitRecipients?: {
|
|
334
|
-
address: string;
|
|
335
350
|
percent: number;
|
|
351
|
+
recipientId: string;
|
|
336
352
|
label?: string | undefined;
|
|
337
353
|
}[] | undefined;
|
|
338
354
|
}>;
|
|
@@ -2346,6 +2362,50 @@ declare const PaginatedWebhookDeliveriesSchema: z.ZodObject<{
|
|
|
2346
2362
|
}>;
|
|
2347
2363
|
type PaginatedWebhookDeliveries = z.infer<typeof PaginatedWebhookDeliveriesSchema>;
|
|
2348
2364
|
|
|
2365
|
+
declare const CreateRecipientSchema: z.ZodObject<{
|
|
2366
|
+
address: z.ZodString;
|
|
2367
|
+
label: z.ZodOptional<z.ZodString>;
|
|
2368
|
+
}, "strip", z.ZodTypeAny, {
|
|
2369
|
+
address: string;
|
|
2370
|
+
label?: string | undefined;
|
|
2371
|
+
}, {
|
|
2372
|
+
address: string;
|
|
2373
|
+
label?: string | undefined;
|
|
2374
|
+
}>;
|
|
2375
|
+
type CreateRecipientInput = z.infer<typeof CreateRecipientSchema>;
|
|
2376
|
+
type CreateRecipientRequest = z.input<typeof CreateRecipientSchema>;
|
|
2377
|
+
declare const RecipientSchema: z.ZodObject<{
|
|
2378
|
+
id: z.ZodString;
|
|
2379
|
+
environment: z.ZodEnum<["live", "test"]>;
|
|
2380
|
+
address: z.ZodString;
|
|
2381
|
+
label: z.ZodNullable<z.ZodString>;
|
|
2382
|
+
payout: z.ZodBoolean;
|
|
2383
|
+
createdAt: z.ZodString;
|
|
2384
|
+
}, "strip", z.ZodTypeAny, {
|
|
2385
|
+
address: string;
|
|
2386
|
+
label: string | null;
|
|
2387
|
+
id: string;
|
|
2388
|
+
environment: "live" | "test";
|
|
2389
|
+
createdAt: string;
|
|
2390
|
+
payout: boolean;
|
|
2391
|
+
}, {
|
|
2392
|
+
address: string;
|
|
2393
|
+
label: string | null;
|
|
2394
|
+
id: string;
|
|
2395
|
+
environment: "live" | "test";
|
|
2396
|
+
createdAt: string;
|
|
2397
|
+
payout: boolean;
|
|
2398
|
+
}>;
|
|
2399
|
+
type Recipient = z.infer<typeof RecipientSchema>;
|
|
2400
|
+
declare const SetRecipientPayoutSchema: z.ZodObject<{
|
|
2401
|
+
payout: z.ZodBoolean;
|
|
2402
|
+
}, "strip", z.ZodTypeAny, {
|
|
2403
|
+
payout: boolean;
|
|
2404
|
+
}, {
|
|
2405
|
+
payout: boolean;
|
|
2406
|
+
}>;
|
|
2407
|
+
type SetRecipientPayoutInput = z.infer<typeof SetRecipientPayoutSchema>;
|
|
2408
|
+
|
|
2349
2409
|
declare const TransactionSourceSchema: z.ZodEnum<["moralis_webhook", "reconciliation_job", "sandbox"]>;
|
|
2350
2410
|
type TransactionSource = z.infer<typeof TransactionSourceSchema>;
|
|
2351
2411
|
declare const TimelineEventTypeSchema: z.ZodEnum<["charge.created", "charge.expired", "transaction.detected", "split.distributed", "webhook.dispatched", "webhook.delivered", "webhook.failed"]>;
|
|
@@ -2452,4 +2512,4 @@ declare const CapabilitiesSchema: z.ZodObject<{
|
|
|
2452
2512
|
}>;
|
|
2453
2513
|
type Capabilities = z.infer<typeof CapabilitiesSchema>;
|
|
2454
2514
|
|
|
2455
|
-
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, EVM_NETWORKS, type Environment, EnvironmentSchema, type ErrorPayload, ErrorPayloadSchema, type EvmNetwork, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, NETWORK_EXPLORERS, NETWORK_LABELS, type Network, NetworkSchema, OPERATIONAL_NETWORKS, type OperationalNetwork, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, SplitRecipientSchema, TOKEN_ADDRESSES, TOKEN_DECIMALS, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type Token, TokenSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, paginatedSchema };
|
|
2515
|
+
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, CONFLICTING_SCOPE_PAIRS, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateRecipientInput, type CreateRecipientRequest, CreateRecipientSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, EVM_NETWORKS, type Environment, EnvironmentSchema, type ErrorPayload, ErrorPayloadSchema, type EvmNetwork, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, NETWORK_EXPLORERS, NETWORK_LABELS, type Network, NetworkSchema, OPERATIONAL_NETWORKS, type OperationalNetwork, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type Recipient, RecipientSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SetRecipientPayoutInput, SetRecipientPayoutSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, type SplitRecipientInput, SplitRecipientInputSchema, SplitRecipientSchema, TOKEN_ADDRESSES, TOKEN_DECIMALS, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type Token, TokenSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, findConflictingScopes, paginatedSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,9 +32,11 @@ type ErrorPayload = z.infer<typeof ErrorPayloadSchema>;
|
|
|
32
32
|
declare const EnvironmentSchema: z.ZodEnum<["live", "test"]>;
|
|
33
33
|
type Environment = z.infer<typeof EnvironmentSchema>;
|
|
34
34
|
|
|
35
|
-
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger"]>;
|
|
35
|
+
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"]>;
|
|
36
36
|
type ApiKeyScope = z.infer<typeof ApiKeyScopeSchema>;
|
|
37
|
-
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger"];
|
|
37
|
+
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"];
|
|
38
|
+
declare const CONFLICTING_SCOPE_PAIRS: ReadonlyArray<readonly [ApiKeyScope, ApiKeyScope]>;
|
|
39
|
+
declare function findConflictingScopes(scopes: readonly ApiKeyScope[]): readonly [ApiKeyScope, ApiKeyScope] | null;
|
|
38
40
|
|
|
39
41
|
declare const NetworkSchema: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
40
42
|
type Network = z.infer<typeof NetworkSchema>;
|
|
@@ -112,6 +114,20 @@ declare const SplitRecipientSchema: z.ZodObject<{
|
|
|
112
114
|
label?: string | undefined;
|
|
113
115
|
}>;
|
|
114
116
|
type SplitRecipient = z.infer<typeof SplitRecipientSchema>;
|
|
117
|
+
declare const SplitRecipientInputSchema: z.ZodObject<{
|
|
118
|
+
recipientId: z.ZodString;
|
|
119
|
+
percent: z.ZodNumber;
|
|
120
|
+
label: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
percent: number;
|
|
123
|
+
recipientId: string;
|
|
124
|
+
label?: string | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
percent: number;
|
|
127
|
+
recipientId: string;
|
|
128
|
+
label?: string | undefined;
|
|
129
|
+
}>;
|
|
130
|
+
type SplitRecipientInput = z.infer<typeof SplitRecipientInputSchema>;
|
|
115
131
|
declare const CHARGE_AMOUNT_MAX = 999999999999;
|
|
116
132
|
declare const CreateChargeSchema: z.ZodObject<{
|
|
117
133
|
amount: z.ZodNumber;
|
|
@@ -223,24 +239,24 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
223
239
|
}, z.ZodUnknown, "strip">>>;
|
|
224
240
|
redirectUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
225
241
|
splitRecipients: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
226
|
-
|
|
242
|
+
recipientId: z.ZodString;
|
|
227
243
|
percent: z.ZodNumber;
|
|
228
244
|
label: z.ZodOptional<z.ZodString>;
|
|
229
245
|
}, "strip", z.ZodTypeAny, {
|
|
230
|
-
address: string;
|
|
231
246
|
percent: number;
|
|
247
|
+
recipientId: string;
|
|
232
248
|
label?: string | undefined;
|
|
233
249
|
}, {
|
|
234
|
-
address: string;
|
|
235
250
|
percent: number;
|
|
251
|
+
recipientId: string;
|
|
236
252
|
label?: string | undefined;
|
|
237
253
|
}>, "many">, {
|
|
238
|
-
address: string;
|
|
239
254
|
percent: number;
|
|
255
|
+
recipientId: string;
|
|
240
256
|
label?: string | undefined;
|
|
241
257
|
}[], {
|
|
242
|
-
address: string;
|
|
243
258
|
percent: number;
|
|
259
|
+
recipientId: string;
|
|
244
260
|
label?: string | undefined;
|
|
245
261
|
}[]>>;
|
|
246
262
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -285,8 +301,8 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
285
301
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
286
302
|
redirectUrl?: string | undefined;
|
|
287
303
|
splitRecipients?: {
|
|
288
|
-
address: string;
|
|
289
304
|
percent: number;
|
|
305
|
+
recipientId: string;
|
|
290
306
|
label?: string | undefined;
|
|
291
307
|
}[] | undefined;
|
|
292
308
|
}, {
|
|
@@ -331,8 +347,8 @@ declare const CreateChargeSchema: z.ZodObject<{
|
|
|
331
347
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
332
348
|
redirectUrl?: string | undefined;
|
|
333
349
|
splitRecipients?: {
|
|
334
|
-
address: string;
|
|
335
350
|
percent: number;
|
|
351
|
+
recipientId: string;
|
|
336
352
|
label?: string | undefined;
|
|
337
353
|
}[] | undefined;
|
|
338
354
|
}>;
|
|
@@ -2346,6 +2362,50 @@ declare const PaginatedWebhookDeliveriesSchema: z.ZodObject<{
|
|
|
2346
2362
|
}>;
|
|
2347
2363
|
type PaginatedWebhookDeliveries = z.infer<typeof PaginatedWebhookDeliveriesSchema>;
|
|
2348
2364
|
|
|
2365
|
+
declare const CreateRecipientSchema: z.ZodObject<{
|
|
2366
|
+
address: z.ZodString;
|
|
2367
|
+
label: z.ZodOptional<z.ZodString>;
|
|
2368
|
+
}, "strip", z.ZodTypeAny, {
|
|
2369
|
+
address: string;
|
|
2370
|
+
label?: string | undefined;
|
|
2371
|
+
}, {
|
|
2372
|
+
address: string;
|
|
2373
|
+
label?: string | undefined;
|
|
2374
|
+
}>;
|
|
2375
|
+
type CreateRecipientInput = z.infer<typeof CreateRecipientSchema>;
|
|
2376
|
+
type CreateRecipientRequest = z.input<typeof CreateRecipientSchema>;
|
|
2377
|
+
declare const RecipientSchema: z.ZodObject<{
|
|
2378
|
+
id: z.ZodString;
|
|
2379
|
+
environment: z.ZodEnum<["live", "test"]>;
|
|
2380
|
+
address: z.ZodString;
|
|
2381
|
+
label: z.ZodNullable<z.ZodString>;
|
|
2382
|
+
payout: z.ZodBoolean;
|
|
2383
|
+
createdAt: z.ZodString;
|
|
2384
|
+
}, "strip", z.ZodTypeAny, {
|
|
2385
|
+
address: string;
|
|
2386
|
+
label: string | null;
|
|
2387
|
+
id: string;
|
|
2388
|
+
environment: "live" | "test";
|
|
2389
|
+
createdAt: string;
|
|
2390
|
+
payout: boolean;
|
|
2391
|
+
}, {
|
|
2392
|
+
address: string;
|
|
2393
|
+
label: string | null;
|
|
2394
|
+
id: string;
|
|
2395
|
+
environment: "live" | "test";
|
|
2396
|
+
createdAt: string;
|
|
2397
|
+
payout: boolean;
|
|
2398
|
+
}>;
|
|
2399
|
+
type Recipient = z.infer<typeof RecipientSchema>;
|
|
2400
|
+
declare const SetRecipientPayoutSchema: z.ZodObject<{
|
|
2401
|
+
payout: z.ZodBoolean;
|
|
2402
|
+
}, "strip", z.ZodTypeAny, {
|
|
2403
|
+
payout: boolean;
|
|
2404
|
+
}, {
|
|
2405
|
+
payout: boolean;
|
|
2406
|
+
}>;
|
|
2407
|
+
type SetRecipientPayoutInput = z.infer<typeof SetRecipientPayoutSchema>;
|
|
2408
|
+
|
|
2349
2409
|
declare const TransactionSourceSchema: z.ZodEnum<["moralis_webhook", "reconciliation_job", "sandbox"]>;
|
|
2350
2410
|
type TransactionSource = z.infer<typeof TransactionSourceSchema>;
|
|
2351
2411
|
declare const TimelineEventTypeSchema: z.ZodEnum<["charge.created", "charge.expired", "transaction.detected", "split.distributed", "webhook.dispatched", "webhook.delivered", "webhook.failed"]>;
|
|
@@ -2452,4 +2512,4 @@ declare const CapabilitiesSchema: z.ZodObject<{
|
|
|
2452
2512
|
}>;
|
|
2453
2513
|
type Capabilities = z.infer<typeof CapabilitiesSchema>;
|
|
2454
2514
|
|
|
2455
|
-
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, EVM_NETWORKS, type Environment, EnvironmentSchema, type ErrorPayload, ErrorPayloadSchema, type EvmNetwork, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, NETWORK_EXPLORERS, NETWORK_LABELS, type Network, NetworkSchema, OPERATIONAL_NETWORKS, type OperationalNetwork, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, SplitRecipientSchema, TOKEN_ADDRESSES, TOKEN_DECIMALS, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type Token, TokenSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, paginatedSchema };
|
|
2515
|
+
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, CONFLICTING_SCOPE_PAIRS, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateRecipientInput, type CreateRecipientRequest, CreateRecipientSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, EVM_NETWORKS, type Environment, EnvironmentSchema, type ErrorPayload, ErrorPayloadSchema, type EvmNetwork, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, NETWORK_EXPLORERS, NETWORK_LABELS, type Network, NetworkSchema, OPERATIONAL_NETWORKS, type OperationalNetwork, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type Recipient, RecipientSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SetRecipientPayoutInput, SetRecipientPayoutSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, type SplitRecipientInput, SplitRecipientInputSchema, SplitRecipientSchema, TOKEN_ADDRESSES, TOKEN_DECIMALS, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type Token, TokenSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, findConflictingScopes, paginatedSchema };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
CHARGE_EXPIRES_IN_MIN_SECONDS: () => CHARGE_EXPIRES_IN_MIN_SECONDS,
|
|
30
30
|
CHARGE_SPLIT_RECIPIENTS_MAX: () => CHARGE_SPLIT_RECIPIENTS_MAX,
|
|
31
31
|
CHECKOUT_PRODUCTS_MAX: () => CHECKOUT_PRODUCTS_MAX,
|
|
32
|
+
CONFLICTING_SCOPE_PAIRS: () => CONFLICTING_SCOPE_PAIRS,
|
|
32
33
|
CapabilitiesSchema: () => CapabilitiesSchema,
|
|
33
34
|
ChargeSchema: () => ChargeSchema,
|
|
34
35
|
ChargeStatusSchema: () => ChargeStatusSchema,
|
|
@@ -38,6 +39,7 @@ __export(index_exports, {
|
|
|
38
39
|
ChargesQueryFieldSchema: () => ChargesQueryFieldSchema,
|
|
39
40
|
CheckoutProductSchema: () => CheckoutProductSchema,
|
|
40
41
|
CreateChargeSchema: () => CreateChargeSchema,
|
|
42
|
+
CreateRecipientSchema: () => CreateRecipientSchema,
|
|
41
43
|
CreateWebhookSchema: () => CreateWebhookSchema,
|
|
42
44
|
DistributionsDateFieldSchema: () => DistributionsDateFieldSchema,
|
|
43
45
|
DistributionsMetricFieldSchema: () => DistributionsMetricFieldSchema,
|
|
@@ -80,9 +82,12 @@ __export(index_exports, {
|
|
|
80
82
|
PendingDistributionEventSchema: () => PendingDistributionEventSchema,
|
|
81
83
|
PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
|
|
82
84
|
PendingDistributionSchema: () => PendingDistributionSchema,
|
|
85
|
+
RecipientSchema: () => RecipientSchema,
|
|
83
86
|
SandboxTriggerSchema: () => SandboxTriggerSchema,
|
|
87
|
+
SetRecipientPayoutSchema: () => SetRecipientPayoutSchema,
|
|
84
88
|
SettlementStatusSchema: () => SettlementStatusSchema,
|
|
85
89
|
SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
|
|
90
|
+
SplitRecipientInputSchema: () => SplitRecipientInputSchema,
|
|
86
91
|
SplitRecipientSchema: () => SplitRecipientSchema,
|
|
87
92
|
TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
|
|
88
93
|
TOKEN_DECIMALS: () => TOKEN_DECIMALS,
|
|
@@ -104,6 +109,7 @@ __export(index_exports, {
|
|
|
104
109
|
WebhookListItemSchema: () => WebhookListItemSchema,
|
|
105
110
|
WebhookPayloadSchema: () => WebhookPayloadSchema,
|
|
106
111
|
WebhookSchema: () => WebhookSchema,
|
|
112
|
+
findConflictingScopes: () => findConflictingScopes,
|
|
107
113
|
paginatedSchema: () => paginatedSchema
|
|
108
114
|
});
|
|
109
115
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -140,11 +146,26 @@ var ApiKeyScopeSchema = import_zod3.z.enum([
|
|
|
140
146
|
"metrics:charges:read",
|
|
141
147
|
"metrics:transactions:read",
|
|
142
148
|
"metrics:distributions:read",
|
|
143
|
-
"sandbox:trigger"
|
|
149
|
+
"sandbox:trigger",
|
|
150
|
+
"charges:split_write",
|
|
151
|
+
"recipients:read",
|
|
152
|
+
"recipients:write",
|
|
153
|
+
"recipients:manage_payout"
|
|
144
154
|
]).describe(
|
|
145
|
-
"What an API key is allowed to do, independent of `tenantId`/`environment` (which scope *whose* data, not *what actions*). A key with none of these can still authenticate but every scoped route rejects it with `403 insufficient_scope`. `metrics:read` alone grants every metrics resource; `metrics:{resource}:read` grants only that one \u2014 a key can hold either or both."
|
|
155
|
+
"What an API key is allowed to do, independent of `tenantId`/`environment` (which scope *whose* data, not *what actions*). A key with none of these can still authenticate but every scoped route rejects it with `403 insufficient_scope`. `metrics:read` alone grants every metrics resource; `metrics:{resource}:read` grants only that one \u2014 a key can hold either or both. `charges:split_write` is required on top of `charges:write` whenever a charge request includes `splitRecipients` \u2014 a key without it can create ordinary charges but never redirect part of the payout. `recipients:write` registers/revokes recipients (addresses eligible to be *referenced* in a split); `recipients:manage_payout` is separate and strictly more sensitive \u2014 it is what lets a recipient actually become an API key's `payoutAddress`, and should be granted only to a key that already went through out-of-band approval for that (Dashboard's own internal key, never a merchant-facing or third-party integration key like a marketplace's). `charges:split_write` can never be combined with `recipients:write`/`recipients:manage_payout` on the same key (see `CONFLICTING_SCOPE_PAIRS`) \u2014 Core rejects such a key outright, before any route runs."
|
|
146
156
|
);
|
|
147
157
|
var API_KEY_SCOPES = ApiKeyScopeSchema.options;
|
|
158
|
+
var CONFLICTING_SCOPE_PAIRS = [
|
|
159
|
+
["charges:split_write", "recipients:write"],
|
|
160
|
+
["charges:split_write", "recipients:manage_payout"]
|
|
161
|
+
];
|
|
162
|
+
function findConflictingScopes(scopes) {
|
|
163
|
+
const held = new Set(scopes);
|
|
164
|
+
for (const [a, b] of CONFLICTING_SCOPE_PAIRS) {
|
|
165
|
+
if (held.has(a) && held.has(b)) return [a, b];
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
148
169
|
|
|
149
170
|
// src/networks.ts
|
|
150
171
|
var import_zod4 = require("zod");
|
|
@@ -314,21 +335,31 @@ var SplitRecipientSchema = import_zod8.z.object({
|
|
|
314
335
|
'Free-form label for your own bookkeeping (e.g. `"supplier"`, `"sales rep"`) \u2014 echoed back unchanged, never interpreted by Klappay.'
|
|
315
336
|
)
|
|
316
337
|
});
|
|
317
|
-
var
|
|
338
|
+
var SplitRecipientInputSchema = import_zod8.z.object({
|
|
339
|
+
recipientId: import_zod8.z.string().describe(
|
|
340
|
+
"id of a `Recipient` you already registered via `POST /v1/recipients` (not a raw address) \u2014 see `recipients:write`/`charges:split_write` scopes. A leaked `charges:write`-only key can never redirect payout to a brand new address this way, only reference one already trusted."
|
|
341
|
+
),
|
|
342
|
+
percent: import_zod8.z.number().positive().max(100).describe(
|
|
343
|
+
"Percent of *your own* net share (i.e. of `100 - feePercent`, not of the charge's gross `amount`) to route to this recipient instead of your own payout wallet. Klappay's fee is computed on the gross amount first and is never diluted by how you choose to split what's left \u2014 see `docs/payments.md`'s \"Settling the payout\" section for the exact math."
|
|
344
|
+
),
|
|
345
|
+
label: import_zod8.z.string().min(1).max(64).optional().describe(
|
|
346
|
+
'Free-form label for your own bookkeeping (e.g. `"supplier"`, `"sales rep"`) \u2014 echoed back unchanged, never interpreted by Klappay. Independent of the label the recipient was registered with.'
|
|
347
|
+
)
|
|
348
|
+
});
|
|
349
|
+
var SplitRecipientsInputSchema = import_zod8.z.array(SplitRecipientInputSchema).max(CHARGE_SPLIT_RECIPIENTS_MAX).superRefine((recipients, ctx) => {
|
|
318
350
|
const seen = /* @__PURE__ */ new Set();
|
|
319
351
|
recipients.forEach((recipient, index) => {
|
|
320
|
-
|
|
321
|
-
if (seen.has(key)) {
|
|
352
|
+
if (seen.has(recipient.recipientId)) {
|
|
322
353
|
ctx.addIssue({
|
|
323
354
|
code: import_zod8.z.ZodIssueCode.custom,
|
|
324
|
-
message: `Duplicate split
|
|
325
|
-
path: [index, "
|
|
355
|
+
message: `Duplicate split recipientId: ${recipient.recipientId}.`,
|
|
356
|
+
path: [index, "recipientId"]
|
|
326
357
|
});
|
|
327
358
|
}
|
|
328
|
-
seen.add(
|
|
359
|
+
seen.add(recipient.recipientId);
|
|
329
360
|
});
|
|
330
361
|
}).describe(
|
|
331
|
-
`Optional extra recipients for this charge's split \u2014 e.g. a supplier or the sales rep who closed the deal \u2014 up to ${CHARGE_SPLIT_RECIPIENTS_MAX}. Frozen at creation exactly like everything else that shapes the split address; cannot be changed afterward. The sum of every \`percent\` here must fit within \`100 - feePercent\` (your own net share) \u2014 a request that doesn't is rejected with \`422 split_recipients_exceed_available_percent\`.`
|
|
362
|
+
`Optional extra recipients for this charge's split \u2014 e.g. a supplier or the sales rep who closed the deal \u2014 up to ${CHARGE_SPLIT_RECIPIENTS_MAX}, each referenced by \`recipientId\` (see \`POST /v1/recipients\`), never a raw address. Requires the \`charges:split_write\` scope in addition to \`charges:write\`. Frozen at creation exactly like everything else that shapes the split address; cannot be changed afterward. The sum of every \`percent\` here must fit within \`100 - feePercent\` (your own net share) \u2014 a request that doesn't is rejected with \`422 split_recipients_exceed_available_percent\`.`
|
|
332
363
|
);
|
|
333
364
|
var CHARGE_AMOUNT_MAX = 999999999999;
|
|
334
365
|
var CreateChargeSchema = import_zod8.z.object({
|
|
@@ -353,7 +384,7 @@ var CreateChargeSchema = import_zod8.z.object({
|
|
|
353
384
|
redirectUrl: import_zod8.z.string().url().refine((value) => /^https?:\/\//.test(value), "must use http or https").optional().describe(
|
|
354
385
|
"Where to send the payer once this charge resolves, if you use Klappay's hosted checkout page (see `checkoutUrl` on the read shape) \u2014 ignored otherwise. Must be `http(s)` \u2014 a browser will navigate here, so `javascript:`/`data:` and other non-navigational schemes are rejected. Otherwise not validated beyond being well-formed; what happens at that destination is yours to build."
|
|
355
386
|
),
|
|
356
|
-
splitRecipients:
|
|
387
|
+
splitRecipients: SplitRecipientsInputSchema.optional()
|
|
357
388
|
});
|
|
358
389
|
var ChargeSchema = import_zod8.z.object({
|
|
359
390
|
id: import_zod8.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
|
|
@@ -826,12 +857,35 @@ var WebhookDeliverySchema = import_zod12.z.object({
|
|
|
826
857
|
var ListWebhookDeliveriesSchema = PaginationQuerySchema;
|
|
827
858
|
var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
|
|
828
859
|
|
|
829
|
-
// src/
|
|
860
|
+
// src/recipients.ts
|
|
830
861
|
var import_zod13 = require("zod");
|
|
831
|
-
var
|
|
862
|
+
var EVM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
|
|
863
|
+
var CreateRecipientSchema = import_zod13.z.object({
|
|
864
|
+
address: import_zod13.z.string().regex(EVM_ADDRESS_REGEX, "must be a 20-byte hex address").describe("EVM address to register as a trusted split recipient for your organization."),
|
|
865
|
+
label: import_zod13.z.string().min(1).max(64).optional().describe('Free-form label for your own bookkeeping (e.g. `"supplier"`) \u2014 never interpreted.')
|
|
866
|
+
});
|
|
867
|
+
var RecipientSchema = import_zod13.z.object({
|
|
868
|
+
id: import_zod13.z.string().describe(
|
|
869
|
+
"Klappay-generated id, e.g. `rc_...` \u2014 this, not the raw address, is what a charge's `splitRecipients[].recipientId` references."
|
|
870
|
+
),
|
|
871
|
+
environment: EnvironmentSchema,
|
|
872
|
+
address: import_zod13.z.string(),
|
|
873
|
+
label: import_zod13.z.string().nullable(),
|
|
874
|
+
payout: import_zod13.z.boolean().describe(
|
|
875
|
+
"Whether this recipient is eligible to be used as an API key's `payoutAddress` (in addition to being referenceable in a split, which every non-revoked recipient already is). Set via `PATCH /v1/recipients/{id}` \u2014 requires the `recipients:manage_payout` scope, deliberately separate from `recipients:write`."
|
|
876
|
+
),
|
|
877
|
+
createdAt: import_zod13.z.string().datetime()
|
|
878
|
+
});
|
|
879
|
+
var SetRecipientPayoutSchema = import_zod13.z.object({
|
|
880
|
+
payout: import_zod13.z.boolean().describe("New payout-eligibility value for this recipient.")
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
// src/timeline.ts
|
|
884
|
+
var import_zod14 = require("zod");
|
|
885
|
+
var TransactionSourceSchema = import_zod14.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
|
|
832
886
|
"How this transfer was detected: `moralis_webhook` (the normal path), `reconciliation_job` (a fallback poller caught it after the webhook was missed or delayed), or `sandbox` (simulated via `POST /v1/sandbox/charges/{id}/trigger`, no real on-chain transfer)."
|
|
833
887
|
);
|
|
834
|
-
var TimelineEventTypeSchema =
|
|
888
|
+
var TimelineEventTypeSchema = import_zod14.z.enum([
|
|
835
889
|
"charge.created",
|
|
836
890
|
"charge.expired",
|
|
837
891
|
"transaction.detected",
|
|
@@ -842,11 +896,11 @@ var TimelineEventTypeSchema = import_zod13.z.enum([
|
|
|
842
896
|
]).describe(
|
|
843
897
|
"`charge.created`: the charge was created. `charge.expired`: `expiresAt` passed with no full payment. `transaction.detected`: a raw on-chain transfer was seen (see the `event`-shaped fields below for details \u2014 a charge can have more than one, e.g. a partial payment followed by the rest). `split.distributed`: a payout to the merchant completed on-chain, for one contributing `(token, network)` pair \u2014 a charge settled across more than one pair emits one of these per pair (see the `token`/`network` fields below). `webhook.dispatched`/`webhook.delivered`/`webhook.failed`: one specific delivery *attempt* for one webhook subscription \u2014 `failed` here means this single attempt failed, not that all retries were exhausted (see `WebhookDeliveryStatusSchema` for the exhausted-all-retries state)."
|
|
844
898
|
);
|
|
845
|
-
var TimelineEventSchema =
|
|
899
|
+
var TimelineEventSchema = import_zod14.z.object({
|
|
846
900
|
type: TimelineEventTypeSchema,
|
|
847
|
-
at:
|
|
848
|
-
txHash:
|
|
849
|
-
amount:
|
|
901
|
+
at: import_zod14.z.string().datetime(),
|
|
902
|
+
txHash: import_zod14.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
|
|
903
|
+
amount: import_zod14.z.number().optional().describe(
|
|
850
904
|
"Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
|
|
851
905
|
),
|
|
852
906
|
source: TransactionSourceSchema.optional().describe(
|
|
@@ -858,49 +912,49 @@ var TimelineEventSchema = import_zod13.z.object({
|
|
|
858
912
|
network: NetworkSchema.optional().describe(
|
|
859
913
|
"Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
|
|
860
914
|
),
|
|
861
|
-
causedTransition:
|
|
915
|
+
causedTransition: import_zod14.z.boolean().optional().describe(
|
|
862
916
|
"Present for `transaction.detected` events only. `true` if this specific transfer changed the charge's status (e.g. PENDING\u2192CONFIRMED) \u2014 a charge paid in installments can have more than one such event."
|
|
863
917
|
),
|
|
864
918
|
event: WebhookEventTypeSchema.optional().describe(
|
|
865
919
|
"Present for `webhook.*` events only \u2014 which event type this delivery was for."
|
|
866
920
|
),
|
|
867
|
-
responseCode:
|
|
921
|
+
responseCode: import_zod14.z.number().nullable().optional().describe(
|
|
868
922
|
"Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
|
|
869
923
|
),
|
|
870
|
-
attempts:
|
|
924
|
+
attempts: import_zod14.z.number().optional().describe(
|
|
871
925
|
"Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
|
|
872
926
|
)
|
|
873
927
|
});
|
|
874
928
|
|
|
875
929
|
// src/health.ts
|
|
876
|
-
var
|
|
877
|
-
var HealthSchema =
|
|
878
|
-
status:
|
|
930
|
+
var import_zod15 = require("zod");
|
|
931
|
+
var HealthSchema = import_zod15.z.object({
|
|
932
|
+
status: import_zod15.z.enum(["ok", "error"]).describe(
|
|
879
933
|
"`error` when the database connectivity check fails \u2014 the HTTP status code mirrors this (503 instead of 200), so a plain uptime check (not just a JSON-aware one) still catches a DB outage."
|
|
880
934
|
),
|
|
881
|
-
version:
|
|
882
|
-
timestamp:
|
|
883
|
-
db:
|
|
884
|
-
pendingWebhooks:
|
|
885
|
-
oldestPendingChargeAgeSeconds:
|
|
886
|
-
lastMoralisEventAgeSeconds:
|
|
935
|
+
version: import_zod15.z.string(),
|
|
936
|
+
timestamp: import_zod15.z.string().datetime(),
|
|
937
|
+
db: import_zod15.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
|
|
938
|
+
pendingWebhooks: import_zod15.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
|
|
939
|
+
oldestPendingChargeAgeSeconds: import_zod15.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
|
|
940
|
+
lastMoralisEventAgeSeconds: import_zod15.z.number().nullable().describe(
|
|
887
941
|
"Seconds since the last on-chain payment notification was received \u2014 a cheap signal for whether payment detection is currently working. `null` if none have ever been received."
|
|
888
942
|
)
|
|
889
943
|
});
|
|
890
944
|
|
|
891
945
|
// src/sandbox.ts
|
|
892
|
-
var
|
|
893
|
-
var SandboxTriggerSchema =
|
|
946
|
+
var import_zod16 = require("zod");
|
|
947
|
+
var SandboxTriggerSchema = import_zod16.z.object({
|
|
894
948
|
event: TriggerableChargeEventSchema,
|
|
895
|
-
amount:
|
|
949
|
+
amount: import_zod16.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
|
|
896
950
|
"Used with `charge.partially_paid` (amount to simulate as received so far \u2014 must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received \u2014 must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event."
|
|
897
951
|
)
|
|
898
952
|
});
|
|
899
953
|
|
|
900
954
|
// src/capabilities.ts
|
|
901
|
-
var
|
|
902
|
-
var CapabilitiesSchema =
|
|
903
|
-
acceptedPayments:
|
|
955
|
+
var import_zod17 = require("zod");
|
|
956
|
+
var CapabilitiesSchema = import_zod17.z.object({
|
|
957
|
+
acceptedPayments: import_zod17.z.array(AcceptedPaymentSchema).describe(
|
|
904
958
|
"Every `(token, network)` pair actually configured for your environment right now \u2014 read straight from the same lookup `POST /v1/charges` validates `acceptedPayments` against, so it can never list a pair that charge creation would then reject. Use this to build a picker UI instead of hardcoding the matrix client-side."
|
|
905
959
|
)
|
|
906
960
|
});
|
|
@@ -915,6 +969,7 @@ var CapabilitiesSchema = import_zod16.z.object({
|
|
|
915
969
|
CHARGE_EXPIRES_IN_MIN_SECONDS,
|
|
916
970
|
CHARGE_SPLIT_RECIPIENTS_MAX,
|
|
917
971
|
CHECKOUT_PRODUCTS_MAX,
|
|
972
|
+
CONFLICTING_SCOPE_PAIRS,
|
|
918
973
|
CapabilitiesSchema,
|
|
919
974
|
ChargeSchema,
|
|
920
975
|
ChargeStatusSchema,
|
|
@@ -924,6 +979,7 @@ var CapabilitiesSchema = import_zod16.z.object({
|
|
|
924
979
|
ChargesQueryFieldSchema,
|
|
925
980
|
CheckoutProductSchema,
|
|
926
981
|
CreateChargeSchema,
|
|
982
|
+
CreateRecipientSchema,
|
|
927
983
|
CreateWebhookSchema,
|
|
928
984
|
DistributionsDateFieldSchema,
|
|
929
985
|
DistributionsMetricFieldSchema,
|
|
@@ -966,9 +1022,12 @@ var CapabilitiesSchema = import_zod16.z.object({
|
|
|
966
1022
|
PendingDistributionEventSchema,
|
|
967
1023
|
PendingDistributionRecipientSchema,
|
|
968
1024
|
PendingDistributionSchema,
|
|
1025
|
+
RecipientSchema,
|
|
969
1026
|
SandboxTriggerSchema,
|
|
1027
|
+
SetRecipientPayoutSchema,
|
|
970
1028
|
SettlementStatusSchema,
|
|
971
1029
|
SplitDistributionStatusSchema,
|
|
1030
|
+
SplitRecipientInputSchema,
|
|
972
1031
|
SplitRecipientSchema,
|
|
973
1032
|
TOKEN_ADDRESSES,
|
|
974
1033
|
TOKEN_DECIMALS,
|
|
@@ -990,6 +1049,7 @@ var CapabilitiesSchema = import_zod16.z.object({
|
|
|
990
1049
|
WebhookListItemSchema,
|
|
991
1050
|
WebhookPayloadSchema,
|
|
992
1051
|
WebhookSchema,
|
|
1052
|
+
findConflictingScopes,
|
|
993
1053
|
paginatedSchema
|
|
994
1054
|
});
|
|
995
1055
|
//# sourceMappingURL=index.js.map
|