@withvlibe/base-sdk 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/README.md +369 -0
- package/dist/VlibeBaseAuth-ChuzgzDl.d.mts +562 -0
- package/dist/VlibeBaseAuth-ChuzgzDl.d.ts +562 -0
- package/dist/index.d.mts +158 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +702 -0
- package/dist/index.mjs +673 -0
- package/dist/react.d.mts +96 -0
- package/dist/react.d.ts +96 -0
- package/dist/react.js +273 -0
- package/dist/react.mjs +245 -0
- package/package.json +73 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { P as PaymentsConfig, C as ConnectStatus, a as CheckoutOptions, b as CheckoutSession, T as Transaction, R as RefundOptions } from './VlibeBaseAuth-ChuzgzDl.js';
|
|
2
|
+
export { r as Address, t as ApiResponse, A as AppCategory, e as AuthConfig, n as AuthSession, B as BasePlan, j as BaseRecord, s as CartItem, f as ColumnType, D as DatabaseConfig, F as FeatureFlag, M as Media, O as Order, q as OrderItem, o as Page, u as PaginatedResponse, p as Product, Q as QueryOptions, k as RealtimePayload, S as Subscription, g as TableColumn, i as TableInfo, h as TableSchema, U as UsageMetric, y as UseAuthReturn, w as UseCollectionOptions, v as UseCollectionReturn, x as UseKVReturn, z as UsePaymentsReturn, m as VerifyResponse, c as VlibeBaseAuth, d as VlibeBaseConfig, V as VlibeBaseDatabase, l as VlibeUser } from './VlibeBaseAuth-ChuzgzDl.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* VlibeBasePayments - Payment processing for Vlibe Base Apps
|
|
6
|
+
*
|
|
7
|
+
* Provides Stripe Connect payment processing with transaction fees.
|
|
8
|
+
* Unlike Vlibe Official (50/50 revenue split), Base apps pay a small
|
|
9
|
+
* transaction fee (0.5-2% depending on plan).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { VlibeBasePayments } from '@withvlibe/base-sdk';
|
|
14
|
+
*
|
|
15
|
+
* const payments = new VlibeBasePayments({
|
|
16
|
+
* appId: process.env.VLIBE_BASE_APP_ID!,
|
|
17
|
+
* appSecret: process.env.VLIBE_BASE_APP_SECRET!,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Create a checkout session
|
|
21
|
+
* const session = await payments.createCheckout({
|
|
22
|
+
* amount: 1999, // $19.99 in cents
|
|
23
|
+
* successUrl: '/success',
|
|
24
|
+
* cancelUrl: '/cancel',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Redirect user to session.url
|
|
28
|
+
*
|
|
29
|
+
* // Get transaction history
|
|
30
|
+
* const transactions = await payments.getTransactions();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
declare class VlibeBasePayments {
|
|
35
|
+
private appId;
|
|
36
|
+
private appSecret;
|
|
37
|
+
private baseUrl;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new VlibeBasePayments instance
|
|
40
|
+
*
|
|
41
|
+
* @param config - Payments configuration
|
|
42
|
+
* @throws Error if appId or appSecret is missing
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This class should only be used server-side. Never expose your
|
|
46
|
+
* appSecret to the client.
|
|
47
|
+
*/
|
|
48
|
+
constructor(config: PaymentsConfig);
|
|
49
|
+
/**
|
|
50
|
+
* Make an authenticated API request
|
|
51
|
+
*/
|
|
52
|
+
private apiRequest;
|
|
53
|
+
/**
|
|
54
|
+
* Get Stripe Connect onboarding URL
|
|
55
|
+
*
|
|
56
|
+
* Redirect users to this URL to connect their Stripe account.
|
|
57
|
+
*
|
|
58
|
+
* @param returnUrl - URL to return to after onboarding
|
|
59
|
+
* @returns The Stripe Connect onboarding URL
|
|
60
|
+
*/
|
|
61
|
+
getConnectOnboardingUrl(returnUrl: string): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Check Stripe Connect status
|
|
64
|
+
*
|
|
65
|
+
* @returns The current Stripe Connect status
|
|
66
|
+
*/
|
|
67
|
+
getConnectStatus(): Promise<ConnectStatus>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a checkout session for one-time payments
|
|
70
|
+
*
|
|
71
|
+
* @param options - Checkout options
|
|
72
|
+
* @returns The checkout session with URL to redirect user
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* Transaction fees are automatically calculated based on your plan:
|
|
76
|
+
* - Free plan: 2% of transaction
|
|
77
|
+
* - Premium plan: 0.5% of transaction
|
|
78
|
+
*/
|
|
79
|
+
createCheckout(options: CheckoutOptions): Promise<CheckoutSession>;
|
|
80
|
+
/**
|
|
81
|
+
* Get checkout session by ID
|
|
82
|
+
*
|
|
83
|
+
* @param sessionId - The checkout session ID
|
|
84
|
+
* @returns The checkout session details
|
|
85
|
+
*/
|
|
86
|
+
getCheckoutSession(sessionId: string): Promise<CheckoutSession | null>;
|
|
87
|
+
/**
|
|
88
|
+
* Get all transactions
|
|
89
|
+
*
|
|
90
|
+
* @param options - Query options
|
|
91
|
+
* @returns List of transactions
|
|
92
|
+
*/
|
|
93
|
+
getTransactions(options?: {
|
|
94
|
+
limit?: number;
|
|
95
|
+
offset?: number;
|
|
96
|
+
status?: 'pending' | 'succeeded' | 'failed' | 'refunded';
|
|
97
|
+
}): Promise<Transaction[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Get a single transaction
|
|
100
|
+
*
|
|
101
|
+
* @param transactionId - The transaction ID
|
|
102
|
+
* @returns The transaction details
|
|
103
|
+
*/
|
|
104
|
+
getTransaction(transactionId: string): Promise<Transaction | null>;
|
|
105
|
+
/**
|
|
106
|
+
* Get transaction summary/stats
|
|
107
|
+
*
|
|
108
|
+
* @returns Transaction statistics
|
|
109
|
+
*/
|
|
110
|
+
getTransactionStats(): Promise<{
|
|
111
|
+
totalRevenue: number;
|
|
112
|
+
totalFees: number;
|
|
113
|
+
netRevenue: number;
|
|
114
|
+
transactionCount: number;
|
|
115
|
+
thisMonth: {
|
|
116
|
+
revenue: number;
|
|
117
|
+
fees: number;
|
|
118
|
+
net: number;
|
|
119
|
+
count: number;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Create a refund
|
|
124
|
+
*
|
|
125
|
+
* @param options - Refund options
|
|
126
|
+
* @returns The updated transaction
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Note: Transaction fees are not refunded when you issue a refund.
|
|
130
|
+
*/
|
|
131
|
+
createRefund(options: RefundOptions): Promise<Transaction>;
|
|
132
|
+
/**
|
|
133
|
+
* Calculate the Vlibe fee for an amount
|
|
134
|
+
*
|
|
135
|
+
* @param amount - Amount in cents
|
|
136
|
+
* @param plan - The Base plan ('free' or 'premium')
|
|
137
|
+
* @returns The fee amount in cents
|
|
138
|
+
*/
|
|
139
|
+
calculateFee(amount: number, plan?: 'free' | 'premium'): number;
|
|
140
|
+
/**
|
|
141
|
+
* Calculate net amount after fees
|
|
142
|
+
*
|
|
143
|
+
* @param amount - Gross amount in cents
|
|
144
|
+
* @param plan - The Base plan ('free' or 'premium')
|
|
145
|
+
* @returns The net amount in cents
|
|
146
|
+
*/
|
|
147
|
+
calculateNetAmount(amount: number, plan?: 'free' | 'premium'): number;
|
|
148
|
+
/**
|
|
149
|
+
* Get the app ID
|
|
150
|
+
*/
|
|
151
|
+
getAppId(): string;
|
|
152
|
+
/**
|
|
153
|
+
* Get the base URL
|
|
154
|
+
*/
|
|
155
|
+
getBaseUrl(): string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { CheckoutOptions, CheckoutSession, ConnectStatus, PaymentsConfig, RefundOptions, Transaction, VlibeBasePayments };
|