@siglume/direct-request-payment 0.4.19 → 0.4.22

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +18 -10
  3. package/bin/siglume-sdrp.mjs +550 -8
  4. package/dist/index.cjs +37 -3
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +27 -2
  7. package/dist/index.d.ts +27 -2
  8. package/dist/index.js +37 -3
  9. package/dist/index.js.map +1 -1
  10. package/docs/announcement-ja.md +17 -3
  11. package/docs/api-reference.md +60 -13
  12. package/docs/merchant-quickstart.md +6 -20
  13. package/docs/metered-statements.md +15 -13
  14. package/docs/payment-lifecycle.md +12 -9
  15. package/docs/pricing.md +7 -4
  16. package/docs/quickstart-10-minutes.md +134 -24
  17. package/docs/sandbox.md +60 -0
  18. package/docs/troubleshooting.md +23 -8
  19. package/examples/express-checkout.ts +37 -13
  20. package/examples/hosted-checkout-python/app.py +46 -31
  21. package/examples/hosted-checkout-python/order_store.py +13 -3
  22. package/examples/hosted-checkout-python/pyproject.toml +1 -1
  23. package/examples/hosted-checkout-typescript/src/order-store.ts +14 -3
  24. package/examples/hosted-checkout-typescript/src/server.ts +49 -37
  25. package/package.json +10 -2
  26. package/templates/express/README.md +40 -6
  27. package/templates/express/siglume-order-store.example.ts +22 -6
  28. package/templates/express/siglume-order-store.sql.ts +585 -0
  29. package/templates/express/siglume-sdrp-routes.ts +138 -64
  30. package/templates/fastapi/README.md +22 -3
  31. package/templates/fastapi/siglume_order_store_example.py +29 -6
  32. package/templates/fastapi/siglume_order_store_sqlalchemy.py +313 -0
  33. package/templates/fastapi/siglume_sdrp_routes.py +112 -49
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare const DEFAULT_SIGLUME_API_BASE = "https://siglume.com/v1";
2
+ declare const DEFAULT_SIGLUME_SANDBOX_API_BASE = "http://127.0.0.1:8787/v1";
2
3
  declare const DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME = "siglume-external-402-v1";
3
4
  declare const DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME = "siglume-external-402-recurring-v1";
4
5
  declare const DIRECT_REQUEST_PAYMENT_MODE = "external_402";
@@ -6,7 +7,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
6
7
  declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
7
8
  declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
8
9
  declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
9
- declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.19";
10
+ declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.22";
10
11
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
11
12
  declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
12
13
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -433,6 +434,27 @@ interface DirectRequestPaymentWebhookSubscription {
433
434
  event_types?: string[];
434
435
  [key: string]: unknown;
435
436
  }
437
+ interface DirectRequestPaymentWebhookTestDeliveryInput {
438
+ event_type: string;
439
+ data?: Record<string, unknown>;
440
+ subscription_ids?: string[];
441
+ }
442
+ interface DirectRequestPaymentWebhookDelivery {
443
+ id?: string;
444
+ subscription_id?: string;
445
+ event_id?: string;
446
+ event_type?: string;
447
+ delivery_status?: string;
448
+ response_status?: number | null;
449
+ delivered_at?: string | null;
450
+ [key: string]: unknown;
451
+ }
452
+ interface DirectRequestPaymentWebhookDeliveryListInput {
453
+ subscription_id?: string;
454
+ event_type?: string;
455
+ status?: string;
456
+ limit?: number;
457
+ }
436
458
  interface DirectRequestPaymentCheckoutSetupInput extends DirectRequestPaymentMerchantSetupInput {
437
459
  create_webhook_subscription?: boolean;
438
460
  prepare_billing_mandate?: boolean;
@@ -612,6 +634,9 @@ declare class DirectRequestPaymentMerchantClient {
612
634
  rotateChallengeSecret(merchant: string): Promise<DirectRequestPaymentMerchantResponse>;
613
635
  prepareBillingMandate(merchant: string, input?: DirectRequestPaymentMerchantBillingMandateInput): Promise<DirectRequestPaymentMerchantResponse>;
614
636
  createWebhookSubscription(input: DirectRequestPaymentWebhookSubscriptionInput): Promise<DirectRequestPaymentWebhookSubscription>;
637
+ listWebhookSubscriptions(): Promise<DirectRequestPaymentWebhookSubscription[]>;
638
+ queueWebhookTestDelivery(input: DirectRequestPaymentWebhookTestDeliveryInput): Promise<Record<string, unknown>>;
639
+ listWebhookDeliveries(input?: DirectRequestPaymentWebhookDeliveryListInput): Promise<DirectRequestPaymentWebhookDelivery[]>;
615
640
  setupCheckout(input: DirectRequestPaymentCheckoutSetupInput): Promise<DirectRequestPaymentCheckoutSetupResult>;
616
641
  request<T>(method: string, path: string, json_body?: unknown): Promise<T>;
617
642
  private requestHostedCheckout;
@@ -700,4 +725,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
700
725
  declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
701
726
  declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
702
727
 
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 };
728
+ export { DEFAULT_SIGLUME_API_BASE, DEFAULT_SIGLUME_SANDBOX_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 DirectRequestPaymentWebhookDelivery, type DirectRequestPaymentWebhookDeliveryListInput, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, type DirectRequestPaymentWebhookTestDeliveryInput, 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
@@ -1,4 +1,5 @@
1
1
  declare const DEFAULT_SIGLUME_API_BASE = "https://siglume.com/v1";
2
+ declare const DEFAULT_SIGLUME_SANDBOX_API_BASE = "http://127.0.0.1:8787/v1";
2
3
  declare const DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME = "siglume-external-402-v1";
3
4
  declare const DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME = "siglume-external-402-recurring-v1";
4
5
  declare const DIRECT_REQUEST_PAYMENT_MODE = "external_402";
@@ -6,7 +7,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
6
7
  declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
7
8
  declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
8
9
  declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
9
- declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.19";
10
+ declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.22";
10
11
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
11
12
  declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
12
13
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -433,6 +434,27 @@ interface DirectRequestPaymentWebhookSubscription {
433
434
  event_types?: string[];
434
435
  [key: string]: unknown;
435
436
  }
437
+ interface DirectRequestPaymentWebhookTestDeliveryInput {
438
+ event_type: string;
439
+ data?: Record<string, unknown>;
440
+ subscription_ids?: string[];
441
+ }
442
+ interface DirectRequestPaymentWebhookDelivery {
443
+ id?: string;
444
+ subscription_id?: string;
445
+ event_id?: string;
446
+ event_type?: string;
447
+ delivery_status?: string;
448
+ response_status?: number | null;
449
+ delivered_at?: string | null;
450
+ [key: string]: unknown;
451
+ }
452
+ interface DirectRequestPaymentWebhookDeliveryListInput {
453
+ subscription_id?: string;
454
+ event_type?: string;
455
+ status?: string;
456
+ limit?: number;
457
+ }
436
458
  interface DirectRequestPaymentCheckoutSetupInput extends DirectRequestPaymentMerchantSetupInput {
437
459
  create_webhook_subscription?: boolean;
438
460
  prepare_billing_mandate?: boolean;
@@ -612,6 +634,9 @@ declare class DirectRequestPaymentMerchantClient {
612
634
  rotateChallengeSecret(merchant: string): Promise<DirectRequestPaymentMerchantResponse>;
613
635
  prepareBillingMandate(merchant: string, input?: DirectRequestPaymentMerchantBillingMandateInput): Promise<DirectRequestPaymentMerchantResponse>;
614
636
  createWebhookSubscription(input: DirectRequestPaymentWebhookSubscriptionInput): Promise<DirectRequestPaymentWebhookSubscription>;
637
+ listWebhookSubscriptions(): Promise<DirectRequestPaymentWebhookSubscription[]>;
638
+ queueWebhookTestDelivery(input: DirectRequestPaymentWebhookTestDeliveryInput): Promise<Record<string, unknown>>;
639
+ listWebhookDeliveries(input?: DirectRequestPaymentWebhookDeliveryListInput): Promise<DirectRequestPaymentWebhookDelivery[]>;
615
640
  setupCheckout(input: DirectRequestPaymentCheckoutSetupInput): Promise<DirectRequestPaymentCheckoutSetupResult>;
616
641
  request<T>(method: string, path: string, json_body?: unknown): Promise<T>;
617
642
  private requestHostedCheckout;
@@ -700,4 +725,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
700
725
  declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
701
726
  declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
702
727
 
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 };
728
+ export { DEFAULT_SIGLUME_API_BASE, DEFAULT_SIGLUME_SANDBOX_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 DirectRequestPaymentWebhookDelivery, type DirectRequestPaymentWebhookDeliveryListInput, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, type DirectRequestPaymentWebhookTestDeliveryInput, 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
@@ -1,5 +1,6 @@
1
1
  // src/index.ts
2
2
  var DEFAULT_SIGLUME_API_BASE = "https://siglume.com/v1";
3
+ var DEFAULT_SIGLUME_SANDBOX_API_BASE = "http://127.0.0.1:8787/v1";
3
4
  var DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME = "siglume-external-402-v1";
4
5
  var DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME = "siglume-external-402-recurring-v1";
5
6
  var DIRECT_REQUEST_PAYMENT_MODE = "external_402";
@@ -7,7 +8,7 @@ var DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
7
8
  var DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
8
9
  var DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
9
10
  var DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
10
- var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.19";
11
+ var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.22";
11
12
  var DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
12
13
  var DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
13
14
  var DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -67,7 +68,7 @@ var DirectRequestPaymentClient = class {
67
68
  throw new SiglumeDirectRequestPaymentError("A fetch implementation is required in this runtime.");
68
69
  }
69
70
  this.#authToken = authToken;
70
- this.base_url = normalizeApiBaseUrl(options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE);
71
+ this.base_url = normalizeApiBaseUrl(options.base_url ?? defaultApiBaseUrl());
71
72
  this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
72
73
  this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
73
74
  this.fetch_impl = fetchImpl;
@@ -219,7 +220,7 @@ var DirectRequestPaymentMerchantClient = class {
219
220
  throw new SiglumeDirectRequestPaymentError("A fetch implementation is required in this runtime.");
220
221
  }
221
222
  this.#authToken = authToken;
222
- this.base_url = normalizeApiBaseUrl(options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE);
223
+ this.base_url = normalizeApiBaseUrl(options.base_url ?? defaultApiBaseUrl());
223
224
  this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
224
225
  this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
225
226
  this.fetch_impl = fetchImpl;
@@ -328,6 +329,30 @@ var DirectRequestPaymentMerchantClient = class {
328
329
  }
329
330
  return this.request("POST", "/market/webhooks/subscriptions", payload);
330
331
  }
332
+ async listWebhookSubscriptions() {
333
+ return this.request("GET", "/market/webhooks/subscriptions");
334
+ }
335
+ async queueWebhookTestDelivery(input) {
336
+ const payload = {
337
+ event_type: requireNonEmpty(input.event_type, "event_type")
338
+ };
339
+ if (input.data !== void 0) {
340
+ payload.data = cloneJsonObject(input.data, "data");
341
+ }
342
+ if (input.subscription_ids !== void 0) {
343
+ payload.subscription_ids = input.subscription_ids.map((subscriptionId) => requireNonEmpty(subscriptionId, "subscription_id"));
344
+ }
345
+ return this.request("POST", "/market/webhooks/test-deliveries", payload);
346
+ }
347
+ async listWebhookDeliveries(input = {}) {
348
+ const params = new URLSearchParams();
349
+ if (input.subscription_id !== void 0) params.set("subscription_id", requireNonEmpty(input.subscription_id, "subscription_id"));
350
+ if (input.event_type !== void 0) params.set("event_type", requireNonEmpty(input.event_type, "event_type"));
351
+ if (input.status !== void 0) params.set("status", requireNonEmpty(input.status, "status"));
352
+ if (input.limit !== void 0) params.set("limit", String(positiveInteger(input.limit, "limit")));
353
+ const query = params.toString();
354
+ return this.request("GET", `/market/webhooks/deliveries${query ? `?${query}` : ""}`);
355
+ }
331
356
  async setupCheckout(input) {
332
357
  const merchant = await this.setupMerchant(input);
333
358
  const merchantKey = merchant.merchant_account.merchant;
@@ -996,6 +1021,14 @@ function envValue(name) {
996
1021
  const value = process.env[name];
997
1022
  return value && value.trim() ? value.trim() : void 0;
998
1023
  }
1024
+ function defaultApiBaseUrl() {
1025
+ const explicit = envValue("SIGLUME_API_BASE");
1026
+ if (explicit) return explicit;
1027
+ if ((envValue("SIGLUME_ENV") || "").toLowerCase() === "sandbox") {
1028
+ return envValue("SIGLUME_SANDBOX_API_BASE") || DEFAULT_SIGLUME_SANDBOX_API_BASE;
1029
+ }
1030
+ return DEFAULT_SIGLUME_API_BASE;
1031
+ }
999
1032
  function bodyBytes(body) {
1000
1033
  if (body instanceof Uint8Array) {
1001
1034
  return body;
@@ -1121,6 +1154,7 @@ async function timingSafeEqualHex(left, right) {
1121
1154
  }
1122
1155
  export {
1123
1156
  DEFAULT_SIGLUME_API_BASE,
1157
+ DEFAULT_SIGLUME_SANDBOX_API_BASE,
1124
1158
  DEFAULT_WEBHOOK_TOLERANCE_SECONDS,
1125
1159
  DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND,
1126
1160
  DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME,