@theengineerscanvas/payment 0.0.0-stage → 0.1.0-rc.16
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 +201 -0
- package/README.md +323 -2
- package/dist/adapters/nestjs/index.cjs +4979 -0
- package/dist/adapters/nestjs/index.cjs.map +1 -0
- package/dist/adapters/nestjs/index.d.cts +313 -0
- package/dist/adapters/nestjs/index.d.ts +313 -0
- package/dist/adapters/nestjs/index.js +4974 -0
- package/dist/adapters/nestjs/index.js.map +1 -0
- package/dist/index.cjs +4865 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +171 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +4822 -0
- package/dist/index.js.map +1 -0
- package/dist/payment-client-DNhLWboh.d.cts +1257 -0
- package/dist/payment-client-DNhLWboh.d.ts +1257 -0
- package/docs/agents/cookbook.md +467 -0
- package/docs/api-stability.md +104 -0
- package/docs/architecture.md +119 -0
- package/docs/bachs-guide.md +359 -0
- package/docs/bachs-sandbox-validation.md +138 -0
- package/docs/concurrency.md +103 -0
- package/docs/extension-guide.md +156 -0
- package/docs/integration-checklist.md +209 -0
- package/docs/migration-guide.md +401 -0
- package/docs/performance.md +86 -0
- package/docs/provider-guide.md +150 -0
- package/docs/public-api.md +1108 -0
- package/docs/security.md +120 -0
- package/docs/versioning.md +95 -0
- package/llms.txt +97 -0
- package/package.json +141 -4
- package/public-api.json +452 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { b as PaymentError, c as PaymentErrorOptions, E as ErrorCode, P as PaymentClientConfig, a as PaymentClient, d as HttpClient, e as HttpRequest, R as Result, f as HttpResponse } from './payment-client-DNhLWboh.cjs';
|
|
2
|
+
export { B as BankCode, C as CancelSubscriptionInput, g as Clock, h as CreateCustomerInput, i as CreateProductInput, j as CreateRecipientInput, k as Currency, l as CurrencyPriceInput, m as CurrencyPriceOption, n as Customer, o as CustomerListQuery, p as CustomerReference, q as CustomerService, r as ErrorCategory, s as EventBus, t as EventHandler, u as EventSubscription, H as HealthStatus, I as IdGenerator, v as InitiateTransferInput, w as ListQuery, L as Logger, M as Metadata, x as MinorUnits, y as Money, z as Page, A as Payment, D as PaymentAttempt, F as PaymentChannel, G as PaymentEvent, J as PaymentEventType, K as PaymentFailed, N as PaymentInitialized, O as PaymentPending, Q as PaymentReference, S as PaymentRequest, T as PaymentRequestItem, U as PaymentStatus, V as PaymentStatusKind, W as PaymentSucceeded, X as PortalSession, Y as PriceType, Z as Product, _ as ProductListQuery, $ as ProductPrice, a0 as ProductPriceInput, a1 as ProductService, a2 as ProductStatus, a3 as Provider, a4 as ProviderCapabilities, a5 as ProviderInstance, a6 as RecurringCadence, a7 as RecurringInterval, a8 as Refund, a9 as RefundCreateInput, aa as RefundFailed, ab as RefundInitiated, ac as RefundRequest, ad as RefundResult, ae as RefundStatus, af as RefundStatusKind, ag as RefundSucceeded, ah as ResolveAccountResult, ai as Subscription, aj as SubscriptionCanceled, ak as SubscriptionListQuery, al as SubscriptionProvider, am as SubscriptionService, an as SubscriptionStatus, ao as SubscriptionStatusKind, ap as SubscriptionUpdated, aq as Transfer, ar as TransferFailed, as as TransferInitiated, at as TransferRecipient, au as TransferReversed, av as TransferStatus, aw as TransferStatusKind, ax as TransferSucceeded, ay as Unsubscribe, az as UpdateCustomerInput, aA as UpdateProductInput, aB as UpdateSubscriptionInput, aC as VerificationCompleted, aD as WebhookEvent, aE as WebhookInput, aF as WebhookReceived, aG as WebhookValidationError, aH as attempt, aI as err, aJ as isFinalRefundStatus, aK as isFinalStatus, aL as isFinalSubscriptionStatus, aM as isFinalTransferStatus, aN as isRecurring, aO as isSubscriptionActive, aP as isSubscriptionDelinquent, aQ as isSubscriptionProvider, aR as isTransitionAllowed, aS as ok } from './payment-client-DNhLWboh.cjs';
|
|
3
|
+
|
|
4
|
+
declare const VERSION = "0.1.0-rc.16";
|
|
5
|
+
|
|
6
|
+
declare class ConfigurationError extends PaymentError {
|
|
7
|
+
readonly code: "CONFIGURATION";
|
|
8
|
+
readonly category: "configuration";
|
|
9
|
+
readonly httpStatus = 500;
|
|
10
|
+
readonly isRetryable = false;
|
|
11
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class ValidationError extends PaymentError {
|
|
15
|
+
readonly code: "VALIDATION";
|
|
16
|
+
readonly category: "validation";
|
|
17
|
+
readonly httpStatus = 400;
|
|
18
|
+
readonly isRetryable = false;
|
|
19
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class ProviderError extends PaymentError {
|
|
23
|
+
readonly code: ErrorCode;
|
|
24
|
+
readonly category: "provider";
|
|
25
|
+
readonly httpStatus: number;
|
|
26
|
+
readonly isRetryable: boolean;
|
|
27
|
+
constructor(message: string, options?: PaymentErrorOptions & {
|
|
28
|
+
readonly httpStatus?: number;
|
|
29
|
+
readonly isRetryable?: boolean;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
declare class ProviderBadRequestError extends ProviderError {
|
|
33
|
+
readonly code: "PROVIDER_BAD_REQUEST";
|
|
34
|
+
readonly httpStatus = 400;
|
|
35
|
+
readonly isRetryable = false;
|
|
36
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
declare class ProviderUnauthorizedError extends ProviderError {
|
|
39
|
+
readonly code: "PROVIDER_UNAUTHORIZED";
|
|
40
|
+
readonly httpStatus: number;
|
|
41
|
+
readonly isRetryable = false;
|
|
42
|
+
constructor(message: string, options?: PaymentErrorOptions & {
|
|
43
|
+
readonly httpStatus?: number;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
declare class ProviderNotFoundError extends ProviderError {
|
|
47
|
+
readonly code: "PROVIDER_NOT_FOUND";
|
|
48
|
+
readonly httpStatus = 404;
|
|
49
|
+
readonly isRetryable = false;
|
|
50
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
51
|
+
}
|
|
52
|
+
declare class ProviderConflictError extends ProviderError {
|
|
53
|
+
readonly code: "PROVIDER_CONFLICT";
|
|
54
|
+
readonly httpStatus = 409;
|
|
55
|
+
readonly isRetryable = false;
|
|
56
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
57
|
+
}
|
|
58
|
+
declare class ProviderRateLimitError extends ProviderError {
|
|
59
|
+
readonly code: "PROVIDER_RATE_LIMIT";
|
|
60
|
+
readonly httpStatus = 429;
|
|
61
|
+
readonly isRetryable = true;
|
|
62
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare class ProviderUnavailableError extends PaymentError {
|
|
66
|
+
readonly code: "PROVIDER_UNAVAILABLE";
|
|
67
|
+
readonly category: "provider";
|
|
68
|
+
readonly httpStatus = 502;
|
|
69
|
+
readonly isRetryable = true;
|
|
70
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The configured provider does not implement the requested capability.
|
|
75
|
+
*
|
|
76
|
+
* Not retryable: repeating the call against the same provider can never
|
|
77
|
+
* succeed. Configure a provider that implements the capability (Bachs
|
|
78
|
+
* implements subscriptions, products, customers, and portal sessions).
|
|
79
|
+
*/
|
|
80
|
+
declare class UnsupportedProviderError extends PaymentError {
|
|
81
|
+
readonly code: ErrorCode;
|
|
82
|
+
readonly category: "unsupported";
|
|
83
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare class NetworkError extends PaymentError {
|
|
87
|
+
readonly code: "NETWORK";
|
|
88
|
+
readonly category: "network";
|
|
89
|
+
readonly httpStatus = 502;
|
|
90
|
+
readonly isRetryable = true;
|
|
91
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class TimeoutError extends PaymentError {
|
|
95
|
+
readonly code: "TIMEOUT";
|
|
96
|
+
readonly category: "timeout";
|
|
97
|
+
readonly httpStatus = 504;
|
|
98
|
+
readonly isRetryable = true;
|
|
99
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A verification the provider answered but declined: an unknown reference, a
|
|
104
|
+
* transaction that cannot be found through the verify endpoint, or a payload
|
|
105
|
+
* whose state contradicts the request.
|
|
106
|
+
*
|
|
107
|
+
* The provider took the request and made a decision, so this is a 422 rather
|
|
108
|
+
* than a gateway error, and retrying the same call cannot succeed.
|
|
109
|
+
*/
|
|
110
|
+
declare class VerificationError extends PaymentError {
|
|
111
|
+
readonly code: "VERIFICATION";
|
|
112
|
+
readonly category: "verification";
|
|
113
|
+
readonly httpStatus = 422;
|
|
114
|
+
readonly isRetryable = false;
|
|
115
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare class RefundError extends PaymentError {
|
|
119
|
+
readonly code: "REFUND";
|
|
120
|
+
readonly category: "refund";
|
|
121
|
+
readonly httpStatus = 402;
|
|
122
|
+
readonly isRetryable = false;
|
|
123
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare class InternalError extends PaymentError {
|
|
127
|
+
readonly code: "INTERNAL";
|
|
128
|
+
readonly category: "internal";
|
|
129
|
+
readonly httpStatus = 500;
|
|
130
|
+
readonly isRetryable = false;
|
|
131
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare function createPaymentClient(config: PaymentClientConfig): PaymentClient;
|
|
135
|
+
declare namespace createPaymentClient {
|
|
136
|
+
var fromEnv: typeof createClientFromEnv;
|
|
137
|
+
}
|
|
138
|
+
declare function createClientFromEnv(): PaymentClient;
|
|
139
|
+
|
|
140
|
+
declare const RefundReasonSymbol: unique symbol;
|
|
141
|
+
type RefundReason = string & {
|
|
142
|
+
readonly [RefundReasonSymbol]: true;
|
|
143
|
+
};
|
|
144
|
+
declare function RefundReason(value: string): RefundReason;
|
|
145
|
+
|
|
146
|
+
interface MockResponse {
|
|
147
|
+
readonly status: number;
|
|
148
|
+
readonly body: string;
|
|
149
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
150
|
+
}
|
|
151
|
+
declare class MockHttpClient implements HttpClient {
|
|
152
|
+
private responses;
|
|
153
|
+
private requests;
|
|
154
|
+
on(method: string, urlMatch: string, response: MockResponse): this;
|
|
155
|
+
getRequests(): ReadonlyArray<HttpRequest>;
|
|
156
|
+
clearRequests(): void;
|
|
157
|
+
reset(): void;
|
|
158
|
+
send(request: HttpRequest): Promise<Result<HttpResponse, PaymentError>>;
|
|
159
|
+
private buildResponse;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface MockClientOptions {
|
|
163
|
+
readonly provider?: string;
|
|
164
|
+
readonly webhookSecret?: string;
|
|
165
|
+
}
|
|
166
|
+
declare function createMockClient(options?: MockClientOptions): {
|
|
167
|
+
client: PaymentClient;
|
|
168
|
+
http: MockHttpClient;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { ConfigurationError, ErrorCode, HttpClient, HttpRequest, HttpResponse, InternalError, type MockClientOptions, MockHttpClient, type MockResponse, NetworkError, PaymentClient, PaymentClientConfig, PaymentError, PaymentErrorOptions, ProviderBadRequestError, ProviderConflictError, ProviderError, ProviderNotFoundError, ProviderRateLimitError, ProviderUnauthorizedError, ProviderUnavailableError, RefundError, RefundReason, Result, TimeoutError, UnsupportedProviderError, VERSION, ValidationError, VerificationError, createMockClient, createPaymentClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { b as PaymentError, c as PaymentErrorOptions, E as ErrorCode, P as PaymentClientConfig, a as PaymentClient, d as HttpClient, e as HttpRequest, R as Result, f as HttpResponse } from './payment-client-DNhLWboh.js';
|
|
2
|
+
export { B as BankCode, C as CancelSubscriptionInput, g as Clock, h as CreateCustomerInput, i as CreateProductInput, j as CreateRecipientInput, k as Currency, l as CurrencyPriceInput, m as CurrencyPriceOption, n as Customer, o as CustomerListQuery, p as CustomerReference, q as CustomerService, r as ErrorCategory, s as EventBus, t as EventHandler, u as EventSubscription, H as HealthStatus, I as IdGenerator, v as InitiateTransferInput, w as ListQuery, L as Logger, M as Metadata, x as MinorUnits, y as Money, z as Page, A as Payment, D as PaymentAttempt, F as PaymentChannel, G as PaymentEvent, J as PaymentEventType, K as PaymentFailed, N as PaymentInitialized, O as PaymentPending, Q as PaymentReference, S as PaymentRequest, T as PaymentRequestItem, U as PaymentStatus, V as PaymentStatusKind, W as PaymentSucceeded, X as PortalSession, Y as PriceType, Z as Product, _ as ProductListQuery, $ as ProductPrice, a0 as ProductPriceInput, a1 as ProductService, a2 as ProductStatus, a3 as Provider, a4 as ProviderCapabilities, a5 as ProviderInstance, a6 as RecurringCadence, a7 as RecurringInterval, a8 as Refund, a9 as RefundCreateInput, aa as RefundFailed, ab as RefundInitiated, ac as RefundRequest, ad as RefundResult, ae as RefundStatus, af as RefundStatusKind, ag as RefundSucceeded, ah as ResolveAccountResult, ai as Subscription, aj as SubscriptionCanceled, ak as SubscriptionListQuery, al as SubscriptionProvider, am as SubscriptionService, an as SubscriptionStatus, ao as SubscriptionStatusKind, ap as SubscriptionUpdated, aq as Transfer, ar as TransferFailed, as as TransferInitiated, at as TransferRecipient, au as TransferReversed, av as TransferStatus, aw as TransferStatusKind, ax as TransferSucceeded, ay as Unsubscribe, az as UpdateCustomerInput, aA as UpdateProductInput, aB as UpdateSubscriptionInput, aC as VerificationCompleted, aD as WebhookEvent, aE as WebhookInput, aF as WebhookReceived, aG as WebhookValidationError, aH as attempt, aI as err, aJ as isFinalRefundStatus, aK as isFinalStatus, aL as isFinalSubscriptionStatus, aM as isFinalTransferStatus, aN as isRecurring, aO as isSubscriptionActive, aP as isSubscriptionDelinquent, aQ as isSubscriptionProvider, aR as isTransitionAllowed, aS as ok } from './payment-client-DNhLWboh.js';
|
|
3
|
+
|
|
4
|
+
declare const VERSION = "0.1.0-rc.16";
|
|
5
|
+
|
|
6
|
+
declare class ConfigurationError extends PaymentError {
|
|
7
|
+
readonly code: "CONFIGURATION";
|
|
8
|
+
readonly category: "configuration";
|
|
9
|
+
readonly httpStatus = 500;
|
|
10
|
+
readonly isRetryable = false;
|
|
11
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class ValidationError extends PaymentError {
|
|
15
|
+
readonly code: "VALIDATION";
|
|
16
|
+
readonly category: "validation";
|
|
17
|
+
readonly httpStatus = 400;
|
|
18
|
+
readonly isRetryable = false;
|
|
19
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class ProviderError extends PaymentError {
|
|
23
|
+
readonly code: ErrorCode;
|
|
24
|
+
readonly category: "provider";
|
|
25
|
+
readonly httpStatus: number;
|
|
26
|
+
readonly isRetryable: boolean;
|
|
27
|
+
constructor(message: string, options?: PaymentErrorOptions & {
|
|
28
|
+
readonly httpStatus?: number;
|
|
29
|
+
readonly isRetryable?: boolean;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
declare class ProviderBadRequestError extends ProviderError {
|
|
33
|
+
readonly code: "PROVIDER_BAD_REQUEST";
|
|
34
|
+
readonly httpStatus = 400;
|
|
35
|
+
readonly isRetryable = false;
|
|
36
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
declare class ProviderUnauthorizedError extends ProviderError {
|
|
39
|
+
readonly code: "PROVIDER_UNAUTHORIZED";
|
|
40
|
+
readonly httpStatus: number;
|
|
41
|
+
readonly isRetryable = false;
|
|
42
|
+
constructor(message: string, options?: PaymentErrorOptions & {
|
|
43
|
+
readonly httpStatus?: number;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
declare class ProviderNotFoundError extends ProviderError {
|
|
47
|
+
readonly code: "PROVIDER_NOT_FOUND";
|
|
48
|
+
readonly httpStatus = 404;
|
|
49
|
+
readonly isRetryable = false;
|
|
50
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
51
|
+
}
|
|
52
|
+
declare class ProviderConflictError extends ProviderError {
|
|
53
|
+
readonly code: "PROVIDER_CONFLICT";
|
|
54
|
+
readonly httpStatus = 409;
|
|
55
|
+
readonly isRetryable = false;
|
|
56
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
57
|
+
}
|
|
58
|
+
declare class ProviderRateLimitError extends ProviderError {
|
|
59
|
+
readonly code: "PROVIDER_RATE_LIMIT";
|
|
60
|
+
readonly httpStatus = 429;
|
|
61
|
+
readonly isRetryable = true;
|
|
62
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare class ProviderUnavailableError extends PaymentError {
|
|
66
|
+
readonly code: "PROVIDER_UNAVAILABLE";
|
|
67
|
+
readonly category: "provider";
|
|
68
|
+
readonly httpStatus = 502;
|
|
69
|
+
readonly isRetryable = true;
|
|
70
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The configured provider does not implement the requested capability.
|
|
75
|
+
*
|
|
76
|
+
* Not retryable: repeating the call against the same provider can never
|
|
77
|
+
* succeed. Configure a provider that implements the capability (Bachs
|
|
78
|
+
* implements subscriptions, products, customers, and portal sessions).
|
|
79
|
+
*/
|
|
80
|
+
declare class UnsupportedProviderError extends PaymentError {
|
|
81
|
+
readonly code: ErrorCode;
|
|
82
|
+
readonly category: "unsupported";
|
|
83
|
+
constructor(message: string, options?: PaymentErrorOptions);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare class NetworkError extends PaymentError {
|
|
87
|
+
readonly code: "NETWORK";
|
|
88
|
+
readonly category: "network";
|
|
89
|
+
readonly httpStatus = 502;
|
|
90
|
+
readonly isRetryable = true;
|
|
91
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class TimeoutError extends PaymentError {
|
|
95
|
+
readonly code: "TIMEOUT";
|
|
96
|
+
readonly category: "timeout";
|
|
97
|
+
readonly httpStatus = 504;
|
|
98
|
+
readonly isRetryable = true;
|
|
99
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A verification the provider answered but declined: an unknown reference, a
|
|
104
|
+
* transaction that cannot be found through the verify endpoint, or a payload
|
|
105
|
+
* whose state contradicts the request.
|
|
106
|
+
*
|
|
107
|
+
* The provider took the request and made a decision, so this is a 422 rather
|
|
108
|
+
* than a gateway error, and retrying the same call cannot succeed.
|
|
109
|
+
*/
|
|
110
|
+
declare class VerificationError extends PaymentError {
|
|
111
|
+
readonly code: "VERIFICATION";
|
|
112
|
+
readonly category: "verification";
|
|
113
|
+
readonly httpStatus = 422;
|
|
114
|
+
readonly isRetryable = false;
|
|
115
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare class RefundError extends PaymentError {
|
|
119
|
+
readonly code: "REFUND";
|
|
120
|
+
readonly category: "refund";
|
|
121
|
+
readonly httpStatus = 402;
|
|
122
|
+
readonly isRetryable = false;
|
|
123
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare class InternalError extends PaymentError {
|
|
127
|
+
readonly code: "INTERNAL";
|
|
128
|
+
readonly category: "internal";
|
|
129
|
+
readonly httpStatus = 500;
|
|
130
|
+
readonly isRetryable = false;
|
|
131
|
+
constructor(message: string, options?: Omit<PaymentErrorOptions, "httpStatus" | "isRetryable">);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare function createPaymentClient(config: PaymentClientConfig): PaymentClient;
|
|
135
|
+
declare namespace createPaymentClient {
|
|
136
|
+
var fromEnv: typeof createClientFromEnv;
|
|
137
|
+
}
|
|
138
|
+
declare function createClientFromEnv(): PaymentClient;
|
|
139
|
+
|
|
140
|
+
declare const RefundReasonSymbol: unique symbol;
|
|
141
|
+
type RefundReason = string & {
|
|
142
|
+
readonly [RefundReasonSymbol]: true;
|
|
143
|
+
};
|
|
144
|
+
declare function RefundReason(value: string): RefundReason;
|
|
145
|
+
|
|
146
|
+
interface MockResponse {
|
|
147
|
+
readonly status: number;
|
|
148
|
+
readonly body: string;
|
|
149
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
150
|
+
}
|
|
151
|
+
declare class MockHttpClient implements HttpClient {
|
|
152
|
+
private responses;
|
|
153
|
+
private requests;
|
|
154
|
+
on(method: string, urlMatch: string, response: MockResponse): this;
|
|
155
|
+
getRequests(): ReadonlyArray<HttpRequest>;
|
|
156
|
+
clearRequests(): void;
|
|
157
|
+
reset(): void;
|
|
158
|
+
send(request: HttpRequest): Promise<Result<HttpResponse, PaymentError>>;
|
|
159
|
+
private buildResponse;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface MockClientOptions {
|
|
163
|
+
readonly provider?: string;
|
|
164
|
+
readonly webhookSecret?: string;
|
|
165
|
+
}
|
|
166
|
+
declare function createMockClient(options?: MockClientOptions): {
|
|
167
|
+
client: PaymentClient;
|
|
168
|
+
http: MockHttpClient;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export { ConfigurationError, ErrorCode, HttpClient, HttpRequest, HttpResponse, InternalError, type MockClientOptions, MockHttpClient, type MockResponse, NetworkError, PaymentClient, PaymentClientConfig, PaymentError, PaymentErrorOptions, ProviderBadRequestError, ProviderConflictError, ProviderError, ProviderNotFoundError, ProviderRateLimitError, ProviderUnauthorizedError, ProviderUnavailableError, RefundError, RefundReason, Result, TimeoutError, UnsupportedProviderError, VERSION, ValidationError, VerificationError, createMockClient, createPaymentClient };
|