@veridid/payments 0.0.0-stage → 1.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/LICENSE +202 -0
- package/README.md +39 -2
- package/build/PaymentsModule.d.mts +20 -0
- package/build/PaymentsModule.d.mts.map +1 -0
- package/build/PaymentsModule.mjs +146 -0
- package/build/PaymentsModule.mjs.map +1 -0
- package/build/PaymentsModuleConfig.d.mts +173 -0
- package/build/PaymentsModuleConfig.d.mts.map +1 -0
- package/build/PaymentsModuleConfig.mjs +35 -0
- package/build/PaymentsModuleConfig.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +9 -0
- package/build/api/PaymentsApi.d.mts +413 -0
- package/build/api/PaymentsApi.d.mts.map +1 -0
- package/build/api/PaymentsApi.mjs +652 -0
- package/build/api/PaymentsApi.mjs.map +1 -0
- package/build/events/PaymentEvents.d.mts +59 -0
- package/build/events/PaymentEvents.d.mts.map +1 -0
- package/build/events/PaymentEvents.mjs +14 -0
- package/build/events/PaymentEvents.mjs.map +1 -0
- package/build/handlers/CancelHandler.mjs +55 -0
- package/build/handlers/CancelHandler.mjs.map +1 -0
- package/build/handlers/ComplianceHandlers.mjs +35 -0
- package/build/handlers/ComplianceHandlers.mjs.map +1 -0
- package/build/handlers/ComplianceResponseHandler.mjs +203 -0
- package/build/handlers/ComplianceResponseHandler.mjs.map +1 -0
- package/build/handlers/HandshakeAcceptHandler.mjs +149 -0
- package/build/handlers/HandshakeAcceptHandler.mjs.map +1 -0
- package/build/handlers/HandshakeRequestHandler.mjs +370 -0
- package/build/handlers/HandshakeRequestHandler.mjs.map +1 -0
- package/build/handlers/MethodsHandler.mjs +87 -0
- package/build/handlers/MethodsHandler.mjs.map +1 -0
- package/build/handlers/ProblemReportHandler.mjs +41 -0
- package/build/handlers/ProblemReportHandler.mjs.map +1 -0
- package/build/handlers/QueryMethodsHandler.mjs +83 -0
- package/build/handlers/QueryMethodsHandler.mjs.map +1 -0
- package/build/handlers/QuoteHandlers.mjs +139 -0
- package/build/handlers/QuoteHandlers.mjs.map +1 -0
- package/build/handlers/ReceiptConfirmHandlers.mjs +473 -0
- package/build/handlers/ReceiptConfirmHandlers.mjs.map +1 -0
- package/build/handlers/RecurringHandler.mjs +527 -0
- package/build/handlers/RecurringHandler.mjs.map +1 -0
- package/build/handlers/RefundHandlers.mjs +117 -0
- package/build/handlers/RefundHandlers.mjs.map +1 -0
- package/build/index.d.mts +57 -0
- package/build/index.mjs +56 -0
- package/build/ledger/EvmLedgerAdapter.d.mts +89 -0
- package/build/ledger/EvmLedgerAdapter.d.mts.map +1 -0
- package/build/ledger/EvmLedgerAdapter.mjs +535 -0
- package/build/ledger/EvmLedgerAdapter.mjs.map +1 -0
- package/build/ledger/EvmLedgerConfig.d.mts +50 -0
- package/build/ledger/EvmLedgerConfig.d.mts.map +1 -0
- package/build/ledger/EvmLedgerConfig.mjs +14 -0
- package/build/ledger/EvmLedgerConfig.mjs.map +1 -0
- package/build/ledger/LedgerRouter.d.mts +12 -0
- package/build/ledger/LedgerRouter.d.mts.map +1 -0
- package/build/ledger/LedgerRouter.mjs +23 -0
- package/build/ledger/LedgerRouter.mjs.map +1 -0
- package/build/ledger/index.d.mts +6 -0
- package/build/ledger/index.mjs +5 -0
- package/build/ledger/pkcs11/Pkcs11HsmDispatcher.mjs +412 -0
- package/build/ledger/pkcs11/Pkcs11HsmDispatcher.mjs.map +1 -0
- package/build/ledger/secure-mobile/SecureMobileDispatcher.d.mts +42 -0
- package/build/ledger/secure-mobile/SecureMobileDispatcher.d.mts.map +1 -0
- package/build/ledger/secure-mobile/SecureMobileDispatcher.mjs +67 -0
- package/build/ledger/secure-mobile/SecureMobileDispatcher.mjs.map +1 -0
- package/build/ledger/secure-mobile/SecureMobileSigner.d.mts +137 -0
- package/build/ledger/secure-mobile/SecureMobileSigner.d.mts.map +1 -0
- package/build/ledger/secure-mobile/index.mjs +1 -0
- package/build/ledger/tokens/StablecoinRegistry.d.mts +67 -0
- package/build/ledger/tokens/StablecoinRegistry.d.mts.map +1 -0
- package/build/ledger/tokens/StablecoinRegistry.mjs +133 -0
- package/build/ledger/tokens/StablecoinRegistry.mjs.map +1 -0
- package/build/ledger/types.d.mts +106 -0
- package/build/ledger/types.d.mts.map +1 -0
- package/build/protocols/v1/ProblemCodes.d.mts +35 -0
- package/build/protocols/v1/ProblemCodes.d.mts.map +1 -0
- package/build/protocols/v1/ProblemCodes.mjs +35 -0
- package/build/protocols/v1/ProblemCodes.mjs.map +1 -0
- package/build/protocols/v1/index.d.mts +59 -0
- package/build/protocols/v1/index.d.mts.map +1 -0
- package/build/protocols/v1/index.mjs +60 -0
- package/build/protocols/v1/index.mjs.map +1 -0
- package/build/protocols/v1/messages/CancelMessage.d.mts +25 -0
- package/build/protocols/v1/messages/CancelMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/CancelMessage.mjs +25 -0
- package/build/protocols/v1/messages/CancelMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ChargeNoticeMessage.d.mts +33 -0
- package/build/protocols/v1/messages/ChargeNoticeMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ChargeNoticeMessage.mjs +25 -0
- package/build/protocols/v1/messages/ChargeNoticeMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ChargeRequestMessage.d.mts +30 -0
- package/build/protocols/v1/messages/ChargeRequestMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ChargeRequestMessage.mjs +25 -0
- package/build/protocols/v1/messages/ChargeRequestMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ComplianceRequestMessage.d.mts +29 -0
- package/build/protocols/v1/messages/ComplianceRequestMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ComplianceRequestMessage.mjs +25 -0
- package/build/protocols/v1/messages/ComplianceRequestMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ComplianceResponseMessage.d.mts +31 -0
- package/build/protocols/v1/messages/ComplianceResponseMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ComplianceResponseMessage.mjs +25 -0
- package/build/protocols/v1/messages/ComplianceResponseMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ConfirmMessage.d.mts +30 -0
- package/build/protocols/v1/messages/ConfirmMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ConfirmMessage.mjs +25 -0
- package/build/protocols/v1/messages/ConfirmMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/HandshakeAcceptMessage.d.mts +30 -0
- package/build/protocols/v1/messages/HandshakeAcceptMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/HandshakeAcceptMessage.mjs +25 -0
- package/build/protocols/v1/messages/HandshakeAcceptMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/HandshakeRequestMessage.d.mts +115 -0
- package/build/protocols/v1/messages/HandshakeRequestMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/HandshakeRequestMessage.mjs +26 -0
- package/build/protocols/v1/messages/HandshakeRequestMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateAcceptMessage.d.mts +32 -0
- package/build/protocols/v1/messages/MandateAcceptMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateAcceptMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateAcceptMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateActivateMessage.d.mts +26 -0
- package/build/protocols/v1/messages/MandateActivateMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateActivateMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateActivateMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateCancelMessage.d.mts +26 -0
- package/build/protocols/v1/messages/MandateCancelMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateCancelMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateCancelMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateOfferMessage.d.mts +64 -0
- package/build/protocols/v1/messages/MandateOfferMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateOfferMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateOfferMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateRefUpdateMessage.d.mts +27 -0
- package/build/protocols/v1/messages/MandateRefUpdateMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateRefUpdateMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateRefUpdateMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MandateUpdateMessage.d.mts +25 -0
- package/build/protocols/v1/messages/MandateUpdateMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MandateUpdateMessage.mjs +25 -0
- package/build/protocols/v1/messages/MandateUpdateMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MethodRevokeMessage.d.mts +25 -0
- package/build/protocols/v1/messages/MethodRevokeMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MethodRevokeMessage.mjs +25 -0
- package/build/protocols/v1/messages/MethodRevokeMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MethodUpdateMessage.d.mts +28 -0
- package/build/protocols/v1/messages/MethodUpdateMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MethodUpdateMessage.mjs +25 -0
- package/build/protocols/v1/messages/MethodUpdateMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/MethodsMessage.d.mts +31 -0
- package/build/protocols/v1/messages/MethodsMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/MethodsMessage.mjs +25 -0
- package/build/protocols/v1/messages/MethodsMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ProblemReportMessage.d.mts +26 -0
- package/build/protocols/v1/messages/ProblemReportMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ProblemReportMessage.mjs +25 -0
- package/build/protocols/v1/messages/ProblemReportMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/QueryMethodsMessage.d.mts +30 -0
- package/build/protocols/v1/messages/QueryMethodsMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/QueryMethodsMessage.mjs +27 -0
- package/build/protocols/v1/messages/QueryMethodsMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/QuoteRequestMessage.d.mts +43 -0
- package/build/protocols/v1/messages/QuoteRequestMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/QuoteRequestMessage.mjs +25 -0
- package/build/protocols/v1/messages/QuoteRequestMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/QuoteResponseMessage.d.mts +55 -0
- package/build/protocols/v1/messages/QuoteResponseMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/QuoteResponseMessage.mjs +25 -0
- package/build/protocols/v1/messages/QuoteResponseMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/ReceiptMessage.d.mts +39 -0
- package/build/protocols/v1/messages/ReceiptMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/ReceiptMessage.mjs +25 -0
- package/build/protocols/v1/messages/ReceiptMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/RefundReceiptMessage.d.mts +48 -0
- package/build/protocols/v1/messages/RefundReceiptMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/RefundReceiptMessage.mjs +25 -0
- package/build/protocols/v1/messages/RefundReceiptMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/RefundRequestMessage.d.mts +47 -0
- package/build/protocols/v1/messages/RefundRequestMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/RefundRequestMessage.mjs +25 -0
- package/build/protocols/v1/messages/RefundRequestMessage.mjs.map +1 -0
- package/build/protocols/v1/messages/SubscriptionStatusMessage.d.mts +29 -0
- package/build/protocols/v1/messages/SubscriptionStatusMessage.d.mts.map +1 -0
- package/build/protocols/v1/messages/SubscriptionStatusMessage.mjs +25 -0
- package/build/protocols/v1/messages/SubscriptionStatusMessage.mjs.map +1 -0
- package/build/repository/BillingCycleRecord.d.mts +43 -0
- package/build/repository/BillingCycleRecord.d.mts.map +1 -0
- package/build/repository/BillingCycleRecord.mjs +35 -0
- package/build/repository/BillingCycleRecord.mjs.map +1 -0
- package/build/repository/BillingCycleRepository.d.mts +14 -0
- package/build/repository/BillingCycleRepository.d.mts.map +1 -0
- package/build/repository/BillingCycleRepository.mjs +41 -0
- package/build/repository/BillingCycleRepository.mjs.map +1 -0
- package/build/repository/MandateRecord.d.mts +53 -0
- package/build/repository/MandateRecord.d.mts.map +1 -0
- package/build/repository/MandateRecord.mjs +50 -0
- package/build/repository/MandateRecord.mjs.map +1 -0
- package/build/repository/MandateRepository.d.mts +13 -0
- package/build/repository/MandateRepository.d.mts.map +1 -0
- package/build/repository/MandateRepository.mjs +32 -0
- package/build/repository/MandateRepository.mjs.map +1 -0
- package/build/repository/PaymentMethodRecord.d.mts +46 -0
- package/build/repository/PaymentMethodRecord.d.mts.map +1 -0
- package/build/repository/PaymentMethodRecord.mjs +45 -0
- package/build/repository/PaymentMethodRecord.mjs.map +1 -0
- package/build/repository/PaymentMethodRepository.d.mts +14 -0
- package/build/repository/PaymentMethodRepository.d.mts.map +1 -0
- package/build/repository/PaymentMethodRepository.mjs +40 -0
- package/build/repository/PaymentMethodRepository.mjs.map +1 -0
- package/build/repository/PaymentRecord.d.mts +21 -0
- package/build/repository/PaymentRecord.d.mts.map +1 -0
- package/build/repository/PaymentRecord.mjs +12 -0
- package/build/repository/PaymentRecord.mjs.map +1 -0
- package/build/repository/PaymentSessionRecord.d.mts +56 -0
- package/build/repository/PaymentSessionRecord.d.mts.map +1 -0
- package/build/repository/PaymentSessionRecord.mjs +46 -0
- package/build/repository/PaymentSessionRecord.mjs.map +1 -0
- package/build/repository/PaymentsRepository.d.mts +14 -0
- package/build/repository/PaymentsRepository.d.mts.map +1 -0
- package/build/repository/PaymentsRepository.mjs +37 -0
- package/build/repository/PaymentsRepository.mjs.map +1 -0
- package/build/repository/QuoteRecord.d.mts +50 -0
- package/build/repository/QuoteRecord.d.mts.map +1 -0
- package/build/repository/QuoteRecord.mjs +48 -0
- package/build/repository/QuoteRecord.mjs.map +1 -0
- package/build/repository/QuoteRepository.d.mts +16 -0
- package/build/repository/QuoteRepository.d.mts.map +1 -0
- package/build/repository/QuoteRepository.mjs +51 -0
- package/build/repository/QuoteRepository.mjs.map +1 -0
- package/build/repository/RefundRecord.d.mts +54 -0
- package/build/repository/RefundRecord.d.mts.map +1 -0
- package/build/repository/RefundRecord.mjs +53 -0
- package/build/repository/RefundRecord.mjs.map +1 -0
- package/build/repository/RefundRepository.d.mts +16 -0
- package/build/repository/RefundRepository.d.mts.map +1 -0
- package/build/repository/RefundRepository.mjs +45 -0
- package/build/repository/RefundRepository.mjs.map +1 -0
- package/build/repository/SigningKeyRecord.d.mts +27 -0
- package/build/repository/SigningKeyRecord.d.mts.map +1 -0
- package/build/repository/SigningKeyRecord.mjs +28 -0
- package/build/repository/SigningKeyRecord.mjs.map +1 -0
- package/build/repository/SigningKeyRepository.d.mts +12 -0
- package/build/repository/SigningKeyRepository.d.mts.map +1 -0
- package/build/repository/SigningKeyRepository.mjs +42 -0
- package/build/repository/SigningKeyRepository.mjs.map +1 -0
- package/build/repository/index.d.mts +15 -0
- package/build/repository/index.mjs +17 -0
- package/build/services/ComplianceService.mjs +48 -0
- package/build/services/ComplianceService.mjs.map +1 -0
- package/build/services/DunningService.mjs +49 -0
- package/build/services/DunningService.mjs.map +1 -0
- package/build/services/IntegrityService.d.mts +8 -0
- package/build/services/IntegrityService.d.mts.map +1 -0
- package/build/services/IntegrityService.mjs +24 -0
- package/build/services/IntegrityService.mjs.map +1 -0
- package/build/services/PaymentsService.d.mts +110 -0
- package/build/services/PaymentsService.d.mts.map +1 -0
- package/build/services/PaymentsService.mjs +75 -0
- package/build/services/PaymentsService.mjs.map +1 -0
- package/build/services/RedactionService.mjs +24 -0
- package/build/services/RedactionService.mjs.map +1 -0
- package/build/services/RefundService.d.mts +88 -0
- package/build/services/RefundService.d.mts.map +1 -0
- package/build/services/RefundService.mjs +150 -0
- package/build/services/RefundService.mjs.map +1 -0
- package/build/services/SettlementService.mjs +169 -0
- package/build/services/SettlementService.mjs.map +1 -0
- package/build/services/SigningService.d.mts +32 -0
- package/build/services/SigningService.d.mts.map +1 -0
- package/build/services/SigningService.mjs +149 -0
- package/build/services/SigningService.mjs.map +1 -0
- package/build/services/TaxService.mjs +65 -0
- package/build/services/TaxService.mjs.map +1 -0
- package/build/utils/caip.mjs +47 -0
- package/build/utils/caip.mjs.map +1 -0
- package/build/utils/duration.mjs +27 -0
- package/build/utils/duration.mjs.map +1 -0
- package/build/utils/period.mjs +12 -0
- package/build/utils/period.mjs.map +1 -0
- package/build/workflow/PaymentsV1Actions.d.mts +84 -0
- package/build/workflow/PaymentsV1Actions.d.mts.map +1 -0
- package/build/workflow/PaymentsV1Actions.mjs +168 -0
- package/build/workflow/PaymentsV1Actions.mjs.map +1 -0
- package/package.json +43 -3
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import { PaymentsModuleConfig } from "../PaymentsModuleConfig.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
|
+
import { LedgerRouter } from "../ledger/LedgerRouter.mjs";
|
|
4
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
5
|
+
import { QueryMethodsMessage } from "../protocols/v1/messages/QueryMethodsMessage.mjs";
|
|
6
|
+
import { ComplianceResponseMessage } from "../protocols/v1/messages/ComplianceResponseMessage.mjs";
|
|
7
|
+
import { HandshakeRequestMessage } from "../protocols/v1/messages/HandshakeRequestMessage.mjs";
|
|
8
|
+
import { HandshakeAcceptMessage } from "../protocols/v1/messages/HandshakeAcceptMessage.mjs";
|
|
9
|
+
import { ReceiptMessage } from "../protocols/v1/messages/ReceiptMessage.mjs";
|
|
10
|
+
import { ConfirmMessage } from "../protocols/v1/messages/ConfirmMessage.mjs";
|
|
11
|
+
import { CancelMessage } from "../protocols/v1/messages/CancelMessage.mjs";
|
|
12
|
+
import { MethodUpdateMessage } from "../protocols/v1/messages/MethodUpdateMessage.mjs";
|
|
13
|
+
import { MethodRevokeMessage } from "../protocols/v1/messages/MethodRevokeMessage.mjs";
|
|
14
|
+
import { MandateOfferMessage } from "../protocols/v1/messages/MandateOfferMessage.mjs";
|
|
15
|
+
import { MandateAcceptMessage } from "../protocols/v1/messages/MandateAcceptMessage.mjs";
|
|
16
|
+
import { MandateActivateMessage } from "../protocols/v1/messages/MandateActivateMessage.mjs";
|
|
17
|
+
import { MandateUpdateMessage } from "../protocols/v1/messages/MandateUpdateMessage.mjs";
|
|
18
|
+
import { MandateCancelMessage } from "../protocols/v1/messages/MandateCancelMessage.mjs";
|
|
19
|
+
import { SubscriptionStatusMessage } from "../protocols/v1/messages/SubscriptionStatusMessage.mjs";
|
|
20
|
+
import { ChargeNoticeMessage } from "../protocols/v1/messages/ChargeNoticeMessage.mjs";
|
|
21
|
+
import { ChargeRequestMessage } from "../protocols/v1/messages/ChargeRequestMessage.mjs";
|
|
22
|
+
import { MandateRefUpdateMessage } from "../protocols/v1/messages/MandateRefUpdateMessage.mjs";
|
|
23
|
+
import { QuoteRequestMessage } from "../protocols/v1/messages/QuoteRequestMessage.mjs";
|
|
24
|
+
import { RefundRequestMessage } from "../protocols/v1/messages/RefundRequestMessage.mjs";
|
|
25
|
+
import "../protocols/v1/index.mjs";
|
|
26
|
+
import { PaymentSessionRecord } from "../repository/PaymentSessionRecord.mjs";
|
|
27
|
+
import { PaymentsRepository } from "../repository/PaymentsRepository.mjs";
|
|
28
|
+
import "../repository/index.mjs";
|
|
29
|
+
import { IntegrityService } from "../services/IntegrityService.mjs";
|
|
30
|
+
import { PaymentsService } from "../services/PaymentsService.mjs";
|
|
31
|
+
import { RefundService } from "../services/RefundService.mjs";
|
|
32
|
+
import { SigningService } from "../services/SigningService.mjs";
|
|
33
|
+
import { AgentContext, injectable } from "@credo-ts/core";
|
|
34
|
+
import { DidCommConnectionsApi, DidCommMessageSender, DidCommOutboundMessageContext, ReturnRouteTypes } from "@credo-ts/didcomm";
|
|
35
|
+
|
|
36
|
+
//#region src/api/PaymentsApi.ts
|
|
37
|
+
var _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10;
|
|
38
|
+
let PaymentsApi = class PaymentsApi {
|
|
39
|
+
constructor(paymentsRepository, ledgerRouter, paymentsService, messageSender, connectionsApi, signing, integrity, config, refundService, agentContext) {
|
|
40
|
+
this.paymentsRepository = paymentsRepository;
|
|
41
|
+
this.ledgerRouter = ledgerRouter;
|
|
42
|
+
this.paymentsService = paymentsService;
|
|
43
|
+
this.messageSender = messageSender;
|
|
44
|
+
this.connectionsApi = connectionsApi;
|
|
45
|
+
this.signing = signing;
|
|
46
|
+
this.integrity = integrity;
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.refundService = refundService;
|
|
49
|
+
this.agentContext = agentContext;
|
|
50
|
+
}
|
|
51
|
+
async sendNativePayment(params) {
|
|
52
|
+
const adapter = this.ledgerRouter.getAdapterForMethod("method:evm");
|
|
53
|
+
if (!adapter || typeof adapter.sendNative !== "function") throw new Error("No EVM ledger adapter with sendNative available");
|
|
54
|
+
return adapter.sendNative(params);
|
|
55
|
+
}
|
|
56
|
+
async sendErc20Payment(params) {
|
|
57
|
+
const adapter = this.ledgerRouter.getAdapterForMethod("method:evm");
|
|
58
|
+
if (!adapter || typeof adapter.sendErc20 !== "function") throw new Error("No EVM ledger adapter with sendErc20 available");
|
|
59
|
+
return adapter.sendErc20(params);
|
|
60
|
+
}
|
|
61
|
+
async prepareNativePayment(params) {
|
|
62
|
+
const adapter = this.ledgerRouter.getAdapterForMethod("method:evm");
|
|
63
|
+
if (!adapter || typeof adapter.prepareNative !== "function") throw new Error("No prepareNative on EVM adapter");
|
|
64
|
+
return adapter.prepareNative(params);
|
|
65
|
+
}
|
|
66
|
+
async prepareErc20Payment(params) {
|
|
67
|
+
const adapter = this.ledgerRouter.getAdapterForMethod("method:evm");
|
|
68
|
+
if (!adapter || typeof adapter.prepareErc20 !== "function") throw new Error("No prepareErc20 on EVM adapter");
|
|
69
|
+
return adapter.prepareErc20(params);
|
|
70
|
+
}
|
|
71
|
+
async broadcastSignedTx(chainId, rawTxHex) {
|
|
72
|
+
const adapter = this.ledgerRouter.getAdapterForMethod("method:evm");
|
|
73
|
+
if (!adapter || typeof adapter.broadcastSignedTx !== "function") throw new Error("No broadcastSignedTx on EVM adapter");
|
|
74
|
+
return adapter.broadcastSignedTx(chainId, rawTxHex);
|
|
75
|
+
}
|
|
76
|
+
createQueryMethods(options) {
|
|
77
|
+
return this.paymentsService.createQueryMethods(options);
|
|
78
|
+
}
|
|
79
|
+
createMethodsResponse(thid, body) {
|
|
80
|
+
return this.paymentsService.createMethodsResponse(thid, body);
|
|
81
|
+
}
|
|
82
|
+
createHandshakeRequest(payload) {
|
|
83
|
+
return this.paymentsService.createHandshakeRequest(payload);
|
|
84
|
+
}
|
|
85
|
+
acceptHandshake(thid, selection) {
|
|
86
|
+
return this.paymentsService.acceptHandshake(thid, selection);
|
|
87
|
+
}
|
|
88
|
+
async sendQueryMethods(connectionId, options, agentContext) {
|
|
89
|
+
const ctx = agentContext ?? this.agentContext;
|
|
90
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
91
|
+
const message = new QueryMethodsMessage({ body: {
|
|
92
|
+
want: options.want,
|
|
93
|
+
meta: options.meta
|
|
94
|
+
} });
|
|
95
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
96
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
97
|
+
agentContext: ctx,
|
|
98
|
+
connection
|
|
99
|
+
});
|
|
100
|
+
await this.messageSender.sendMessage(outbound);
|
|
101
|
+
return { id: message.id };
|
|
102
|
+
}
|
|
103
|
+
async sendHandshakeRequest(connectionId, payload, agentContext) {
|
|
104
|
+
const ctx = agentContext ?? this.agentContext;
|
|
105
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
106
|
+
const created = this.paymentsService.createHandshakeRequest(payload);
|
|
107
|
+
const termsHash = this.integrity.computeTermsHash(created.body.terms);
|
|
108
|
+
created.body.integrity = created.body.integrity || { terms_sha256: termsHash };
|
|
109
|
+
if (created.body.integrity.terms_sha256 !== termsHash) created.body.integrity.terms_sha256 = termsHash;
|
|
110
|
+
const jws = await this.signing.createJws({
|
|
111
|
+
agentContext: ctx,
|
|
112
|
+
payload: created.body,
|
|
113
|
+
purpose: "handshake-request",
|
|
114
|
+
threadId: created.thid,
|
|
115
|
+
connectionId
|
|
116
|
+
});
|
|
117
|
+
const signedBody = {
|
|
118
|
+
...created.body,
|
|
119
|
+
jws: jws.jws
|
|
120
|
+
};
|
|
121
|
+
const message = new HandshakeRequestMessage({
|
|
122
|
+
id: created.id,
|
|
123
|
+
thid: created.thid,
|
|
124
|
+
body: signedBody
|
|
125
|
+
});
|
|
126
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
127
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
128
|
+
agentContext: ctx,
|
|
129
|
+
connection
|
|
130
|
+
});
|
|
131
|
+
await this.messageSender.sendMessage(outbound);
|
|
132
|
+
const rec = await this.paymentsRepository.getSessionByThread(ctx, created.thid) ?? new PaymentSessionRecord({
|
|
133
|
+
threadId: created.thid,
|
|
134
|
+
state: "requested",
|
|
135
|
+
connectionId
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
rec.metadata.set("request", created.body);
|
|
139
|
+
rec.requestId = created.body?.terms?.request_id;
|
|
140
|
+
rec.termsSha256 = created.body?.integrity?.terms_sha256;
|
|
141
|
+
rec.confirmationsRequired = created.body?.terms?.network?.confirmations_required;
|
|
142
|
+
rec.expiresAt = created.body?.session?.ttl ? new Date(created.body.session.ttl) : rec.expiresAt;
|
|
143
|
+
rec.nonce = created.body?.session?.nonce ?? rec.nonce;
|
|
144
|
+
} catch (_e) {}
|
|
145
|
+
await this.paymentsRepository.saveSession(ctx, rec);
|
|
146
|
+
return {
|
|
147
|
+
id: message.id,
|
|
148
|
+
thid: created.thid
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async sendHandshakeAccept(connectionId, thid, selection, agentContext) {
|
|
152
|
+
const ctx = agentContext ?? this.agentContext;
|
|
153
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
154
|
+
const created = this.paymentsService.acceptHandshake(thid, selection);
|
|
155
|
+
const message = new HandshakeAcceptMessage({
|
|
156
|
+
id: created.id,
|
|
157
|
+
thid,
|
|
158
|
+
body: created.body
|
|
159
|
+
});
|
|
160
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
161
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
162
|
+
agentContext: ctx,
|
|
163
|
+
connection
|
|
164
|
+
});
|
|
165
|
+
await this.messageSender.sendMessage(outbound);
|
|
166
|
+
const session = await this.paymentsRepository.getSessionByThread(ctx, thid);
|
|
167
|
+
if (session) {
|
|
168
|
+
session.state = "accepted";
|
|
169
|
+
try {
|
|
170
|
+
session.metadata.set("accept", created.body);
|
|
171
|
+
} catch (_e) {}
|
|
172
|
+
await this.paymentsRepository.update(ctx, session);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
id: message.id,
|
|
176
|
+
thid
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async sendComplianceResponse(connectionId, thid, body, agentContext) {
|
|
180
|
+
const ctx = agentContext ?? this.agentContext;
|
|
181
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
182
|
+
const message = new ComplianceResponseMessage({
|
|
183
|
+
thid,
|
|
184
|
+
body
|
|
185
|
+
});
|
|
186
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
187
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
188
|
+
agentContext: ctx,
|
|
189
|
+
connection
|
|
190
|
+
});
|
|
191
|
+
await this.messageSender.sendMessage(outbound);
|
|
192
|
+
const session = await this.paymentsRepository.getSessionByThread(ctx, thid);
|
|
193
|
+
if (session) {
|
|
194
|
+
try {
|
|
195
|
+
session.metadata.set("compliance", {
|
|
196
|
+
...session.metadata.get("compliance") || {},
|
|
197
|
+
sent: body
|
|
198
|
+
});
|
|
199
|
+
} catch (_e) {}
|
|
200
|
+
await this.paymentsRepository.update(ctx, session);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
id: message.id,
|
|
204
|
+
thid
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async sendReceipt(connectionId, thid, body, agentContext) {
|
|
208
|
+
const ctx = agentContext ?? this.agentContext;
|
|
209
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
210
|
+
const jws = await this.signing.createJws({
|
|
211
|
+
agentContext: ctx,
|
|
212
|
+
payload: body,
|
|
213
|
+
purpose: "receipt",
|
|
214
|
+
threadId: thid,
|
|
215
|
+
connectionId
|
|
216
|
+
});
|
|
217
|
+
const message = new ReceiptMessage({
|
|
218
|
+
thid,
|
|
219
|
+
body: {
|
|
220
|
+
...body,
|
|
221
|
+
jws: jws.jws
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
225
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
226
|
+
agentContext: ctx,
|
|
227
|
+
connection
|
|
228
|
+
});
|
|
229
|
+
await this.messageSender.sendMessage(outbound);
|
|
230
|
+
try {
|
|
231
|
+
const session = await this.paymentsRepository.getSessionByThread(ctx, thid);
|
|
232
|
+
const txRef = body?.proofs?.[0]?.tx_ref;
|
|
233
|
+
if (session && txRef) {
|
|
234
|
+
session.lastReceiptTxRef = txRef;
|
|
235
|
+
session.settlementStatus = session.settlementStatus || "received";
|
|
236
|
+
await this.paymentsRepository.update(ctx, session);
|
|
237
|
+
}
|
|
238
|
+
} catch (_e) {}
|
|
239
|
+
return {
|
|
240
|
+
id: message.id,
|
|
241
|
+
thid
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
async sendConfirm(connectionId, thid, body, agentContext) {
|
|
245
|
+
const ctx = agentContext ?? this.agentContext;
|
|
246
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
247
|
+
const jws = await this.signing.createJws({
|
|
248
|
+
agentContext: ctx,
|
|
249
|
+
payload: body,
|
|
250
|
+
purpose: "confirm",
|
|
251
|
+
threadId: thid,
|
|
252
|
+
connectionId
|
|
253
|
+
});
|
|
254
|
+
const message = new ConfirmMessage({
|
|
255
|
+
thid,
|
|
256
|
+
body: {
|
|
257
|
+
...body,
|
|
258
|
+
jws: jws.jws
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
262
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
263
|
+
agentContext: ctx,
|
|
264
|
+
connection
|
|
265
|
+
});
|
|
266
|
+
await this.messageSender.sendMessage(outbound);
|
|
267
|
+
return {
|
|
268
|
+
id: message.id,
|
|
269
|
+
thid
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
async sendCancel(connectionId, thid, body, agentContext) {
|
|
273
|
+
const ctx = agentContext ?? this.agentContext;
|
|
274
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
275
|
+
const message = new CancelMessage({
|
|
276
|
+
thid,
|
|
277
|
+
body
|
|
278
|
+
});
|
|
279
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
280
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
281
|
+
agentContext: ctx,
|
|
282
|
+
connection
|
|
283
|
+
});
|
|
284
|
+
await this.messageSender.sendMessage(outbound);
|
|
285
|
+
return {
|
|
286
|
+
id: message.id,
|
|
287
|
+
thid
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
async sendMethodUpdate(connectionId, thid, body, agentContext) {
|
|
291
|
+
const ctx = agentContext ?? this.agentContext;
|
|
292
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
293
|
+
const message = new MethodUpdateMessage({
|
|
294
|
+
thid,
|
|
295
|
+
body
|
|
296
|
+
});
|
|
297
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
298
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
299
|
+
agentContext: ctx,
|
|
300
|
+
connection
|
|
301
|
+
});
|
|
302
|
+
await this.messageSender.sendMessage(outbound);
|
|
303
|
+
return {
|
|
304
|
+
id: message.id,
|
|
305
|
+
thid
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
async sendMethodRevoke(connectionId, thid, body, agentContext) {
|
|
309
|
+
const ctx = agentContext ?? this.agentContext;
|
|
310
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
311
|
+
const message = new MethodRevokeMessage({
|
|
312
|
+
thid,
|
|
313
|
+
body
|
|
314
|
+
});
|
|
315
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
316
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
317
|
+
agentContext: ctx,
|
|
318
|
+
connection
|
|
319
|
+
});
|
|
320
|
+
await this.messageSender.sendMessage(outbound);
|
|
321
|
+
return {
|
|
322
|
+
id: message.id,
|
|
323
|
+
thid
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
async sendMandateOffer(connectionId, body, agentContext) {
|
|
327
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
328
|
+
const ctx = agentContext ?? this.agentContext;
|
|
329
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
330
|
+
const digest = this.integrity.computeTermsHash(body);
|
|
331
|
+
const withDigest = {
|
|
332
|
+
...body,
|
|
333
|
+
mandate_terms_sha256: body.mandate_terms_sha256 || digest
|
|
334
|
+
};
|
|
335
|
+
const thid = `mof_${Math.random().toString(36).slice(2)}`;
|
|
336
|
+
const message = new MandateOfferMessage({
|
|
337
|
+
thid,
|
|
338
|
+
body: withDigest
|
|
339
|
+
});
|
|
340
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
341
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
342
|
+
agentContext: ctx,
|
|
343
|
+
connection
|
|
344
|
+
});
|
|
345
|
+
await this.messageSender.sendMessage(outbound);
|
|
346
|
+
return {
|
|
347
|
+
id: message.id,
|
|
348
|
+
thid
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
async sendMandateAccept(connectionId, thid, body, agentContext) {
|
|
352
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
353
|
+
const ctx = agentContext ?? this.agentContext;
|
|
354
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
355
|
+
const message = new MandateAcceptMessage({
|
|
356
|
+
thid,
|
|
357
|
+
body
|
|
358
|
+
});
|
|
359
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
360
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
361
|
+
agentContext: ctx,
|
|
362
|
+
connection
|
|
363
|
+
});
|
|
364
|
+
await this.messageSender.sendMessage(outbound);
|
|
365
|
+
return {
|
|
366
|
+
id: message.id,
|
|
367
|
+
thid
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
async sendMandateActivate(connectionId, thid, body, agentContext) {
|
|
371
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
372
|
+
const ctx = agentContext ?? this.agentContext;
|
|
373
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
374
|
+
const message = new MandateActivateMessage({
|
|
375
|
+
thid,
|
|
376
|
+
body
|
|
377
|
+
});
|
|
378
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
379
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
380
|
+
agentContext: ctx,
|
|
381
|
+
connection
|
|
382
|
+
});
|
|
383
|
+
await this.messageSender.sendMessage(outbound);
|
|
384
|
+
return {
|
|
385
|
+
id: message.id,
|
|
386
|
+
thid
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
async sendMandateUpdate(connectionId, thid, body, agentContext) {
|
|
390
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
391
|
+
const ctx = agentContext ?? this.agentContext;
|
|
392
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
393
|
+
const message = new MandateUpdateMessage({
|
|
394
|
+
thid,
|
|
395
|
+
body
|
|
396
|
+
});
|
|
397
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
398
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
399
|
+
agentContext: ctx,
|
|
400
|
+
connection
|
|
401
|
+
});
|
|
402
|
+
await this.messageSender.sendMessage(outbound);
|
|
403
|
+
return {
|
|
404
|
+
id: message.id,
|
|
405
|
+
thid
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
async sendMandateCancel(connectionId, thid, body, agentContext) {
|
|
409
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
410
|
+
const ctx = agentContext ?? this.agentContext;
|
|
411
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
412
|
+
const message = new MandateCancelMessage({
|
|
413
|
+
thid,
|
|
414
|
+
body
|
|
415
|
+
});
|
|
416
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
417
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
418
|
+
agentContext: ctx,
|
|
419
|
+
connection
|
|
420
|
+
});
|
|
421
|
+
await this.messageSender.sendMessage(outbound);
|
|
422
|
+
return {
|
|
423
|
+
id: message.id,
|
|
424
|
+
thid
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
async sendChargeNotice(connectionId, thid, body, agentContext) {
|
|
428
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
429
|
+
const ctx = agentContext ?? this.agentContext;
|
|
430
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
431
|
+
const message = new ChargeNoticeMessage({
|
|
432
|
+
thid,
|
|
433
|
+
body
|
|
434
|
+
});
|
|
435
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
436
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
437
|
+
agentContext: ctx,
|
|
438
|
+
connection
|
|
439
|
+
});
|
|
440
|
+
await this.messageSender.sendMessage(outbound);
|
|
441
|
+
return {
|
|
442
|
+
id: message.id,
|
|
443
|
+
thid
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
async sendChargeRequest(connectionId, thid, body, agentContext) {
|
|
447
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
448
|
+
const ctx = agentContext ?? this.agentContext;
|
|
449
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
450
|
+
const termsHash = this.integrity.computeTermsHash(body.terms);
|
|
451
|
+
const message = new ChargeRequestMessage({
|
|
452
|
+
thid,
|
|
453
|
+
body: {
|
|
454
|
+
...body,
|
|
455
|
+
integrity: { terms_sha256: body.integrity?.terms_sha256 || termsHash }
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
459
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
460
|
+
agentContext: ctx,
|
|
461
|
+
connection
|
|
462
|
+
});
|
|
463
|
+
await this.messageSender.sendMessage(outbound);
|
|
464
|
+
return {
|
|
465
|
+
id: message.id,
|
|
466
|
+
thid
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
async sendSubscriptionStatus(connectionId, thid, body, agentContext) {
|
|
470
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
471
|
+
const ctx = agentContext ?? this.agentContext;
|
|
472
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
473
|
+
const message = new SubscriptionStatusMessage({
|
|
474
|
+
thid,
|
|
475
|
+
body
|
|
476
|
+
});
|
|
477
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
478
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
479
|
+
agentContext: ctx,
|
|
480
|
+
connection
|
|
481
|
+
});
|
|
482
|
+
await this.messageSender.sendMessage(outbound);
|
|
483
|
+
return {
|
|
484
|
+
id: message.id,
|
|
485
|
+
thid
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
async sendMandateRefUpdate(connectionId, thid, body, agentContext) {
|
|
489
|
+
if (!this.config.subscriptionsProfile) throw new Error("Subscriptions profile is disabled");
|
|
490
|
+
const ctx = agentContext ?? this.agentContext;
|
|
491
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
492
|
+
const message = new MandateRefUpdateMessage({
|
|
493
|
+
thid,
|
|
494
|
+
body
|
|
495
|
+
});
|
|
496
|
+
message.setReturnRouting(ReturnRouteTypes.none);
|
|
497
|
+
const outbound = new DidCommOutboundMessageContext(message, {
|
|
498
|
+
agentContext: ctx,
|
|
499
|
+
connection
|
|
500
|
+
});
|
|
501
|
+
await this.messageSender.sendMessage(outbound);
|
|
502
|
+
return {
|
|
503
|
+
id: message.id,
|
|
504
|
+
thid
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
async hasStoredMethod(connectionId, code, agentContext) {
|
|
508
|
+
const { PaymentMethodRepository } = await import("../repository/PaymentMethodRepository.mjs");
|
|
509
|
+
const ctx = agentContext ?? this.agentContext;
|
|
510
|
+
const pmRepo = ctx.dependencyManager.resolve(PaymentMethodRepository);
|
|
511
|
+
const conn = await this.connectionsApi.getById(connectionId);
|
|
512
|
+
return (await pmRepo.findByConnection(ctx, conn.id) || []).some((r) => r.status === "verified" && (!code || r.code === code));
|
|
513
|
+
}
|
|
514
|
+
async getDefaultMethodRef(connectionId, code, agentContext) {
|
|
515
|
+
const { PaymentMethodRepository } = await import("../repository/PaymentMethodRepository.mjs");
|
|
516
|
+
const ctx = agentContext ?? this.agentContext;
|
|
517
|
+
const pmRepo = ctx.dependencyManager.resolve(PaymentMethodRepository);
|
|
518
|
+
const conn = await this.connectionsApi.getById(connectionId);
|
|
519
|
+
return (await pmRepo.findDefault(ctx, conn.id, code))?.id ?? null;
|
|
520
|
+
}
|
|
521
|
+
async getSessionByThread(thid, agentContext) {
|
|
522
|
+
try {
|
|
523
|
+
const ctx = agentContext ?? this.agentContext;
|
|
524
|
+
return await this.paymentsRepository.getSessionByThread(ctx, thid) ?? null;
|
|
525
|
+
} catch {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
async listSessions(agentContext) {
|
|
530
|
+
const ctx = agentContext ?? this.agentContext;
|
|
531
|
+
return this.paymentsRepository.getAll(ctx);
|
|
532
|
+
}
|
|
533
|
+
async sendQuoteRequest(connectionId, options, agentContext) {
|
|
534
|
+
const ctx = agentContext ?? this.agentContext;
|
|
535
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
536
|
+
try {
|
|
537
|
+
const [{ QuoteRepository }, { QuoteRecord }] = await Promise.all([import("../repository/QuoteRepository.mjs"), import("../repository/QuoteRecord.mjs")]);
|
|
538
|
+
const quoteRepo = ctx.dependencyManager.resolve(QuoteRepository);
|
|
539
|
+
const existing = await quoteRepo.findByQuoteId(ctx, options.quoteId).catch(() => null);
|
|
540
|
+
const expiresAt = options.expiresIn ? new Date(Date.now() + options.expiresIn * 1e3) : new Date(Date.now() + 1440 * 60 * 1e3);
|
|
541
|
+
if (!existing) {
|
|
542
|
+
const record = new QuoteRecord({
|
|
543
|
+
quoteId: options.quoteId,
|
|
544
|
+
connectionId: connection.id,
|
|
545
|
+
status: "requested",
|
|
546
|
+
expiresAt,
|
|
547
|
+
terms: options.terms,
|
|
548
|
+
methodPreference: options.methodPreference,
|
|
549
|
+
mandateId: options.mandateId,
|
|
550
|
+
cycleId: options.cycleId
|
|
551
|
+
});
|
|
552
|
+
await quoteRepo.save(ctx, record);
|
|
553
|
+
}
|
|
554
|
+
} catch (_e) {}
|
|
555
|
+
const outbound = new DidCommOutboundMessageContext(new QuoteRequestMessage({ body: {
|
|
556
|
+
quote_id: options.quoteId,
|
|
557
|
+
terms: options.terms,
|
|
558
|
+
method_preference: options.methodPreference,
|
|
559
|
+
expires_in: options.expiresIn,
|
|
560
|
+
mandate_id: options.mandateId,
|
|
561
|
+
cycle_id: options.cycleId
|
|
562
|
+
} }), {
|
|
563
|
+
agentContext: ctx,
|
|
564
|
+
connection
|
|
565
|
+
});
|
|
566
|
+
await this.messageSender.sendMessage(outbound);
|
|
567
|
+
return {
|
|
568
|
+
success: true,
|
|
569
|
+
quoteId: options.quoteId
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
async sendRefundRequest(connectionId, options, agentContext) {
|
|
573
|
+
const ctx = agentContext ?? this.agentContext;
|
|
574
|
+
const connection = await this.connectionsApi.getById(connectionId);
|
|
575
|
+
try {
|
|
576
|
+
const [{ RefundRepository }, { RefundRecord }] = await Promise.all([import("../repository/RefundRepository.mjs"), import("../repository/RefundRecord.mjs")]);
|
|
577
|
+
const refundRepo = ctx.dependencyManager.resolve(RefundRepository);
|
|
578
|
+
if (!await refundRepo.findByRefundId(ctx, options.refundId).catch(() => null)) {
|
|
579
|
+
const record = new RefundRecord({
|
|
580
|
+
refundId: options.refundId,
|
|
581
|
+
connectionId: connection.id,
|
|
582
|
+
originalSessionId: options.originalSessionId,
|
|
583
|
+
originalTxRef: options.originalTxRef,
|
|
584
|
+
status: "requested",
|
|
585
|
+
reason: options.reason,
|
|
586
|
+
amount: options.amount,
|
|
587
|
+
mandateId: options.mandateId,
|
|
588
|
+
cycleId: options.cycleId
|
|
589
|
+
});
|
|
590
|
+
await refundRepo.save(ctx, record);
|
|
591
|
+
}
|
|
592
|
+
} catch (_e) {}
|
|
593
|
+
const outbound = new DidCommOutboundMessageContext(new RefundRequestMessage({ body: {
|
|
594
|
+
refund_id: options.refundId,
|
|
595
|
+
original_session_id: options.originalSessionId,
|
|
596
|
+
original_tx_ref: options.originalTxRef,
|
|
597
|
+
reason: options.reason,
|
|
598
|
+
amount: options.amount,
|
|
599
|
+
explanation: options.explanation,
|
|
600
|
+
mandate_id: options.mandateId,
|
|
601
|
+
cycle_id: options.cycleId
|
|
602
|
+
} }), {
|
|
603
|
+
agentContext: ctx,
|
|
604
|
+
connection
|
|
605
|
+
});
|
|
606
|
+
await this.messageSender.sendMessage(outbound);
|
|
607
|
+
return {
|
|
608
|
+
success: true,
|
|
609
|
+
refundId: options.refundId
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
async getPendingRefunds(connectionId, agentContext) {
|
|
613
|
+
const ctx = agentContext ?? this.agentContext;
|
|
614
|
+
return this.refundService.getPendingRefunds(ctx, connectionId);
|
|
615
|
+
}
|
|
616
|
+
async getRefundById(refundId, agentContext) {
|
|
617
|
+
const ctx = agentContext ?? this.agentContext;
|
|
618
|
+
return this.refundService.getRefundById(ctx, refundId);
|
|
619
|
+
}
|
|
620
|
+
async getRefundsForSession(originalSessionId, agentContext) {
|
|
621
|
+
const ctx = agentContext ?? this.agentContext;
|
|
622
|
+
return this.refundService.getRefundsForSession(ctx, originalSessionId);
|
|
623
|
+
}
|
|
624
|
+
async processRefund(options, agentContext) {
|
|
625
|
+
const ctx = agentContext ?? this.agentContext;
|
|
626
|
+
return this.refundService.processRefund(ctx, options);
|
|
627
|
+
}
|
|
628
|
+
async getRefundStats(connectionId, agentContext) {
|
|
629
|
+
const ctx = agentContext ?? this.agentContext;
|
|
630
|
+
return this.refundService.getRefundStats(ctx, connectionId);
|
|
631
|
+
}
|
|
632
|
+
async bulkProcessRefunds(refunds, agentContext) {
|
|
633
|
+
const ctx = agentContext ?? this.agentContext;
|
|
634
|
+
return this.refundService.bulkProcessRefunds(ctx, refunds);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
PaymentsApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [
|
|
638
|
+
PaymentsRepository,
|
|
639
|
+
LedgerRouter,
|
|
640
|
+
PaymentsService,
|
|
641
|
+
DidCommMessageSender,
|
|
642
|
+
DidCommConnectionsApi,
|
|
643
|
+
SigningService,
|
|
644
|
+
IntegrityService,
|
|
645
|
+
PaymentsModuleConfig,
|
|
646
|
+
RefundService,
|
|
647
|
+
AgentContext
|
|
648
|
+
])], PaymentsApi);
|
|
649
|
+
|
|
650
|
+
//#endregion
|
|
651
|
+
export { PaymentsApi };
|
|
652
|
+
//# sourceMappingURL=PaymentsApi.mjs.map
|