@parsrun/payments 0.1.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/README.md +184 -0
- package/dist/billing/index.d.ts +121 -0
- package/dist/billing/index.js +1082 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing-service-LsAFesou.d.ts +578 -0
- package/dist/dunning/index.d.ts +310 -0
- package/dist/dunning/index.js +2677 -0
- package/dist/dunning/index.js.map +1 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +7698 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +1396 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/iyzico.d.ts +250 -0
- package/dist/providers/iyzico.js +469 -0
- package/dist/providers/iyzico.js.map +1 -0
- package/dist/providers/paddle.d.ts +66 -0
- package/dist/providers/paddle.js +437 -0
- package/dist/providers/paddle.js.map +1 -0
- package/dist/providers/stripe.d.ts +122 -0
- package/dist/providers/stripe.js +586 -0
- package/dist/providers/stripe.js.map +1 -0
- package/dist/schema-C5Zcju_j.d.ts +4191 -0
- package/dist/types.d.ts +388 -0
- package/dist/types.js +74 -0
- package/dist/types.js.map +1 -0
- package/dist/usage/index.d.ts +2674 -0
- package/dist/usage/index.js +2916 -0
- package/dist/usage/index.js.map +1 -0
- package/dist/webhooks/index.d.ts +89 -0
- package/dist/webhooks/index.js +188 -0
- package/dist/webhooks/index.js.map +1 -0
- package/package.json +91 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { PaymentServiceConfig, CreateCustomerOptions, Customer, CreateCheckoutOptions, CheckoutSession, CreateSubscriptionOptions, Subscription, UpdateSubscriptionOptions, CreatePortalOptions, PortalSession, Product, Price, WebhookEventType, WebhookHandler, WebhookEvent } from './types.js';
|
|
2
|
+
export { Address, BillingInterval, CheckoutLineItem, CurrencyCode, Invoice, PaddleProviderConfig, PaymentError, PaymentErrorCodes, PaymentIntent, PaymentProvider, PaymentProviderType, PaymentStatus, StripeProviderConfig, SubscriptionStatus } from './types.js';
|
|
3
|
+
export { StripeProvider, createStripeProvider } from './providers/stripe.js';
|
|
4
|
+
export { PaddleProvider, createPaddleProvider } from './providers/paddle.js';
|
|
5
|
+
export { IyzicoAddress, IyzicoBasketItem, IyzicoBuyer, IyzicoCancelResult, IyzicoCheckoutOptions, IyzicoCheckoutResult, IyzicoInstallmentResult, IyzicoPaymentResult, IyzicoProvider, IyzicoProviderConfig, IyzicoRefundResult, IyzicoThreeDSInitResult, createIyzicoProvider } from './providers/iyzico.js';
|
|
6
|
+
import { WebhookHandlerRegistry, WebhookProcessResult } from './webhooks/index.js';
|
|
7
|
+
export { WebhookProcessor, createWebhookHandler, createWebhookHandlerRegistry, createWebhookProcessor } from './webhooks/index.js';
|
|
8
|
+
import { B as BillingService, c as createBillingService } from './billing-service-LsAFesou.js';
|
|
9
|
+
export { o as BillingCustomer, a as BillingError, q as BillingErrorCode, b as BillingErrorCodes, k as BillingLogger, d as BillingRegion, j as BillingServiceConfig, n as BillingSubscription, C as CancelOptions, m as CancelResult, F as FallbackConfig, i as FallbackContext, h as FallbackOperation, G as GetSubscriptionOptions, P as ProviderRoutingRule, p as ProviderSelection, g as ProviderStrategyConfig, f as RegionDetectionContext, R as RegionDetectionResult, e as RegionDetector, S as SubscribeOptions, l as SubscribeResult } from './billing-service-LsAFesou.js';
|
|
10
|
+
export { FallbackExecutor, ProviderStrategy, createDisabledFallback, createFallbackExecutor, createProviderStrategy } from './billing/index.js';
|
|
11
|
+
import { UsageService, createUsageService } from './usage/index.js';
|
|
12
|
+
export { AccessStatus, AccessStatusInfo, AlertStatus, BillingIntegration, BillingIntegrationConfig, DrizzleDb, DrizzleUsageStorage, DrizzleUsageStorageConfig, GetUsageOptions, LimitPeriod, MemoryUsageStorage, PeriodType, Plan, PlanFeature, PlanTier, QuotaCheckResult, QuotaExceededError, QuotaManager, QuotaManagerConfig, QuotaStatus, ResetPeriod, SubscriptionEvent, SubscriptionEventType, SubscriptionHandler, SubscriptionItemMapping, SubscriptionItemResolver, SubscriptionItemResolverConfig, SubscriptionLifecycle, SyncStrategy, TrackUsageOptions, UsageAggregate, UsageAlert, UsageError, UsageErrorCode, UsageErrorCodes, UsageEvent, UsageMeter, UsageMeterConfig, UsageRecord, UsageReporter, UsageServiceConfig, UsageStorage, UsageTracker, UsageTrackerConfig, UsageWebhookEventType, createBillingIntegration, createDrizzleUsageStorage, createMemoryUsageStorage, createQuotaManager, createSubscriptionItemResolver, createSubscriptionLifecycle, createUsageMeter, createUsageTracker, integrateBillingWithUsage, usageSchema } from './usage/index.js';
|
|
13
|
+
import { D as DunningManager, c as createDunningManager } from './schema-C5Zcju_j.js';
|
|
14
|
+
export { z as DrizzleDunningStorage, a0 as DrizzleDunningStorageConfig, F as DunningAction, L as DunningContext, U as DunningEvent, V as DunningEventHandler, ad as DunningEventRow, T as DunningEventType, X as DunningLogger, W as DunningManagerConfig, Q as DunningNotification, b as DunningScheduler, Z as DunningSchedulerConfig, H as DunningSequence, h as DunningSequenceBuilder, a1 as DunningSequenceRow, J as DunningState, a7 as DunningStateRow, I as DunningStatus, G as DunningStep, g as DunningStepBuilder, a3 as DunningStepRow, Y as DunningStorage, _ as ErrorCodeMapping, K as ExecutedStep, a9 as ExecutedStepRow, M as MemoryDunningStorage, ae as NewDunningEvent, a2 as NewDunningSequence, a8 as NewDunningState, a4 as NewDunningStep, aa as NewExecutedStep, a6 as NewPaymentFailure, ag as NewRetryStrategy, ac as NewScheduledStep, N as NotificationChannel, S as NotificationResult, E as PaymentFailure, C as PaymentFailureCategory, a5 as PaymentFailureRow, p as PaymentRetrier, $ as PaymentRetrierConfig, P as PaymentRetryCalculator, O as RetryResult, R as RetryStrategy, af as RetryStrategyRow, ab as ScheduledStepRow, k as aggressiveSequence, x as allErrorCodeMappings, a as createDefaultDunningConfig, A as createDrizzleDunningStorage, e as createDunningCronHandler, f as createDunningEdgeHandler, d as createDunningScheduler, y as createMemoryDunningStorage, r as createPaymentRetrier, q as createPaymentRetryCalculator, t as defaultRetryStrategies, n as defaultSequences, B as dunningSchema, i as dunningSequence, s as dunningStep, o as getSequenceByTier, w as iyzicoErrorCodes, l as lenientSequence, m as minimalSequence, v as paddleErrorCodes, j as standardSaasSequence, u as stripeErrorCodes } from './schema-C5Zcju_j.js';
|
|
15
|
+
export { CardDetails, CreatePaymentIntentRequest, CreateRefundRequest, IyzicoConfig, Money, PaddleConfig, CreateCustomerRequest as ParsCreateCustomerRequest, CreateSubscriptionRequest as ParsCreateSubscriptionRequest, CurrencyCode as ParsCurrencyCode, PaymentIntent as ParsPaymentIntentType, PaymentMethod as ParsPaymentMethod, Price as ParsPrice, Subscription as ParsSubscription, SubscriptionStatus as ParsSubscriptionStatus, WebhookEvent as ParsWebhookEvent, WebhookEventType as ParsWebhookEventType, PaymentCustomer, PaymentIntentStatus, PaymentsConfig, PriceInterval, Refund, RefundStatus, StripeConfig, cardDetails, createCustomerRequest, createPaymentIntentRequest, createRefundRequest, createSubscriptionRequest, currencyCode, iyzicoConfig, money, paddleConfig, paymentIntent as parsPaymentIntent, price as parsPrice, subscription as parsSubscription, subscriptionStatus as parsSubscriptionStatus, paymentCustomer, paymentIntentStatus, paymentMethod, paymentsConfig, priceInterval, refund, refundStatus, stripeConfig, type, webhookEvent, webhookEventType } from '@parsrun/types';
|
|
16
|
+
import 'drizzle-orm/postgres-js';
|
|
17
|
+
import 'drizzle-orm/neon-http';
|
|
18
|
+
import 'drizzle-orm/pg-core';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @parsrun/payments
|
|
22
|
+
* Edge-compatible payment processing for Pars
|
|
23
|
+
*
|
|
24
|
+
* Supports multiple providers:
|
|
25
|
+
* - Stripe
|
|
26
|
+
* - Paddle
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { createPaymentService, createStripeProvider } from '@parsrun/payments';
|
|
31
|
+
*
|
|
32
|
+
* const payments = createPaymentService({
|
|
33
|
+
* provider: createStripeProvider({
|
|
34
|
+
* secretKey: process.env.STRIPE_SECRET_KEY,
|
|
35
|
+
* webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
36
|
+
* }),
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Create checkout session
|
|
40
|
+
* const checkout = await payments.createCheckout({
|
|
41
|
+
* lineItems: [{ priceId: 'price_xxx', quantity: 1 }],
|
|
42
|
+
* successUrl: 'https://example.com/success',
|
|
43
|
+
* cancelUrl: 'https://example.com/cancel',
|
|
44
|
+
* mode: 'subscription',
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Handle webhooks
|
|
48
|
+
* app.post('/webhooks/stripe', async (c) => {
|
|
49
|
+
* const result = await payments.handleWebhook(c.req.raw);
|
|
50
|
+
* return c.json({ received: result.success });
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Payment Service
|
|
57
|
+
* High-level payment service with provider abstraction
|
|
58
|
+
*/
|
|
59
|
+
declare class PaymentService {
|
|
60
|
+
private provider;
|
|
61
|
+
private webhookProcessor;
|
|
62
|
+
private debug;
|
|
63
|
+
constructor(config: PaymentServiceConfig);
|
|
64
|
+
/**
|
|
65
|
+
* Get provider type
|
|
66
|
+
*/
|
|
67
|
+
get providerType(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get webhook handler registry
|
|
70
|
+
*/
|
|
71
|
+
get webhooks(): WebhookHandlerRegistry;
|
|
72
|
+
/**
|
|
73
|
+
* Create a customer
|
|
74
|
+
*/
|
|
75
|
+
createCustomer(options: CreateCustomerOptions): Promise<Customer>;
|
|
76
|
+
/**
|
|
77
|
+
* Get a customer by ID
|
|
78
|
+
*/
|
|
79
|
+
getCustomer(customerId: string): Promise<Customer | null>;
|
|
80
|
+
/**
|
|
81
|
+
* Update a customer
|
|
82
|
+
*/
|
|
83
|
+
updateCustomer(customerId: string, options: Partial<CreateCustomerOptions>): Promise<Customer>;
|
|
84
|
+
/**
|
|
85
|
+
* Delete a customer
|
|
86
|
+
*/
|
|
87
|
+
deleteCustomer(customerId: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Create a checkout session
|
|
90
|
+
*/
|
|
91
|
+
createCheckout(options: CreateCheckoutOptions): Promise<CheckoutSession>;
|
|
92
|
+
/**
|
|
93
|
+
* Get a checkout session
|
|
94
|
+
*/
|
|
95
|
+
getCheckout(sessionId: string): Promise<CheckoutSession | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Create a subscription
|
|
98
|
+
*/
|
|
99
|
+
createSubscription(options: CreateSubscriptionOptions): Promise<Subscription>;
|
|
100
|
+
/**
|
|
101
|
+
* Get a subscription
|
|
102
|
+
*/
|
|
103
|
+
getSubscription(subscriptionId: string): Promise<Subscription | null>;
|
|
104
|
+
/**
|
|
105
|
+
* Update a subscription
|
|
106
|
+
*/
|
|
107
|
+
updateSubscription(subscriptionId: string, options: UpdateSubscriptionOptions): Promise<Subscription>;
|
|
108
|
+
/**
|
|
109
|
+
* Cancel a subscription
|
|
110
|
+
*/
|
|
111
|
+
cancelSubscription(subscriptionId: string, cancelAtPeriodEnd?: boolean): Promise<Subscription>;
|
|
112
|
+
/**
|
|
113
|
+
* List subscriptions for a customer
|
|
114
|
+
*/
|
|
115
|
+
listSubscriptions(customerId: string): Promise<Subscription[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Create a customer portal session
|
|
118
|
+
*/
|
|
119
|
+
createPortalSession(options: CreatePortalOptions): Promise<PortalSession>;
|
|
120
|
+
/**
|
|
121
|
+
* Get a product
|
|
122
|
+
*/
|
|
123
|
+
getProduct(productId: string): Promise<Product | null>;
|
|
124
|
+
/**
|
|
125
|
+
* Get a price
|
|
126
|
+
*/
|
|
127
|
+
getPrice(priceId: string): Promise<Price | null>;
|
|
128
|
+
/**
|
|
129
|
+
* List prices
|
|
130
|
+
*/
|
|
131
|
+
listPrices(productId?: string): Promise<Price[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Register a webhook handler
|
|
134
|
+
*/
|
|
135
|
+
onWebhook(type: WebhookEventType | "*", handler: WebhookHandler): this;
|
|
136
|
+
/**
|
|
137
|
+
* Handle a webhook request
|
|
138
|
+
*/
|
|
139
|
+
handleWebhook(request: Request): Promise<WebhookProcessResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Handle raw webhook payload
|
|
142
|
+
*/
|
|
143
|
+
handleWebhookRaw(payload: string | Uint8Array, signature: string): Promise<WebhookProcessResult>;
|
|
144
|
+
/**
|
|
145
|
+
* Verify a webhook (without handling)
|
|
146
|
+
*/
|
|
147
|
+
verifyWebhook(payload: string | Uint8Array, signature: string): Promise<WebhookEvent | null>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Create a payment service
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* // With Stripe
|
|
155
|
+
* const payments = createPaymentService({
|
|
156
|
+
* provider: createStripeProvider({
|
|
157
|
+
* secretKey: process.env.STRIPE_SECRET_KEY,
|
|
158
|
+
* webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
159
|
+
* }),
|
|
160
|
+
* });
|
|
161
|
+
*
|
|
162
|
+
* // With Paddle
|
|
163
|
+
* const payments = createPaymentService({
|
|
164
|
+
* provider: createPaddleProvider({
|
|
165
|
+
* apiKey: process.env.PADDLE_API_KEY,
|
|
166
|
+
* environment: 'sandbox',
|
|
167
|
+
* webhookSecret: process.env.PADDLE_WEBHOOK_SECRET,
|
|
168
|
+
* }),
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function createPaymentService(config: PaymentServiceConfig): PaymentService;
|
|
173
|
+
|
|
174
|
+
declare const _default: {
|
|
175
|
+
PaymentService: typeof PaymentService;
|
|
176
|
+
createPaymentService: typeof createPaymentService;
|
|
177
|
+
BillingService: typeof BillingService;
|
|
178
|
+
createBillingService: typeof createBillingService;
|
|
179
|
+
UsageService: typeof UsageService;
|
|
180
|
+
createUsageService: typeof createUsageService;
|
|
181
|
+
DunningManager: typeof DunningManager;
|
|
182
|
+
createDunningManager: typeof createDunningManager;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { BillingService, CheckoutSession, CreateCheckoutOptions, CreateCustomerOptions, CreatePortalOptions, CreateSubscriptionOptions, Customer, DunningManager, PaymentService, PaymentServiceConfig, PortalSession, Price, Product, Subscription, UpdateSubscriptionOptions, UsageService, WebhookEvent, WebhookEventType, WebhookHandler, WebhookHandlerRegistry, WebhookProcessResult, createBillingService, createDunningManager, createPaymentService, createUsageService, _default as default };
|