@nehorai/payments 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/factory.d.cts +4 -4
- package/dist/factory.d.ts +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/{payment-orchestrator-CPaLmDM5.d.ts → payment-orchestrator-Bf2XX07D.d.ts} +2 -2
- package/dist/{payment-orchestrator-Co_X6T_V.d.cts → payment-orchestrator-BmAZcr84.d.cts} +2 -2
- package/dist/{payment-types-68W-PlGg.d.cts → payment-types-DUs8IALw.d.cts} +72 -1
- package/dist/{payment-types-68W-PlGg.d.ts → payment-types-DUs8IALw.d.ts} +72 -1
- package/dist/providers/interfaces/index.cjs.map +1 -1
- package/dist/providers/interfaces/index.d.cts +35 -66
- package/dist/providers/interfaces/index.d.ts +35 -66
- package/dist/{routing-engine.interface-DJzGXor9.d.cts → routing-engine.interface-B8tYJvJO.d.cts} +1 -1
- package/dist/{routing-engine.interface-h9_GmQ4b.d.ts → routing-engine.interface-BrhDxYN6.d.ts} +1 -1
- package/dist/services/index.d.cts +4 -4
- package/dist/services/index.d.ts +4 -4
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/webhook-handler.interface-BP_Ew2Mu.d.ts +79 -0
- package/dist/webhook-handler.interface-Dq9hNM80.d.cts +79 -0
- package/package.json +1 -1
package/dist/types/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AuthorizationResult, a as AuthorizePaymentParams, C as
|
|
1
|
+
import { n as PaymentProvider } from '../payment-types-DUs8IALw.cjs';
|
|
2
|
+
export { A as AuthorizationResult, a as AuthorizePaymentParams, C as CancelSubscriptionParams, b as CancelSubscriptionResult, c as CapturePaymentParams, d as CaptureResult, e as CardBrand, f as CreatePaymentIntentParams, g as CreateSubscriptionParams, h as CurrencyConversion, P as PaymentAmount, i as PaymentError, j as PaymentErrorCode, k as PaymentIntentResult, l as PaymentMetadata, m as PaymentMethodType, o as ProviderHealthStatus, p as ProviderMetadata, R as RefundParams, q as RefundResult, S as SubscriptionInterval, r as SubscriptionResult, s as SubscriptionStatus, T as TaxInvoiceStatus, t as TransactionType, V as VoidPaymentParams, u as VoidResult } from '../payment-types-DUs8IALw.cjs';
|
|
3
3
|
import { c as TransactionStatus } from '../state-machine-Cu6_qKnv.cjs';
|
|
4
4
|
export { D as DEFAULT_AUTH_HOLD_DAYS, H as HOLD_STATES, S as SUCCESS_STATES, a as StateTransitionResult, T as TERMINAL_STATES, b as TransactionEvent, V as VALID_TRANSITIONS, d as attemptTransition, e as calculateCaptureDeadline, f as canCapture, g as canRefund, h as canTransition, i as canVoid, j as getNextStatus, k as isAuthorizationExpired, l as isHoldState, m as isSuccessState, n as isTerminalState } from '../state-machine-Cu6_qKnv.cjs';
|
|
5
5
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AuthorizationResult, a as AuthorizePaymentParams, C as
|
|
1
|
+
import { n as PaymentProvider } from '../payment-types-DUs8IALw.js';
|
|
2
|
+
export { A as AuthorizationResult, a as AuthorizePaymentParams, C as CancelSubscriptionParams, b as CancelSubscriptionResult, c as CapturePaymentParams, d as CaptureResult, e as CardBrand, f as CreatePaymentIntentParams, g as CreateSubscriptionParams, h as CurrencyConversion, P as PaymentAmount, i as PaymentError, j as PaymentErrorCode, k as PaymentIntentResult, l as PaymentMetadata, m as PaymentMethodType, o as ProviderHealthStatus, p as ProviderMetadata, R as RefundParams, q as RefundResult, S as SubscriptionInterval, r as SubscriptionResult, s as SubscriptionStatus, T as TaxInvoiceStatus, t as TransactionType, V as VoidPaymentParams, u as VoidResult } from '../payment-types-DUs8IALw.js';
|
|
3
3
|
import { c as TransactionStatus } from '../state-machine-Cu6_qKnv.js';
|
|
4
4
|
export { D as DEFAULT_AUTH_HOLD_DAYS, H as HOLD_STATES, S as SUCCESS_STATES, a as StateTransitionResult, T as TERMINAL_STATES, b as TransactionEvent, V as VALID_TRANSITIONS, d as attemptTransition, e as calculateCaptureDeadline, f as canCapture, g as canRefund, h as canTransition, i as canVoid, j as getNextStatus, k as isAuthorizationExpired, l as isHoldState, m as isSuccessState, n as isTerminalState } from '../state-machine-Cu6_qKnv.js';
|
|
5
5
|
|
package/dist/utils/index.d.cts
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { n as PaymentProvider } from './payment-types-DUs8IALw.js';
|
|
2
|
+
import { c as TransactionStatus } from './state-machine-Cu6_qKnv.js';
|
|
3
|
+
import { WebhookProcessingResult, ReconciliationResult } from './types/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @nehorai/payments - Webhook Handler Interface
|
|
7
|
+
*
|
|
8
|
+
* Defines the contract for processing incoming webhooks from payment providers.
|
|
9
|
+
* Handles idempotency, reconciliation, and event-to-action mapping.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parsed webhook event with standardized fields
|
|
14
|
+
*/
|
|
15
|
+
interface ParsedWebhookEvent {
|
|
16
|
+
/** Provider that sent the webhook */
|
|
17
|
+
provider: PaymentProvider;
|
|
18
|
+
/** Provider's unique event ID */
|
|
19
|
+
eventId: string;
|
|
20
|
+
/** Standardized event type */
|
|
21
|
+
eventType: string;
|
|
22
|
+
/** Associated payment intent/transaction ID */
|
|
23
|
+
providerTransactionId?: string;
|
|
24
|
+
/** Amount in minor units (if applicable) */
|
|
25
|
+
amountMinor?: number;
|
|
26
|
+
/** Currency (if applicable) */
|
|
27
|
+
currency?: string;
|
|
28
|
+
/** New status (if status change event) */
|
|
29
|
+
newStatus?: TransactionStatus;
|
|
30
|
+
/** Error details (if failure event) */
|
|
31
|
+
error?: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
/** Original timestamp from provider */
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
/** Full raw payload */
|
|
38
|
+
rawPayload: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Result of parsing a webhook event
|
|
42
|
+
*/
|
|
43
|
+
interface ParseWebhookResult {
|
|
44
|
+
success: boolean;
|
|
45
|
+
event?: ParsedWebhookEvent;
|
|
46
|
+
error?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handler function for a specific event type
|
|
50
|
+
*/
|
|
51
|
+
type EventHandler = (event: ParsedWebhookEvent) => Promise<WebhookProcessingResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Map of event types to handler functions
|
|
54
|
+
*/
|
|
55
|
+
type EventHandlerMap = Map<string, EventHandler>;
|
|
56
|
+
/**
|
|
57
|
+
* Webhook Handler Interface
|
|
58
|
+
*
|
|
59
|
+
* Provider-specific webhook handlers implement this interface.
|
|
60
|
+
* Enables consistent webhook processing across all providers.
|
|
61
|
+
*/
|
|
62
|
+
interface IWebhookHandler {
|
|
63
|
+
/**
|
|
64
|
+
* Provider this handler is for
|
|
65
|
+
*/
|
|
66
|
+
readonly provider: PaymentProvider;
|
|
67
|
+
/**
|
|
68
|
+
* Event types this handler can process
|
|
69
|
+
*/
|
|
70
|
+
readonly supportedEventTypes: readonly string[];
|
|
71
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
72
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
73
|
+
canHandle(eventType: string): boolean;
|
|
74
|
+
reconcile(transactionId: string, providerTransactionId: string): Promise<ReconciliationResult>;
|
|
75
|
+
mapEventType(providerEventType: string): string;
|
|
76
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type { EventHandler as E, IWebhookHandler as I, ParseWebhookResult as P, EventHandlerMap as a, ParsedWebhookEvent as b };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { n as PaymentProvider } from './payment-types-DUs8IALw.cjs';
|
|
2
|
+
import { c as TransactionStatus } from './state-machine-Cu6_qKnv.cjs';
|
|
3
|
+
import { WebhookProcessingResult, ReconciliationResult } from './types/index.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @nehorai/payments - Webhook Handler Interface
|
|
7
|
+
*
|
|
8
|
+
* Defines the contract for processing incoming webhooks from payment providers.
|
|
9
|
+
* Handles idempotency, reconciliation, and event-to-action mapping.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parsed webhook event with standardized fields
|
|
14
|
+
*/
|
|
15
|
+
interface ParsedWebhookEvent {
|
|
16
|
+
/** Provider that sent the webhook */
|
|
17
|
+
provider: PaymentProvider;
|
|
18
|
+
/** Provider's unique event ID */
|
|
19
|
+
eventId: string;
|
|
20
|
+
/** Standardized event type */
|
|
21
|
+
eventType: string;
|
|
22
|
+
/** Associated payment intent/transaction ID */
|
|
23
|
+
providerTransactionId?: string;
|
|
24
|
+
/** Amount in minor units (if applicable) */
|
|
25
|
+
amountMinor?: number;
|
|
26
|
+
/** Currency (if applicable) */
|
|
27
|
+
currency?: string;
|
|
28
|
+
/** New status (if status change event) */
|
|
29
|
+
newStatus?: TransactionStatus;
|
|
30
|
+
/** Error details (if failure event) */
|
|
31
|
+
error?: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
/** Original timestamp from provider */
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
/** Full raw payload */
|
|
38
|
+
rawPayload: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Result of parsing a webhook event
|
|
42
|
+
*/
|
|
43
|
+
interface ParseWebhookResult {
|
|
44
|
+
success: boolean;
|
|
45
|
+
event?: ParsedWebhookEvent;
|
|
46
|
+
error?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handler function for a specific event type
|
|
50
|
+
*/
|
|
51
|
+
type EventHandler = (event: ParsedWebhookEvent) => Promise<WebhookProcessingResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Map of event types to handler functions
|
|
54
|
+
*/
|
|
55
|
+
type EventHandlerMap = Map<string, EventHandler>;
|
|
56
|
+
/**
|
|
57
|
+
* Webhook Handler Interface
|
|
58
|
+
*
|
|
59
|
+
* Provider-specific webhook handlers implement this interface.
|
|
60
|
+
* Enables consistent webhook processing across all providers.
|
|
61
|
+
*/
|
|
62
|
+
interface IWebhookHandler {
|
|
63
|
+
/**
|
|
64
|
+
* Provider this handler is for
|
|
65
|
+
*/
|
|
66
|
+
readonly provider: PaymentProvider;
|
|
67
|
+
/**
|
|
68
|
+
* Event types this handler can process
|
|
69
|
+
*/
|
|
70
|
+
readonly supportedEventTypes: readonly string[];
|
|
71
|
+
parseEvent(rawPayload: Record<string, unknown>): ParseWebhookResult;
|
|
72
|
+
processEvent(event: ParsedWebhookEvent): Promise<WebhookProcessingResult>;
|
|
73
|
+
canHandle(eventType: string): boolean;
|
|
74
|
+
reconcile(transactionId: string, providerTransactionId: string): Promise<ReconciliationResult>;
|
|
75
|
+
mapEventType(providerEventType: string): string;
|
|
76
|
+
mapStatus(providerStatus: string): TransactionStatus | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type { EventHandler as E, IWebhookHandler as I, ParseWebhookResult as P, EventHandlerMap as a, ParsedWebhookEvent as b };
|