@siglume/direct-request-payment 0.4.16 → 0.4.17
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 +16 -0
- package/README.md +10 -9
- package/dist/index.cjs +59 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -11
- package/dist/index.d.ts +67 -11
- package/dist/index.js +59 -17
- package/dist/index.js.map +1 -1
- package/docs/merchant-quickstart.md +7 -4
- package/docs/metered-statements.md +2 -2
- package/docs/pricing.md +25 -23
- package/examples/express-checkout.ts +3 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
|
|
|
6
6
|
declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
|
|
7
7
|
declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
|
|
8
8
|
declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
9
|
-
declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.
|
|
9
|
+
declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.17";
|
|
10
10
|
declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
|
|
11
11
|
declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
|
|
12
12
|
declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
|
|
@@ -14,6 +14,7 @@ declare const DIRECT_REQUEST_PAYMENT_METERED_FINALITY = "aggregated_onchain_sett
|
|
|
14
14
|
type DirectRequestPaymentCurrency = "JPY" | "USD";
|
|
15
15
|
type DirectRequestPaymentToken = "JPYC" | "USDC";
|
|
16
16
|
type DirectRequestPaymentMeteredPlanType = "micro" | "nano";
|
|
17
|
+
type DirectRequestPaymentSettlementTrigger = "amount_threshold" | "scheduled_close";
|
|
17
18
|
type DirectRequestPaymentMinorAmount = string;
|
|
18
19
|
type DirectRequestPaymentRawWebhookBody = Uint8Array | ArrayBuffer | string;
|
|
19
20
|
type DirectRequestPaymentWebhookSignatureBody = DirectRequestPaymentRawWebhookBody | Record<string, unknown>;
|
|
@@ -95,7 +96,7 @@ interface DirectRequestPaymentSettlementBatch {
|
|
|
95
96
|
plan_type: string;
|
|
96
97
|
settlement_cadence: string;
|
|
97
98
|
status: string;
|
|
98
|
-
settlement_trigger?:
|
|
99
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | null;
|
|
99
100
|
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
100
101
|
threshold_reached_at?: string | null;
|
|
101
102
|
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
@@ -135,21 +136,68 @@ interface DirectRequestPaymentSettlementBatch {
|
|
|
135
136
|
support_reference?: string | null;
|
|
136
137
|
[key: string]: unknown;
|
|
137
138
|
}
|
|
139
|
+
interface DirectRequestPaymentMeteredOpenPeriod {
|
|
140
|
+
plan_type?: DirectRequestPaymentMeteredPlanType | string;
|
|
141
|
+
settlement_cadence?: "weekly" | "monthly" | string;
|
|
142
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
143
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
144
|
+
period_start?: string | null;
|
|
145
|
+
period_end?: string | null;
|
|
146
|
+
close_at?: string | null;
|
|
147
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | null;
|
|
148
|
+
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
149
|
+
threshold_reached_at?: string | null;
|
|
150
|
+
provider_gross_amount_minor?: DirectRequestPaymentMinorAmount;
|
|
151
|
+
provider_usage_amount_minor?: DirectRequestPaymentMinorAmount;
|
|
152
|
+
protocol_fee_minor?: DirectRequestPaymentMinorAmount;
|
|
153
|
+
provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
154
|
+
buyer_debit_minor?: DirectRequestPaymentMinorAmount;
|
|
155
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
156
|
+
[key: string]: unknown;
|
|
157
|
+
}
|
|
158
|
+
interface DirectRequestPaymentPastDueBlock {
|
|
159
|
+
settlement_batch_id?: string;
|
|
160
|
+
plan_type?: DirectRequestPaymentMeteredPlanType | string;
|
|
161
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
162
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
163
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
164
|
+
past_due_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
165
|
+
failure_reason_code?: string | null;
|
|
166
|
+
support_reference?: string | null;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
interface DirectRequestPaymentBalanceSufficiency {
|
|
170
|
+
sufficient?: boolean;
|
|
171
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
172
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
173
|
+
required_minor?: DirectRequestPaymentMinorAmount;
|
|
174
|
+
available_minor?: DirectRequestPaymentMinorAmount;
|
|
175
|
+
[key: string]: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface DirectRequestPaymentProviderMeteredTotals {
|
|
178
|
+
settled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
179
|
+
unsettled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
180
|
+
past_due_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
181
|
+
terminal_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
182
|
+
uncollectible_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
183
|
+
written_off_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
184
|
+
[key: string]: DirectRequestPaymentMinorAmount | undefined;
|
|
185
|
+
}
|
|
138
186
|
interface DirectRequestPaymentBuyerMeteredSummary {
|
|
139
187
|
role: "buyer";
|
|
140
|
-
open_periods:
|
|
188
|
+
open_periods: DirectRequestPaymentMeteredOpenPeriod[];
|
|
141
189
|
settlement_batches: DirectRequestPaymentSettlementBatch[];
|
|
142
|
-
past_due_blocks:
|
|
143
|
-
balance_sufficiency?:
|
|
190
|
+
past_due_blocks: DirectRequestPaymentPastDueBlock[];
|
|
191
|
+
balance_sufficiency?: DirectRequestPaymentBalanceSufficiency;
|
|
144
192
|
[key: string]: unknown;
|
|
145
193
|
}
|
|
146
194
|
interface DirectRequestPaymentProviderMeteredSummary {
|
|
147
195
|
role: "provider";
|
|
148
196
|
timezone?: string | null;
|
|
149
197
|
filters?: Record<string, unknown>;
|
|
150
|
-
open_periods:
|
|
198
|
+
open_periods: DirectRequestPaymentMeteredOpenPeriod[];
|
|
151
199
|
periods: DirectRequestPaymentSettlementBatch[];
|
|
152
|
-
totals:
|
|
200
|
+
totals: DirectRequestPaymentProviderMeteredTotals;
|
|
153
201
|
[key: string]: unknown;
|
|
154
202
|
}
|
|
155
203
|
interface DirectRequestPaymentChallengeInput {
|
|
@@ -426,6 +474,14 @@ interface DirectRequestPaymentWebhookEvent {
|
|
|
426
474
|
settlement_cadence?: "per_payment" | "weekly" | "monthly" | string | null;
|
|
427
475
|
finality?: string | null;
|
|
428
476
|
protocol_fee_minor?: DirectRequestPaymentMinorAmount | null;
|
|
477
|
+
provider_gross_amount_minor?: DirectRequestPaymentMinorAmount | null;
|
|
478
|
+
provider_usage_amount_minor?: DirectRequestPaymentMinorAmount | null;
|
|
479
|
+
provider_receivable_minor?: DirectRequestPaymentMinorAmount | null;
|
|
480
|
+
buyer_debit_minor?: DirectRequestPaymentMinorAmount | null;
|
|
481
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | string | null;
|
|
482
|
+
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
483
|
+
threshold_reached_at?: string | null;
|
|
484
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
429
485
|
settlement_status?: string | null;
|
|
430
486
|
settlement_batch_id?: string | null;
|
|
431
487
|
chain_receipt_id?: string | null;
|
|
@@ -436,7 +492,7 @@ interface DirectRequestPaymentWebhookEvent {
|
|
|
436
492
|
[key: string]: unknown;
|
|
437
493
|
}
|
|
438
494
|
type DirectPaymentConfirmationKind = "standard_settled" | "metered_usage_accepted" | "metered_batch_settled" | "unknown";
|
|
439
|
-
type DirectPaymentConfirmationUnknownReason = "not_direct_payment_confirmed" | "invalid_metered_settlement_confirmation" | "missing_standard_settlement_fields" | "missing_metered_usage_fields" | "unknown_confirmation_shape";
|
|
495
|
+
type DirectPaymentConfirmationUnknownReason = "not_direct_payment_confirmed" | "unsupported_confirmation_mode" | "invalid_metered_settlement_confirmation" | "missing_standard_settlement_fields" | "missing_metered_usage_fields" | "unknown_confirmation_shape";
|
|
440
496
|
interface DirectPaymentStandardSettledClassification {
|
|
441
497
|
kind: "standard_settled";
|
|
442
498
|
event: DirectRequestPaymentWebhookEvent;
|
|
@@ -503,7 +559,7 @@ declare class SiglumeWebhookPayloadError extends SiglumeDirectRequestPaymentErro
|
|
|
503
559
|
constructor(message: string);
|
|
504
560
|
}
|
|
505
561
|
declare class DirectRequestPaymentClient {
|
|
506
|
-
|
|
562
|
+
#private;
|
|
507
563
|
readonly base_url: string;
|
|
508
564
|
readonly timeout_ms: number;
|
|
509
565
|
readonly user_agent: string;
|
|
@@ -531,7 +587,7 @@ declare class DirectRequestPaymentClient {
|
|
|
531
587
|
request<T>(method: string, path: string, json_body?: unknown): Promise<T>;
|
|
532
588
|
}
|
|
533
589
|
declare class DirectRequestPaymentMerchantClient {
|
|
534
|
-
|
|
590
|
+
#private;
|
|
535
591
|
readonly base_url: string;
|
|
536
592
|
readonly timeout_ms: number;
|
|
537
593
|
readonly user_agent: string;
|
|
@@ -644,4 +700,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
|
|
|
644
700
|
declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
|
|
645
701
|
declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
|
|
646
702
|
|
|
647
|
-
export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
|
|
703
|
+
export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBalanceSufficiency, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredOpenPeriod, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentPastDueBlock, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderMeteredTotals, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentSettlementTrigger, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
|
|
|
6
6
|
declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
|
|
7
7
|
declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
|
|
8
8
|
declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
9
|
-
declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.
|
|
9
|
+
declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.17";
|
|
10
10
|
declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
|
|
11
11
|
declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
|
|
12
12
|
declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
|
|
@@ -14,6 +14,7 @@ declare const DIRECT_REQUEST_PAYMENT_METERED_FINALITY = "aggregated_onchain_sett
|
|
|
14
14
|
type DirectRequestPaymentCurrency = "JPY" | "USD";
|
|
15
15
|
type DirectRequestPaymentToken = "JPYC" | "USDC";
|
|
16
16
|
type DirectRequestPaymentMeteredPlanType = "micro" | "nano";
|
|
17
|
+
type DirectRequestPaymentSettlementTrigger = "amount_threshold" | "scheduled_close";
|
|
17
18
|
type DirectRequestPaymentMinorAmount = string;
|
|
18
19
|
type DirectRequestPaymentRawWebhookBody = Uint8Array | ArrayBuffer | string;
|
|
19
20
|
type DirectRequestPaymentWebhookSignatureBody = DirectRequestPaymentRawWebhookBody | Record<string, unknown>;
|
|
@@ -95,7 +96,7 @@ interface DirectRequestPaymentSettlementBatch {
|
|
|
95
96
|
plan_type: string;
|
|
96
97
|
settlement_cadence: string;
|
|
97
98
|
status: string;
|
|
98
|
-
settlement_trigger?:
|
|
99
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | null;
|
|
99
100
|
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
100
101
|
threshold_reached_at?: string | null;
|
|
101
102
|
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
@@ -135,21 +136,68 @@ interface DirectRequestPaymentSettlementBatch {
|
|
|
135
136
|
support_reference?: string | null;
|
|
136
137
|
[key: string]: unknown;
|
|
137
138
|
}
|
|
139
|
+
interface DirectRequestPaymentMeteredOpenPeriod {
|
|
140
|
+
plan_type?: DirectRequestPaymentMeteredPlanType | string;
|
|
141
|
+
settlement_cadence?: "weekly" | "monthly" | string;
|
|
142
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
143
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
144
|
+
period_start?: string | null;
|
|
145
|
+
period_end?: string | null;
|
|
146
|
+
close_at?: string | null;
|
|
147
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | null;
|
|
148
|
+
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
149
|
+
threshold_reached_at?: string | null;
|
|
150
|
+
provider_gross_amount_minor?: DirectRequestPaymentMinorAmount;
|
|
151
|
+
provider_usage_amount_minor?: DirectRequestPaymentMinorAmount;
|
|
152
|
+
protocol_fee_minor?: DirectRequestPaymentMinorAmount;
|
|
153
|
+
provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
154
|
+
buyer_debit_minor?: DirectRequestPaymentMinorAmount;
|
|
155
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
156
|
+
[key: string]: unknown;
|
|
157
|
+
}
|
|
158
|
+
interface DirectRequestPaymentPastDueBlock {
|
|
159
|
+
settlement_batch_id?: string;
|
|
160
|
+
plan_type?: DirectRequestPaymentMeteredPlanType | string;
|
|
161
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
162
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
163
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
164
|
+
past_due_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
165
|
+
failure_reason_code?: string | null;
|
|
166
|
+
support_reference?: string | null;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
interface DirectRequestPaymentBalanceSufficiency {
|
|
170
|
+
sufficient?: boolean;
|
|
171
|
+
currency?: DirectRequestPaymentCurrency | string;
|
|
172
|
+
token_symbol?: DirectRequestPaymentToken | string;
|
|
173
|
+
required_minor?: DirectRequestPaymentMinorAmount;
|
|
174
|
+
available_minor?: DirectRequestPaymentMinorAmount;
|
|
175
|
+
[key: string]: unknown;
|
|
176
|
+
}
|
|
177
|
+
interface DirectRequestPaymentProviderMeteredTotals {
|
|
178
|
+
settled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
179
|
+
unsettled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
180
|
+
past_due_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
181
|
+
terminal_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
182
|
+
uncollectible_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
183
|
+
written_off_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
|
|
184
|
+
[key: string]: DirectRequestPaymentMinorAmount | undefined;
|
|
185
|
+
}
|
|
138
186
|
interface DirectRequestPaymentBuyerMeteredSummary {
|
|
139
187
|
role: "buyer";
|
|
140
|
-
open_periods:
|
|
188
|
+
open_periods: DirectRequestPaymentMeteredOpenPeriod[];
|
|
141
189
|
settlement_batches: DirectRequestPaymentSettlementBatch[];
|
|
142
|
-
past_due_blocks:
|
|
143
|
-
balance_sufficiency?:
|
|
190
|
+
past_due_blocks: DirectRequestPaymentPastDueBlock[];
|
|
191
|
+
balance_sufficiency?: DirectRequestPaymentBalanceSufficiency;
|
|
144
192
|
[key: string]: unknown;
|
|
145
193
|
}
|
|
146
194
|
interface DirectRequestPaymentProviderMeteredSummary {
|
|
147
195
|
role: "provider";
|
|
148
196
|
timezone?: string | null;
|
|
149
197
|
filters?: Record<string, unknown>;
|
|
150
|
-
open_periods:
|
|
198
|
+
open_periods: DirectRequestPaymentMeteredOpenPeriod[];
|
|
151
199
|
periods: DirectRequestPaymentSettlementBatch[];
|
|
152
|
-
totals:
|
|
200
|
+
totals: DirectRequestPaymentProviderMeteredTotals;
|
|
153
201
|
[key: string]: unknown;
|
|
154
202
|
}
|
|
155
203
|
interface DirectRequestPaymentChallengeInput {
|
|
@@ -426,6 +474,14 @@ interface DirectRequestPaymentWebhookEvent {
|
|
|
426
474
|
settlement_cadence?: "per_payment" | "weekly" | "monthly" | string | null;
|
|
427
475
|
finality?: string | null;
|
|
428
476
|
protocol_fee_minor?: DirectRequestPaymentMinorAmount | null;
|
|
477
|
+
provider_gross_amount_minor?: DirectRequestPaymentMinorAmount | null;
|
|
478
|
+
provider_usage_amount_minor?: DirectRequestPaymentMinorAmount | null;
|
|
479
|
+
provider_receivable_minor?: DirectRequestPaymentMinorAmount | null;
|
|
480
|
+
buyer_debit_minor?: DirectRequestPaymentMinorAmount | null;
|
|
481
|
+
settlement_trigger?: DirectRequestPaymentSettlementTrigger | string | null;
|
|
482
|
+
settlement_threshold_minor?: DirectRequestPaymentMinorAmount | null;
|
|
483
|
+
threshold_reached_at?: string | null;
|
|
484
|
+
total_unsettled_exposure_minor?: DirectRequestPaymentMinorAmount | null;
|
|
429
485
|
settlement_status?: string | null;
|
|
430
486
|
settlement_batch_id?: string | null;
|
|
431
487
|
chain_receipt_id?: string | null;
|
|
@@ -436,7 +492,7 @@ interface DirectRequestPaymentWebhookEvent {
|
|
|
436
492
|
[key: string]: unknown;
|
|
437
493
|
}
|
|
438
494
|
type DirectPaymentConfirmationKind = "standard_settled" | "metered_usage_accepted" | "metered_batch_settled" | "unknown";
|
|
439
|
-
type DirectPaymentConfirmationUnknownReason = "not_direct_payment_confirmed" | "invalid_metered_settlement_confirmation" | "missing_standard_settlement_fields" | "missing_metered_usage_fields" | "unknown_confirmation_shape";
|
|
495
|
+
type DirectPaymentConfirmationUnknownReason = "not_direct_payment_confirmed" | "unsupported_confirmation_mode" | "invalid_metered_settlement_confirmation" | "missing_standard_settlement_fields" | "missing_metered_usage_fields" | "unknown_confirmation_shape";
|
|
440
496
|
interface DirectPaymentStandardSettledClassification {
|
|
441
497
|
kind: "standard_settled";
|
|
442
498
|
event: DirectRequestPaymentWebhookEvent;
|
|
@@ -503,7 +559,7 @@ declare class SiglumeWebhookPayloadError extends SiglumeDirectRequestPaymentErro
|
|
|
503
559
|
constructor(message: string);
|
|
504
560
|
}
|
|
505
561
|
declare class DirectRequestPaymentClient {
|
|
506
|
-
|
|
562
|
+
#private;
|
|
507
563
|
readonly base_url: string;
|
|
508
564
|
readonly timeout_ms: number;
|
|
509
565
|
readonly user_agent: string;
|
|
@@ -531,7 +587,7 @@ declare class DirectRequestPaymentClient {
|
|
|
531
587
|
request<T>(method: string, path: string, json_body?: unknown): Promise<T>;
|
|
532
588
|
}
|
|
533
589
|
declare class DirectRequestPaymentMerchantClient {
|
|
534
|
-
|
|
590
|
+
#private;
|
|
535
591
|
readonly base_url: string;
|
|
536
592
|
readonly timeout_ms: number;
|
|
537
593
|
readonly user_agent: string;
|
|
@@ -644,4 +700,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
|
|
|
644
700
|
declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
|
|
645
701
|
declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
|
|
646
702
|
|
|
647
|
-
export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
|
|
703
|
+
export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBalanceSufficiency, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredOpenPeriod, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentPastDueBlock, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderMeteredTotals, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentSettlementTrigger, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
|
|
|
7
7
|
var DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
|
|
8
8
|
var DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
|
|
9
9
|
var DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
10
|
-
var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.
|
|
10
|
+
var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.17";
|
|
11
11
|
var DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
|
|
12
12
|
var DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
|
|
13
13
|
var DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
|
|
@@ -50,7 +50,7 @@ var SiglumeWebhookPayloadError = class extends SiglumeDirectRequestPaymentError
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
var DirectRequestPaymentClient = class {
|
|
53
|
-
|
|
53
|
+
#authToken;
|
|
54
54
|
base_url;
|
|
55
55
|
timeout_ms;
|
|
56
56
|
user_agent;
|
|
@@ -66,8 +66,8 @@ var DirectRequestPaymentClient = class {
|
|
|
66
66
|
if (!fetchImpl) {
|
|
67
67
|
throw new SiglumeDirectRequestPaymentError("A fetch implementation is required in this runtime.");
|
|
68
68
|
}
|
|
69
|
-
this
|
|
70
|
-
this.base_url = (options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE)
|
|
69
|
+
this.#authToken = authToken;
|
|
70
|
+
this.base_url = normalizeApiBaseUrl(options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE);
|
|
71
71
|
this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
|
|
72
72
|
this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
|
|
73
73
|
this.fetch_impl = fetchImpl;
|
|
@@ -170,7 +170,7 @@ var DirectRequestPaymentClient = class {
|
|
|
170
170
|
try {
|
|
171
171
|
const headers = {
|
|
172
172
|
"Accept": "application/json",
|
|
173
|
-
"Authorization": `Bearer ${this
|
|
173
|
+
"Authorization": `Bearer ${this.#authToken}`,
|
|
174
174
|
"User-Agent": this.user_agent
|
|
175
175
|
};
|
|
176
176
|
let body;
|
|
@@ -202,7 +202,7 @@ var DirectRequestPaymentClient = class {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
var DirectRequestPaymentMerchantClient = class {
|
|
205
|
-
|
|
205
|
+
#authToken;
|
|
206
206
|
base_url;
|
|
207
207
|
timeout_ms;
|
|
208
208
|
user_agent;
|
|
@@ -218,8 +218,8 @@ var DirectRequestPaymentMerchantClient = class {
|
|
|
218
218
|
if (!fetchImpl) {
|
|
219
219
|
throw new SiglumeDirectRequestPaymentError("A fetch implementation is required in this runtime.");
|
|
220
220
|
}
|
|
221
|
-
this
|
|
222
|
-
this.base_url = (options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE)
|
|
221
|
+
this.#authToken = authToken;
|
|
222
|
+
this.base_url = normalizeApiBaseUrl(options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE);
|
|
223
223
|
this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
|
|
224
224
|
this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
|
|
225
225
|
this.fetch_impl = fetchImpl;
|
|
@@ -237,7 +237,7 @@ var DirectRequestPaymentMerchantClient = class {
|
|
|
237
237
|
payload.allowed_currencies = normalizeAllowedCurrencies(input.allowed_currencies);
|
|
238
238
|
}
|
|
239
239
|
if (input.webhook_callback_url !== void 0) {
|
|
240
|
-
payload.webhook_callback_url =
|
|
240
|
+
payload.webhook_callback_url = normalizeHttpsUrl(input.webhook_callback_url, "webhook_callback_url");
|
|
241
241
|
}
|
|
242
242
|
if (input.billing_mandate_cap_minor !== void 0) {
|
|
243
243
|
payload.billing_mandate_cap_minor = positiveInteger(input.billing_mandate_cap_minor, "billing_mandate_cap_minor");
|
|
@@ -317,7 +317,7 @@ var DirectRequestPaymentMerchantClient = class {
|
|
|
317
317
|
}
|
|
318
318
|
async createWebhookSubscription(input) {
|
|
319
319
|
const payload = {
|
|
320
|
-
callback_url:
|
|
320
|
+
callback_url: normalizeHttpsUrl(input.callback_url, "callback_url"),
|
|
321
321
|
event_types: input.event_types?.length ? input.event_types.map((eventType) => requireNonEmpty(eventType, "event_type")) : ["direct_payment.confirmed", "direct_payment.spent"]
|
|
322
322
|
};
|
|
323
323
|
if (input.description !== void 0) {
|
|
@@ -360,7 +360,7 @@ var DirectRequestPaymentMerchantClient = class {
|
|
|
360
360
|
try {
|
|
361
361
|
const headers = {
|
|
362
362
|
"Accept": "application/json",
|
|
363
|
-
"Authorization": `Bearer ${this
|
|
363
|
+
"Authorization": `Bearer ${this.#authToken}`,
|
|
364
364
|
"User-Agent": this.user_agent
|
|
365
365
|
};
|
|
366
366
|
let body;
|
|
@@ -598,11 +598,6 @@ function parseDirectRequestPaymentWebhookEvent(payload) {
|
|
|
598
598
|
occurred_at: requireNonEmpty(stringOrNull(event.occurred_at) ?? "", "webhook occurred_at"),
|
|
599
599
|
data: { ...data }
|
|
600
600
|
};
|
|
601
|
-
if (parsed.type === "direct_payment.confirmed" && !DIRECT_REQUEST_PAYMENT_CONFIRMED_WEBHOOK_MODES.has(String(parsed.data.mode ?? ""))) {
|
|
602
|
-
throw new SiglumeWebhookPayloadError(
|
|
603
|
-
"direct_payment.confirmed webhook must carry a supported Direct Request Payment mode."
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
601
|
return parsed;
|
|
607
602
|
}
|
|
608
603
|
function classifyDirectPaymentConfirmation(event) {
|
|
@@ -613,6 +608,7 @@ function classifyDirectPaymentConfirmation(event) {
|
|
|
613
608
|
const settlementCadence = stringOrNull(data.settlement_cadence);
|
|
614
609
|
const finality = stringOrNull(data.finality);
|
|
615
610
|
const settlementStatus = stringOrNull(data.settlement_status);
|
|
611
|
+
const mode = stringOrNull(data.mode);
|
|
616
612
|
if (event.type !== "direct_payment.confirmed") {
|
|
617
613
|
return {
|
|
618
614
|
kind: "unknown",
|
|
@@ -627,7 +623,21 @@ function classifyDirectPaymentConfirmation(event) {
|
|
|
627
623
|
finality
|
|
628
624
|
};
|
|
629
625
|
}
|
|
630
|
-
if (
|
|
626
|
+
if (!DIRECT_REQUEST_PAYMENT_CONFIRMED_WEBHOOK_MODES.has(mode ?? "")) {
|
|
627
|
+
return {
|
|
628
|
+
kind: "unknown",
|
|
629
|
+
event,
|
|
630
|
+
data,
|
|
631
|
+
reason: "unsupported_confirmation_mode",
|
|
632
|
+
requirement_id: requirementId,
|
|
633
|
+
settlement_batch_id: stringOrNull(data.settlement_batch_id),
|
|
634
|
+
pricing_band: pricingBand,
|
|
635
|
+
settlement_cadence: settlementCadence,
|
|
636
|
+
settlement_status: settlementStatus,
|
|
637
|
+
finality
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
if (mode === "metered_settlement_batch") {
|
|
631
641
|
const settlementBatchId = stringOrNull(data.settlement_batch_id);
|
|
632
642
|
const chainReceiptId = stringOrNull(data.chain_receipt_id);
|
|
633
643
|
const usageEventDigest = stringOrNull(data.usage_event_digest);
|
|
@@ -799,6 +809,38 @@ function normalizeAllowedCurrencies(value) {
|
|
|
799
809
|
function defaultTokenForCurrency(currency) {
|
|
800
810
|
return currency === "JPY" ? "JPYC" : "USDC";
|
|
801
811
|
}
|
|
812
|
+
function normalizeApiBaseUrl(value) {
|
|
813
|
+
let url;
|
|
814
|
+
try {
|
|
815
|
+
url = new URL(requireNonEmpty(value, "base_url"));
|
|
816
|
+
} catch {
|
|
817
|
+
throw new SiglumeDirectRequestPaymentError("base_url must be an absolute URL such as https://siglume.com/v1.");
|
|
818
|
+
}
|
|
819
|
+
if (url.username || url.password) {
|
|
820
|
+
throw new SiglumeDirectRequestPaymentError("base_url must not include userinfo.");
|
|
821
|
+
}
|
|
822
|
+
if (!isAllowedCheckoutOriginScheme(url)) {
|
|
823
|
+
throw new SiglumeDirectRequestPaymentError(
|
|
824
|
+
"base_url must use https, except http is allowed for localhost, 127.0.0.1, or [::1]."
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
return url.toString().replace(/\/+$/, "");
|
|
828
|
+
}
|
|
829
|
+
function normalizeHttpsUrl(value, name) {
|
|
830
|
+
let url;
|
|
831
|
+
try {
|
|
832
|
+
url = new URL(requireNonEmpty(value, name));
|
|
833
|
+
} catch {
|
|
834
|
+
throw new SiglumeDirectRequestPaymentError(`${name} must be an absolute https URL.`);
|
|
835
|
+
}
|
|
836
|
+
if (url.username || url.password) {
|
|
837
|
+
throw new SiglumeDirectRequestPaymentError(`${name} must not include userinfo.`);
|
|
838
|
+
}
|
|
839
|
+
if (url.protocol !== "https:" || !url.hostname) {
|
|
840
|
+
throw new SiglumeDirectRequestPaymentError(`${name} must use https.`);
|
|
841
|
+
}
|
|
842
|
+
return url.toString();
|
|
843
|
+
}
|
|
802
844
|
function normalizeOriginList(value) {
|
|
803
845
|
if (!Array.isArray(value)) {
|
|
804
846
|
throw new SiglumeDirectRequestPaymentError("checkout_allowed_origins must be an array of origin URLs.");
|