@phpsandbox/sdk 0.3.4 → 0.4.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 +19 -0
- package/dist/browser/phpsandbox-sdk.esm.js +324 -9
- package/dist/browser/phpsandbox-sdk.esm.min.js +10 -10
- package/dist/browser/phpsandbox-sdk.iife.js +324 -9
- package/dist/browser/phpsandbox-sdk.iife.min.js +10 -10
- package/dist/errors/index.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +8 -3
- package/dist/payments.d.ts +347 -0
- package/dist/payments.js +256 -0
- package/dist/servers.d.ts +30 -2
- package/dist/servers.js +33 -6
- package/package.json +1 -1
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type RemoteErrorSource = 'core' | 'runtime';
|
|
1
|
+
export type RemoteErrorSource = 'core' | 'platform' | 'runtime';
|
|
2
2
|
declare const remoteErrorCodes: readonly ["ActionNotFound", "AuthenticationRequired", "BadGateway", "BadRequest", "Conflict", "FileAlreadyExists", "FileIsDirectory", "FileNotDirectory", "FileNotFound", "FilesystemUnavailable", "InternalError", "InvalidArgument", "InvalidConfiguration", "InvalidRequest", "InvalidResponse", "InvalidServiceCommand", "MethodNotAllowed", "NotebookInitializationFailed", "NotebookUnavailable", "NotFound", "PayloadTooLarge", "PermissionDenied", "RateLimited", "RequestFailed", "RuntimeOperationFailed", "ServiceNotFound", "ServiceUnavailable", "UnprocessableEntity", "ValidationFailed", "WorkspaceUnavailable"];
|
|
3
3
|
export type RemoteErrorCode = (typeof remoteErrorCodes)[number];
|
|
4
4
|
export type TransportErrorCode = 'ConnectionFailed' | 'ConnectionTimeout' | 'InvalidResponse' | 'SendTimeout';
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ import { PublicationApi } from './publication/index.js';
|
|
|
18
18
|
import { ServerApi } from './servers.js';
|
|
19
19
|
import { Feedback } from './feedback.js';
|
|
20
20
|
import { IntegrationApi, SandboxIntegrationApi } from './integrations/index.js';
|
|
21
|
+
import { PaymentsApi, NotebookPayments } from './payments.js';
|
|
22
|
+
export * from './payments.js';
|
|
21
23
|
export type { Disposable } from './types.js';
|
|
22
24
|
export { LspConnection } from './lsp.js';
|
|
23
25
|
export { FileChangeFilter, FileChangeType, FileType } from './filesystem.js';
|
|
@@ -35,7 +37,7 @@ export type { ConfigPortMapping, ProjectConfig } from './config.js';
|
|
|
35
37
|
export { PHPSandboxError, RemoteError, TransportError } from './errors/index.js';
|
|
36
38
|
export type { HttpResponseDiagnostics, RemoteErrorCode, RemoteErrorSource, TransportErrorCode, ValidationErrorDetails, } from './errors/index.js';
|
|
37
39
|
export * from './publication/index.js';
|
|
38
|
-
export type { CreateServerInput, ServerData, ServerInstance, ServerListOptions, ServerMemberData, ServerSshOptions, } from './servers.js';
|
|
40
|
+
export type { CreateServerInput, ServerData, ServerInstance, ServerListOptions, ServerMemberData, ServerInvitationData, ServerInvitationTarget, ServerOrganizationTarget, ShareServerInput, ServerSshOptions, } from './servers.js';
|
|
39
41
|
export type { ConfigureFeedbackInput, FeedbackData, FeedbackListOptions, FeedbackSource, FeedbackStatus, FeedbackType, FeedbackWidgetConfig, FeedbackWidgetTarget, SubmitFeedbackInput, UpdateFeedbackInput, } from './feedback.js';
|
|
40
42
|
export type { Integration, IntegrationAuthorization, IntegrationAuthorizationType, IntegrationData, IntegrationProvider, IntegrationReference, LinkIntegrationInput, UpdateIntegrationInput, AttachSandboxIntegrationInput, SandboxIntegration, SandboxIntegrationData, SandboxIntegrationEffect, SandboxIntegrationReference, UpdateSandboxIntegrationInput, } from './integrations/index.js';
|
|
41
43
|
interface Result<TType extends 'success' | 'error' | 'running', TData extends object> {
|
|
@@ -329,6 +331,7 @@ declare class ClientImplementation {
|
|
|
329
331
|
readonly publications: PublicationApi;
|
|
330
332
|
readonly servers: ServerApi;
|
|
331
333
|
readonly integrations: IntegrationApi;
|
|
334
|
+
readonly payments: PaymentsApi;
|
|
332
335
|
readonly options: PHPSandboxClientOptions;
|
|
333
336
|
private readonly runtimeTransportValue;
|
|
334
337
|
get runtimeTransport(): RuntimeTransport;
|
|
@@ -364,6 +367,7 @@ export declare class PHPSandbox {
|
|
|
364
367
|
readonly publications: PublicationApi;
|
|
365
368
|
readonly servers: ServerApi;
|
|
366
369
|
readonly integrations: IntegrationApi;
|
|
370
|
+
readonly payments: PaymentsApi;
|
|
367
371
|
private constructor();
|
|
368
372
|
whoami(): Promise<Identity>;
|
|
369
373
|
get runtimeTransport(): RuntimeTransport;
|
|
@@ -399,6 +403,7 @@ export declare class NotebookInstance {
|
|
|
399
403
|
readonly config: Config;
|
|
400
404
|
readonly secrets: NotebookSecrets;
|
|
401
405
|
readonly integrations: SandboxIntegrationApi;
|
|
406
|
+
readonly payments: NotebookPayments;
|
|
402
407
|
readonly preview: NotebookPreview;
|
|
403
408
|
readonly mail: NotebookMail;
|
|
404
409
|
readonly feedback: Feedback;
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,8 @@ import { RestRuntimeInvoker } from './runtime/rest.js';
|
|
|
31
31
|
import { Feedback } from './feedback.js';
|
|
32
32
|
import { IntegrationApi, SandboxIntegrationApi } from './integrations/index.js';
|
|
33
33
|
import { authenticatedRequest } from './http.js';
|
|
34
|
+
import { PaymentsApi, NotebookPayments } from './payments.js';
|
|
35
|
+
export * from './payments.js';
|
|
34
36
|
export { LspConnection } from './lsp.js';
|
|
35
37
|
export { FileChangeFilter, FileChangeType, FileType } from './filesystem.js';
|
|
36
38
|
export { notebookBuiltinServices, notebookKnownServices } from './services.js';
|
|
@@ -86,6 +88,7 @@ class ClientImplementation {
|
|
|
86
88
|
this.notebook = new NotebookApi(this);
|
|
87
89
|
this.servers = new ServerApi(this);
|
|
88
90
|
this.integrations = new IntegrationApi(this);
|
|
91
|
+
this.payments = new PaymentsApi(this);
|
|
89
92
|
this.options = { ...options };
|
|
90
93
|
this.runtimeTransportValue = runtimeTransport;
|
|
91
94
|
this.baseUrl = normalizeApiBaseUrl(url);
|
|
@@ -157,7 +160,7 @@ class ClientImplementation {
|
|
|
157
160
|
headers: this.headers,
|
|
158
161
|
}));
|
|
159
162
|
if (!response.ok) {
|
|
160
|
-
throw await responseError(response);
|
|
163
|
+
throw await responseError(response, path.startsWith('/platform/') ? 'platform' : 'core');
|
|
161
164
|
}
|
|
162
165
|
if (response.status === 204) {
|
|
163
166
|
return { data: undefined };
|
|
@@ -195,10 +198,10 @@ class ClientImplementation {
|
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
async function responseError(response) {
|
|
201
|
+
async function responseError(response, source = 'core') {
|
|
199
202
|
const body = await response.text();
|
|
200
203
|
try {
|
|
201
|
-
return remoteError(
|
|
204
|
+
return remoteError(source, errorPayload(body === '' ? undefined : JSON.parse(body)), response);
|
|
202
205
|
}
|
|
203
206
|
catch {
|
|
204
207
|
return new TransportError(`PHPSandbox API returned an invalid error response (HTTP ${response.status}).`, 'InvalidResponse', response, {
|
|
@@ -220,6 +223,7 @@ export class PHPSandbox {
|
|
|
220
223
|
this.publications = client.publications;
|
|
221
224
|
this.servers = client.servers;
|
|
222
225
|
this.integrations = client.integrations;
|
|
226
|
+
this.payments = client.payments;
|
|
223
227
|
}
|
|
224
228
|
async whoami() {
|
|
225
229
|
const { data } = await this.client.get('/auth/whoami');
|
|
@@ -287,6 +291,7 @@ export class NotebookInstance {
|
|
|
287
291
|
this.config = new Config(this);
|
|
288
292
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
289
293
|
this.integrations = new SandboxIntegrationApi(this.data.id, client);
|
|
294
|
+
this.payments = new NotebookPayments(this.data.id, client);
|
|
290
295
|
this.preview = new NotebookPreview(client, this.data.id);
|
|
291
296
|
this.mail = new NotebookMail(client, this.data.id);
|
|
292
297
|
this.feedback = new Feedback(client, this.data.id);
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Client } from './index.js';
|
|
3
|
+
export declare const DEFAULT_PAYMENT_CALLBACK_PATH = "/api/phpsandbox-payments/events";
|
|
4
|
+
export declare const paymentModeSchema: z.ZodEnum<{
|
|
5
|
+
test: "test";
|
|
6
|
+
live: "live";
|
|
7
|
+
}>;
|
|
8
|
+
export type PaymentMode = z.infer<typeof paymentModeSchema>;
|
|
9
|
+
declare const accountSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
mode: z.ZodEnum<{
|
|
12
|
+
test: "test";
|
|
13
|
+
live: "live";
|
|
14
|
+
}>;
|
|
15
|
+
chargesEnabled: z.ZodBoolean;
|
|
16
|
+
payoutsEnabled: z.ZodBoolean;
|
|
17
|
+
detailsSubmitted: z.ZodBoolean;
|
|
18
|
+
requirements: z.ZodArray<z.ZodString>;
|
|
19
|
+
disabledReason: z.ZodNullable<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type PaymentAccountData = z.infer<typeof accountSchema>;
|
|
22
|
+
declare const accessSchema: z.ZodObject<{
|
|
23
|
+
subscribed: z.ZodBoolean;
|
|
24
|
+
liveAllowed: z.ZodBoolean;
|
|
25
|
+
testConfigured: z.ZodBoolean;
|
|
26
|
+
liveConfigured: z.ZodBoolean;
|
|
27
|
+
feeBasisPoints: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
canRead: z.ZodBoolean;
|
|
29
|
+
canManage: z.ZodBoolean;
|
|
30
|
+
canRefund: z.ZodBoolean;
|
|
31
|
+
recoveryEndsAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type PaymentsAccess = z.infer<typeof accessSchema>;
|
|
34
|
+
declare const applicationsSchema: z.ZodObject<{
|
|
35
|
+
notebookId: z.ZodString;
|
|
36
|
+
applications: z.ZodArray<z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
url: z.ZodNullable<z.ZodString>;
|
|
39
|
+
healthy: z.ZodBoolean;
|
|
40
|
+
passwordProtected: z.ZodBoolean;
|
|
41
|
+
deployedAt: z.ZodNullable<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type PaymentApplicationsData = z.infer<typeof applicationsSchema>;
|
|
45
|
+
declare const bindingSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
notebookId: z.ZodString;
|
|
48
|
+
applicationId: z.ZodNullable<z.ZodString>;
|
|
49
|
+
mode: z.ZodEnum<{
|
|
50
|
+
test: "test";
|
|
51
|
+
live: "live";
|
|
52
|
+
}>;
|
|
53
|
+
revision: z.ZodNumber;
|
|
54
|
+
accountId: z.ZodString;
|
|
55
|
+
enabled: z.ZodBoolean;
|
|
56
|
+
callbackUrl: z.ZodNullable<z.ZodString>;
|
|
57
|
+
originUrl: z.ZodNullable<z.ZodString>;
|
|
58
|
+
runtimeConfigured: z.ZodBoolean;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type PaymentBindingData = z.infer<typeof bindingSchema>;
|
|
61
|
+
declare const priceSchema: z.ZodObject<{
|
|
62
|
+
billingInterval: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
63
|
+
month: "month";
|
|
64
|
+
year: "year";
|
|
65
|
+
}>>>;
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
amount: z.ZodNumber;
|
|
69
|
+
currency: z.ZodString;
|
|
70
|
+
bindingId: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type PaymentPriceData = z.infer<typeof priceSchema>;
|
|
73
|
+
declare const transactionSchema: z.ZodObject<{
|
|
74
|
+
subscriptionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
75
|
+
periodStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
76
|
+
periodEnd: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
bindingId: z.ZodString;
|
|
79
|
+
orderId: z.ZodString;
|
|
80
|
+
priceId: z.ZodString;
|
|
81
|
+
amount: z.ZodNumber;
|
|
82
|
+
currency: z.ZodString;
|
|
83
|
+
feeAmount: z.ZodNumber;
|
|
84
|
+
revision: z.ZodNumber;
|
|
85
|
+
refundedAmount: z.ZodNumber;
|
|
86
|
+
status: z.ZodEnum<{
|
|
87
|
+
pending: "pending";
|
|
88
|
+
failed: "failed";
|
|
89
|
+
paid: "paid";
|
|
90
|
+
refunded: "refunded";
|
|
91
|
+
partially_refunded: "partially_refunded";
|
|
92
|
+
}>;
|
|
93
|
+
checkoutUrl: z.ZodNullable<z.ZodString>;
|
|
94
|
+
deliveredAt: z.ZodNullable<z.ZodString>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export type PaymentTransactionData = z.infer<typeof transactionSchema>;
|
|
97
|
+
declare const subscriptionSchema: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
bindingId: z.ZodString;
|
|
100
|
+
priceId: z.ZodString;
|
|
101
|
+
orderId: z.ZodString;
|
|
102
|
+
status: z.ZodEnum<{
|
|
103
|
+
pending: "pending";
|
|
104
|
+
incomplete: "incomplete";
|
|
105
|
+
incomplete_expired: "incomplete_expired";
|
|
106
|
+
trialing: "trialing";
|
|
107
|
+
active: "active";
|
|
108
|
+
past_due: "past_due";
|
|
109
|
+
canceled: "canceled";
|
|
110
|
+
unpaid: "unpaid";
|
|
111
|
+
paused: "paused";
|
|
112
|
+
}>;
|
|
113
|
+
billingInterval: z.ZodEnum<{
|
|
114
|
+
month: "month";
|
|
115
|
+
year: "year";
|
|
116
|
+
}>;
|
|
117
|
+
paidThrough: z.ZodNullable<z.ZodString>;
|
|
118
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
119
|
+
checkoutUrl: z.ZodNullable<z.ZodString>;
|
|
120
|
+
revision: z.ZodNumber;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
export type PaymentSubscriptionData = z.infer<typeof subscriptionSchema>;
|
|
123
|
+
export interface PaymentSubscriptionPortalInput {
|
|
124
|
+
returnPath: string;
|
|
125
|
+
}
|
|
126
|
+
declare const refundResultSchema: z.ZodObject<{
|
|
127
|
+
subscriptionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
128
|
+
periodStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
129
|
+
periodEnd: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
bindingId: z.ZodString;
|
|
132
|
+
orderId: z.ZodString;
|
|
133
|
+
priceId: z.ZodString;
|
|
134
|
+
amount: z.ZodNumber;
|
|
135
|
+
currency: z.ZodString;
|
|
136
|
+
feeAmount: z.ZodNumber;
|
|
137
|
+
revision: z.ZodNumber;
|
|
138
|
+
refundedAmount: z.ZodNumber;
|
|
139
|
+
status: z.ZodEnum<{
|
|
140
|
+
pending: "pending";
|
|
141
|
+
failed: "failed";
|
|
142
|
+
paid: "paid";
|
|
143
|
+
refunded: "refunded";
|
|
144
|
+
partially_refunded: "partially_refunded";
|
|
145
|
+
}>;
|
|
146
|
+
checkoutUrl: z.ZodNullable<z.ZodString>;
|
|
147
|
+
deliveredAt: z.ZodNullable<z.ZodString>;
|
|
148
|
+
refund: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
amount: z.ZodNumber;
|
|
151
|
+
status: z.ZodEnum<{
|
|
152
|
+
pending: "pending";
|
|
153
|
+
failed: "failed";
|
|
154
|
+
succeeded: "succeeded";
|
|
155
|
+
canceled: "canceled";
|
|
156
|
+
requires_action: "requires_action";
|
|
157
|
+
}>;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
export type PaymentRefundResult = z.infer<typeof refundResultSchema>;
|
|
161
|
+
declare const activationSchema: z.ZodObject<{
|
|
162
|
+
revision: z.ZodNumber;
|
|
163
|
+
reviewId: z.ZodString;
|
|
164
|
+
expiresAt: z.ZodString;
|
|
165
|
+
blockers: z.ZodArray<z.ZodString>;
|
|
166
|
+
binding: z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
notebookId: z.ZodString;
|
|
169
|
+
applicationId: z.ZodNullable<z.ZodString>;
|
|
170
|
+
mode: z.ZodEnum<{
|
|
171
|
+
test: "test";
|
|
172
|
+
live: "live";
|
|
173
|
+
}>;
|
|
174
|
+
revision: z.ZodNumber;
|
|
175
|
+
accountId: z.ZodString;
|
|
176
|
+
enabled: z.ZodBoolean;
|
|
177
|
+
callbackUrl: z.ZodNullable<z.ZodString>;
|
|
178
|
+
originUrl: z.ZodNullable<z.ZodString>;
|
|
179
|
+
runtimeConfigured: z.ZodBoolean;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
account: z.ZodObject<{
|
|
182
|
+
id: z.ZodString;
|
|
183
|
+
mode: z.ZodEnum<{
|
|
184
|
+
test: "test";
|
|
185
|
+
live: "live";
|
|
186
|
+
}>;
|
|
187
|
+
chargesEnabled: z.ZodBoolean;
|
|
188
|
+
payoutsEnabled: z.ZodBoolean;
|
|
189
|
+
detailsSubmitted: z.ZodBoolean;
|
|
190
|
+
requirements: z.ZodArray<z.ZodString>;
|
|
191
|
+
disabledReason: z.ZodNullable<z.ZodString>;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
feeBasisPoints: z.ZodNullable<z.ZodNumber>;
|
|
194
|
+
prices: z.ZodArray<z.ZodObject<{
|
|
195
|
+
billingInterval: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
196
|
+
month: "month";
|
|
197
|
+
year: "year";
|
|
198
|
+
}>>>;
|
|
199
|
+
id: z.ZodString;
|
|
200
|
+
name: z.ZodString;
|
|
201
|
+
amount: z.ZodNumber;
|
|
202
|
+
currency: z.ZodString;
|
|
203
|
+
bindingId: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
export type PaymentActivationReview = z.infer<typeof activationSchema>;
|
|
207
|
+
export interface ConfigurePaymentsInput {
|
|
208
|
+
expectedRevision: number;
|
|
209
|
+
applicationId?: string | null;
|
|
210
|
+
callbackPath?: string;
|
|
211
|
+
}
|
|
212
|
+
export interface CreatePaymentPriceInput {
|
|
213
|
+
billingInterval?: 'month' | 'year';
|
|
214
|
+
requestId: string;
|
|
215
|
+
name: string;
|
|
216
|
+
amount: number;
|
|
217
|
+
currency: string;
|
|
218
|
+
}
|
|
219
|
+
export interface CreatePaymentCheckoutInput {
|
|
220
|
+
requestId: string;
|
|
221
|
+
orderId: string;
|
|
222
|
+
priceId: string;
|
|
223
|
+
successPath: string;
|
|
224
|
+
cancelPath: string;
|
|
225
|
+
}
|
|
226
|
+
export interface RefundPaymentInput {
|
|
227
|
+
requestId: string;
|
|
228
|
+
amount?: number;
|
|
229
|
+
}
|
|
230
|
+
export declare class PaymentsApi {
|
|
231
|
+
private readonly client;
|
|
232
|
+
readonly runtime: PaymentRuntime;
|
|
233
|
+
constructor(client: Client);
|
|
234
|
+
forNotebook(notebookId: string): NotebookPayments;
|
|
235
|
+
applications(notebookId: string): Promise<PaymentApplicationsData>;
|
|
236
|
+
access(): Promise<PaymentsAccess>;
|
|
237
|
+
accounts(): Promise<PaymentAccountData[]>;
|
|
238
|
+
createAccount(mode: PaymentMode, country?: string): Promise<PaymentAccountData>;
|
|
239
|
+
onboarding(mode: PaymentMode): Promise<{
|
|
240
|
+
url: string;
|
|
241
|
+
expiresAt: string;
|
|
242
|
+
}>;
|
|
243
|
+
}
|
|
244
|
+
export declare class NotebookPayments {
|
|
245
|
+
private readonly notebookId;
|
|
246
|
+
private readonly client;
|
|
247
|
+
constructor(notebookId: string, client: Client);
|
|
248
|
+
private path;
|
|
249
|
+
get(mode?: PaymentMode): Promise<PaymentBindingData | null>;
|
|
250
|
+
configure(input: ConfigurePaymentsInput, mode?: PaymentMode): Promise<PaymentBindingData>;
|
|
251
|
+
provision(mode?: PaymentMode): Promise<PaymentBindingData>;
|
|
252
|
+
prices(mode?: PaymentMode): Promise<PaymentPriceData[]>;
|
|
253
|
+
createPrice(input: CreatePaymentPriceInput, mode?: PaymentMode): Promise<PaymentPriceData>;
|
|
254
|
+
prepareActivation(mode?: PaymentMode): Promise<PaymentActivationReview>;
|
|
255
|
+
activate(reviewId: string, mode?: PaymentMode): Promise<PaymentBindingData>;
|
|
256
|
+
disable(mode?: PaymentMode): Promise<PaymentBindingData>;
|
|
257
|
+
checkout(input: CreatePaymentCheckoutInput, mode?: PaymentMode): Promise<PaymentTransactionData>;
|
|
258
|
+
subscribe(input: CreatePaymentCheckoutInput, mode?: PaymentMode): Promise<PaymentSubscriptionData>;
|
|
259
|
+
subscriptions(mode?: PaymentMode): Promise<PaymentSubscriptionData[]>;
|
|
260
|
+
subscription(id: string, mode?: PaymentMode): Promise<PaymentSubscriptionData>;
|
|
261
|
+
cancelSubscription(id: string, mode?: PaymentMode): Promise<PaymentSubscriptionData>;
|
|
262
|
+
subscriptionPortal(id: string, input: PaymentSubscriptionPortalInput, mode?: PaymentMode): Promise<{
|
|
263
|
+
url: string;
|
|
264
|
+
}>;
|
|
265
|
+
transactions(mode?: PaymentMode): Promise<PaymentTransactionData[]>;
|
|
266
|
+
refund(id: string, input: RefundPaymentInput, mode?: PaymentMode): Promise<PaymentRefundResult>;
|
|
267
|
+
}
|
|
268
|
+
declare const paymentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
269
|
+
id: z.ZodString;
|
|
270
|
+
type: z.ZodLiteral<"payment.updated">;
|
|
271
|
+
mode: z.ZodEnum<{
|
|
272
|
+
test: "test";
|
|
273
|
+
live: "live";
|
|
274
|
+
}>;
|
|
275
|
+
transaction: z.ZodObject<{
|
|
276
|
+
subscriptionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
277
|
+
periodStart: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
278
|
+
periodEnd: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
279
|
+
id: z.ZodString;
|
|
280
|
+
bindingId: z.ZodString;
|
|
281
|
+
orderId: z.ZodString;
|
|
282
|
+
priceId: z.ZodString;
|
|
283
|
+
amount: z.ZodNumber;
|
|
284
|
+
currency: z.ZodString;
|
|
285
|
+
feeAmount: z.ZodNumber;
|
|
286
|
+
revision: z.ZodNumber;
|
|
287
|
+
refundedAmount: z.ZodNumber;
|
|
288
|
+
status: z.ZodEnum<{
|
|
289
|
+
pending: "pending";
|
|
290
|
+
failed: "failed";
|
|
291
|
+
paid: "paid";
|
|
292
|
+
refunded: "refunded";
|
|
293
|
+
partially_refunded: "partially_refunded";
|
|
294
|
+
}>;
|
|
295
|
+
checkoutUrl: z.ZodNullable<z.ZodString>;
|
|
296
|
+
deliveredAt: z.ZodNullable<z.ZodString>;
|
|
297
|
+
}, z.core.$strip>;
|
|
298
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
299
|
+
id: z.ZodString;
|
|
300
|
+
type: z.ZodLiteral<"subscription.updated">;
|
|
301
|
+
mode: z.ZodEnum<{
|
|
302
|
+
test: "test";
|
|
303
|
+
live: "live";
|
|
304
|
+
}>;
|
|
305
|
+
subscription: z.ZodObject<{
|
|
306
|
+
id: z.ZodString;
|
|
307
|
+
bindingId: z.ZodString;
|
|
308
|
+
priceId: z.ZodString;
|
|
309
|
+
orderId: z.ZodString;
|
|
310
|
+
status: z.ZodEnum<{
|
|
311
|
+
pending: "pending";
|
|
312
|
+
incomplete: "incomplete";
|
|
313
|
+
incomplete_expired: "incomplete_expired";
|
|
314
|
+
trialing: "trialing";
|
|
315
|
+
active: "active";
|
|
316
|
+
past_due: "past_due";
|
|
317
|
+
canceled: "canceled";
|
|
318
|
+
unpaid: "unpaid";
|
|
319
|
+
paused: "paused";
|
|
320
|
+
}>;
|
|
321
|
+
billingInterval: z.ZodEnum<{
|
|
322
|
+
month: "month";
|
|
323
|
+
year: "year";
|
|
324
|
+
}>;
|
|
325
|
+
paidThrough: z.ZodNullable<z.ZodString>;
|
|
326
|
+
cancelAtPeriodEnd: z.ZodBoolean;
|
|
327
|
+
checkoutUrl: z.ZodNullable<z.ZodString>;
|
|
328
|
+
revision: z.ZodNumber;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
}, z.core.$strip>], "type">;
|
|
331
|
+
export type PaymentEvent = z.infer<typeof paymentEventSchema>;
|
|
332
|
+
/** Verify the original bytes before parsing JSON. Use only in trusted server code. */
|
|
333
|
+
export declare function verifyPaymentEvent(body: string, signature: string, token: string, mode: PaymentMode, now?: number): Promise<PaymentEvent>;
|
|
334
|
+
export declare class PaymentRuntime {
|
|
335
|
+
private readonly client;
|
|
336
|
+
constructor(client: Client);
|
|
337
|
+
checkout(input: CreatePaymentCheckoutInput): Promise<PaymentTransactionData>;
|
|
338
|
+
transaction(id: string): Promise<PaymentTransactionData>;
|
|
339
|
+
subscribe(input: CreatePaymentCheckoutInput): Promise<PaymentSubscriptionData>;
|
|
340
|
+
subscription(id: string): Promise<PaymentSubscriptionData>;
|
|
341
|
+
cancelSubscription(id: string): Promise<PaymentSubscriptionData>;
|
|
342
|
+
subscriptionPortal(id: string, input: PaymentSubscriptionPortalInput): Promise<{
|
|
343
|
+
url: string;
|
|
344
|
+
}>;
|
|
345
|
+
prices(): Promise<PaymentPriceData[]>;
|
|
346
|
+
}
|
|
347
|
+
export {};
|