@wix/auto_sdk_payments_checkout-sessions 1.0.9 → 1.0.11

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.
Files changed (49) hide show
  1. package/build/cjs/index.d.ts +12 -6
  2. package/build/cjs/index.js +6 -0
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/index.typings.d.ts +157 -46
  5. package/build/cjs/index.typings.js +6 -0
  6. package/build/cjs/index.typings.js.map +1 -1
  7. package/build/cjs/meta.d.ts +143 -41
  8. package/build/cjs/meta.js +6 -0
  9. package/build/cjs/meta.js.map +1 -1
  10. package/build/cjs/schemas.d.ts +6 -6
  11. package/build/cjs/schemas.js +58 -26
  12. package/build/cjs/schemas.js.map +1 -1
  13. package/build/es/index.d.mts +12 -6
  14. package/build/es/index.mjs +6 -0
  15. package/build/es/index.mjs.map +1 -1
  16. package/build/es/index.typings.d.mts +157 -46
  17. package/build/es/index.typings.mjs +6 -0
  18. package/build/es/index.typings.mjs.map +1 -1
  19. package/build/es/meta.d.mts +143 -41
  20. package/build/es/meta.mjs +6 -0
  21. package/build/es/meta.mjs.map +1 -1
  22. package/build/es/schemas.d.mts +6 -6
  23. package/build/es/schemas.mjs +58 -26
  24. package/build/es/schemas.mjs.map +1 -1
  25. package/build/internal/cjs/index.d.ts +12 -6
  26. package/build/internal/cjs/index.js +6 -0
  27. package/build/internal/cjs/index.js.map +1 -1
  28. package/build/internal/cjs/index.typings.d.ts +157 -46
  29. package/build/internal/cjs/index.typings.js +6 -0
  30. package/build/internal/cjs/index.typings.js.map +1 -1
  31. package/build/internal/cjs/meta.d.ts +143 -41
  32. package/build/internal/cjs/meta.js +6 -0
  33. package/build/internal/cjs/meta.js.map +1 -1
  34. package/build/internal/cjs/schemas.d.ts +6 -6
  35. package/build/internal/cjs/schemas.js +58 -26
  36. package/build/internal/cjs/schemas.js.map +1 -1
  37. package/build/internal/es/index.d.mts +12 -6
  38. package/build/internal/es/index.mjs +6 -0
  39. package/build/internal/es/index.mjs.map +1 -1
  40. package/build/internal/es/index.typings.d.mts +157 -46
  41. package/build/internal/es/index.typings.mjs +6 -0
  42. package/build/internal/es/index.typings.mjs.map +1 -1
  43. package/build/internal/es/meta.d.mts +143 -41
  44. package/build/internal/es/meta.mjs +6 -0
  45. package/build/internal/es/meta.mjs.map +1 -1
  46. package/build/internal/es/schemas.d.mts +6 -6
  47. package/build/internal/es/schemas.mjs +58 -26
  48. package/build/internal/es/schemas.mjs.map +1 -1
  49. package/package.json +2 -2
@@ -1,17 +1,23 @@
1
1
  import { HttpClient, NonNullablePaths, MaybeContext, BuildRESTFunction } from '@wix/sdk-types';
2
- import { Cart, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse } from './index.typings.js';
2
+ import { Cart, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse, ConstructCheckoutSessionApplicationErrors } from './index.typings.js';
3
3
  export { CallbackUrls, CheckoutSession, ConstructCheckoutSessionRequest, CustomerInfo, FreeTrialPeriod, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionInfo, SubscriptionSettings, WebhookType, WebhookTypeWithLiterals } from './index.typings.js';
4
4
 
5
5
  declare function constructCheckoutSession$1(httpClient: HttpClient): ConstructCheckoutSessionSignature;
6
6
  interface ConstructCheckoutSessionSignature {
7
7
  /**
8
- * Constructs a new checkout session.
9
- * @param - Cart details including line items to be checked out.
10
- * @returns Response after constructing a checkout session.
8
+ * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`
9
+ * and `id`.
10
+ *
11
+ * Each call creates a new, independent session; the method is not idempotent, so a retry produces
12
+ * an additional session rather than recovering an existing one.
13
+ * @param - Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details.
14
+ * @returns Response after creating a checkout session.
11
15
  */
12
- (cart: NonNullablePaths<Cart, `items` | `items.${number}.name` | `items.${number}.price` | `items.${number}.quantity`, 4>, options: NonNullablePaths<ConstructCheckoutSessionOptions, `callbackUrls` | `callbackUrls.postFlowUrl` | `callbackUrls.thankYouPageUrl`, 3>): Promise<ConstructCheckoutSessionResponse>;
16
+ (cart: NonNullablePaths<Cart, `items` | `items.${number}.name` | `items.${number}.price` | `items.${number}.quantity` | `items.${number}.subscriptionInfo.subscriptionSettings` | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency` | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`, 7>, options: NonNullablePaths<ConstructCheckoutSessionOptions, `callbackUrls` | `callbackUrls.postFlowUrl` | `callbackUrls.thankYouPageUrl`, 3>): Promise<ConstructCheckoutSessionResponse & {
17
+ __applicationErrorsType?: ConstructCheckoutSessionApplicationErrors;
18
+ }>;
13
19
  }
14
20
 
15
21
  declare const constructCheckoutSession: MaybeContext<BuildRESTFunction<typeof constructCheckoutSession$1> & typeof constructCheckoutSession$1>;
16
22
 
17
- export { Cart, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse, constructCheckoutSession };
23
+ export { Cart, ConstructCheckoutSessionApplicationErrors, ConstructCheckoutSessionOptions, ConstructCheckoutSessionResponse, constructCheckoutSession };
@@ -49,6 +49,12 @@ function resolveWixPaymentsPlatformV1CheckoutSessionsUrl(opts) {
49
49
  srcPath: "/_api/checkout-sessions",
50
50
  destPath: ""
51
51
  }
52
+ ],
53
+ "manage.base44.com": [
54
+ {
55
+ srcPath: "/_api/checkout-sessions",
56
+ destPath: ""
57
+ }
52
58
  ]
53
59
  };
54
60
  return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
@@ -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\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 * Webhook event types to register. When empty, defaults to [ORDER_APPROVED].\n * @maxSize 10\n */\n webhookTypes?: WebhookTypeWithLiterals[];\n}\n\n/** Type of webhook event to register. */\nexport enum WebhookType {\n /** Registers wix.ecom.v1.order_approved webhook. */\n ORDER_APPROVED = 'ORDER_APPROVED',\n /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_canceled webhook. */\n SUBSCRIPTION_CANCELED = 'SUBSCRIPTION_CANCELED',\n /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_expired webhook. */\n SUBSCRIPTION_ENDED = 'SUBSCRIPTION_ENDED',\n}\n\n/** @enumType */\nexport type WebhookTypeWithLiterals =\n | WebhookType\n | 'ORDER_APPROVED'\n | 'SUBSCRIPTION_CANCELED'\n | 'SUBSCRIPTION_ENDED';\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 srcPath: '/payments/base44/v1/subscriptions',\n destPath: '/v1/subscriptions',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\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 WebhookType,\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 SubscriptionFrequency,\n WebhookType,\n} 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 {\n SubscriptionFrequencyWithLiterals,\n WebhookTypeWithLiterals,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;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;;;ADYO,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;AAuHL,IAAK,cAAL,kBAAKC,iBAAL;AAEL,EAAAA,aAAA,oBAAiB;AAEjB,EAAAA,aAAA,2BAAwB;AAExB,EAAAA,aAAA,wBAAqB;AANX,SAAAA;AAAA,GAAA;AA2CZ,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;;;AErRO,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","WebhookType","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 Wix-hosted checkout page generated for a specific set of line items. */\nexport interface CheckoutSession {\n /**\n * Checkout session ID, generated by this call. The caller does not supply it.\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL of the Wix-hosted checkout page where the buyer completes payment. The buyer enters the page as\n * an anonymous shopper; any session held by the calling app is not carried over.\n *\n * The URL carries query parameters Wix needs in order to render the page correctly (for example, a\n * `successUrl` parameter derived from `callbackUrls.thankYouPageUrl`). Pass the URL through to the\n * buyer unchanged — do not strip, reorder, rewrite, or otherwise mutate its query string.\n * @readonly\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to create a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */\n cart: Cart;\n /** URLs the buyer is redirected to after completing or leaving the checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/**\n * Recurring subscription configuration for a line item.\n *\n * `LineItem.name` and `subscriptionInfo.title`/`description` render in different parts of the\n * Wix-hosted checkout page: `LineItem.name` is the line label in the cart-summary list, while\n * `subscriptionInfo.title` and `subscriptionInfo.description` are the heading and body text on the\n * recurring-billing summary block (the area that shows the buyer the cadence and the free-trial terms,\n * if any). Set them to complementary values rather than duplicating `LineItem.name`.\n */\nexport interface SubscriptionInfo {\n /**\n * Billing frequency, cycles, and free trial configuration. Required when `subscriptionInfo` is set on a\n * line item.\n */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription name shown to the buyer in the recurring-billing summary block on the Wix-hosted\n * checkout page (the heading of that block).\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer in the recurring-billing summary block on the\n * Wix-hosted checkout page (the body text below the title).\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/**\n * Configuration for recurring subscription charges.\n *\n * `autoRenewal` and `billingCycles` are mutually exclusive — `autoRenewal: true` describes an\n * open-ended subscription that renews indefinitely, while `billingCycles: N` describes a fixed-term\n * subscription that stops after N charges. Setting `autoRenewal: true` together with any\n * `billingCycles` value is rejected with `INVALID_ARGUMENT` (application code\n * `AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT`).\n */\nexport interface SubscriptionSettings {\n /** Billing frequency unit. Required when `subscriptionSettings` is set; `UNDEFINED` is rejected. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. For `DAY` frequency, the minimum is 7 — the shortest\n * billing cadence supported is weekly; values 1–6 with `frequency: DAY` are rejected with\n * `INVALID_ARGUMENT` (rule code `MIN_VALUE`). Default: `1`.\n *\n * Note that `freeTrialPeriod.interval` does **not** share this floor — a `DAY` trial may have\n * `interval` as low as 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /**\n * Whether the subscription renews automatically. Cannot be `true` when `billingCycles` is set.\n *\n * Default: `true` when both `autoRenewal` and `billingCycles` are omitted; `false` when `billingCycles`\n * is set and `autoRenewal` is omitted.\n */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles before the subscription stops. Cannot be set when `autoRenewal` is `true`.\n *\n * When omitted along with `autoRenewal`, 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 /** Unknown frequency. */\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/**\n * Free trial period before the first subscription charge.\n *\n * The `frequency` enum is shared with `SubscriptionSettings.frequency` for convenience, but here it\n * describes a one-off duration unit (the length of the trial), not a recurring billing cadence. A\n * `frequency: MONTH` + `interval: 3` trial means \"a single 3-month trial,\" not \"billed every three\n * months.\"\n */\nexport interface FreeTrialPeriod {\n /**\n * Trial period frequency unit. Required when `freeTrialPeriod` is set; `UNDEFINED` should be\n * treated as a client mistake and is not a valid runtime value.\n */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Length of the trial period in `frequency` units. For example, `interval: 14` with `frequency: DAY`\n * gives a 14-day trial.\n *\n * Unlike `SubscriptionSettings.interval`, this field's `DAY` floor is `1` — there is no weekly-floor\n * restriction on the trial length. Values ≤ 0 are rejected with `INVALID_ARGUMENT` (rule code\n * `MIN_VALUE`).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name of the item, shown on the checkout page.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item to charge for.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Per-unit price as a decimal string in the merchant account currency. For example, `\"19.99\"`.\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /**\n * Subscription configuration. When set, the line item follows a scheduled-billing model defined by\n * `subscriptionSettings` instead of a single immediate charge. The recurring charge each billing\n * cycle is `price × quantity`, and `quantity` is locked at session creation.\n *\n * At most one line item per request may set `subscriptionInfo`. Requests with two or more\n * subscription line items are rejected with `MULTIPLE_SUBSCRIPTION_ITEMS`.\n */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/**\n * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the\n * Wix checkout page.\n */\nexport interface CustomerInfo {\n /**\n * Buyer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Buyer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Buyer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Buyer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\n/** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */\nexport interface Cart {\n /**\n * Line items the buyer is paying for in this checkout session.\n *\n * At most one subscription line item (an item with `subscriptionInfo` set) is allowed per request.\n * Requests with two or more subscription items are rejected. One-time items can be combined with a\n * single subscription item; in that case the buyer is charged once at checkout for the one-time items\n * and (if applicable) the first cycle of the subscription, and any subsequent cycles are billed on\n * the subscription's own schedule.\n * @maxSize 100\n */\n items?: LineItem[];\n /**\n * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the\n * Wix checkout page.\n */\n customerInfo?: CustomerInfo;\n}\n\n/**\n * URLs the buyer is redirected to after the checkout flow.\n *\n * The buyer is sent to one of the URLs below — `postFlowUrl` if they explicitly leave via **Continue\n * browsing**, `thankYouPageUrl` after a successful payment.\n *\n * If the buyer abandons the page implicitly (closing the tab, navigating away, network failure), no\n * callback URL is invoked and the checkout session is not resumed.\n */\nexport interface CallbackUrls {\n /**\n * URL the buyer is redirected to from the Wix checkout page when they choose to leave without\n * completing payment — both when they click **Continue browsing** and when they navigate back to\n * a cart-style page.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL the buyer is redirected to after a successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after creating a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The created checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n /**\n * Webhook event types to register. Default: `[ORDER_APPROVED]`.\n * @maxSize 10\n */\n webhookTypes?: WebhookTypeWithLiterals[];\n}\n\n/** Webhook event types to register. */\nexport enum WebhookType {\n /** Order Approved webhook (`wix.ecom.v1.order_approved`). */\n ORDER_APPROVED = 'ORDER_APPROVED',\n /**\n * Subscription Contract Canceled webhook\n * (`wix.ecom.subscription_contracts.v1.subscription_contract_canceled`).\n */\n SUBSCRIPTION_CANCELED = 'SUBSCRIPTION_CANCELED',\n /**\n * Subscription Contract Expired webhook\n * (`wix.ecom.subscription_contracts.v1.subscription_contract_expired`).\n */\n SUBSCRIPTION_ENDED = 'SUBSCRIPTION_ENDED',\n}\n\n/** @enumType */\nexport type WebhookTypeWithLiterals =\n | WebhookType\n | 'ORDER_APPROVED'\n | 'SUBSCRIPTION_CANCELED'\n | 'SUBSCRIPTION_ENDED';\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * PEM-formatted RS256 public key used to verify the JWT signature on incoming webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/** @docsIgnore */\nexport type ConstructCheckoutSessionApplicationErrors =\n | {\n code?: 'MULTIPLE_SUBSCRIPTION_ITEMS';\n description?: string;\n data?: Record<string, any>;\n }\n | {\n code?: 'AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT';\n description?: string;\n data?: Record<string, any>;\n };\n\n/**\n * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`\n * and `id`.\n *\n * Each call creates a new, independent session; the method is not idempotent, so a retry produces\n * an additional session rather than recovering an existing one.\n * @param cart - Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details.\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 cart.items.subscriptionInfo.subscriptionSettings\n * @requiredField cart.items.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency\n * @requiredField cart.items.subscriptionInfo.subscriptionSettings.frequency\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 creating 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 | `items.${number}.subscriptionInfo.subscriptionSettings`\n | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency`\n | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`,\n 7\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<\n ConstructCheckoutSessionResponse & {\n __applicationErrorsType?: ConstructCheckoutSessionApplicationErrors;\n }\n> {\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 /** URLs the buyer is redirected to after completing or leaving the 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 srcPath: '/payments/base44/v1/subscriptions',\n destPath: '/v1/subscriptions',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\n },\n ],\n 'manage.base44.com': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/**\n * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`\n * and `id`.\n *\n * Each call creates a new, independent session; the method is not idempotent, so a retry produces\n * an additional session rather than recovering an existing one.\n */\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 ConstructCheckoutSessionApplicationErrors,\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 | `items.${number}.subscriptionInfo.subscriptionSettings`\n | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency`\n | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`,\n 7\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 * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`\n * and `id`.\n *\n * Each call creates a new, independent session; the method is not idempotent, so a retry produces\n * an additional session rather than recovering an existing one.\n * @param - Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details.\n * @returns Response after creating 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 | `items.${number}.subscriptionInfo.subscriptionSettings`\n | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency`\n | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`,\n 7\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n ): Promise<\n ConstructCheckoutSessionResponse & {\n __applicationErrorsType?: ConstructCheckoutSessionApplicationErrors;\n }\n >;\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 WebhookType,\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 SubscriptionFrequency,\n WebhookType,\n} 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 {\n SubscriptionFrequencyWithLiterals,\n WebhookTypeWithLiterals,\n ConstructCheckoutSessionApplicationErrors,\n} from './payments-platform-v1-checkout-session-checkout-sessions.universal.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;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;AASd,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;;;ADuCO,IAAK,wBAAL,kBAAKC,2BAAL;AAEL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AANG,SAAAA;AAAA,GAAA;AAsKL,IAAK,cAAL,kBAAKC,iBAAL;AAEL,EAAAA,aAAA,oBAAiB;AAKjB,EAAAA,aAAA,2BAAwB;AAKxB,EAAAA,aAAA,wBAAqB;AAZX,SAAAA;AAAA,GAAA;AAqEZ,eAAsBC,0BACpB,MAWA,SAWA;AAEA,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;;;AE3YO,SAASC,0BACd,YACmC;AACnC,SAAO,CACL,MAWA,YAQAA;AAAA,IACE;AAAA,IACA;AAAA;AAAA,IAEA,EAAE,WAAW;AAAA,EACf;AACJ;;;ACvCA,IAAAC,uBAAiC;AAG1B,IAAMC,4BAGK,2DAAiBA,yBAA8B;","names":["constructCheckoutSession","SubscriptionFrequency","WebhookType","constructCheckoutSession","sdkTransformError","constructCheckoutSession","import_rest_modules","constructCheckoutSession"]}
@@ -1,55 +1,94 @@
1
1
  import { NonNullablePaths } from '@wix/sdk-types';
2
2
 
3
- /** A CheckoutSession is a simple entity used for demonstration purposes. */
3
+ /** A Wix-hosted checkout page generated for a specific set of line items. */
4
4
  interface CheckoutSession {
5
5
  /**
6
- * Cart ID (from ecom cart service).
6
+ * Checkout session ID, generated by this call. The caller does not supply it.
7
7
  * @readonly
8
8
  * @format GUID
9
9
  */
10
10
  _id?: string | null;
11
11
  /**
12
- * URL to redirect buyer.
12
+ * URL of the Wix-hosted checkout page where the buyer completes payment. The buyer enters the page as
13
+ * an anonymous shopper; any session held by the calling app is not carried over.
14
+ *
15
+ * The URL carries query parameters Wix needs in order to render the page correctly (for example, a
16
+ * `successUrl` parameter derived from `callbackUrls.thankYouPageUrl`). Pass the URL through to the
17
+ * buyer unchanged — do not strip, reorder, rewrite, or otherwise mutate its query string.
18
+ * @readonly
13
19
  * @format WEB_URL
14
20
  */
15
21
  redirectUrl?: string | null;
16
22
  }
17
- /** Request to construct a checkout session. */
23
+ /** Request to create a checkout session. */
18
24
  interface ConstructCheckoutSessionRequest {
19
- /** Cart details including line items to be checked out. */
25
+ /** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */
20
26
  cart: Cart;
21
- /** Callback URLs for redirecting the user after checkout flow. */
27
+ /** URLs the buyer is redirected to after completing or leaving the checkout flow. */
22
28
  callbackUrls: CallbackUrls;
23
29
  }
24
- /** Subscription display and settings for a recurring line item. */
30
+ /**
31
+ * Recurring subscription configuration for a line item.
32
+ *
33
+ * `LineItem.name` and `subscriptionInfo.title`/`description` render in different parts of the
34
+ * Wix-hosted checkout page: `LineItem.name` is the line label in the cart-summary list, while
35
+ * `subscriptionInfo.title` and `subscriptionInfo.description` are the heading and body text on the
36
+ * recurring-billing summary block (the area that shows the buyer the cadence and the free-trial terms,
37
+ * if any). Set them to complementary values rather than duplicating `LineItem.name`.
38
+ */
25
39
  interface SubscriptionInfo {
26
- /** Subscription settings such as frequency and billing cycles. */
40
+ /**
41
+ * Billing frequency, cycles, and free trial configuration. Required when `subscriptionInfo` is set on a
42
+ * line item.
43
+ */
27
44
  subscriptionSettings?: SubscriptionSettings;
28
45
  /**
29
- * Subscription title shown to the buyer.
46
+ * Subscription name shown to the buyer in the recurring-billing summary block on the Wix-hosted
47
+ * checkout page (the heading of that block).
30
48
  * @maxLength 150
31
49
  */
32
50
  title?: string | null;
33
51
  /**
34
- * Subscription description shown to the buyer.
52
+ * Subscription description shown to the buyer in the recurring-billing summary block on the
53
+ * Wix-hosted checkout page (the body text below the title).
35
54
  * @maxLength 500
36
55
  */
37
56
  description?: string | null;
38
57
  }
39
- /** Configuration for recurring subscription charges. */
58
+ /**
59
+ * Configuration for recurring subscription charges.
60
+ *
61
+ * `autoRenewal` and `billingCycles` are mutually exclusive — `autoRenewal: true` describes an
62
+ * open-ended subscription that renews indefinitely, while `billingCycles: N` describes a fixed-term
63
+ * subscription that stops after N charges. Setting `autoRenewal: true` together with any
64
+ * `billingCycles` value is rejected with `INVALID_ARGUMENT` (application code
65
+ * `AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT`).
66
+ */
40
67
  interface SubscriptionSettings {
41
- /** Frequency unit for recurring charges. */
68
+ /** Billing frequency unit. Required when `subscriptionSettings` is set; `UNDEFINED` is rejected. */
42
69
  frequency?: SubscriptionFrequencyWithLiterals;
43
70
  /**
44
- * Number of frequency units between charges. Default: 1.
71
+ * Number of frequency units between charges. For `DAY` frequency, the minimum is 7 — the shortest
72
+ * billing cadence supported is weekly; values 1–6 with `frequency: DAY` are rejected with
73
+ * `INVALID_ARGUMENT` (rule code `MIN_VALUE`). Default: `1`.
74
+ *
75
+ * Note that `freeTrialPeriod.interval` does **not** share this floor — a `DAY` trial may have
76
+ * `interval` as low as 1.
45
77
  * @min 1
46
78
  * @max 3650
47
79
  */
48
80
  interval?: number | null;
49
- /** Whether the subscription renews automatically. */
81
+ /**
82
+ * Whether the subscription renews automatically. Cannot be `true` when `billingCycles` is set.
83
+ *
84
+ * Default: `true` when both `autoRenewal` and `billingCycles` are omitted; `false` when `billingCycles`
85
+ * is set and `autoRenewal` is omitted.
86
+ */
50
87
  autoRenewal?: boolean | null;
51
88
  /**
52
- * Number of billing cycles. If not provided and `auto_renewal` is not set, the subscription renews indefinitely.
89
+ * Number of billing cycles before the subscription stops. Cannot be set when `autoRenewal` is `true`.
90
+ *
91
+ * When omitted along with `autoRenewal`, the subscription renews indefinitely.
53
92
  * @min 1
54
93
  */
55
94
  billingCycles?: number | null;
@@ -58,6 +97,7 @@ interface SubscriptionSettings {
58
97
  }
59
98
  /** Frequency unit for subscription billing and trial periods. */
60
99
  declare enum SubscriptionFrequency {
100
+ /** Unknown frequency. */
61
101
  UNDEFINED = "UNDEFINED",
62
102
  DAY = "DAY",
63
103
  WEEK = "WEEK",
@@ -66,12 +106,27 @@ declare enum SubscriptionFrequency {
66
106
  }
67
107
  /** @enumType */
68
108
  type SubscriptionFrequencyWithLiterals = SubscriptionFrequency | 'UNDEFINED' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
69
- /** Free trial period before the first subscription charge. */
109
+ /**
110
+ * Free trial period before the first subscription charge.
111
+ *
112
+ * The `frequency` enum is shared with `SubscriptionSettings.frequency` for convenience, but here it
113
+ * describes a one-off duration unit (the length of the trial), not a recurring billing cadence. A
114
+ * `frequency: MONTH` + `interval: 3` trial means "a single 3-month trial," not "billed every three
115
+ * months."
116
+ */
70
117
  interface FreeTrialPeriod {
71
- /** Frequency unit for the trial period. */
118
+ /**
119
+ * Trial period frequency unit. Required when `freeTrialPeriod` is set; `UNDEFINED` should be
120
+ * treated as a client mistake and is not a valid runtime value.
121
+ */
72
122
  frequency?: SubscriptionFrequencyWithLiterals;
73
123
  /**
74
- * Duration in frequency units (e.g., 14 with DAY = 14-day trial).
124
+ * Length of the trial period in `frequency` units. For example, `interval: 14` with `frequency: DAY`
125
+ * gives a 14-day trial.
126
+ *
127
+ * Unlike `SubscriptionSettings.interval`, this field's `DAY` floor is `1` — there is no weekly-floor
128
+ * restriction on the trial length. Values ≤ 0 are rejected with `INVALID_ARGUMENT` (rule code
129
+ * `MIN_VALUE`).
75
130
  * @min 1
76
131
  * @max 999
77
132
  */
@@ -79,94 +134,131 @@ interface FreeTrialPeriod {
79
134
  }
80
135
  interface LineItem {
81
136
  /**
82
- * Name or title of the item.
137
+ * Name of the item, shown on the checkout page.
83
138
  * @minLength 1
84
139
  * @maxLength 255
85
140
  */
86
141
  name?: string | null;
87
142
  /**
88
- * Quantity of this item in the cart.
143
+ * Quantity of this item to charge for.
89
144
  * @min 1
90
145
  */
91
146
  quantity?: number | null;
92
147
  /**
93
- * Price of the item as a string (e.g., "19.99").
148
+ * Per-unit price as a decimal string in the merchant account currency. For example, `"19.99"`.
94
149
  * @minLength 1
95
150
  * @maxLength 50
96
151
  */
97
152
  price?: string | null;
98
- /** Optional. When provided, the item becomes a recurring subscription. */
153
+ /**
154
+ * Subscription configuration. When set, the line item follows a scheduled-billing model defined by
155
+ * `subscriptionSettings` instead of a single immediate charge. The recurring charge each billing
156
+ * cycle is `price × quantity`, and `quantity` is locked at session creation.
157
+ *
158
+ * At most one line item per request may set `subscriptionInfo`. Requests with two or more
159
+ * subscription line items are rejected with `MULTIPLE_SUBSCRIPTION_ITEMS`.
160
+ */
99
161
  subscriptionInfo?: SubscriptionInfo;
100
162
  }
101
- /** Customer information for pre-filling checkout details. */
163
+ /**
164
+ * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the
165
+ * Wix checkout page.
166
+ */
102
167
  interface CustomerInfo {
103
168
  /**
104
- * Customer's first name.
169
+ * Buyer's first name.
105
170
  * @maxLength 100
106
171
  */
107
172
  firstName?: string | null;
108
173
  /**
109
- * Customer's last name.
174
+ * Buyer's last name.
110
175
  * @maxLength 100
111
176
  */
112
177
  lastName?: string | null;
113
178
  /**
114
- * Customer's phone number.
179
+ * Buyer's phone number.
115
180
  * @format PHONE
116
181
  */
117
182
  phone?: string | null;
118
183
  /**
119
- * Customer's email address.
184
+ * Buyer's email address.
120
185
  * @format EMAIL
121
186
  */
122
187
  email?: string | null;
123
188
  }
189
+ /** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */
124
190
  interface Cart {
125
191
  /**
126
- * List of items in the cart.
192
+ * Line items the buyer is paying for in this checkout session.
193
+ *
194
+ * At most one subscription line item (an item with `subscriptionInfo` set) is allowed per request.
195
+ * Requests with two or more subscription items are rejected. One-time items can be combined with a
196
+ * single subscription item; in that case the buyer is charged once at checkout for the one-time items
197
+ * and (if applicable) the first cycle of the subscription, and any subsequent cycles are billed on
198
+ * the subscription's own schedule.
127
199
  * @maxSize 100
128
200
  */
129
201
  items?: LineItem[];
130
- /** Optional customer information to pre-fill checkout form. */
202
+ /**
203
+ * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the
204
+ * Wix checkout page.
205
+ */
131
206
  customerInfo?: CustomerInfo;
132
207
  }
208
+ /**
209
+ * URLs the buyer is redirected to after the checkout flow.
210
+ *
211
+ * The buyer is sent to one of the URLs below — `postFlowUrl` if they explicitly leave via **Continue
212
+ * browsing**, `thankYouPageUrl` after a successful payment.
213
+ *
214
+ * If the buyer abandons the page implicitly (closing the tab, navigating away, network failure), no
215
+ * callback URL is invoked and the checkout session is not resumed.
216
+ */
133
217
  interface CallbackUrls {
134
218
  /**
135
- * URL to redirect after the checkout flow completes.
219
+ * URL the buyer is redirected to from the Wix checkout page when they choose to leave without
220
+ * completing payment — both when they click **Continue browsing** and when they navigate back to
221
+ * a cart-style page.
136
222
  * @format WEB_URL
137
223
  */
138
224
  postFlowUrl?: string | null;
139
225
  /**
140
- * URL for the thank you page after successful payment.
226
+ * URL the buyer is redirected to after a successful payment.
141
227
  * @format WEB_URL
142
228
  */
143
229
  thankYouPageUrl?: string | null;
144
230
  }
145
- /** Response after constructing a checkout session. */
231
+ /** Response after creating a checkout session. */
146
232
  interface ConstructCheckoutSessionResponse {
147
- /** The constructed checkout session. */
233
+ /** The created checkout session. */
148
234
  checkoutSession?: CheckoutSession;
149
235
  }
150
236
  /** Request to register a webhook URL. */
151
237
  interface RegisterCheckoutSessionWebhookRequest {
152
238
  /**
153
- * The URL to receive webhook notifications.
239
+ * URL to receive webhook notifications.
154
240
  * @format WEB_URL
155
241
  */
156
242
  url?: string | null;
157
243
  /**
158
- * Webhook event types to register. When empty, defaults to [ORDER_APPROVED].
244
+ * Webhook event types to register. Default: `[ORDER_APPROVED]`.
159
245
  * @maxSize 10
160
246
  */
161
247
  webhookTypes?: WebhookTypeWithLiterals[];
162
248
  }
163
- /** Type of webhook event to register. */
249
+ /** Webhook event types to register. */
164
250
  declare enum WebhookType {
165
- /** Registers wix.ecom.v1.order_approved webhook. */
251
+ /** Order Approved webhook (`wix.ecom.v1.order_approved`). */
166
252
  ORDER_APPROVED = "ORDER_APPROVED",
167
- /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_canceled webhook. */
253
+ /**
254
+ * Subscription Contract Canceled webhook
255
+ * (`wix.ecom.subscription_contracts.v1.subscription_contract_canceled`).
256
+ */
168
257
  SUBSCRIPTION_CANCELED = "SUBSCRIPTION_CANCELED",
169
- /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_expired webhook. */
258
+ /**
259
+ * Subscription Contract Expired webhook
260
+ * (`wix.ecom.subscription_contracts.v1.subscription_contract_expired`).
261
+ */
170
262
  SUBSCRIPTION_ENDED = "SUBSCRIPTION_ENDED"
171
263
  }
172
264
  /** @enumType */
@@ -174,14 +266,28 @@ type WebhookTypeWithLiterals = WebhookType | 'ORDER_APPROVED' | 'SUBSCRIPTION_CA
174
266
  /** Response after registering a webhook. */
175
267
  interface RegisterCheckoutSessionWebhookResponse {
176
268
  /**
177
- * The webhook public key used for verifying webhook payloads.
269
+ * PEM-formatted RS256 public key used to verify the JWT signature on incoming webhook payloads.
178
270
  * @maxLength 1000
179
271
  */
180
272
  publicKey?: string | null;
181
273
  }
274
+ /** @docsIgnore */
275
+ type ConstructCheckoutSessionApplicationErrors = {
276
+ code?: 'MULTIPLE_SUBSCRIPTION_ITEMS';
277
+ description?: string;
278
+ data?: Record<string, any>;
279
+ } | {
280
+ code?: 'AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT';
281
+ description?: string;
282
+ data?: Record<string, any>;
283
+ };
182
284
  /**
183
- * Constructs a new checkout session.
184
- * @param cart - Cart details including line items to be checked out.
285
+ * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`
286
+ * and `id`.
287
+ *
288
+ * Each call creates a new, independent session; the method is not idempotent, so a retry produces
289
+ * an additional session rather than recovering an existing one.
290
+ * @param cart - Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details.
185
291
  * @public
186
292
  * @documentationMaturity preview
187
293
  * @requiredField cart
@@ -189,18 +295,23 @@ interface RegisterCheckoutSessionWebhookResponse {
189
295
  * @requiredField cart.items.name
190
296
  * @requiredField cart.items.price
191
297
  * @requiredField cart.items.quantity
298
+ * @requiredField cart.items.subscriptionInfo.subscriptionSettings
299
+ * @requiredField cart.items.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency
300
+ * @requiredField cart.items.subscriptionInfo.subscriptionSettings.frequency
192
301
  * @requiredField options
193
302
  * @requiredField options.callbackUrls
194
303
  * @requiredField options.callbackUrls.postFlowUrl
195
304
  * @requiredField options.callbackUrls.thankYouPageUrl
196
305
  * @permissionId payments:platform:v1:checkout_session:construct_checkout_session
197
- * @returns Response after constructing a checkout session.
306
+ * @returns Response after creating a checkout session.
198
307
  * @fqn wix.payments.platform.v1.CheckoutSessions.ConstructCheckoutSession
199
308
  */
200
- declare function constructCheckoutSession(cart: NonNullablePaths<Cart, `items` | `items.${number}.name` | `items.${number}.price` | `items.${number}.quantity`, 4>, options: NonNullablePaths<ConstructCheckoutSessionOptions, `callbackUrls` | `callbackUrls.postFlowUrl` | `callbackUrls.thankYouPageUrl`, 3>): Promise<ConstructCheckoutSessionResponse>;
309
+ declare function constructCheckoutSession(cart: NonNullablePaths<Cart, `items` | `items.${number}.name` | `items.${number}.price` | `items.${number}.quantity` | `items.${number}.subscriptionInfo.subscriptionSettings` | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency` | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`, 7>, options: NonNullablePaths<ConstructCheckoutSessionOptions, `callbackUrls` | `callbackUrls.postFlowUrl` | `callbackUrls.thankYouPageUrl`, 3>): Promise<ConstructCheckoutSessionResponse & {
310
+ __applicationErrorsType?: ConstructCheckoutSessionApplicationErrors;
311
+ }>;
201
312
  interface ConstructCheckoutSessionOptions {
202
- /** Callback URLs for redirecting the user after checkout flow. */
313
+ /** URLs the buyer is redirected to after completing or leaving the checkout flow. */
203
314
  callbackUrls: CallbackUrls;
204
315
  }
205
316
 
206
- 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, WebhookType, type WebhookTypeWithLiterals, constructCheckoutSession };
317
+ export { type CallbackUrls, type Cart, type CheckoutSession, type ConstructCheckoutSessionApplicationErrors, type ConstructCheckoutSessionOptions, type ConstructCheckoutSessionRequest, type ConstructCheckoutSessionResponse, type CustomerInfo, type FreeTrialPeriod, type LineItem, type RegisterCheckoutSessionWebhookRequest, type RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, type SubscriptionFrequencyWithLiterals, type SubscriptionInfo, type SubscriptionSettings, WebhookType, type WebhookTypeWithLiterals, constructCheckoutSession };
@@ -49,6 +49,12 @@ function resolveWixPaymentsPlatformV1CheckoutSessionsUrl(opts) {
49
49
  srcPath: "/_api/checkout-sessions",
50
50
  destPath: ""
51
51
  }
52
+ ],
53
+ "manage.base44.com": [
54
+ {
55
+ srcPath: "/_api/checkout-sessions",
56
+ destPath: ""
57
+ }
52
58
  ]
53
59
  };
54
60
  return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
@@ -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\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 * Webhook event types to register. When empty, defaults to [ORDER_APPROVED].\n * @maxSize 10\n */\n webhookTypes?: WebhookTypeWithLiterals[];\n}\n\n/** Type of webhook event to register. */\nexport enum WebhookType {\n /** Registers wix.ecom.v1.order_approved webhook. */\n ORDER_APPROVED = 'ORDER_APPROVED',\n /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_canceled webhook. */\n SUBSCRIPTION_CANCELED = 'SUBSCRIPTION_CANCELED',\n /** Registers wix.ecom.subscription_contracts.v1.subscription_contract_expired webhook. */\n SUBSCRIPTION_ENDED = 'SUBSCRIPTION_ENDED',\n}\n\n/** @enumType */\nexport type WebhookTypeWithLiterals =\n | WebhookType\n | 'ORDER_APPROVED'\n | 'SUBSCRIPTION_CANCELED'\n | 'SUBSCRIPTION_ENDED';\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 srcPath: '/payments/base44/v1/subscriptions',\n destPath: '/v1/subscriptions',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\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;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,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;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;;;ADYO,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;AAuHL,IAAK,cAAL,kBAAKC,iBAAL;AAEL,EAAAA,aAAA,oBAAiB;AAEjB,EAAAA,aAAA,2BAAwB;AAExB,EAAAA,aAAA,wBAAqB;AANX,SAAAA;AAAA,GAAA;AA2CZ,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","WebhookType","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 Wix-hosted checkout page generated for a specific set of line items. */\nexport interface CheckoutSession {\n /**\n * Checkout session ID, generated by this call. The caller does not supply it.\n * @readonly\n * @format GUID\n */\n _id?: string | null;\n /**\n * URL of the Wix-hosted checkout page where the buyer completes payment. The buyer enters the page as\n * an anonymous shopper; any session held by the calling app is not carried over.\n *\n * The URL carries query parameters Wix needs in order to render the page correctly (for example, a\n * `successUrl` parameter derived from `callbackUrls.thankYouPageUrl`). Pass the URL through to the\n * buyer unchanged — do not strip, reorder, rewrite, or otherwise mutate its query string.\n * @readonly\n * @format WEB_URL\n */\n redirectUrl?: string | null;\n}\n\n/** Request to create a checkout session. */\nexport interface ConstructCheckoutSessionRequest {\n /** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */\n cart: Cart;\n /** URLs the buyer is redirected to after completing or leaving the checkout flow. */\n callbackUrls: CallbackUrls;\n}\n\n/**\n * Recurring subscription configuration for a line item.\n *\n * `LineItem.name` and `subscriptionInfo.title`/`description` render in different parts of the\n * Wix-hosted checkout page: `LineItem.name` is the line label in the cart-summary list, while\n * `subscriptionInfo.title` and `subscriptionInfo.description` are the heading and body text on the\n * recurring-billing summary block (the area that shows the buyer the cadence and the free-trial terms,\n * if any). Set them to complementary values rather than duplicating `LineItem.name`.\n */\nexport interface SubscriptionInfo {\n /**\n * Billing frequency, cycles, and free trial configuration. Required when `subscriptionInfo` is set on a\n * line item.\n */\n subscriptionSettings?: SubscriptionSettings;\n /**\n * Subscription name shown to the buyer in the recurring-billing summary block on the Wix-hosted\n * checkout page (the heading of that block).\n * @maxLength 150\n */\n title?: string | null;\n /**\n * Subscription description shown to the buyer in the recurring-billing summary block on the\n * Wix-hosted checkout page (the body text below the title).\n * @maxLength 500\n */\n description?: string | null;\n}\n\n/**\n * Configuration for recurring subscription charges.\n *\n * `autoRenewal` and `billingCycles` are mutually exclusive — `autoRenewal: true` describes an\n * open-ended subscription that renews indefinitely, while `billingCycles: N` describes a fixed-term\n * subscription that stops after N charges. Setting `autoRenewal: true` together with any\n * `billingCycles` value is rejected with `INVALID_ARGUMENT` (application code\n * `AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT`).\n */\nexport interface SubscriptionSettings {\n /** Billing frequency unit. Required when `subscriptionSettings` is set; `UNDEFINED` is rejected. */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Number of frequency units between charges. For `DAY` frequency, the minimum is 7 — the shortest\n * billing cadence supported is weekly; values 1–6 with `frequency: DAY` are rejected with\n * `INVALID_ARGUMENT` (rule code `MIN_VALUE`). Default: `1`.\n *\n * Note that `freeTrialPeriod.interval` does **not** share this floor — a `DAY` trial may have\n * `interval` as low as 1.\n * @min 1\n * @max 3650\n */\n interval?: number | null;\n /**\n * Whether the subscription renews automatically. Cannot be `true` when `billingCycles` is set.\n *\n * Default: `true` when both `autoRenewal` and `billingCycles` are omitted; `false` when `billingCycles`\n * is set and `autoRenewal` is omitted.\n */\n autoRenewal?: boolean | null;\n /**\n * Number of billing cycles before the subscription stops. Cannot be set when `autoRenewal` is `true`.\n *\n * When omitted along with `autoRenewal`, 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 /** Unknown frequency. */\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/**\n * Free trial period before the first subscription charge.\n *\n * The `frequency` enum is shared with `SubscriptionSettings.frequency` for convenience, but here it\n * describes a one-off duration unit (the length of the trial), not a recurring billing cadence. A\n * `frequency: MONTH` + `interval: 3` trial means \"a single 3-month trial,\" not \"billed every three\n * months.\"\n */\nexport interface FreeTrialPeriod {\n /**\n * Trial period frequency unit. Required when `freeTrialPeriod` is set; `UNDEFINED` should be\n * treated as a client mistake and is not a valid runtime value.\n */\n frequency?: SubscriptionFrequencyWithLiterals;\n /**\n * Length of the trial period in `frequency` units. For example, `interval: 14` with `frequency: DAY`\n * gives a 14-day trial.\n *\n * Unlike `SubscriptionSettings.interval`, this field's `DAY` floor is `1` — there is no weekly-floor\n * restriction on the trial length. Values ≤ 0 are rejected with `INVALID_ARGUMENT` (rule code\n * `MIN_VALUE`).\n * @min 1\n * @max 999\n */\n interval?: number;\n}\n\nexport interface LineItem {\n /**\n * Name of the item, shown on the checkout page.\n * @minLength 1\n * @maxLength 255\n */\n name?: string | null;\n /**\n * Quantity of this item to charge for.\n * @min 1\n */\n quantity?: number | null;\n /**\n * Per-unit price as a decimal string in the merchant account currency. For example, `\"19.99\"`.\n * @minLength 1\n * @maxLength 50\n */\n price?: string | null;\n /**\n * Subscription configuration. When set, the line item follows a scheduled-billing model defined by\n * `subscriptionSettings` instead of a single immediate charge. The recurring charge each billing\n * cycle is `price × quantity`, and `quantity` is locked at session creation.\n *\n * At most one line item per request may set `subscriptionInfo`. Requests with two or more\n * subscription line items are rejected with `MULTIPLE_SUBSCRIPTION_ITEMS`.\n */\n subscriptionInfo?: SubscriptionInfo;\n}\n\n/**\n * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the\n * Wix checkout page.\n */\nexport interface CustomerInfo {\n /**\n * Buyer's first name.\n * @maxLength 100\n */\n firstName?: string | null;\n /**\n * Buyer's last name.\n * @maxLength 100\n */\n lastName?: string | null;\n /**\n * Buyer's phone number.\n * @format PHONE\n */\n phone?: string | null;\n /**\n * Buyer's email address.\n * @format EMAIL\n */\n email?: string | null;\n}\n\n/** Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details. */\nexport interface Cart {\n /**\n * Line items the buyer is paying for in this checkout session.\n *\n * At most one subscription line item (an item with `subscriptionInfo` set) is allowed per request.\n * Requests with two or more subscription items are rejected. One-time items can be combined with a\n * single subscription item; in that case the buyer is charged once at checkout for the one-time items\n * and (if applicable) the first cycle of the subscription, and any subsequent cycles are billed on\n * the subscription's own schedule.\n * @maxSize 100\n */\n items?: LineItem[];\n /**\n * Buyer details used to pre-fill the checkout form. The buyer can edit any of these fields on the\n * Wix checkout page.\n */\n customerInfo?: CustomerInfo;\n}\n\n/**\n * URLs the buyer is redirected to after the checkout flow.\n *\n * The buyer is sent to one of the URLs below — `postFlowUrl` if they explicitly leave via **Continue\n * browsing**, `thankYouPageUrl` after a successful payment.\n *\n * If the buyer abandons the page implicitly (closing the tab, navigating away, network failure), no\n * callback URL is invoked and the checkout session is not resumed.\n */\nexport interface CallbackUrls {\n /**\n * URL the buyer is redirected to from the Wix checkout page when they choose to leave without\n * completing payment — both when they click **Continue browsing** and when they navigate back to\n * a cart-style page.\n * @format WEB_URL\n */\n postFlowUrl?: string | null;\n /**\n * URL the buyer is redirected to after a successful payment.\n * @format WEB_URL\n */\n thankYouPageUrl?: string | null;\n}\n\n/** Response after creating a checkout session. */\nexport interface ConstructCheckoutSessionResponse {\n /** The created checkout session. */\n checkoutSession?: CheckoutSession;\n}\n\n/** Request to register a webhook URL. */\nexport interface RegisterCheckoutSessionWebhookRequest {\n /**\n * URL to receive webhook notifications.\n * @format WEB_URL\n */\n url?: string | null;\n /**\n * Webhook event types to register. Default: `[ORDER_APPROVED]`.\n * @maxSize 10\n */\n webhookTypes?: WebhookTypeWithLiterals[];\n}\n\n/** Webhook event types to register. */\nexport enum WebhookType {\n /** Order Approved webhook (`wix.ecom.v1.order_approved`). */\n ORDER_APPROVED = 'ORDER_APPROVED',\n /**\n * Subscription Contract Canceled webhook\n * (`wix.ecom.subscription_contracts.v1.subscription_contract_canceled`).\n */\n SUBSCRIPTION_CANCELED = 'SUBSCRIPTION_CANCELED',\n /**\n * Subscription Contract Expired webhook\n * (`wix.ecom.subscription_contracts.v1.subscription_contract_expired`).\n */\n SUBSCRIPTION_ENDED = 'SUBSCRIPTION_ENDED',\n}\n\n/** @enumType */\nexport type WebhookTypeWithLiterals =\n | WebhookType\n | 'ORDER_APPROVED'\n | 'SUBSCRIPTION_CANCELED'\n | 'SUBSCRIPTION_ENDED';\n\n/** Response after registering a webhook. */\nexport interface RegisterCheckoutSessionWebhookResponse {\n /**\n * PEM-formatted RS256 public key used to verify the JWT signature on incoming webhook payloads.\n * @maxLength 1000\n */\n publicKey?: string | null;\n}\n\n/** @docsIgnore */\nexport type ConstructCheckoutSessionApplicationErrors =\n | {\n code?: 'MULTIPLE_SUBSCRIPTION_ITEMS';\n description?: string;\n data?: Record<string, any>;\n }\n | {\n code?: 'AUTO_RENEWAL_AND_BILLING_CYCLES_CONFLICT';\n description?: string;\n data?: Record<string, any>;\n };\n\n/**\n * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`\n * and `id`.\n *\n * Each call creates a new, independent session; the method is not idempotent, so a retry produces\n * an additional session rather than recovering an existing one.\n * @param cart - Items, quantities, and prices the buyer is paying for, plus optional pre-fill customer details.\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 cart.items.subscriptionInfo.subscriptionSettings\n * @requiredField cart.items.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency\n * @requiredField cart.items.subscriptionInfo.subscriptionSettings.frequency\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 creating 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 | `items.${number}.subscriptionInfo.subscriptionSettings`\n | `items.${number}.subscriptionInfo.subscriptionSettings.freeTrialPeriod.frequency`\n | `items.${number}.subscriptionInfo.subscriptionSettings.frequency`,\n 7\n >,\n options: NonNullablePaths<\n ConstructCheckoutSessionOptions,\n | `callbackUrls`\n | `callbackUrls.postFlowUrl`\n | `callbackUrls.thankYouPageUrl`,\n 3\n >\n): Promise<\n ConstructCheckoutSessionResponse & {\n __applicationErrorsType?: ConstructCheckoutSessionApplicationErrors;\n }\n> {\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 /** URLs the buyer is redirected to after completing or leaving the 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 srcPath: '/payments/base44/v1/subscriptions',\n destPath: '/v1/subscriptions',\n },\n ],\n 'manage._base_domain_': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\n },\n ],\n 'manage.base44.com': [\n {\n srcPath: '/_api/checkout-sessions',\n destPath: '',\n },\n ],\n };\n\n return resolveUrl(Object.assign(opts, { domainToMappings }));\n}\n\nconst PACKAGE_NAME = '@wix/auto_sdk_payments_checkout-sessions';\n\n/**\n * Creates a Wix-hosted checkout session for the supplied line items and returns its `redirectUrl`\n * and `id`.\n *\n * Each call creates a new, independent session; the method is not idempotent, so a retry produces\n * an additional session rather than recovering an existing one.\n */\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;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,MACA;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,wBAAwB;AAAA,MACtB;AAAA,QACE,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB;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;AASd,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;;;ADuCO,IAAK,wBAAL,kBAAKC,2BAAL;AAEL,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,UAAO;AANG,SAAAA;AAAA,GAAA;AAsKL,IAAK,cAAL,kBAAKC,iBAAL;AAEL,EAAAA,aAAA,oBAAiB;AAKjB,EAAAA,aAAA,2BAAwB;AAKxB,EAAAA,aAAA,wBAAqB;AAZX,SAAAA;AAAA,GAAA;AAqEZ,eAAsBC,0BACpB,MAWA,SAWA;AAEA,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","WebhookType","constructCheckoutSession","sdkTransformError"]}