@wix/auto_sdk_payments_checkout-sessions 1.0.0 → 1.0.2
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/build/cjs/index.d.ts +1 -1
- package/build/cjs/index.js +10 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.typings.d.ts +59 -1
- package/build/cjs/index.typings.js +10 -0
- package/build/cjs/index.typings.js.map +1 -1
- package/build/cjs/meta.d.ts +59 -1
- package/build/cjs/meta.js +12 -0
- package/build/cjs/meta.js.map +1 -1
- package/build/es/index.d.mts +1 -1
- package/build/es/index.mjs +9 -0
- package/build/es/index.mjs.map +1 -1
- package/build/es/index.typings.d.mts +59 -1
- package/build/es/index.typings.mjs +9 -0
- package/build/es/index.typings.mjs.map +1 -1
- package/build/es/meta.d.mts +59 -1
- package/build/es/meta.mjs +11 -0
- package/build/es/meta.mjs.map +1 -1
- package/build/internal/cjs/index.d.ts +1 -1
- package/build/internal/cjs/index.js +10 -0
- package/build/internal/cjs/index.js.map +1 -1
- package/build/internal/cjs/index.typings.d.ts +59 -1
- package/build/internal/cjs/index.typings.js +10 -0
- package/build/internal/cjs/index.typings.js.map +1 -1
- package/build/internal/cjs/meta.d.ts +59 -1
- package/build/internal/cjs/meta.js +12 -0
- package/build/internal/cjs/meta.js.map +1 -1
- package/build/internal/es/index.d.mts +1 -1
- package/build/internal/es/index.mjs +9 -0
- package/build/internal/es/index.mjs.map +1 -1
- package/build/internal/es/index.typings.d.mts +59 -1
- package/build/internal/es/index.typings.mjs +9 -0
- package/build/internal/es/index.typings.mjs.map +1 -1
- package/build/internal/es/meta.d.mts +59 -1
- package/build/internal/es/meta.mjs +11 -0
- package/build/internal/es/meta.mjs.map +1 -1
- package/package.json +4 -4
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
|
|
2
2
|
import { Cart, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse } from './index.typings.js';
|
|
3
|
-
export { CallbackUrls, CheckoutSession, ConstructCheckoutSessionRequest, CustomerInfo, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse } from './index.typings.js';
|
|
3
|
+
export { CallbackUrls, CheckoutSession, ConstructCheckoutSessionRequest, CustomerInfo, FreeTrialPeriod, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionInfo, SubscriptionSettings } from './index.typings.js';
|
|
4
4
|
|
|
5
5
|
declare function constructCheckoutSession$1(httpClient: HttpClient): ConstructCheckoutSessionSignature;
|
|
6
6
|
interface ConstructCheckoutSessionSignature {
|
package/build/cjs/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
SubscriptionFrequency: () => SubscriptionFrequency,
|
|
23
24
|
constructCheckoutSession: () => constructCheckoutSession4
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -65,6 +66,14 @@ function constructCheckoutSession(payload) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
69
|
+
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
70
|
+
SubscriptionFrequency2["UNDEFINED"] = "UNDEFINED";
|
|
71
|
+
SubscriptionFrequency2["DAY"] = "DAY";
|
|
72
|
+
SubscriptionFrequency2["WEEK"] = "WEEK";
|
|
73
|
+
SubscriptionFrequency2["MONTH"] = "MONTH";
|
|
74
|
+
SubscriptionFrequency2["YEAR"] = "YEAR";
|
|
75
|
+
return SubscriptionFrequency2;
|
|
76
|
+
})(SubscriptionFrequency || {});
|
|
68
77
|
async function constructCheckoutSession2(cart, options) {
|
|
69
78
|
const { httpClient, sideEffects } = arguments[2];
|
|
70
79
|
const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
|
|
@@ -112,6 +121,7 @@ var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
|
|
|
112
121
|
var constructCheckoutSession4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(constructCheckoutSession3);
|
|
113
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
114
123
|
0 && (module.exports = {
|
|
124
|
+
SubscriptionFrequency,
|
|
115
125
|
constructCheckoutSession
|
|
116
126
|
});
|
|
117
127
|
//# sourceMappingURL=index.js.map
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.public.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.context.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Cart,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionResponse,\n constructCheckoutSession as universalConstructCheckoutSession,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/payments' };\n\nexport function constructCheckoutSession(\n httpClient: HttpClient\n): ConstructCheckoutSessionSignature {\n return (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ) =>\n universalConstructCheckoutSession(\n cart,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface ConstructCheckoutSessionSignature {\n /**\n * Constructs a new checkout session.\n * @param - Cart details including line items to be checked out.\n * @returns Response after constructing a checkout session.\n */\n (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ): Promise<ConstructCheckoutSessionResponse>;\n}\n\nexport {\n CallbackUrls,\n Cart,\n CheckoutSession,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionRequest,\n ConstructCheckoutSessionResponse,\n CustomerInfo,\n LineItem,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { constructCheckoutSession as publicConstructCheckoutSession } from './payments-platform-v1-checkout-session-checkout-sessions.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const constructCheckoutSession: MaybeContext<\n BuildRESTFunction<typeof publicConstructCheckoutSession> &\n typeof publicConstructCheckoutSession\n> = /*#__PURE__*/ createRESTModule(publicConstructCheckoutSession);\n\nexport {\n CheckoutSession,\n ConstructCheckoutSessionRequest,\n LineItem,\n CustomerInfo,\n Cart,\n CallbackUrls,\n ConstructCheckoutSessionResponse,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n ConstructCheckoutSessionOptions,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAGO;;;ACJP,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD6FA,eAAsBC,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,eAAO,uEAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AE1LO,SAASC,0BACd,YACmC;AACnC,SAAO,CACL,MAQA,YAQAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnCA,IAAAC,uBAAiC;AAG1B,IAAMC,4BAGK,2DAAiBA,yBAA8B;","names":["constructCheckoutSession","constructCheckoutSession","sdkTransformError","constructCheckoutSession","import_rest_modules","constructCheckoutSession"]}
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.public.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.context.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.context.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/** Subscription display and settings for a recurring line item. */\nexport interface SubscriptionInfo {\n /** Subscription settings such as frequency and billing cycles. */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription title shown to the buyer.\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer.\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/** Configuration for recurring subscription charges. */\nexport interface SubscriptionSettings {\n /** Frequency unit for recurring charges. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. Default: 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /** Whether the subscription renews automatically. */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.\n * @min 1\n */\n billingCycles?: number | null;\n /** Free trial period before the first charge. */\n freeTrialPeriod?: FreeTrialPeriod;\n}\n\n/** Frequency unit for subscription billing and trial periods. */\nexport enum SubscriptionFrequency {\n UNDEFINED = 'UNDEFINED',\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n YEAR = 'YEAR',\n}\n\n/** @enumType */\nexport type SubscriptionFrequencyWithLiterals =\n | SubscriptionFrequency\n | 'UNDEFINED'\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR';\n\n/** Free trial period before the first subscription charge. */\nexport interface FreeTrialPeriod {\n /** Frequency unit for the trial period. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Duration in frequency units (e.g., 14 with DAY = 14-day trial).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /** Optional. When provided, the item becomes a recurring subscription. */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Cart,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionResponse,\n constructCheckoutSession as universalConstructCheckoutSession,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/payments' };\n\nexport function constructCheckoutSession(\n httpClient: HttpClient\n): ConstructCheckoutSessionSignature {\n return (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ) =>\n universalConstructCheckoutSession(\n cart,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface ConstructCheckoutSessionSignature {\n /**\n * Constructs a new checkout session.\n * @param - Cart details including line items to be checked out.\n * @returns Response after constructing a checkout session.\n */\n (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ): Promise<ConstructCheckoutSessionResponse>;\n}\n\nexport {\n CallbackUrls,\n Cart,\n CheckoutSession,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionRequest,\n ConstructCheckoutSessionResponse,\n CustomerInfo,\n FreeTrialPeriod,\n LineItem,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n SubscriptionFrequency,\n SubscriptionInfo,\n SubscriptionSettings,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { constructCheckoutSession as publicConstructCheckoutSession } from './payments-platform-v1-checkout-session-checkout-sessions.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const constructCheckoutSession: MaybeContext<\n BuildRESTFunction<typeof publicConstructCheckoutSession> &\n typeof publicConstructCheckoutSession\n> = /*#__PURE__*/ createRESTModule(publicConstructCheckoutSession);\n\nexport { SubscriptionFrequency } from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\nexport {\n CheckoutSession,\n ConstructCheckoutSessionRequest,\n SubscriptionInfo,\n SubscriptionSettings,\n FreeTrialPeriod,\n LineItem,\n CustomerInfo,\n Cart,\n CallbackUrls,\n ConstructCheckoutSessionResponse,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n ConstructCheckoutSessionOptions,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\nexport { SubscriptionFrequencyWithLiterals } from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAGO;;;ACJP,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ADsBO,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AALG,SAAAA;AAAA,GAAA;AA4IZ,eAAsBC,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,eAAO,uEAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AE/PO,SAASC,0BACd,YACmC;AACnC,SAAO,CACL,MAQA,YAQAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnCA,IAAAC,uBAAiC;AAG1B,IAAMC,4BAGK,2DAAiBA,yBAA8B;","names":["constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession","sdkTransformError","constructCheckoutSession","import_rest_modules","constructCheckoutSession"]}
|
|
@@ -21,6 +21,62 @@ interface ConstructCheckoutSessionRequest {
|
|
|
21
21
|
/** Callback URLs for redirecting the user after checkout flow. */
|
|
22
22
|
callbackUrls: CallbackUrls;
|
|
23
23
|
}
|
|
24
|
+
/** Subscription display and settings for a recurring line item. */
|
|
25
|
+
interface SubscriptionInfo {
|
|
26
|
+
/** Subscription settings such as frequency and billing cycles. */
|
|
27
|
+
subscriptionSettings?: SubscriptionSettings;
|
|
28
|
+
/**
|
|
29
|
+
* Subscription title shown to the buyer.
|
|
30
|
+
* @maxLength 150
|
|
31
|
+
*/
|
|
32
|
+
title?: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Subscription description shown to the buyer.
|
|
35
|
+
* @maxLength 500
|
|
36
|
+
*/
|
|
37
|
+
description?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/** Configuration for recurring subscription charges. */
|
|
40
|
+
interface SubscriptionSettings {
|
|
41
|
+
/** Frequency unit for recurring charges. */
|
|
42
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
43
|
+
/**
|
|
44
|
+
* Number of frequency units between charges. Default: 1.
|
|
45
|
+
* @min 1
|
|
46
|
+
* @max 3650
|
|
47
|
+
*/
|
|
48
|
+
interval?: number | null;
|
|
49
|
+
/** Whether the subscription renews automatically. */
|
|
50
|
+
autoRenewal?: boolean | null;
|
|
51
|
+
/**
|
|
52
|
+
* Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.
|
|
53
|
+
* @min 1
|
|
54
|
+
*/
|
|
55
|
+
billingCycles?: number | null;
|
|
56
|
+
/** Free trial period before the first charge. */
|
|
57
|
+
freeTrialPeriod?: FreeTrialPeriod;
|
|
58
|
+
}
|
|
59
|
+
/** Frequency unit for subscription billing and trial periods. */
|
|
60
|
+
declare enum SubscriptionFrequency {
|
|
61
|
+
UNDEFINED = "UNDEFINED",
|
|
62
|
+
DAY = "DAY",
|
|
63
|
+
WEEK = "WEEK",
|
|
64
|
+
MONTH = "MONTH",
|
|
65
|
+
YEAR = "YEAR"
|
|
66
|
+
}
|
|
67
|
+
/** @enumType */
|
|
68
|
+
type SubscriptionFrequencyWithLiterals = SubscriptionFrequency | 'UNDEFINED' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
69
|
+
/** Free trial period before the first subscription charge. */
|
|
70
|
+
interface FreeTrialPeriod {
|
|
71
|
+
/** Frequency unit for the trial period. */
|
|
72
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
73
|
+
/**
|
|
74
|
+
* Duration in frequency units (e.g., 14 with DAY = 14-day trial).
|
|
75
|
+
* @min 1
|
|
76
|
+
* @max 999
|
|
77
|
+
*/
|
|
78
|
+
interval?: number;
|
|
79
|
+
}
|
|
24
80
|
interface LineItem {
|
|
25
81
|
/**
|
|
26
82
|
* Name or title of the item.
|
|
@@ -39,6 +95,8 @@ interface LineItem {
|
|
|
39
95
|
* @maxLength 50
|
|
40
96
|
*/
|
|
41
97
|
price?: string | null;
|
|
98
|
+
/** Optional. When provided, the item becomes a recurring subscription. */
|
|
99
|
+
subscriptionInfo?: SubscriptionInfo;
|
|
42
100
|
}
|
|
43
101
|
/** Customer information for pre-filling checkout details. */
|
|
44
102
|
interface CustomerInfo {
|
|
@@ -129,4 +187,4 @@ interface ConstructCheckoutSessionOptions {
|
|
|
129
187
|
callbackUrls: CallbackUrls;
|
|
130
188
|
}
|
|
131
189
|
|
|
132
|
-
export { type CallbackUrls, type Cart, type CheckoutSession, type ConstructCheckoutSessionOptions, type ConstructCheckoutSessionRequest, type ConstructCheckoutSessionResponse, type CustomerInfo, type LineItem, type RegisterCheckoutSessionWebhookRequest, type RegisterCheckoutSessionWebhookResponse, constructCheckoutSession };
|
|
190
|
+
export { type CallbackUrls, type Cart, type CheckoutSession, type ConstructCheckoutSessionOptions, type ConstructCheckoutSessionRequest, type ConstructCheckoutSessionResponse, type CustomerInfo, type FreeTrialPeriod, type LineItem, type RegisterCheckoutSessionWebhookRequest, type RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, type SubscriptionFrequencyWithLiterals, type SubscriptionInfo, type SubscriptionSettings, constructCheckoutSession };
|
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.typings.ts
|
|
21
21
|
var index_typings_exports = {};
|
|
22
22
|
__export(index_typings_exports, {
|
|
23
|
+
SubscriptionFrequency: () => SubscriptionFrequency,
|
|
23
24
|
constructCheckoutSession: () => constructCheckoutSession2
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_typings_exports);
|
|
@@ -65,6 +66,14 @@ function constructCheckoutSession(payload) {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
69
|
+
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
70
|
+
SubscriptionFrequency2["UNDEFINED"] = "UNDEFINED";
|
|
71
|
+
SubscriptionFrequency2["DAY"] = "DAY";
|
|
72
|
+
SubscriptionFrequency2["WEEK"] = "WEEK";
|
|
73
|
+
SubscriptionFrequency2["MONTH"] = "MONTH";
|
|
74
|
+
SubscriptionFrequency2["YEAR"] = "YEAR";
|
|
75
|
+
return SubscriptionFrequency2;
|
|
76
|
+
})(SubscriptionFrequency || {});
|
|
68
77
|
async function constructCheckoutSession2(cart, options) {
|
|
69
78
|
const { httpClient, sideEffects } = arguments[2];
|
|
70
79
|
const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
|
|
@@ -98,6 +107,7 @@ async function constructCheckoutSession2(cart, options) {
|
|
|
98
107
|
}
|
|
99
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
100
109
|
0 && (module.exports = {
|
|
110
|
+
SubscriptionFrequency,
|
|
101
111
|
constructCheckoutSession
|
|
102
112
|
});
|
|
103
113
|
//# sourceMappingURL=index.typings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.typings.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAGO;;;ACJP,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD6FA,eAAsBC,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,eAAO,uEAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["constructCheckoutSession","constructCheckoutSession","sdkTransformError"]}
|
|
1
|
+
{"version":3,"sources":["../../index.typings.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/** Subscription display and settings for a recurring line item. */\nexport interface SubscriptionInfo {\n /** Subscription settings such as frequency and billing cycles. */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription title shown to the buyer.\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer.\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/** Configuration for recurring subscription charges. */\nexport interface SubscriptionSettings {\n /** Frequency unit for recurring charges. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. Default: 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /** Whether the subscription renews automatically. */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.\n * @min 1\n */\n billingCycles?: number | null;\n /** Free trial period before the first charge. */\n freeTrialPeriod?: FreeTrialPeriod;\n}\n\n/** Frequency unit for subscription billing and trial periods. */\nexport enum SubscriptionFrequency {\n UNDEFINED = 'UNDEFINED',\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n YEAR = 'YEAR',\n}\n\n/** @enumType */\nexport type SubscriptionFrequencyWithLiterals =\n | SubscriptionFrequency\n | 'UNDEFINED'\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR';\n\n/** Free trial period before the first subscription charge. */\nexport interface FreeTrialPeriod {\n /** Frequency unit for the trial period. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Duration in frequency units (e.g., 14 with DAY = 14-day trial).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /** Optional. When provided, the item becomes a recurring subscription. */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,6BAAoD;AACpD,oCAGO;;;ACJP,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ADsBO,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AALG,SAAAA;AAAA,GAAA;AA4IZ,eAAsBC,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,cAAU,qEAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,eAAO,uEAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,uBAAmB,uBAAAC;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;","names":["constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession","sdkTransformError"]}
|
package/build/cjs/meta.d.ts
CHANGED
|
@@ -22,6 +22,62 @@ interface ConstructCheckoutSessionRequest {
|
|
|
22
22
|
/** Callback URLs for redirecting the user after checkout flow. */
|
|
23
23
|
callbackUrls: CallbackUrls;
|
|
24
24
|
}
|
|
25
|
+
/** Subscription display and settings for a recurring line item. */
|
|
26
|
+
interface SubscriptionInfo {
|
|
27
|
+
/** Subscription settings such as frequency and billing cycles. */
|
|
28
|
+
subscriptionSettings?: SubscriptionSettings;
|
|
29
|
+
/**
|
|
30
|
+
* Subscription title shown to the buyer.
|
|
31
|
+
* @maxLength 150
|
|
32
|
+
*/
|
|
33
|
+
title?: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Subscription description shown to the buyer.
|
|
36
|
+
* @maxLength 500
|
|
37
|
+
*/
|
|
38
|
+
description?: string | null;
|
|
39
|
+
}
|
|
40
|
+
/** Configuration for recurring subscription charges. */
|
|
41
|
+
interface SubscriptionSettings {
|
|
42
|
+
/** Frequency unit for recurring charges. */
|
|
43
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
44
|
+
/**
|
|
45
|
+
* Number of frequency units between charges. Default: 1.
|
|
46
|
+
* @min 1
|
|
47
|
+
* @max 3650
|
|
48
|
+
*/
|
|
49
|
+
interval?: number | null;
|
|
50
|
+
/** Whether the subscription renews automatically. */
|
|
51
|
+
autoRenewal?: boolean | null;
|
|
52
|
+
/**
|
|
53
|
+
* Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.
|
|
54
|
+
* @min 1
|
|
55
|
+
*/
|
|
56
|
+
billingCycles?: number | null;
|
|
57
|
+
/** Free trial period before the first charge. */
|
|
58
|
+
freeTrialPeriod?: FreeTrialPeriod;
|
|
59
|
+
}
|
|
60
|
+
/** Frequency unit for subscription billing and trial periods. */
|
|
61
|
+
declare enum SubscriptionFrequency {
|
|
62
|
+
UNDEFINED = "UNDEFINED",
|
|
63
|
+
DAY = "DAY",
|
|
64
|
+
WEEK = "WEEK",
|
|
65
|
+
MONTH = "MONTH",
|
|
66
|
+
YEAR = "YEAR"
|
|
67
|
+
}
|
|
68
|
+
/** @enumType */
|
|
69
|
+
type SubscriptionFrequencyWithLiterals = SubscriptionFrequency | 'UNDEFINED' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
70
|
+
/** Free trial period before the first subscription charge. */
|
|
71
|
+
interface FreeTrialPeriod {
|
|
72
|
+
/** Frequency unit for the trial period. */
|
|
73
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
74
|
+
/**
|
|
75
|
+
* Duration in frequency units (e.g., 14 with DAY = 14-day trial).
|
|
76
|
+
* @min 1
|
|
77
|
+
* @max 999
|
|
78
|
+
*/
|
|
79
|
+
interval?: number;
|
|
80
|
+
}
|
|
25
81
|
interface LineItem {
|
|
26
82
|
/**
|
|
27
83
|
* Name or title of the item.
|
|
@@ -40,6 +96,8 @@ interface LineItem {
|
|
|
40
96
|
* @maxLength 50
|
|
41
97
|
*/
|
|
42
98
|
price?: string | null;
|
|
99
|
+
/** Optional. When provided, the item becomes a recurring subscription. */
|
|
100
|
+
subscriptionInfo?: SubscriptionInfo;
|
|
43
101
|
}
|
|
44
102
|
/** Customer information for pre-filling checkout details. */
|
|
45
103
|
interface CustomerInfo {
|
|
@@ -119,4 +177,4 @@ type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q
|
|
|
119
177
|
};
|
|
120
178
|
declare function constructCheckoutSession(): __PublicMethodMetaInfo<'POST', {}, ConstructCheckoutSessionRequest$1, ConstructCheckoutSessionRequest, ConstructCheckoutSessionResponse$1, ConstructCheckoutSessionResponse>;
|
|
121
179
|
|
|
122
|
-
export { type CallbackUrls as CallbackUrlsOriginal, type Cart as CartOriginal, type CheckoutSession as CheckoutSessionOriginal, type ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequestOriginal, type ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponseOriginal, type CustomerInfo as CustomerInfoOriginal, type LineItem as LineItemOriginal, type RegisterCheckoutSessionWebhookRequest as RegisterCheckoutSessionWebhookRequestOriginal, type RegisterCheckoutSessionWebhookResponse as RegisterCheckoutSessionWebhookResponseOriginal, type __PublicMethodMetaInfo, constructCheckoutSession };
|
|
180
|
+
export { type CallbackUrls as CallbackUrlsOriginal, type Cart as CartOriginal, type CheckoutSession as CheckoutSessionOriginal, type ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequestOriginal, type ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponseOriginal, type CustomerInfo as CustomerInfoOriginal, type FreeTrialPeriod as FreeTrialPeriodOriginal, type LineItem as LineItemOriginal, type RegisterCheckoutSessionWebhookRequest as RegisterCheckoutSessionWebhookRequestOriginal, type RegisterCheckoutSessionWebhookResponse as RegisterCheckoutSessionWebhookResponseOriginal, SubscriptionFrequency as SubscriptionFrequencyOriginal, type SubscriptionFrequencyWithLiterals as SubscriptionFrequencyWithLiteralsOriginal, type SubscriptionInfo as SubscriptionInfoOriginal, type SubscriptionSettings as SubscriptionSettingsOriginal, type __PublicMethodMetaInfo, constructCheckoutSession };
|
package/build/cjs/meta.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// meta.ts
|
|
21
21
|
var meta_exports = {};
|
|
22
22
|
__export(meta_exports, {
|
|
23
|
+
SubscriptionFrequencyOriginal: () => SubscriptionFrequency,
|
|
23
24
|
constructCheckoutSession: () => constructCheckoutSession2
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(meta_exports);
|
|
@@ -60,6 +61,16 @@ function constructCheckoutSession(payload) {
|
|
|
60
61
|
return __constructCheckoutSession;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
// src/payments-platform-v1-checkout-session-checkout-sessions.types.ts
|
|
65
|
+
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
66
|
+
SubscriptionFrequency2["UNDEFINED"] = "UNDEFINED";
|
|
67
|
+
SubscriptionFrequency2["DAY"] = "DAY";
|
|
68
|
+
SubscriptionFrequency2["WEEK"] = "WEEK";
|
|
69
|
+
SubscriptionFrequency2["MONTH"] = "MONTH";
|
|
70
|
+
SubscriptionFrequency2["YEAR"] = "YEAR";
|
|
71
|
+
return SubscriptionFrequency2;
|
|
72
|
+
})(SubscriptionFrequency || {});
|
|
73
|
+
|
|
63
74
|
// src/payments-platform-v1-checkout-session-checkout-sessions.meta.ts
|
|
64
75
|
function constructCheckoutSession2() {
|
|
65
76
|
const payload = {};
|
|
@@ -83,6 +94,7 @@ function constructCheckoutSession2() {
|
|
|
83
94
|
}
|
|
84
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
96
|
0 && (module.exports = {
|
|
97
|
+
SubscriptionFrequencyOriginal,
|
|
86
98
|
constructCheckoutSession
|
|
87
99
|
});
|
|
88
100
|
//# sourceMappingURL=meta.js.map
|
package/build/cjs/meta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../meta.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.meta.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.meta.js';\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","import * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSessionTypes from './payments-platform-v1-checkout-session-checkout-sessions.types.js';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport type __PublicMethodMetaInfo<\n K = string,\n M = unknown,\n T = unknown,\n S = unknown,\n Q = unknown,\n R = unknown\n> = {\n getUrl: (context: any) => string;\n httpMethod: K;\n path: string;\n pathParams: M;\n __requestType: T;\n __originalRequestType: S;\n __responseType: Q;\n __originalResponseType: R;\n};\n\nexport function constructCheckoutSession(): __PublicMethodMetaInfo<\n 'POST',\n {},\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.ConstructCheckoutSessionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.ConstructCheckoutSessionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.ConstructCheckoutSessionResponse,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.ConstructCheckoutSessionResponse\n> {\n const payload = {} as any;\n\n const getRequestOptions =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n const getUrl = (context: any): string => {\n const { url } = getRequestOptions(context);\n return url!;\n };\n\n return {\n getUrl,\n httpMethod: 'POST',\n path: '/v1/checkout-sessions/construct',\n pathParams: {},\n __requestType: null as any,\n __originalRequestType: null as any,\n __responseType: null as any,\n __originalResponseType: null as any,\n };\n}\n\nexport {\n CheckoutSession as CheckoutSessionOriginal,\n ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequestOriginal,\n LineItem as LineItemOriginal,\n CustomerInfo as CustomerInfoOriginal,\n Cart as CartOriginal,\n CallbackUrls as CallbackUrlsOriginal,\n ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponseOriginal,\n RegisterCheckoutSessionWebhookRequest as RegisterCheckoutSessionWebhookRequestOriginal,\n RegisterCheckoutSessionWebhookResponse as RegisterCheckoutSessionWebhookResponseOriginal,\n} from './payments-platform-v1-checkout-session-checkout-sessions.types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACzBO,SAASC,4BAOd;AACA,QAAM,UAAU,CAAC;AAEjB,QAAM,oBAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,QAAM,SAAS,CAAC,YAAyB;AACvC,UAAM,EAAE,IAAI,IAAI,kBAAkB,OAAO;AACzC,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,YAAY,CAAC;AAAA,IACb,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,gBAAgB;AAAA,IAChB,wBAAwB;AAAA,EAC1B;AACF;","names":["constructCheckoutSession","constructCheckoutSession"]}
|
|
1
|
+
{"version":3,"sources":["../../meta.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.types.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.meta.ts"],"sourcesContent":["export * from './src/payments-platform-v1-checkout-session-checkout-sessions.meta.js';\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/** Subscription display and settings for a recurring line item. */\nexport interface SubscriptionInfo {\n /** Subscription settings such as frequency and billing cycles. */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription title shown to the buyer.\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer.\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/** Configuration for recurring subscription charges. */\nexport interface SubscriptionSettings {\n /** Frequency unit for recurring charges. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. Default: 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /** Whether the subscription renews automatically. */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.\n * @min 1\n */\n billingCycles?: number | null;\n /** Free trial period before the first charge. */\n freeTrialPeriod?: FreeTrialPeriod;\n}\n\n/** Frequency unit for subscription billing and trial periods. */\nexport enum SubscriptionFrequency {\n UNDEFINED = 'UNDEFINED',\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n YEAR = 'YEAR',\n}\n\n/** @enumType */\nexport type SubscriptionFrequencyWithLiterals =\n | SubscriptionFrequency\n | 'UNDEFINED'\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR';\n\n/** Free trial period before the first subscription charge. */\nexport interface FreeTrialPeriod {\n /** Frequency unit for the trial period. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Duration in frequency units (e.g., 14 with DAY = 14-day trial).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /** Optional. When provided, the item becomes a recurring subscription. */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n","import * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSessionTypes from './payments-platform-v1-checkout-session-checkout-sessions.types.js';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport type __PublicMethodMetaInfo<\n K = string,\n M = unknown,\n T = unknown,\n S = unknown,\n Q = unknown,\n R = unknown\n> = {\n getUrl: (context: any) => string;\n httpMethod: K;\n path: string;\n pathParams: M;\n __requestType: T;\n __originalRequestType: S;\n __responseType: Q;\n __originalResponseType: R;\n};\n\nexport function constructCheckoutSession(): __PublicMethodMetaInfo<\n 'POST',\n {},\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.ConstructCheckoutSessionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.ConstructCheckoutSessionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.ConstructCheckoutSessionResponse,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.ConstructCheckoutSessionResponse\n> {\n const payload = {} as any;\n\n const getRequestOptions =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n const getUrl = (context: any): string => {\n const { url } = getRequestOptions(context);\n return url!;\n };\n\n return {\n getUrl,\n httpMethod: 'POST',\n path: '/v1/checkout-sessions/construct',\n pathParams: {},\n __requestType: null as any,\n __originalRequestType: null as any,\n __responseType: null as any,\n __originalResponseType: null as any,\n };\n}\n\nexport {\n CheckoutSession as CheckoutSessionOriginal,\n ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequestOriginal,\n SubscriptionInfo as SubscriptionInfoOriginal,\n SubscriptionSettings as SubscriptionSettingsOriginal,\n SubscriptionFrequency as SubscriptionFrequencyOriginal,\n SubscriptionFrequencyWithLiterals as SubscriptionFrequencyWithLiteralsOriginal,\n FreeTrialPeriod as FreeTrialPeriodOriginal,\n LineItem as LineItemOriginal,\n CustomerInfo as CustomerInfoOriginal,\n Cart as CartOriginal,\n CallbackUrls as CallbackUrlsOriginal,\n ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponseOriginal,\n RegisterCheckoutSessionWebhookRequest as RegisterCheckoutSessionWebhookRequestOriginal,\n RegisterCheckoutSessionWebhookResponse as RegisterCheckoutSessionWebhookResponseOriginal,\n} from './payments-platform-v1-checkout-session-checkout-sessions.types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,kCAAAA;AAAA;AAAA;;;ACAA,0BAA2B;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,aAAO,gCAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACcO,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AALG,SAAAA;AAAA,GAAA;;;ACvCL,SAASC,4BAOd;AACA,QAAM,UAAU,CAAC;AAEjB,QAAM,oBAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,QAAM,SAAS,CAAC,YAAyB;AACvC,UAAM,EAAE,IAAI,IAAI,kBAAkB,OAAO;AACzC,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,YAAY,CAAC;AAAA,IACb,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,gBAAgB;AAAA,IAChB,wBAAwB;AAAA,EAC1B;AACF;","names":["constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession"]}
|
package/build/es/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
|
|
2
2
|
import { Cart, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse } from './index.typings.mjs';
|
|
3
|
-
export { CallbackUrls, CheckoutSession, ConstructCheckoutSessionRequest, CustomerInfo, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse } from './index.typings.mjs';
|
|
3
|
+
export { CallbackUrls, CheckoutSession, ConstructCheckoutSessionRequest, CustomerInfo, FreeTrialPeriod, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionInfo, SubscriptionSettings } from './index.typings.mjs';
|
|
4
4
|
|
|
5
5
|
declare function constructCheckoutSession$1(httpClient: HttpClient): ConstructCheckoutSessionSignature;
|
|
6
6
|
interface ConstructCheckoutSessionSignature {
|
package/build/es/index.mjs
CHANGED
|
@@ -42,6 +42,14 @@ function constructCheckoutSession(payload) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
45
|
+
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
46
|
+
SubscriptionFrequency2["UNDEFINED"] = "UNDEFINED";
|
|
47
|
+
SubscriptionFrequency2["DAY"] = "DAY";
|
|
48
|
+
SubscriptionFrequency2["WEEK"] = "WEEK";
|
|
49
|
+
SubscriptionFrequency2["MONTH"] = "MONTH";
|
|
50
|
+
SubscriptionFrequency2["YEAR"] = "YEAR";
|
|
51
|
+
return SubscriptionFrequency2;
|
|
52
|
+
})(SubscriptionFrequency || {});
|
|
45
53
|
async function constructCheckoutSession2(cart, options) {
|
|
46
54
|
const { httpClient, sideEffects } = arguments[2];
|
|
47
55
|
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
@@ -88,6 +96,7 @@ function constructCheckoutSession3(httpClient) {
|
|
|
88
96
|
import { createRESTModule } from "@wix/sdk-runtime/rest-modules";
|
|
89
97
|
var constructCheckoutSession4 = /* @__PURE__ */ createRESTModule(constructCheckoutSession3);
|
|
90
98
|
export {
|
|
99
|
+
SubscriptionFrequency,
|
|
91
100
|
constructCheckoutSession4 as constructCheckoutSession
|
|
92
101
|
};
|
|
93
102
|
//# sourceMappingURL=index.mjs.map
|
package/build/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.public.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Cart,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionResponse,\n constructCheckoutSession as universalConstructCheckoutSession,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/payments' };\n\nexport function constructCheckoutSession(\n httpClient: HttpClient\n): ConstructCheckoutSessionSignature {\n return (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ) =>\n universalConstructCheckoutSession(\n cart,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface ConstructCheckoutSessionSignature {\n /**\n * Constructs a new checkout session.\n * @param - Cart details including line items to be checked out.\n * @returns Response after constructing a checkout session.\n */\n (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ): Promise<ConstructCheckoutSessionResponse>;\n}\n\nexport {\n CallbackUrls,\n Cart,\n CheckoutSession,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionRequest,\n ConstructCheckoutSessionResponse,\n CustomerInfo,\n LineItem,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { constructCheckoutSession as publicConstructCheckoutSession } from './payments-platform-v1-checkout-session-checkout-sessions.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const constructCheckoutSession: MaybeContext<\n BuildRESTFunction<typeof publicConstructCheckoutSession> &\n typeof publicConstructCheckoutSession\n> = /*#__PURE__*/ createRESTModule(publicConstructCheckoutSession);\n\nexport {\n CheckoutSession,\n ConstructCheckoutSessionRequest,\n LineItem,\n CustomerInfo,\n Cart,\n CallbackUrls,\n ConstructCheckoutSessionResponse,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n ConstructCheckoutSessionOptions,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,kBAAkB;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AD6FA,eAAsBA,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,WAAO,wCAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AE1LO,SAASC,0BACd,YACmC;AACnC,SAAO,CACL,MAQA,YAQAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnCA,SAAS,wBAAwB;AAG1B,IAAMC,4BAGK,iCAAiBA,yBAA8B;","names":["constructCheckoutSession","constructCheckoutSession","constructCheckoutSession"]}
|
|
1
|
+
{"version":3,"sources":["../../src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.http.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.public.ts","../../src/payments-platform-v1-checkout-session-checkout-sessions.context.ts"],"sourcesContent":["import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';\nimport {\n renameKeysFromSDKRequestToRESTRequest,\n renameKeysFromRESTResponseToSDKResponse,\n} from '@wix/sdk-runtime/rename-all-nested-keys';\nimport { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport * as ambassadorWixPaymentsPlatformV1CheckoutSession from './payments-platform-v1-checkout-session-checkout-sessions.http.js';\n\n/** A CheckoutSession is a simple entity used for demonstration purposes. */\nexport interface CheckoutSession {\n /**\n * Cart ID (from ecom cart service).\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL to redirect buyer.\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to construct a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Cart details including line items to be checked out. */\n cart: Cart;\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/** Subscription display and settings for a recurring line item. */\nexport interface SubscriptionInfo {\n /** Subscription settings such as frequency and billing cycles. */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription title shown to the buyer.\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer.\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/** Configuration for recurring subscription charges. */\nexport interface SubscriptionSettings {\n /** Frequency unit for recurring charges. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. Default: 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /** Whether the subscription renews automatically. */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.\n * @min 1\n */\n billingCycles?: number | null;\n /** Free trial period before the first charge. */\n freeTrialPeriod?: FreeTrialPeriod;\n}\n\n/** Frequency unit for subscription billing and trial periods. */\nexport enum SubscriptionFrequency {\n UNDEFINED = 'UNDEFINED',\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n YEAR = 'YEAR',\n}\n\n/** @enumType */\nexport type SubscriptionFrequencyWithLiterals =\n | SubscriptionFrequency\n | 'UNDEFINED'\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR';\n\n/** Free trial period before the first subscription charge. */\nexport interface FreeTrialPeriod {\n /** Frequency unit for the trial period. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Duration in frequency units (e.g., 14 with DAY = 14-day trial).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name or title of the item.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item in the cart.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Price of the item as a string (e.g., \"19.99\").\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /** Optional. When provided, the item becomes a recurring subscription. */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/** Customer information for pre-filling checkout details. */\nexport interface CustomerInfo {\n /**\n * Customer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Customer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Customer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Customer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\nexport interface Cart {\n /**\n * List of items in the cart.\n * @maxSize 100\n */\n items?: LineItem[];\n /** Optional customer information to pre-fill checkout form. */\n customerInfo?: CustomerInfo;\n}\n\nexport interface CallbackUrls {\n /**\n * URL to redirect after the checkout flow completes.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL for the thank you page after successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after constructing a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The constructed checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * The URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n}\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * The webhook public key used for verifying webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/**\n * Constructs a new checkout session.\n * @param cart - Cart details including line items to be checked out.\n * @public\n * @documentationMaturity preview\n * @requiredField cart\n * @requiredField cart.items\n * @requiredField cart.items.name\n * @requiredField cart.items.price\n * @requiredField cart.items.quantity\n * @requiredField options\n * @requiredField options.callbackUrls\n * @requiredField options.callbackUrls.postFlowUrl\n * @requiredField options.callbackUrls.thankYouPageUrl\n * @permissionId payments:platform:v1:checkout_session:construct_checkout_session\n * @returns Response after constructing a checkout session.\n * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession\n */\nexport async function constructCheckoutSession(\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<ConstructCheckoutSessionResponse> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n cart: cart,\n callbackUrls: options?.callbackUrls,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.constructCheckoutSession(\n payload\n );\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n\n return renameKeysFromRESTResponseToSDKResponse(result.data)!;\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n cart: '$[0]',\n callbackUrls: '$[1].callbackUrls',\n },\n singleArgumentUnchanged: false,\n },\n ['cart', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface ConstructCheckoutSessionOptions {\n /** Callback URLs for redirecting the user after checkout flow. */\n callbackUrls: CallbackUrls;\n}\n","import { resolveUrl } from '@wix/sdk-runtime/rest-modules';\nimport { ResolveUrlOpts } from '@wix/sdk-runtime/rest-modules';\nimport { RequestOptionsFactory } from '@wix/sdk-types';\n\nfunction resolveWixPaymentsPlatformV1CheckoutSessionsUrl(\n opts: Omit<ResolveUrlOpts, 'domainToMappings'>\n) {\n const domainToMappings = {\n 'www.wixapis.com': [\n {\n srcPath: '/payments/platform/v1/checkout-sessions',\n destPath: '/v1/checkout-sessions',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/** Constructs a new checkout session. */\nexport function constructCheckoutSession(\n payload: object\n): RequestOptionsFactory<any> {\n function __constructCheckoutSession({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn:\n 'wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/construct',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __constructCheckoutSession;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n Cart,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionResponse,\n constructCheckoutSession as universalConstructCheckoutSession,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n\nexport const __metadata = { PACKAGE_NAME: '@wix/payments' };\n\nexport function constructCheckoutSession(\n httpClient: HttpClient\n): ConstructCheckoutSessionSignature {\n return (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ) =>\n universalConstructCheckoutSession(\n cart,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface ConstructCheckoutSessionSignature {\n /**\n * Constructs a new checkout session.\n * @param - Cart details including line items to be checked out.\n * @returns Response after constructing a checkout session.\n */\n (\n cart: NonNullablePaths<\n Cart,\n | `items`\n | `items.${number}.name`\n | `items.${number}.price`\n | `items.${number}.quantity`,\n 4\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ): Promise<ConstructCheckoutSessionResponse>;\n}\n\nexport {\n CallbackUrls,\n Cart,\n CheckoutSession,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionRequest,\n ConstructCheckoutSessionResponse,\n CustomerInfo,\n FreeTrialPeriod,\n LineItem,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n SubscriptionFrequency,\n SubscriptionInfo,\n SubscriptionSettings,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n","import { constructCheckoutSession as publicConstructCheckoutSession } from './payments-platform-v1-checkout-session-checkout-sessions.public.js';\nimport { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nimport { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';\n\nexport const constructCheckoutSession: MaybeContext<\n BuildRESTFunction<typeof publicConstructCheckoutSession> &\n typeof publicConstructCheckoutSession\n> = /*#__PURE__*/ createRESTModule(publicConstructCheckoutSession);\n\nexport { SubscriptionFrequency } from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\nexport {\n CheckoutSession,\n ConstructCheckoutSessionRequest,\n SubscriptionInfo,\n SubscriptionSettings,\n FreeTrialPeriod,\n LineItem,\n CustomerInfo,\n Cart,\n CallbackUrls,\n ConstructCheckoutSessionResponse,\n RegisterCheckoutSessionWebhookRequest,\n RegisterCheckoutSessionWebhookResponse,\n ConstructCheckoutSessionOptions,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\nexport { SubscriptionFrequencyWithLiterals } from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;AACpD;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,kBAAkB;AAI3B,SAAS,gDACP,MACA;AACA,QAAM,mBAAmB;AAAA,IACvB,mBAAmB;AAAA,MACjB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,WAAW,OAAO,OAAO,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7D;AAEA,IAAM,eAAe;AAGd,SAAS,yBACd,SAC4B;AAC5B,WAAS,2BAA2B,EAAE,KAAK,GAAQ;AACjD,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WACE;AAAA,MACF,aAAa;AAAA,MACb,kBAAkB;AAAA,QAChB,wBAAwB;AAAA,MAC1B;AAAA,MACA,KAAK,gDAAgD;AAAA,QACnD,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ADsBO,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AALG,SAAAA;AAAA,GAAA;AA4IZ,eAAsBC,0BACpB,MAQA,SAO2C;AAE3C,QAAM,EAAE,YAAY,YAAY,IAAI,UAAU,CAAC;AAK/C,QAAM,UAAU,sCAAsC;AAAA,IACpD;AAAA,IACA,cAAc,SAAS;AAAA,EACzB,CAAC;AAED,QAAM,UAC2C;AAAA,IAC7C;AAAA,EACF;AAEF,eAAa,aAAa;AAC1B,MAAI;AACF,UAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;AAC/C,iBAAa,YAAY,MAAM;AAE/B,WAAO,wCAAwC,OAAO,IAAI;AAAA,EAC5D,SAAS,KAAU;AACjB,UAAM,mBAAmB;AAAA,MACvB;AAAA,MACA;AAAA,QACE,wBAAwB,CAAC;AAAA,QACzB,0BAA0B;AAAA,UACxB,MAAM;AAAA,UACN,cAAc;AAAA,QAChB;AAAA,QACA,yBAAyB;AAAA,MAC3B;AAAA,MACA,CAAC,QAAQ,SAAS;AAAA,IACpB;AACA,iBAAa,UAAU,GAAG;AAE1B,UAAM;AAAA,EACR;AACF;;;AE/PO,SAASC,0BACd,YACmC;AACnC,SAAO,CACL,MAQA,YAQAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACnCA,SAAS,wBAAwB;AAG1B,IAAMC,4BAGK,iCAAiBA,yBAA8B;","names":["SubscriptionFrequency","constructCheckoutSession","constructCheckoutSession","constructCheckoutSession"]}
|
|
@@ -21,6 +21,62 @@ interface ConstructCheckoutSessionRequest {
|
|
|
21
21
|
/** Callback URLs for redirecting the user after checkout flow. */
|
|
22
22
|
callbackUrls: CallbackUrls;
|
|
23
23
|
}
|
|
24
|
+
/** Subscription display and settings for a recurring line item. */
|
|
25
|
+
interface SubscriptionInfo {
|
|
26
|
+
/** Subscription settings such as frequency and billing cycles. */
|
|
27
|
+
subscriptionSettings?: SubscriptionSettings;
|
|
28
|
+
/**
|
|
29
|
+
* Subscription title shown to the buyer.
|
|
30
|
+
* @maxLength 150
|
|
31
|
+
*/
|
|
32
|
+
title?: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Subscription description shown to the buyer.
|
|
35
|
+
* @maxLength 500
|
|
36
|
+
*/
|
|
37
|
+
description?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/** Configuration for recurring subscription charges. */
|
|
40
|
+
interface SubscriptionSettings {
|
|
41
|
+
/** Frequency unit for recurring charges. */
|
|
42
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
43
|
+
/**
|
|
44
|
+
* Number of frequency units between charges. Default: 1.
|
|
45
|
+
* @min 1
|
|
46
|
+
* @max 3650
|
|
47
|
+
*/
|
|
48
|
+
interval?: number | null;
|
|
49
|
+
/** Whether the subscription renews automatically. */
|
|
50
|
+
autoRenewal?: boolean | null;
|
|
51
|
+
/**
|
|
52
|
+
* Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.
|
|
53
|
+
* @min 1
|
|
54
|
+
*/
|
|
55
|
+
billingCycles?: number | null;
|
|
56
|
+
/** Free trial period before the first charge. */
|
|
57
|
+
freeTrialPeriod?: FreeTrialPeriod;
|
|
58
|
+
}
|
|
59
|
+
/** Frequency unit for subscription billing and trial periods. */
|
|
60
|
+
declare enum SubscriptionFrequency {
|
|
61
|
+
UNDEFINED = "UNDEFINED",
|
|
62
|
+
DAY = "DAY",
|
|
63
|
+
WEEK = "WEEK",
|
|
64
|
+
MONTH = "MONTH",
|
|
65
|
+
YEAR = "YEAR"
|
|
66
|
+
}
|
|
67
|
+
/** @enumType */
|
|
68
|
+
type SubscriptionFrequencyWithLiterals = SubscriptionFrequency | 'UNDEFINED' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
69
|
+
/** Free trial period before the first subscription charge. */
|
|
70
|
+
interface FreeTrialPeriod {
|
|
71
|
+
/** Frequency unit for the trial period. */
|
|
72
|
+
frequency?: SubscriptionFrequencyWithLiterals;
|
|
73
|
+
/**
|
|
74
|
+
* Duration in frequency units (e.g., 14 with DAY = 14-day trial).
|
|
75
|
+
* @min 1
|
|
76
|
+
* @max 999
|
|
77
|
+
*/
|
|
78
|
+
interval?: number;
|
|
79
|
+
}
|
|
24
80
|
interface LineItem {
|
|
25
81
|
/**
|
|
26
82
|
* Name or title of the item.
|
|
@@ -39,6 +95,8 @@ interface LineItem {
|
|
|
39
95
|
* @maxLength 50
|
|
40
96
|
*/
|
|
41
97
|
price?: string | null;
|
|
98
|
+
/** Optional. When provided, the item becomes a recurring subscription. */
|
|
99
|
+
subscriptionInfo?: SubscriptionInfo;
|
|
42
100
|
}
|
|
43
101
|
/** Customer information for pre-filling checkout details. */
|
|
44
102
|
interface CustomerInfo {
|
|
@@ -129,4 +187,4 @@ interface ConstructCheckoutSessionOptions {
|
|
|
129
187
|
callbackUrls: CallbackUrls;
|
|
130
188
|
}
|
|
131
189
|
|
|
132
|
-
export { type CallbackUrls, type Cart, type CheckoutSession, type ConstructCheckoutSessionOptions, type ConstructCheckoutSessionRequest, type ConstructCheckoutSessionResponse, type CustomerInfo, type LineItem, type RegisterCheckoutSessionWebhookRequest, type RegisterCheckoutSessionWebhookResponse, constructCheckoutSession };
|
|
190
|
+
export { type CallbackUrls, type Cart, type CheckoutSession, type ConstructCheckoutSessionOptions, type ConstructCheckoutSessionRequest, type ConstructCheckoutSessionResponse, type CustomerInfo, type FreeTrialPeriod, type LineItem, type RegisterCheckoutSessionWebhookRequest, type RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, type SubscriptionFrequencyWithLiterals, type SubscriptionInfo, type SubscriptionSettings, constructCheckoutSession };
|
|
@@ -42,6 +42,14 @@ function constructCheckoutSession(payload) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
45
|
+
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
46
|
+
SubscriptionFrequency2["UNDEFINED"] = "UNDEFINED";
|
|
47
|
+
SubscriptionFrequency2["DAY"] = "DAY";
|
|
48
|
+
SubscriptionFrequency2["WEEK"] = "WEEK";
|
|
49
|
+
SubscriptionFrequency2["MONTH"] = "MONTH";
|
|
50
|
+
SubscriptionFrequency2["YEAR"] = "YEAR";
|
|
51
|
+
return SubscriptionFrequency2;
|
|
52
|
+
})(SubscriptionFrequency || {});
|
|
45
53
|
async function constructCheckoutSession2(cart, options) {
|
|
46
54
|
const { httpClient, sideEffects } = arguments[2];
|
|
47
55
|
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
@@ -74,6 +82,7 @@ async function constructCheckoutSession2(cart, options) {
|
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
export {
|
|
85
|
+
SubscriptionFrequency,
|
|
77
86
|
constructCheckoutSession2 as constructCheckoutSession
|
|
78
87
|
};
|
|
79
88
|
//# sourceMappingURL=index.typings.mjs.map
|