@base44-preview/sdk 0.8.53-pr.323.f5fc4fa → 0.8.53-pr.326.00e68ce
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 +0 -1
- package/dist/client.js +0 -3
- package/dist/client.types.d.ts +0 -5
- package/dist/index.d.ts +0 -1
- package/dist/modules/connectors.types.d.ts +30 -14
- package/package.json +1 -1
- package/dist/modules/payments-checkout.d.ts +0 -18
- package/dist/modules/payments-checkout.js +0 -239
- package/dist/modules/payments.d.ts +0 -20
- package/dist/modules/payments.js +0 -69
- package/dist/modules/payments.types.d.ts +0 -624
- package/dist/modules/payments.types.js +0 -1
package/README.md
CHANGED
|
@@ -29,7 +29,6 @@ The SDK provides access to Base44's functionality through the following modules:
|
|
|
29
29
|
- **[`entities`](https://docs.base44.com/developers/references/sdk/docs/interfaces/entities)**: Work with your app's data entities using CRUD operations.
|
|
30
30
|
- **[`functions`](https://docs.base44.com/developers/references/sdk/docs/interfaces/functions)**: Execute backend functions.
|
|
31
31
|
- **[`integrations`](https://docs.base44.com/developers/references/sdk/docs/type-aliases/integrations)**: Access pre-built and third-party integrations.
|
|
32
|
-
- **[`payments`](https://docs.base44.com/developers/references/sdk/docs/interfaces/payments)**: Embed checkouts, look up purchases, and handle refunds and subscriptions with the service role.
|
|
33
32
|
|
|
34
33
|
## Quickstarts
|
|
35
34
|
|
package/dist/client.js
CHANGED
|
@@ -14,7 +14,6 @@ import { createAppModule } from "./modules/app.js";
|
|
|
14
14
|
import { createUsersModule } from "./modules/users.js";
|
|
15
15
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
16
16
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
17
|
-
import { createPaymentsModule, createServiceRolePaymentsModule, } from "./modules/payments.js";
|
|
18
17
|
import { createActorsModule, resolveActorsHost, } from "./modules/actors.js";
|
|
19
18
|
/**
|
|
20
19
|
* Creates a Base44 client.
|
|
@@ -203,7 +202,6 @@ export function createClient(config) {
|
|
|
203
202
|
appLogs: createAppLogsModule(axiosClient, appId),
|
|
204
203
|
app: createAppModule(axiosClient, appId),
|
|
205
204
|
users: createUsersModule(axiosClient, appId),
|
|
206
|
-
payments: createPaymentsModule(axiosClient, appId),
|
|
207
205
|
analytics: createAnalyticsModule({
|
|
208
206
|
axiosClient,
|
|
209
207
|
serverUrl,
|
|
@@ -254,7 +252,6 @@ export function createClient(config) {
|
|
|
254
252
|
headers: aiGatewayHeaders,
|
|
255
253
|
}),
|
|
256
254
|
appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
|
|
257
|
-
payments: createServiceRolePaymentsModule(serviceRoleAxiosClient, appId),
|
|
258
255
|
cleanup: () => {
|
|
259
256
|
if (socket) {
|
|
260
257
|
socket.disconnect();
|
package/dist/client.types.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { EntitiesModule } from "./modules/entities.types.js";
|
|
|
2
2
|
import type { IntegrationsModule } from "./modules/integrations.types.js";
|
|
3
3
|
import type { AuthModule } from "./modules/auth.types.js";
|
|
4
4
|
import type { SsoModule } from "./modules/sso.types.js";
|
|
5
|
-
import type { PaymentsModule, ServiceRolePaymentsModule } from "./modules/payments.types.js";
|
|
6
5
|
import type { ConnectorsModule, UserConnectorsModule } from "./modules/connectors.types.js";
|
|
7
6
|
import type { FunctionsModule } from "./modules/functions.types.js";
|
|
8
7
|
import type { AgentsModule } from "./modules/agents.types.js";
|
|
@@ -139,8 +138,6 @@ export interface Base44Client {
|
|
|
139
138
|
functions: FunctionsModule;
|
|
140
139
|
/** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */
|
|
141
140
|
integrations: IntegrationsModule;
|
|
142
|
-
/** {@link PaymentsModule | Payments module} for checkouts and purchases. */
|
|
143
|
-
payments: PaymentsModule;
|
|
144
141
|
/** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
|
|
145
142
|
cleanup: () => void;
|
|
146
143
|
/**
|
|
@@ -236,8 +233,6 @@ export interface Base44Client {
|
|
|
236
233
|
functions: FunctionsModule;
|
|
237
234
|
/** {@link IntegrationsModule | Integrations module} with elevated permissions. */
|
|
238
235
|
integrations: IntegrationsModule;
|
|
239
|
-
/** {@link ServiceRolePaymentsModule | Payments module} for creating checkouts, refunds, and subscription changes. */
|
|
240
|
-
payments: ServiceRolePaymentsModule;
|
|
241
236
|
/** {@link SsoModule | SSO module} for generating SSO tokens. */
|
|
242
237
|
sso: SsoModule;
|
|
243
238
|
/** Cleanup function to disconnect WebSocket connections. */
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
|
14
14
|
export type { AppModule, AppPublicSettings, AppPublicSettingsResponse, } from "./modules/app.types.js";
|
|
15
15
|
export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, } from "./modules/actors.types.js";
|
|
16
16
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
17
|
-
export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
|
|
18
17
|
export { Actor, type Conn } from "./actor.js";
|
|
19
18
|
export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
|
|
20
19
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
|
@@ -44,16 +44,28 @@ export interface AppUserConnectorConnectionResponse {
|
|
|
44
44
|
/**
|
|
45
45
|
* How far a metered connector call progressed through the Base44 proxy.
|
|
46
46
|
*
|
|
47
|
-
* Only `not_sent` proves that the provider
|
|
48
|
-
* `timed_out` and `sent_unconfirmed`
|
|
49
|
-
* automatically retry non-idempotent
|
|
47
|
+
* Only `not_sent` proves that the provider didn't execute the request.
|
|
48
|
+
* `timed_out` and `sent_unconfirmed` don't prove that, so don't
|
|
49
|
+
* automatically retry a non-idempotent request based on those phases.
|
|
50
50
|
*/
|
|
51
|
-
export type ConnectorApiResponsePhase =
|
|
51
|
+
export type ConnectorApiResponsePhase =
|
|
52
|
+
/** The provider didn't execute the request. Only this phase proves that. */
|
|
53
|
+
"not_sent"
|
|
54
|
+
/** The provider returned a response. */
|
|
55
|
+
| "responded"
|
|
56
|
+
/** The call timed out. This doesn't prove the provider didn't execute the request. */
|
|
57
|
+
| "timed_out"
|
|
58
|
+
/** The request was sent, and completion wasn't confirmed. This doesn't prove the provider didn't execute the request. */
|
|
59
|
+
| "sent_unconfirmed";
|
|
52
60
|
/**
|
|
53
61
|
* A request to forward to a metered connector's API through the Base44 proxy.
|
|
54
62
|
*/
|
|
55
63
|
export interface ConnectorApiRequest {
|
|
56
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* HTTP method for the upstream request.
|
|
66
|
+
*
|
|
67
|
+
* Default: `'GET'`.
|
|
68
|
+
*/
|
|
57
69
|
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
|
58
70
|
/**
|
|
59
71
|
* Which of the connector's API hosts to call, by the name it declares.
|
|
@@ -79,7 +91,7 @@ export interface ConnectorApiRequest {
|
|
|
79
91
|
* The upstream API's response, as returned by the Base44 connector proxy.
|
|
80
92
|
*/
|
|
81
93
|
export interface ConnectorApiResponse<T = unknown> {
|
|
82
|
-
/**
|
|
94
|
+
/** Whether the upstream API returned a 2xx status. Proxy and upstream errors are `false`. */
|
|
83
95
|
success: boolean;
|
|
84
96
|
/** How far the call progressed. Only `not_sent` proves the provider did not execute it. */
|
|
85
97
|
phase: ConnectorApiResponsePhase;
|
|
@@ -87,7 +99,7 @@ export interface ConnectorApiResponse<T = unknown> {
|
|
|
87
99
|
status: number | null;
|
|
88
100
|
/**
|
|
89
101
|
* The parsed upstream response body, or proxy error details when no response
|
|
90
|
-
* was received. `null` when the response was binary
|
|
102
|
+
* was received. `null` when the response was binary. See {@link dataBase64}.
|
|
91
103
|
*/
|
|
92
104
|
data: T | null;
|
|
93
105
|
/**
|
|
@@ -148,15 +160,17 @@ export interface ConnectorProxyRawResponse {
|
|
|
148
160
|
*
|
|
149
161
|
* ## Metered connectors
|
|
150
162
|
*
|
|
151
|
-
* A few [platform connectors](#shared-connectors) are backed by paid
|
|
163
|
+
* A few [platform connectors](#shared-connectors) are backed by paid 3rd-party APIs that charge Base44 per call. For those, the OAuth token isn't available to your code. {@linkcode getConnection | getConnection()} rejects with a `403`. Call them with {@linkcode callApi | callApi()} instead. The proxy attaches the credential server-side, forwards the request, and bills your workspace's integration credits for the call.
|
|
152
164
|
*
|
|
153
|
-
* This applies to platform connectors only. A workspace-registered or app user connector runs on
|
|
165
|
+
* This applies to platform connectors only. A workspace-registered or app user connector runs on your own OAuth app, so the provider invoices you directly and there's nothing for Base44 to meter. Those keep normal token access via {@linkcode getWorkspaceConnection | getWorkspaceConnection()} and {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()}.
|
|
154
166
|
*
|
|
155
|
-
*
|
|
167
|
+
* Keep the following in mind when writing against a metered connector:
|
|
156
168
|
*
|
|
157
169
|
* - **Cost varies by endpoint, sometimes sharply.** The same connector can charge two orders of magnitude more for one endpoint than another, so avoid putting an expensive call inside a loop and batch wherever the provider supports it. Each response reports what it actually cost as `creditsCharged`.
|
|
158
|
-
* - **Provider and transport outcomes are returned, not thrown.** A provider `4xx`/`5xx` or a connection failure comes back as `success: false` with its `phase
|
|
159
|
-
* - **Only `phase: 'not_sent'` proves the provider
|
|
170
|
+
* - **Provider and transport outcomes are returned, not thrown.** A provider `4xx`/`5xx` or a connection failure comes back as `success: false` with its `phase`. Authorization, quota, and invalid proxy requests reject the promise.
|
|
171
|
+
* - **Only `phase: 'not_sent'` proves the provider didn't execute the request.** A timeout or an in-flight failure doesn't prove the provider didn't execute the request, so don't automatically retry a non-idempotent call unless the provider supports an idempotency key.
|
|
172
|
+
*
|
|
173
|
+
* Pass a {@link ConnectorApiRequest} to {@linkcode callApi | callApi()}. It returns a {@link ConnectorApiResponse}. {@link ConnectorApiResponsePhase} reports how far that call progressed through the proxy.
|
|
160
174
|
*
|
|
161
175
|
* ## Available connectors
|
|
162
176
|
*
|
|
@@ -418,11 +432,13 @@ export interface ConnectorsModule {
|
|
|
418
432
|
/**
|
|
419
433
|
* Calls a [metered connector's](#metered-connectors) API through the Base44 proxy.
|
|
420
434
|
*
|
|
421
|
-
* Use this for a shared platform connector identified by an integration type.
|
|
435
|
+
* Use this for a shared platform connector identified by an integration type. The proxy adds the OAuth credential to the outgoing request, forwards it, and bills the workspace for the call, so you don't handle the token yourself.
|
|
436
|
+
*
|
|
437
|
+
* An upstream error is reported in `success` and `status`, not thrown. Only Base44-side failures reject the promise.
|
|
422
438
|
*
|
|
423
439
|
* @param integrationType - The type of integration, such as `'x'`. See [Available connectors](#available-connectors).
|
|
424
440
|
* @param request - The upstream request to forward. See {@link ConnectorApiRequest}.
|
|
425
|
-
* @returns Promise resolving to a {@link ConnectorApiResponse}.
|
|
441
|
+
* @returns Promise resolving to a {@link ConnectorApiResponse}.
|
|
426
442
|
*
|
|
427
443
|
* @example
|
|
428
444
|
* ```typescript
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CheckoutElement, CheckoutMount, CompleteCheckoutResult, MountableCheckout, MountCheckoutOptions } from "./payments.types.js";
|
|
2
|
-
/** @internal */
|
|
3
|
-
export type LoadScript = (src: string) => Promise<void>;
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface MountCheckoutDeps {
|
|
6
|
-
completeCheckout: (checkoutId: string) => Promise<CompleteCheckoutResult>;
|
|
7
|
-
loadScript: LoadScript;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Appends a script tag once per URL and resolves when it loads.
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const loadScript: LoadScript;
|
|
14
|
-
/**
|
|
15
|
-
* Mounts the embedded checkout that createCheckout() returned.
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export declare function mountCheckout(element: CheckoutElement, checkout: MountableCheckout, options: MountCheckoutOptions, deps: MountCheckoutDeps): Promise<CheckoutMount>;
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
// PayPal JS SDK v6: https://developer.paypal.com/sdk/js/reference
|
|
2
|
-
const PAYPAL_SCRIPT_URLS = {
|
|
3
|
-
live: "https://www.paypal.com/web-sdk/v6/core",
|
|
4
|
-
sandbox: "https://www.sandbox.paypal.com/web-sdk/v6/core",
|
|
5
|
-
};
|
|
6
|
-
// Use v3 rather than a dated release, because Base44 creates sessions with ui_mode "embedded",
|
|
7
|
-
// which dahlia and later reject.
|
|
8
|
-
const STRIPE_SCRIPT_URL = "https://js.stripe.com/v3/";
|
|
9
|
-
function browserGlobals() {
|
|
10
|
-
return window;
|
|
11
|
-
}
|
|
12
|
-
const scriptLoads = new Map();
|
|
13
|
-
/**
|
|
14
|
-
* Appends a script tag once per URL and resolves when it loads.
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export const loadScript = (src) => {
|
|
18
|
-
let load = scriptLoads.get(src);
|
|
19
|
-
if (!load) {
|
|
20
|
-
load = new Promise((resolve, reject) => {
|
|
21
|
-
const script = document.createElement("script");
|
|
22
|
-
script.src = src;
|
|
23
|
-
script.async = true;
|
|
24
|
-
script.onload = () => resolve();
|
|
25
|
-
script.onerror = () => {
|
|
26
|
-
// Forget the failure so a later mount can retry.
|
|
27
|
-
scriptLoads.delete(src);
|
|
28
|
-
script.remove();
|
|
29
|
-
reject(new Error(`Failed to load ${src}`));
|
|
30
|
-
};
|
|
31
|
-
document.head.appendChild(script);
|
|
32
|
-
});
|
|
33
|
-
scriptLoads.set(src, load);
|
|
34
|
-
}
|
|
35
|
-
return load;
|
|
36
|
-
};
|
|
37
|
-
async function loadGlobal(src, read, load) {
|
|
38
|
-
if (!read()) {
|
|
39
|
-
await load(src);
|
|
40
|
-
}
|
|
41
|
-
const value = read();
|
|
42
|
-
if (!value) {
|
|
43
|
-
throw new Error(`${src} loaded but didn't define its global`);
|
|
44
|
-
}
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
// Stripe asks for a single Stripe instance per key.
|
|
48
|
-
const stripeInstances = new Map();
|
|
49
|
-
// Stripe allows one Embedded Checkout at a time, so mounts run in order and replace the last.
|
|
50
|
-
let stripeQueue = Promise.resolve();
|
|
51
|
-
let activeStripeCheckout = null;
|
|
52
|
-
function mountStripe(element, embedded, deps) {
|
|
53
|
-
const mount = stripeQueue.then(async () => {
|
|
54
|
-
var _a;
|
|
55
|
-
const Stripe = await loadGlobal(STRIPE_SCRIPT_URL, () => browserGlobals().Stripe, deps.loadScript);
|
|
56
|
-
let stripe = stripeInstances.get(embedded.publishable_key);
|
|
57
|
-
if (!stripe) {
|
|
58
|
-
stripe = Stripe(embedded.publishable_key);
|
|
59
|
-
stripeInstances.set(embedded.publishable_key, stripe);
|
|
60
|
-
}
|
|
61
|
-
// Try the pre-dahlia name first, since dahlia and later reject the ui_mode Base44 sessions use.
|
|
62
|
-
// A newer Stripe.js that the app loaded itself is still tried rather than refused.
|
|
63
|
-
const create = (_a = stripe.initEmbeddedCheckout) !== null && _a !== void 0 ? _a : stripe.createEmbeddedCheckoutPage;
|
|
64
|
-
if (typeof create !== "function") {
|
|
65
|
-
throw new Error("Stripe.js doesn't support Embedded Checkout");
|
|
66
|
-
}
|
|
67
|
-
activeStripeCheckout === null || activeStripeCheckout === void 0 ? void 0 : activeStripeCheckout.destroy();
|
|
68
|
-
const checkout = await create.call(stripe, {
|
|
69
|
-
fetchClientSecret: () => Promise.resolve(embedded.client_secret),
|
|
70
|
-
});
|
|
71
|
-
try {
|
|
72
|
-
checkout.mount(element);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
checkout.destroy();
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
let destroyed = false;
|
|
79
|
-
const handle = {
|
|
80
|
-
destroy() {
|
|
81
|
-
if (destroyed)
|
|
82
|
-
return;
|
|
83
|
-
destroyed = true;
|
|
84
|
-
if (activeStripeCheckout === handle)
|
|
85
|
-
activeStripeCheckout = null;
|
|
86
|
-
checkout.destroy();
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
activeStripeCheckout = handle;
|
|
90
|
-
return handle;
|
|
91
|
-
});
|
|
92
|
-
stripeQueue = mount.catch(() => undefined);
|
|
93
|
-
return mount;
|
|
94
|
-
}
|
|
95
|
-
// The v6 script for one environment defines the same global as the other's.
|
|
96
|
-
let loadedPayPalEnvironment;
|
|
97
|
-
async function mountPayPal(element, checkoutId, currency, embedded, options, deps) {
|
|
98
|
-
var _a;
|
|
99
|
-
const environment = embedded.environment;
|
|
100
|
-
const scriptUrl = PAYPAL_SCRIPT_URLS[environment];
|
|
101
|
-
if (!scriptUrl) {
|
|
102
|
-
throw new Error("This checkout is missing embedded.environment. Pass the full result of createCheckout() to mountCheckout().");
|
|
103
|
-
}
|
|
104
|
-
if (loadedPayPalEnvironment && loadedPayPalEnvironment !== environment) {
|
|
105
|
-
throw new Error(`PayPal's ${loadedPayPalEnvironment} script is already loaded on this page, so a ${environment} checkout can't mount. Reload the page first.`);
|
|
106
|
-
}
|
|
107
|
-
// The environment of a PayPal script the app loaded itself can't be detected, so it's trusted.
|
|
108
|
-
if (!browserGlobals().paypal && !loadedPayPalEnvironment) {
|
|
109
|
-
loadedPayPalEnvironment = environment;
|
|
110
|
-
}
|
|
111
|
-
let paypal;
|
|
112
|
-
try {
|
|
113
|
-
paypal = await loadGlobal(scriptUrl, () => browserGlobals().paypal, deps.loadScript);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
if (!browserGlobals().paypal)
|
|
117
|
-
loadedPayPalEnvironment = undefined;
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
if (typeof paypal.createInstance !== "function") {
|
|
121
|
-
throw new Error("Another PayPal JS SDK version is already loaded on this page. Remove it to use mountCheckout().");
|
|
122
|
-
}
|
|
123
|
-
const subscription = embedded.intent === "subscription";
|
|
124
|
-
const sdk = await paypal.createInstance({
|
|
125
|
-
clientId: embedded.client_id,
|
|
126
|
-
merchantId: embedded.merchant_id,
|
|
127
|
-
// Sent only when set, since the backend returns null when no attribution ID is configured.
|
|
128
|
-
...(embedded.partner_attribution_id
|
|
129
|
-
? { partnerAttributionId: embedded.partner_attribution_id }
|
|
130
|
-
: {}),
|
|
131
|
-
components: [subscription ? "paypal-subscriptions" : "paypal-payments"],
|
|
132
|
-
pageType: "checkout",
|
|
133
|
-
});
|
|
134
|
-
const methods = await sdk.findEligibleMethods({
|
|
135
|
-
currencyCode: currency.toUpperCase(),
|
|
136
|
-
...(subscription ? { paymentFlow: "RECURRING_PAYMENT" } : {}),
|
|
137
|
-
});
|
|
138
|
-
if (!methods.isEligible("paypal")) {
|
|
139
|
-
throw new Error("PayPal isn't available for this checkout");
|
|
140
|
-
}
|
|
141
|
-
const createSession = subscription
|
|
142
|
-
? (_a = sdk.createPayPalSubscriptionPaymentSession) !== null && _a !== void 0 ? _a : sdk.createPayPalSubscriptionSession
|
|
143
|
-
: sdk.createPayPalOneTimePaymentSession;
|
|
144
|
-
if (typeof createSession !== "function") {
|
|
145
|
-
throw new Error("The loaded PayPal JS SDK can't create this checkout");
|
|
146
|
-
}
|
|
147
|
-
let destroyed = false;
|
|
148
|
-
let completing = false;
|
|
149
|
-
// App callbacks run only while mounted, and their own errors never reach PayPal or onError.
|
|
150
|
-
const notify = (callback) => {
|
|
151
|
-
if (destroyed)
|
|
152
|
-
return;
|
|
153
|
-
try {
|
|
154
|
-
callback();
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
console.error("[Base44 SDK] A mountCheckout() callback threw", error);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
const button = document.createElement("paypal-button");
|
|
161
|
-
const session = createSession.call(sdk, {
|
|
162
|
-
// Errors are reported here, not rethrown, so PayPal doesn't report them a second time.
|
|
163
|
-
async onApprove() {
|
|
164
|
-
completing = true;
|
|
165
|
-
button.disabled = true;
|
|
166
|
-
let result;
|
|
167
|
-
try {
|
|
168
|
-
// Runs even after destroy(), so an approved payment is still captured.
|
|
169
|
-
result = await deps.completeCheckout(checkoutId);
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
// Re-enabled only on failure, since a paid order can't be approved again.
|
|
173
|
-
completing = false;
|
|
174
|
-
button.disabled = false;
|
|
175
|
-
notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
completing = false;
|
|
179
|
-
notify(() => { var _a; return (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options, result); });
|
|
180
|
-
},
|
|
181
|
-
onCancel() {
|
|
182
|
-
notify(() => { var _a; return (_a = options.onCancel) === null || _a === void 0 ? void 0 : _a.call(options); });
|
|
183
|
-
},
|
|
184
|
-
onError(error) {
|
|
185
|
-
notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
button.setAttribute("type", subscription ? "subscribe" : "pay");
|
|
189
|
-
const onClick = () => {
|
|
190
|
-
if (completing)
|
|
191
|
-
return;
|
|
192
|
-
// Not awaited before start(), which must run inside the click to open PayPal's popup.
|
|
193
|
-
const id = Promise.resolve(subscription ? { subscriptionId: checkoutId } : { orderId: checkoutId });
|
|
194
|
-
const report = (error) => notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
|
|
195
|
-
try {
|
|
196
|
-
Promise.resolve(session.start({ presentationMode: "auto" }, id)).catch(report);
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
report(error);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
button.addEventListener("click", onClick);
|
|
203
|
-
element.appendChild(button);
|
|
204
|
-
return {
|
|
205
|
-
destroy() {
|
|
206
|
-
var _a;
|
|
207
|
-
if (destroyed)
|
|
208
|
-
return;
|
|
209
|
-
destroyed = true;
|
|
210
|
-
button.removeEventListener("click", onClick);
|
|
211
|
-
button.remove();
|
|
212
|
-
(_a = session.destroy) === null || _a === void 0 ? void 0 : _a.call(session);
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Mounts the embedded checkout that createCheckout() returned.
|
|
218
|
-
* @internal
|
|
219
|
-
*/
|
|
220
|
-
export async function mountCheckout(element, checkout, options, deps) {
|
|
221
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
222
|
-
throw new Error("mountCheckout() requires a browser environment");
|
|
223
|
-
}
|
|
224
|
-
if (!element) {
|
|
225
|
-
throw new Error("mountCheckout() requires an element to render in");
|
|
226
|
-
}
|
|
227
|
-
const embedded = checkout === null || checkout === void 0 ? void 0 : checkout.embedded;
|
|
228
|
-
if (!embedded) {
|
|
229
|
-
throw new Error("This checkout isn't embedded. Create it with presentation: 'embedded', or send the buyer to its redirect_url.");
|
|
230
|
-
}
|
|
231
|
-
switch (embedded.provider) {
|
|
232
|
-
case "stripe":
|
|
233
|
-
return mountStripe(element, embedded, deps);
|
|
234
|
-
case "paypal":
|
|
235
|
-
return mountPayPal(element, checkout.checkout_id, checkout.currency, embedded, options, deps);
|
|
236
|
-
default:
|
|
237
|
-
throw new Error(`Embedded checkout isn't supported for provider ${embedded.provider}`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { PaymentsModule, ServiceRolePaymentsModule } from "./payments.types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates the payments module for anonymous and user authentication.
|
|
5
|
-
*
|
|
6
|
-
* @param axios - Axios instance
|
|
7
|
-
* @param appId - Application ID
|
|
8
|
-
* @returns Payments module for the browser
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare function createPaymentsModule(axios: AxiosInstance, appId: string): PaymentsModule;
|
|
12
|
-
/**
|
|
13
|
-
* Creates the payments module for service role authentication.
|
|
14
|
-
*
|
|
15
|
-
* @param axios - Axios instance (should be service role client)
|
|
16
|
-
* @param appId - Application ID
|
|
17
|
-
* @returns Payments module for backend functions
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export declare function createServiceRolePaymentsModule(axios: AxiosInstance, appId: string): ServiceRolePaymentsModule;
|
package/dist/modules/payments.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { loadScript, mountCheckout } from "./payments-checkout.js";
|
|
2
|
-
function requireId(value, name) {
|
|
3
|
-
if (!value || typeof value !== "string") {
|
|
4
|
-
throw new Error(`${name} is required and must be a string`);
|
|
5
|
-
}
|
|
6
|
-
return encodeURIComponent(value);
|
|
7
|
-
}
|
|
8
|
-
function createPaymentsRequests(axios, appId) {
|
|
9
|
-
const base = `/apps/${appId}/payments`;
|
|
10
|
-
return {
|
|
11
|
-
async completeCheckout(checkoutId) {
|
|
12
|
-
const id = requireId(checkoutId, "Checkout ID");
|
|
13
|
-
return axios.post(`${base}/checkout-sessions/${id}/complete`);
|
|
14
|
-
},
|
|
15
|
-
async listPurchases(params = {}) {
|
|
16
|
-
return axios.get(`${base}/purchases`, { params });
|
|
17
|
-
},
|
|
18
|
-
async createCheckout(params) {
|
|
19
|
-
return axios.post(`${base}/checkout-sessions`, params);
|
|
20
|
-
},
|
|
21
|
-
async refund(params) {
|
|
22
|
-
return axios.post(`${base}/refunds`, params);
|
|
23
|
-
},
|
|
24
|
-
async cancelSubscription(subscriptionId, options = {}) {
|
|
25
|
-
const id = requireId(subscriptionId, "Subscription ID");
|
|
26
|
-
return axios.post(`${base}/subscriptions/${id}/cancel`, options);
|
|
27
|
-
},
|
|
28
|
-
async pauseSubscription(subscriptionId) {
|
|
29
|
-
const id = requireId(subscriptionId, "Subscription ID");
|
|
30
|
-
return axios.post(`${base}/subscriptions/${id}/pause`);
|
|
31
|
-
},
|
|
32
|
-
async resumeSubscription(subscriptionId) {
|
|
33
|
-
const id = requireId(subscriptionId, "Subscription ID");
|
|
34
|
-
return axios.post(`${base}/subscriptions/${id}/resume`);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates the payments module for anonymous and user authentication.
|
|
40
|
-
*
|
|
41
|
-
* @param axios - Axios instance
|
|
42
|
-
* @param appId - Application ID
|
|
43
|
-
* @returns Payments module for the browser
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export function createPaymentsModule(axios, appId) {
|
|
47
|
-
const requests = createPaymentsRequests(axios, appId);
|
|
48
|
-
return {
|
|
49
|
-
completeCheckout: requests.completeCheckout,
|
|
50
|
-
listPurchases: requests.listPurchases,
|
|
51
|
-
mountCheckout(element, checkout, options = {}) {
|
|
52
|
-
return mountCheckout(element, checkout, options, {
|
|
53
|
-
completeCheckout: requests.completeCheckout,
|
|
54
|
-
loadScript,
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates the payments module for service role authentication.
|
|
61
|
-
*
|
|
62
|
-
* @param axios - Axios instance (should be service role client)
|
|
63
|
-
* @param appId - Application ID
|
|
64
|
-
* @returns Payments module for backend functions
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export function createServiceRolePaymentsModule(axios, appId) {
|
|
68
|
-
return createPaymentsRequests(axios, appId);
|
|
69
|
-
}
|
|
@@ -1,624 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How often a recurring item bills.
|
|
3
|
-
*/
|
|
4
|
-
export type PaymentsRecurringFrequency = "day" | "week" | "month" | "year";
|
|
5
|
-
/**
|
|
6
|
-
* Free trial before the first charge of a recurring item.
|
|
7
|
-
*/
|
|
8
|
-
export interface CheckoutFreeTrial {
|
|
9
|
-
/** Unit of the trial length. Stripe supports only `'day'` and `'week'`. */
|
|
10
|
-
frequency: PaymentsRecurringFrequency;
|
|
11
|
-
/** Number of `frequency` units the trial lasts, from 1 to 999. */
|
|
12
|
-
interval: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Billing terms that turn a checkout item into a subscription.
|
|
16
|
-
*/
|
|
17
|
-
export interface CheckoutItemRecurring {
|
|
18
|
-
/** Unit of the billing period. */
|
|
19
|
-
frequency: PaymentsRecurringFrequency;
|
|
20
|
-
/** Number of `frequency` units between charges, from 1 to 3650. Defaults to `1`. */
|
|
21
|
-
interval?: number;
|
|
22
|
-
/** Whether the subscription renews automatically at the end of its billing cycles. Stripe doesn't support `false`. */
|
|
23
|
-
auto_renewal?: boolean;
|
|
24
|
-
/** Number of billing cycles before the subscription ends, at least 1. Omit for no limit. Not supported for Stripe. */
|
|
25
|
-
billing_cycles?: number;
|
|
26
|
-
/** Free trial before the first charge. Stripe applies one trial to the whole checkout, so every recurring item must request the same trial. */
|
|
27
|
-
free_trial?: CheckoutFreeTrial;
|
|
28
|
-
/** Subscription title shown to the buyer, up to 150 characters. */
|
|
29
|
-
title?: string;
|
|
30
|
-
/** Subscription description shown to the buyer, up to 500 characters. */
|
|
31
|
-
description?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* A line item in a checkout.
|
|
35
|
-
*/
|
|
36
|
-
export interface CheckoutItem {
|
|
37
|
-
/** Item name shown to the buyer, 1 to 255 characters. */
|
|
38
|
-
name: string;
|
|
39
|
-
/** Unit price in the currency's minor units, such as cents. Must be greater than `0`. Providers may also reject a total below their minimum charge. */
|
|
40
|
-
amount: number;
|
|
41
|
-
/** Number of units, from 1 to 1,000,000. Defaults to `1`. */
|
|
42
|
-
quantity?: number;
|
|
43
|
-
/** Whether the item ships, so the provider collects a shipping address. */
|
|
44
|
-
shippable?: boolean;
|
|
45
|
-
/** Billing terms. Set this to sell the item as a subscription. PayPal and Wix Payments allow one recurring item per checkout, and PayPal allows no other items with it. */
|
|
46
|
-
recurring?: CheckoutItemRecurring;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Details about the buyer, used to prefill the checkout. Every field is optional.
|
|
50
|
-
*/
|
|
51
|
-
export interface CheckoutBuyer {
|
|
52
|
-
/** Buyer's email address. */
|
|
53
|
-
email?: string;
|
|
54
|
-
/** Buyer's first name. */
|
|
55
|
-
first_name?: string;
|
|
56
|
-
/** Buyer's last name. */
|
|
57
|
-
last_name?: string;
|
|
58
|
-
/** Buyer's phone number. */
|
|
59
|
-
phone?: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* How the buyer pays.
|
|
63
|
-
*
|
|
64
|
-
* - `'redirect'`: The buyer leaves the app for the provider's hosted checkout page at `redirect_url`.
|
|
65
|
-
* - `'embedded'`: The checkout renders inside the app with [`mountCheckout()`](/developers/references/sdk/docs/interfaces/payments#mountcheckout).
|
|
66
|
-
*/
|
|
67
|
-
export type CheckoutPresentation = "redirect" | "embedded";
|
|
68
|
-
/**
|
|
69
|
-
* Parameters for [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout).
|
|
70
|
-
*/
|
|
71
|
-
export interface CreateCheckoutParams {
|
|
72
|
-
/** Items to sell, 1 to 100 entries. */
|
|
73
|
-
items: CheckoutItem[];
|
|
74
|
-
/** Three-letter ISO currency code, such as `'usd'`. Defaults to the payment account's currency. Required for PayPal. */
|
|
75
|
-
currency?: string;
|
|
76
|
-
/** App-relative path the buyer returns to after paying, such as `'/thank-you'`. Must start with `/`. */
|
|
77
|
-
success_path: string;
|
|
78
|
-
/** App-relative path the buyer returns to after cancelling. Must start with `/`. Not supported for Stripe embedded checkout. */
|
|
79
|
-
cancel_path?: string;
|
|
80
|
-
/** Details about the buyer, used to prefill the checkout. */
|
|
81
|
-
buyer?: CheckoutBuyer;
|
|
82
|
-
/** Your own key-value pairs, up to 50 keys. Returned in each purchase's `metadata` to service role callers only. Not supported for PayPal. */
|
|
83
|
-
metadata?: Record<string, string>;
|
|
84
|
-
/** Key that makes retries return the same checkout instead of creating another, 1 to 200 characters. Not supported for Wix Payments or PayPal subscriptions. */
|
|
85
|
-
idempotency_key?: string;
|
|
86
|
-
/** How the buyer pays. Defaults to `'redirect'`. PayPal apps must pass `'embedded'`, and Wix Payments supports only `'redirect'`. */
|
|
87
|
-
presentation?: CheckoutPresentation;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Data that Stripe Embedded Checkout needs to render.
|
|
91
|
-
*/
|
|
92
|
-
export interface StripeEmbeddedCheckout {
|
|
93
|
-
/** Payment provider. */
|
|
94
|
-
provider: "stripe";
|
|
95
|
-
/** Stripe publishable key of the app's payment account. */
|
|
96
|
-
publishable_key: string;
|
|
97
|
-
/** Client secret of the Stripe Checkout Session. */
|
|
98
|
-
client_secret: string;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Data that the PayPal button needs to render.
|
|
102
|
-
*/
|
|
103
|
-
export interface PayPalEmbeddedCheckout {
|
|
104
|
-
/** Payment provider. */
|
|
105
|
-
provider: "paypal";
|
|
106
|
-
/** PayPal client ID. */
|
|
107
|
-
client_id: string;
|
|
108
|
-
/** PayPal merchant ID of the app's seller account. */
|
|
109
|
-
merchant_id: string;
|
|
110
|
-
/** PayPal partner attribution ID, when set. */
|
|
111
|
-
partner_attribution_id?: string | null;
|
|
112
|
-
/** Whether the checkout is a one-time payment or a subscription. */
|
|
113
|
-
intent: "capture" | "subscription";
|
|
114
|
-
/** PayPal environment the checkout was created in. */
|
|
115
|
-
environment: "sandbox" | "live";
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Data that an embedded checkout needs to render, by provider.
|
|
119
|
-
*/
|
|
120
|
-
export type EmbeddedCheckout = StripeEmbeddedCheckout | PayPalEmbeddedCheckout;
|
|
121
|
-
/**
|
|
122
|
-
* Result of [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout).
|
|
123
|
-
*
|
|
124
|
-
* Exactly one of `redirect_url` and `embedded` is set, depending on the checkout's `presentation`.
|
|
125
|
-
*/
|
|
126
|
-
export interface CreateCheckoutResult {
|
|
127
|
-
/** ID of the checkout. For Stripe it's the Checkout Session ID, and for PayPal it's the PayPal order or subscription ID. */
|
|
128
|
-
checkout_id: string;
|
|
129
|
-
/** Three-letter ISO currency code of the checkout, in lowercase. */
|
|
130
|
-
currency: string;
|
|
131
|
-
/** Amount the buyer pays now, in minor units. It's `0` for a subscription that starts with a free trial. */
|
|
132
|
-
amount_total: number;
|
|
133
|
-
/** Absolute URL of the provider's hosted checkout page, for redirect checkouts. */
|
|
134
|
-
redirect_url: string | null;
|
|
135
|
-
/** Data for [`mountCheckout()`](/developers/references/sdk/docs/interfaces/payments#mountcheckout), for embedded checkouts. */
|
|
136
|
-
embedded: EmbeddedCheckout | null;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Result of [`completeCheckout()`](/developers/references/sdk/docs/interfaces/payments#completecheckout).
|
|
140
|
-
*/
|
|
141
|
-
export interface CompleteCheckoutResult {
|
|
142
|
-
/** ID of the checkout. */
|
|
143
|
-
checkout_id: string;
|
|
144
|
-
/** Whether the payment went through or the provider is still processing it. */
|
|
145
|
-
status: "paid" | "pending";
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Status of a purchase.
|
|
149
|
-
*
|
|
150
|
-
* - `'pending'`: The buyer hasn't finished paying, or the provider is still processing the payment.
|
|
151
|
-
* - `'paid'`: The payment went through.
|
|
152
|
-
* - `'refunded'`: The payment was refunded.
|
|
153
|
-
* - `'canceled'`: The checkout or subscription was canceled.
|
|
154
|
-
* - `'failed'`: The payment failed.
|
|
155
|
-
* - `'unknown'`: The provider reported a state that doesn't map to the others.
|
|
156
|
-
*/
|
|
157
|
-
export type PurchaseStatus = "pending" | "paid" | "refunded" | "canceled" | "failed" | "unknown";
|
|
158
|
-
/**
|
|
159
|
-
* A line item of a purchase.
|
|
160
|
-
*/
|
|
161
|
-
export interface PurchaseItem {
|
|
162
|
-
/** Item name. */
|
|
163
|
-
name: string;
|
|
164
|
-
/** Unit price in minor units, when the provider reports it. */
|
|
165
|
-
amount?: number | null;
|
|
166
|
-
/** Number of units, when the provider reports it. */
|
|
167
|
-
quantity?: number | null;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* A completed or in-progress checkout.
|
|
171
|
-
*/
|
|
172
|
-
export interface Purchase {
|
|
173
|
-
/** ID of the checkout the purchase came from. */
|
|
174
|
-
checkout_id: string;
|
|
175
|
-
/** Status of the purchase. */
|
|
176
|
-
status: PurchaseStatus;
|
|
177
|
-
/** Line items of the purchase. */
|
|
178
|
-
items: PurchaseItem[];
|
|
179
|
-
/** Total amount in minor units. */
|
|
180
|
-
amount_total?: number | null;
|
|
181
|
-
/** Three-letter ISO currency code, in lowercase. */
|
|
182
|
-
currency?: string | null;
|
|
183
|
-
/** Buyer's email address. */
|
|
184
|
-
buyer_email?: string | null;
|
|
185
|
-
/** The metadata passed to [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout). Always `null` unless you call with the service role. */
|
|
186
|
-
metadata?: Record<string, string> | null;
|
|
187
|
-
/** ID of the subscription, for recurring purchases. */
|
|
188
|
-
subscription_id?: string | null;
|
|
189
|
-
/** ID of the payment to pass to [`refund()`](/developers/references/sdk/docs/interfaces/service-role-payments#refund). It's `null` where the provider doesn't name a single payment, such as PayPal subscriptions. */
|
|
190
|
-
payment_id?: string | null;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Parameters for [`listPurchases()`](/developers/references/sdk/docs/interfaces/payments#listpurchases).
|
|
194
|
-
*/
|
|
195
|
-
export interface ListPurchasesParams {
|
|
196
|
-
/** Only return the purchase from this checkout. */
|
|
197
|
-
checkout_id?: string;
|
|
198
|
-
/** Only return purchases of this subscription. */
|
|
199
|
-
subscription_id?: string;
|
|
200
|
-
/** Maximum number of purchases to return, from 1 to 100. Defaults to `20`. */
|
|
201
|
-
limit?: number;
|
|
202
|
-
/** The `next_cursor` from the previous page. Send the same filters and `limit` as that call. */
|
|
203
|
-
cursor?: string;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Parameters for [`listPurchases()`](/developers/references/sdk/docs/interfaces/service-role-payments#listpurchases) with the service role.
|
|
207
|
-
*/
|
|
208
|
-
export interface ServiceRoleListPurchasesParams extends ListPurchasesParams {
|
|
209
|
-
/** Only return purchases made with this email address. */
|
|
210
|
-
buyer_email?: string;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* A page of purchases.
|
|
214
|
-
*/
|
|
215
|
-
export interface ListPurchasesResult {
|
|
216
|
-
/** Purchases on this page. */
|
|
217
|
-
items: Purchase[];
|
|
218
|
-
/** Cursor for the next page, or `null` on the last page. */
|
|
219
|
-
next_cursor: string | null;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Parameters for [`refund()`](/developers/references/sdk/docs/interfaces/service-role-payments#refund).
|
|
223
|
-
*/
|
|
224
|
-
export interface RefundParams {
|
|
225
|
-
/** The `payment_id` of the purchase to refund. */
|
|
226
|
-
payment_id: string;
|
|
227
|
-
/** Amount to refund in minor units. Must be greater than `0`. */
|
|
228
|
-
amount: number;
|
|
229
|
-
/** Key that makes retries return the original refund instead of refunding twice, 1 to 100 characters. */
|
|
230
|
-
idempotency_key: string;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Result of [`refund()`](/developers/references/sdk/docs/interfaces/service-role-payments#refund).
|
|
234
|
-
*/
|
|
235
|
-
export interface RefundResult {
|
|
236
|
-
/** Provider's ID of the refund. */
|
|
237
|
-
refund_id: string;
|
|
238
|
-
/** ID of the refunded payment. */
|
|
239
|
-
payment_id: string;
|
|
240
|
-
/** Refunded amount in minor units. */
|
|
241
|
-
amount: number;
|
|
242
|
-
/** Three-letter ISO currency code, in lowercase. */
|
|
243
|
-
currency: string;
|
|
244
|
-
/** Whether the refund went through or the provider is still processing it. */
|
|
245
|
-
status: "succeeded" | "pending";
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Options for [`cancelSubscription()`](/developers/references/sdk/docs/interfaces/service-role-payments#cancelsubscription).
|
|
249
|
-
*/
|
|
250
|
-
export interface CancelSubscriptionOptions {
|
|
251
|
-
/** Cancel at the end of the current billing period instead of now. Defaults to `false`. Not supported for PayPal. */
|
|
252
|
-
at_period_end?: boolean;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* State of a subscription after a change.
|
|
256
|
-
*/
|
|
257
|
-
export interface SubscriptionResult {
|
|
258
|
-
/** ID of the subscription. */
|
|
259
|
-
subscription_id: string;
|
|
260
|
-
/** Current status of the subscription. */
|
|
261
|
-
status: "active" | "past_due" | "paused" | "canceled";
|
|
262
|
-
/** Whether the subscription is set to cancel at the end of the current billing period. */
|
|
263
|
-
cancel_at_period_end: boolean;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Error codes that payments methods reject with, in the `code` of a `Base44Error`.
|
|
267
|
-
*
|
|
268
|
-
* Some notable ones:
|
|
269
|
-
*
|
|
270
|
-
* - `payment_declined`: The buyer's payment method was declined when completing the checkout. The buyer can try again with another method.
|
|
271
|
-
* - `refund_failed`: The refund's outcome is unknown. Retry with the same `idempotency_key` and `amount`, which returns the original refund if one was made.
|
|
272
|
-
* - `refund_in_progress`: A refund with the same `idempotency_key` is still running.
|
|
273
|
-
* - `refund_amount_mismatch`: The `idempotency_key` was already used for a different amount.
|
|
274
|
-
* - `rate_limited`: Too many requests. Wait for the number of seconds in the `Retry-After` response header, available at `error.originalError.response.headers['retry-after']`.
|
|
275
|
-
* - `refund_not_supported`, `subscription_action_not_supported`, `complete_not_supported`, `presentation_not_supported`: The app's payment provider doesn't support the operation.
|
|
276
|
-
*/
|
|
277
|
-
export type PaymentsErrorCode = "forbidden" | "unauthenticated" | "not_found" | "conflict" | "rate_limited" | "payments_not_connected" | "invalid_request" | "invalid_items" | "amount_below_minimum" | "currency_mismatch" | "currency_required" | "invalid_metadata" | "idempotency_not_supported" | "idempotency_key_reused" | "multiple_subscription_items" | "recurring_option_not_supported" | "invalid_cursor" | "presentation_not_supported" | "embedded_checkout_unavailable" | "checkout_not_found" | "checkout_not_approved" | "checkout_closed" | "payment_declined" | "complete_not_supported" | "provider_unavailable" | "payment_not_found" | "refund_rejected" | "refund_in_progress" | "refund_amount_mismatch" | "refund_temporarily_unavailable" | "refund_failed" | "refund_not_supported" | "subscription_not_found" | "subscription_not_active" | "subscription_action_not_supported";
|
|
278
|
-
/**
|
|
279
|
-
* Callbacks for [`mountCheckout()`](/developers/references/sdk/docs/interfaces/payments#mountcheckout).
|
|
280
|
-
*/
|
|
281
|
-
export interface MountCheckoutOptions {
|
|
282
|
-
/**
|
|
283
|
-
* Called after the buyer approves a PayPal payment and the SDK completes the checkout.
|
|
284
|
-
*
|
|
285
|
-
* Stripe doesn't call this. After a Stripe payment, the buyer returns to the checkout's `success_path` with a `session_id` query parameter. That parameter is the `checkout_id`. Check the purchase there with [`listPurchases()`](/developers/references/sdk/docs/interfaces/payments#listpurchases).
|
|
286
|
-
*/
|
|
287
|
-
onComplete?: (result: CompleteCheckoutResult) => void;
|
|
288
|
-
/** Called when the buyer closes the PayPal window without paying. The button stays mounted so the buyer can try again. */
|
|
289
|
-
onCancel?: () => void;
|
|
290
|
-
/**
|
|
291
|
-
* Called when a PayPal checkout fails after it's mounted, including a declined payment with the `payment_declined` code. The button stays mounted so the buyer can try again. If it keeps failing with `payment_declined`, create a new checkout and mount it. Stripe shows its own errors inside the checkout.
|
|
292
|
-
*
|
|
293
|
-
* The error is a `Base44Error` when completing the checkout fails, or PayPal's own error object when the PayPal window fails.
|
|
294
|
-
*/
|
|
295
|
-
onError?: (error: unknown) => void;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* An element on the page to render the checkout in, such as the result of `document.getElementById()`.
|
|
299
|
-
*
|
|
300
|
-
* Typed structurally so that the SDK's types don't require the DOM library in backend code.
|
|
301
|
-
*/
|
|
302
|
-
export interface CheckoutElement {
|
|
303
|
-
/** Present on every DOM element. */
|
|
304
|
-
appendChild(node: never): unknown;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* The fields of a {@linkcode CreateCheckoutResult} that [`mountCheckout()`](/developers/references/sdk/docs/interfaces/payments#mountcheckout) reads.
|
|
308
|
-
*/
|
|
309
|
-
export interface MountableCheckout {
|
|
310
|
-
/** ID of the checkout. */
|
|
311
|
-
checkout_id: string;
|
|
312
|
-
/** Three-letter ISO currency code of the checkout. */
|
|
313
|
-
currency: string;
|
|
314
|
-
/** Data for the embedded checkout. Mounting rejects when it's `null`. */
|
|
315
|
-
embedded: EmbeddedCheckout | null;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* A mounted embedded checkout.
|
|
319
|
-
*/
|
|
320
|
-
export interface CheckoutMount {
|
|
321
|
-
/** Removes the checkout from the page. Call it when the component that holds it unmounts. For Stripe, mounting another checkout destroys this one for you. */
|
|
322
|
-
destroy: () => void;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Payments module for selling from the app through its connected payment provider.
|
|
326
|
-
*
|
|
327
|
-
* This module provides:
|
|
328
|
-
* - An embedded checkout that renders in any framework, with a PayPal button or Stripe Embedded Checkout
|
|
329
|
-
* - Completing PayPal checkouts
|
|
330
|
-
* - Lookup of the signed-in user's purchases
|
|
331
|
-
*
|
|
332
|
-
* Creating checkouts, refunds, and subscription changes are in {@linkcode ServiceRolePaymentsModule}.
|
|
333
|
-
*
|
|
334
|
-
* Each app connects one provider, which is Stripe, PayPal, or Wix Payments. Amounts are always integers in the currency's minor units, such as cents.
|
|
335
|
-
*
|
|
336
|
-
* | | Stripe | PayPal | Wix Payments |
|
|
337
|
-
* | :- | :- | :- | :- |
|
|
338
|
-
* | Redirect checkout | Yes | No | Yes |
|
|
339
|
-
* | Embedded checkout | Yes | Yes, the only mode | No |
|
|
340
|
-
* | Refunds | Yes | Yes | No |
|
|
341
|
-
* | Cancel a subscription | Yes, now or at period end | Yes, now only | No |
|
|
342
|
-
* | Pause and resume a subscription | Yes | Yes | No |
|
|
343
|
-
*
|
|
344
|
-
* ## Authentication modes
|
|
345
|
-
*
|
|
346
|
-
* - **Anonymous or user authentication** (`base44.payments`): Completes checkouts, mounts embedded checkouts, and lists the signed-in user's own purchases.
|
|
347
|
-
* - **Service role authentication** (`base44.asServiceRole.payments`): Creates checkouts, lists any purchase, refunds payments, and changes subscriptions. Use it in backend functions.
|
|
348
|
-
*
|
|
349
|
-
* Failed requests reject with a `Base44Error` whose `code` is one of the {@linkcode PaymentsErrorCode} values. Invalid arguments and [`mountCheckout()`](#mountcheckout) failures reject with a plain `Error`.
|
|
350
|
-
*/
|
|
351
|
-
export interface PaymentsModule {
|
|
352
|
-
/**
|
|
353
|
-
* Completes a PayPal checkout after the buyer approves it.
|
|
354
|
-
*
|
|
355
|
-
* When you use {@linkcode mountCheckout | mountCheckout()}, it calls this for you. Call it yourself only if you render the PayPal button yourself. Calling it again for the same checkout returns the same result.
|
|
356
|
-
*
|
|
357
|
-
* Only PayPal checkouts need completing. Other providers reject with `complete_not_supported`.
|
|
358
|
-
*
|
|
359
|
-
* @param checkoutId - The `checkout_id` from [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout).
|
|
360
|
-
* @returns Promise resolving to the checkout's payment status.
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```typescript
|
|
364
|
-
* // Complete a PayPal checkout in your own onApprove handler
|
|
365
|
-
* const { status } = await base44.payments.completeCheckout(checkoutId);
|
|
366
|
-
* if (status === 'paid') {
|
|
367
|
-
* showThankYou();
|
|
368
|
-
* }
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
completeCheckout(checkoutId: string): Promise<CompleteCheckoutResult>;
|
|
372
|
-
/**
|
|
373
|
-
* Lists the signed-in user's purchases.
|
|
374
|
-
*
|
|
375
|
-
* Only purchases made with the user's own email address are returned. Rejects with `forbidden` when no user is signed in. PayPal apps must pass `checkout_id` or `subscription_id`, and get at most one purchase.
|
|
376
|
-
*
|
|
377
|
-
* @param params - Optional filters and pagination.
|
|
378
|
-
* @returns Promise resolving to a page of purchases.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```typescript
|
|
382
|
-
* // Check a purchase on the success page
|
|
383
|
-
* const { items } = await base44.payments.listPurchases({ checkout_id: checkoutId });
|
|
384
|
-
* const paid = items[0]?.status === 'paid';
|
|
385
|
-
* ```
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```typescript
|
|
389
|
-
* // Page through the user's purchases
|
|
390
|
-
* let cursor: string | undefined;
|
|
391
|
-
* do {
|
|
392
|
-
* const page = await base44.payments.listPurchases({ limit: 50, cursor });
|
|
393
|
-
* page.items.forEach((purchase) => console.log(purchase.checkout_id, purchase.status));
|
|
394
|
-
* cursor = page.next_cursor ?? undefined;
|
|
395
|
-
* } while (cursor);
|
|
396
|
-
* ```
|
|
397
|
-
*/
|
|
398
|
-
listPurchases(params?: ListPurchasesParams): Promise<ListPurchasesResult>;
|
|
399
|
-
/**
|
|
400
|
-
* Renders an embedded checkout inside an element on the page.
|
|
401
|
-
*
|
|
402
|
-
* Pass the result of a [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout) call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page.
|
|
403
|
-
*
|
|
404
|
-
* The SDK loads the provider's script and renders the checkout for you:
|
|
405
|
-
* - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
|
|
406
|
-
* - Stripe: Mounts Stripe Embedded Checkout. After paying, the buyer returns to the checkout's `success_path`. Stripe allows one embedded checkout per page, so mounting another Stripe checkout destroys the previous one.
|
|
407
|
-
*
|
|
408
|
-
* Requires a browser environment and can't be used in the backend. Rejects when the checkout isn't embedded, when the provider's script fails to load, or when PayPal isn't available for the checkout's currency.
|
|
409
|
-
*
|
|
410
|
-
* @param element - Element to render the checkout in. It should be empty.
|
|
411
|
-
* @param checkout - The result of [`createCheckout()`](/developers/references/sdk/docs/interfaces/service-role-payments#createcheckout).
|
|
412
|
-
* @param options - Callbacks for the checkout's outcome.
|
|
413
|
-
* @returns Promise resolving to the mounted checkout once it renders.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```typescript
|
|
417
|
-
* // Create the checkout in a backend function, then mount it
|
|
418
|
-
* const { data: checkout } = await base44.functions.invoke('createCheckout', { planId });
|
|
419
|
-
*
|
|
420
|
-
* const mount = await base44.payments.mountCheckout(
|
|
421
|
-
* document.getElementById('checkout')!,
|
|
422
|
-
* checkout,
|
|
423
|
-
* {
|
|
424
|
-
* onComplete: ({ status }) => navigate(status === 'paid' ? '/thank-you' : '/processing'),
|
|
425
|
-
* onError: () => setError('The payment failed. Please try again.'),
|
|
426
|
-
* }
|
|
427
|
-
* );
|
|
428
|
-
*
|
|
429
|
-
* // Later, when the page unmounts
|
|
430
|
-
* mount.destroy();
|
|
431
|
-
* ```
|
|
432
|
-
*
|
|
433
|
-
* @example
|
|
434
|
-
* ```tsx
|
|
435
|
-
* // React component
|
|
436
|
-
* function Checkout({ checkout }: { checkout: CreateCheckoutResult }) {
|
|
437
|
-
* const ref = useRef<HTMLDivElement>(null);
|
|
438
|
-
*
|
|
439
|
-
* useEffect(() => {
|
|
440
|
-
* let mount: CheckoutMount | undefined;
|
|
441
|
-
* let cancelled = false;
|
|
442
|
-
* base44.payments
|
|
443
|
-
* .mountCheckout(ref.current!, checkout, { onComplete: () => navigate('/thank-you') })
|
|
444
|
-
* .then((m) => (cancelled ? m.destroy() : (mount = m)))
|
|
445
|
-
* .catch(() => setError('The checkout could not load.'));
|
|
446
|
-
* return () => {
|
|
447
|
-
* cancelled = true;
|
|
448
|
-
* mount?.destroy();
|
|
449
|
-
* };
|
|
450
|
-
* }, [checkout]);
|
|
451
|
-
*
|
|
452
|
-
* return <div ref={ref} />;
|
|
453
|
-
* }
|
|
454
|
-
* ```
|
|
455
|
-
*/
|
|
456
|
-
mountCheckout(element: CheckoutElement, checkout: MountableCheckout, options?: MountCheckoutOptions): Promise<CheckoutMount>;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Payments module with service role authentication, for backend functions.
|
|
460
|
-
*
|
|
461
|
-
* Creates checkouts, lists any purchase, refunds payments, and changes subscriptions. See {@linkcode PaymentsModule} for which providers support which operations.
|
|
462
|
-
*
|
|
463
|
-
* Refunds take a required `idempotency_key` and checkouts take an optional one, so retrying them doesn't charge or refund twice. Repeating a subscription change returns the subscription's current state.
|
|
464
|
-
*/
|
|
465
|
-
export interface ServiceRolePaymentsModule {
|
|
466
|
-
/**
|
|
467
|
-
* Creates a checkout.
|
|
468
|
-
*
|
|
469
|
-
* For a redirect checkout, send the buyer to the returned `redirect_url`. For an embedded checkout, return the result to the page and pass it to [`mountCheckout()`](/developers/references/sdk/docs/interfaces/payments#mountcheckout).
|
|
470
|
-
*
|
|
471
|
-
* A checkout with a `recurring` item creates a subscription.
|
|
472
|
-
*
|
|
473
|
-
* @param params - Items, return paths, and options for the checkout.
|
|
474
|
-
* @returns Promise resolving to the checkout.
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* ```typescript
|
|
478
|
-
* // Create a redirect checkout in a backend function
|
|
479
|
-
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
480
|
-
*
|
|
481
|
-
* Deno.serve(async (req) => {
|
|
482
|
-
* const base44 = createClientFromRequest(req);
|
|
483
|
-
* const checkout = await base44.asServiceRole.payments.createCheckout({
|
|
484
|
-
* items: [{ name: 'T-shirt', amount: 2500, quantity: 2, shippable: true }],
|
|
485
|
-
* currency: 'usd',
|
|
486
|
-
* success_path: '/thank-you',
|
|
487
|
-
* cancel_path: '/cart',
|
|
488
|
-
* });
|
|
489
|
-
*
|
|
490
|
-
* return Response.json({ url: checkout.redirect_url });
|
|
491
|
-
* });
|
|
492
|
-
* ```
|
|
493
|
-
*
|
|
494
|
-
* @example
|
|
495
|
-
* ```typescript
|
|
496
|
-
* // Create an embedded subscription checkout for the signed-in user
|
|
497
|
-
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
498
|
-
*
|
|
499
|
-
* Deno.serve(async (req) => {
|
|
500
|
-
* const base44 = createClientFromRequest(req);
|
|
501
|
-
* const user = await base44.auth.me();
|
|
502
|
-
* const checkout = await base44.asServiceRole.payments.createCheckout({
|
|
503
|
-
* items: [{
|
|
504
|
-
* name: 'Pro plan',
|
|
505
|
-
* amount: 1500,
|
|
506
|
-
* recurring: { frequency: 'month', free_trial: { frequency: 'day', interval: 14 } },
|
|
507
|
-
* }],
|
|
508
|
-
* currency: 'usd',
|
|
509
|
-
* success_path: '/welcome',
|
|
510
|
-
* buyer: { email: user.email },
|
|
511
|
-
* presentation: 'embedded',
|
|
512
|
-
* });
|
|
513
|
-
*
|
|
514
|
-
* // Pass this to base44.payments.mountCheckout() on the page
|
|
515
|
-
* return Response.json(checkout);
|
|
516
|
-
* });
|
|
517
|
-
* ```
|
|
518
|
-
*/
|
|
519
|
-
createCheckout(params: CreateCheckoutParams): Promise<CreateCheckoutResult>;
|
|
520
|
-
/**
|
|
521
|
-
* Completes a PayPal checkout after the buyer approves it.
|
|
522
|
-
*
|
|
523
|
-
* See [`base44.payments.completeCheckout()`](/developers/references/sdk/docs/interfaces/payments#completecheckout).
|
|
524
|
-
*
|
|
525
|
-
* @param checkoutId - The `checkout_id` from {@linkcode createCheckout | createCheckout()}.
|
|
526
|
-
* @returns Promise resolving to the checkout's payment status.
|
|
527
|
-
*
|
|
528
|
-
* @example
|
|
529
|
-
* ```typescript
|
|
530
|
-
* // Complete a PayPal checkout from a backend function
|
|
531
|
-
* const { status } = await base44.asServiceRole.payments.completeCheckout(checkoutId);
|
|
532
|
-
* ```
|
|
533
|
-
*/
|
|
534
|
-
completeCheckout(checkoutId: string): Promise<CompleteCheckoutResult>;
|
|
535
|
-
/**
|
|
536
|
-
* Lists the app's purchases.
|
|
537
|
-
*
|
|
538
|
-
* Unlike [`base44.payments.listPurchases()`](/developers/references/sdk/docs/interfaces/payments#listpurchases), it returns any buyer's purchases and includes their `metadata`. PayPal apps must pass `checkout_id` or `subscription_id`, and get at most one purchase.
|
|
539
|
-
*
|
|
540
|
-
* @param params - Optional filters and pagination.
|
|
541
|
-
* @returns Promise resolving to a page of purchases.
|
|
542
|
-
*
|
|
543
|
-
* @example
|
|
544
|
-
* ```typescript
|
|
545
|
-
* // Find a buyer's purchases
|
|
546
|
-
* const { items } = await base44.asServiceRole.payments.listPurchases({
|
|
547
|
-
* buyer_email: 'buyer@example.com',
|
|
548
|
-
* });
|
|
549
|
-
* ```
|
|
550
|
-
*/
|
|
551
|
-
listPurchases(params?: ServiceRoleListPurchasesParams): Promise<ListPurchasesResult>;
|
|
552
|
-
/**
|
|
553
|
-
* Refunds all or part of a payment.
|
|
554
|
-
*
|
|
555
|
-
* Retrying with the same `idempotency_key` and `amount` returns the original refund instead of refunding twice. When the call rejects with `refund_failed`, the outcome is unknown, so retry it with the same values.
|
|
556
|
-
*
|
|
557
|
-
* Not supported for Wix Payments.
|
|
558
|
-
*
|
|
559
|
-
* @param params - The payment, amount, and idempotency key.
|
|
560
|
-
* @returns Promise resolving to the refund.
|
|
561
|
-
*
|
|
562
|
-
* @example
|
|
563
|
-
* ```typescript
|
|
564
|
-
* // Refund a purchase in full
|
|
565
|
-
* const { items } = await base44.asServiceRole.payments.listPurchases({ checkout_id: checkoutId });
|
|
566
|
-
* const purchase = items[0];
|
|
567
|
-
*
|
|
568
|
-
* const refund = await base44.asServiceRole.payments.refund({
|
|
569
|
-
* payment_id: purchase.payment_id!,
|
|
570
|
-
* amount: purchase.amount_total!,
|
|
571
|
-
* idempotency_key: `refund-${checkoutId}`,
|
|
572
|
-
* });
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
refund(params: RefundParams): Promise<RefundResult>;
|
|
576
|
-
/**
|
|
577
|
-
* Cancels a subscription, now or at the end of the current billing period.
|
|
578
|
-
*
|
|
579
|
-
* Not supported for Wix Payments. PayPal supports cancelling now only.
|
|
580
|
-
*
|
|
581
|
-
* @param subscriptionId - The `subscription_id` of the purchase.
|
|
582
|
-
* @param options - When to cancel.
|
|
583
|
-
* @returns Promise resolving to the subscription's state.
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* ```typescript
|
|
587
|
-
* // Cancel at the end of the billing period
|
|
588
|
-
* await base44.asServiceRole.payments.cancelSubscription(subscriptionId, {
|
|
589
|
-
* at_period_end: true,
|
|
590
|
-
* });
|
|
591
|
-
* ```
|
|
592
|
-
*/
|
|
593
|
-
cancelSubscription(subscriptionId: string, options?: CancelSubscriptionOptions): Promise<SubscriptionResult>;
|
|
594
|
-
/**
|
|
595
|
-
* Pauses a subscription's billing.
|
|
596
|
-
*
|
|
597
|
-
* Not supported for Wix Payments.
|
|
598
|
-
*
|
|
599
|
-
* @param subscriptionId - The `subscription_id` of the purchase.
|
|
600
|
-
* @returns Promise resolving to the subscription's state.
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* ```typescript
|
|
604
|
-
* // Pause a subscription
|
|
605
|
-
* await base44.asServiceRole.payments.pauseSubscription(subscriptionId);
|
|
606
|
-
* ```
|
|
607
|
-
*/
|
|
608
|
-
pauseSubscription(subscriptionId: string): Promise<SubscriptionResult>;
|
|
609
|
-
/**
|
|
610
|
-
* Resumes a paused subscription's billing.
|
|
611
|
-
*
|
|
612
|
-
* Not supported for Wix Payments.
|
|
613
|
-
*
|
|
614
|
-
* @param subscriptionId - The `subscription_id` of the purchase.
|
|
615
|
-
* @returns Promise resolving to the subscription's state.
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* ```typescript
|
|
619
|
-
* // Resume a paused subscription
|
|
620
|
-
* await base44.asServiceRole.payments.resumeSubscription(subscriptionId);
|
|
621
|
-
* ```
|
|
622
|
-
*/
|
|
623
|
-
resumeSubscription(subscriptionId: string): Promise<SubscriptionResult>;
|
|
624
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|