@wix/auto_sdk_payments_checkout-sessions 1.0.2 → 1.0.3
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 +60 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.typings.d.ts +24 -1
- package/build/cjs/index.typings.js +51 -0
- package/build/cjs/index.typings.js.map +1 -1
- package/build/cjs/meta.d.ts +19 -2
- package/build/cjs/meta.js +41 -0
- package/build/cjs/meta.js.map +1 -1
- package/build/es/index.d.mts +1 -1
- package/build/es/index.mjs +59 -0
- package/build/es/index.mjs.map +1 -1
- package/build/es/index.typings.d.mts +24 -1
- package/build/es/index.typings.mjs +50 -0
- package/build/es/index.typings.mjs.map +1 -1
- package/build/es/meta.d.mts +19 -2
- package/build/es/meta.mjs +40 -0
- package/build/es/meta.mjs.map +1 -1
- package/build/internal/cjs/index.d.ts +15 -3
- package/build/internal/cjs/index.js +60 -0
- package/build/internal/cjs/index.js.map +1 -1
- package/build/internal/cjs/index.typings.d.ts +35 -1
- package/build/internal/cjs/index.typings.js +51 -0
- package/build/internal/cjs/index.typings.js.map +1 -1
- package/build/internal/cjs/meta.d.ts +19 -2
- package/build/internal/cjs/meta.js +41 -0
- package/build/internal/cjs/meta.js.map +1 -1
- package/build/internal/es/index.d.mts +15 -3
- package/build/internal/es/index.mjs +59 -0
- package/build/internal/es/index.mjs.map +1 -1
- package/build/internal/es/index.typings.d.mts +35 -1
- package/build/internal/es/index.typings.mjs +50 -0
- package/build/internal/es/index.typings.mjs.map +1 -1
- package/build/internal/es/meta.d.mts +19 -2
- package/build/internal/es/meta.mjs +40 -0
- package/build/internal/es/meta.mjs.map +1 -1
- package/package.json +2 -2
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, FreeTrialPeriod, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionInfo, SubscriptionSettings } from './index.typings.js';
|
|
3
|
+
export { CallbackUrls, CancelSubscriptionOptions, CancelSubscriptionRequest, CancelSubscriptionResponse, 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
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
SubscriptionFrequency: () => SubscriptionFrequency,
|
|
24
|
+
cancelSubscription: () => cancelSubscription4,
|
|
24
25
|
constructCheckoutSession: () => constructCheckoutSession4
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -64,6 +65,27 @@ function constructCheckoutSession(payload) {
|
|
|
64
65
|
}
|
|
65
66
|
return __constructCheckoutSession;
|
|
66
67
|
}
|
|
68
|
+
function cancelSubscription(payload) {
|
|
69
|
+
function __cancelSubscription({ host }) {
|
|
70
|
+
const metadata = {
|
|
71
|
+
entityFqdn: "wix.payments.platform.v1.checkout_session",
|
|
72
|
+
method: "POST",
|
|
73
|
+
methodFqn: "wix.payments.platform.v1.CheckoutSessions.CancelSubscription",
|
|
74
|
+
packageName: PACKAGE_NAME,
|
|
75
|
+
migrationOptions: {
|
|
76
|
+
optInTransformResponse: true
|
|
77
|
+
},
|
|
78
|
+
url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({
|
|
79
|
+
protoPath: "/v1/checkout-sessions/cancel-subscription",
|
|
80
|
+
data: payload,
|
|
81
|
+
host
|
|
82
|
+
}),
|
|
83
|
+
data: payload
|
|
84
|
+
};
|
|
85
|
+
return metadata;
|
|
86
|
+
}
|
|
87
|
+
return __cancelSubscription;
|
|
88
|
+
}
|
|
67
89
|
|
|
68
90
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
69
91
|
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
@@ -105,6 +127,34 @@ async function constructCheckoutSession2(cart, options) {
|
|
|
105
127
|
throw transformedError;
|
|
106
128
|
}
|
|
107
129
|
}
|
|
130
|
+
async function cancelSubscription2(subscriptionContractId, options) {
|
|
131
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
132
|
+
const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
|
|
133
|
+
subscriptionContractId,
|
|
134
|
+
reason: options?.reason
|
|
135
|
+
});
|
|
136
|
+
const reqOpts = cancelSubscription(payload);
|
|
137
|
+
sideEffects?.onSiteCall?.();
|
|
138
|
+
try {
|
|
139
|
+
const result = await httpClient.request(reqOpts);
|
|
140
|
+
sideEffects?.onSuccess?.(result);
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const transformedError = (0, import_transform_error.transformError)(
|
|
143
|
+
err,
|
|
144
|
+
{
|
|
145
|
+
spreadPathsToArguments: {},
|
|
146
|
+
explicitPathsToArguments: {
|
|
147
|
+
subscriptionContractId: "$[0]",
|
|
148
|
+
reason: "$[1].reason"
|
|
149
|
+
},
|
|
150
|
+
singleArgumentUnchanged: false
|
|
151
|
+
},
|
|
152
|
+
["subscriptionContractId", "options"]
|
|
153
|
+
);
|
|
154
|
+
sideEffects?.onError?.(err);
|
|
155
|
+
throw transformedError;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
108
158
|
|
|
109
159
|
// src/payments-platform-v1-checkout-session-checkout-sessions.public.ts
|
|
110
160
|
function constructCheckoutSession3(httpClient) {
|
|
@@ -115,13 +165,23 @@ function constructCheckoutSession3(httpClient) {
|
|
|
115
165
|
{ httpClient }
|
|
116
166
|
);
|
|
117
167
|
}
|
|
168
|
+
function cancelSubscription3(httpClient) {
|
|
169
|
+
return (subscriptionContractId, options) => cancelSubscription2(
|
|
170
|
+
subscriptionContractId,
|
|
171
|
+
options,
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
{ httpClient }
|
|
174
|
+
);
|
|
175
|
+
}
|
|
118
176
|
|
|
119
177
|
// src/payments-platform-v1-checkout-session-checkout-sessions.context.ts
|
|
120
178
|
var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
|
|
121
179
|
var constructCheckoutSession4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(constructCheckoutSession3);
|
|
180
|
+
var cancelSubscription4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(cancelSubscription3);
|
|
122
181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
123
182
|
0 && (module.exports = {
|
|
124
183
|
SubscriptionFrequency,
|
|
184
|
+
cancelSubscription,
|
|
125
185
|
constructCheckoutSession
|
|
126
186
|
});
|
|
127
187
|
//# 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\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"]}
|
|
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/** Request to cancel a subscription. */\nexport interface CancelSubscriptionRequest {\n /**\n * Ecom subscription contract ID used to resolve the billing subscription.\n * @format GUID\n */\n subscriptionContractId: string;\n /**\n * Optional reason for cancellation.\n * @maxLength 500\n */\n reason?: string | null;\n}\n\n/** Response after canceling a subscription. */\nexport interface CancelSubscriptionResponse {}\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\n/**\n * Cancels a subscription by resolving the billing subscription from the Ecom subscription contract.\n * @param subscriptionContractId - Ecom subscription contract ID used to resolve the billing subscription.\n * @internal\n * @documentationMaturity preview\n * @requiredField subscriptionContractId\n * @permissionId payments:platform:v1:checkout_session:cancel_subscription\n * @returns Response after canceling a subscription.\n * @fqn wix.payments.platform.v1.CheckoutSessions.CancelSubscription\n */\nexport async function cancelSubscription(\n subscriptionContractId: string,\n options?: CancelSubscriptionOptions\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n subscriptionContractId: subscriptionContractId,\n reason: options?.reason,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.cancelSubscription(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n subscriptionContractId: '$[0]',\n reason: '$[1].reason',\n },\n singleArgumentUnchanged: false,\n },\n ['subscriptionContractId', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface CancelSubscriptionOptions {\n /**\n * Optional reason for cancellation.\n * @maxLength 500\n */\n reason?: string | null;\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\n/** Cancels a subscription by resolving the billing subscription from the Ecom subscription contract. */\nexport function cancelSubscription(\n payload: object\n): RequestOptionsFactory<any> {\n function __cancelSubscription({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn: 'wix.payments.platform.v1.CheckoutSessions.CancelSubscription',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/cancel-subscription',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __cancelSubscription;\n}\n","import { HttpClient, NonNullablePaths } from '@wix/sdk-types';\nimport {\n CancelSubscriptionOptions,\n Cart,\n ConstructCheckoutSessionOptions,\n ConstructCheckoutSessionResponse,\n cancelSubscription as universalCancelSubscription,\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\n/** @internal */\nexport function cancelSubscription(\n httpClient: HttpClient\n): CancelSubscriptionSignature {\n return (\n subscriptionContractId: string,\n options?: CancelSubscriptionOptions\n ) =>\n universalCancelSubscription(\n subscriptionContractId,\n options,\n // @ts-ignore\n { httpClient }\n );\n}\n\ninterface CancelSubscriptionSignature {\n /**\n * Cancels a subscription by resolving the billing subscription from the Ecom subscription contract.\n * @param - Ecom subscription contract ID used to resolve the billing subscription.\n * @returns Response after canceling a subscription.\n */\n (\n subscriptionContractId: string,\n options?: CancelSubscriptionOptions\n ): Promise<void>;\n}\n\nexport {\n CallbackUrls,\n CancelSubscriptionOptions,\n CancelSubscriptionRequest,\n CancelSubscriptionResponse,\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 {\n constructCheckoutSession as publicConstructCheckoutSession,\n cancelSubscription as publicCancelSubscription,\n} 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/** @internal */\nexport const cancelSubscription: MaybeContext<\n BuildRESTFunction<typeof publicCancelSubscription> &\n typeof publicCancelSubscription\n> = /*#__PURE__*/ createRESTModule(publicCancelSubscription);\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 CancelSubscriptionRequest,\n CancelSubscriptionResponse,\n ConstructCheckoutSessionOptions,\n CancelSubscriptionOptions,\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":"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","names":["cancelSubscription","constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession","sdkTransformError","cancelSubscription","constructCheckoutSession","cancelSubscription","import_rest_modules","constructCheckoutSession","cancelSubscription"]}
|
|
@@ -163,6 +163,22 @@ interface RegisterCheckoutSessionWebhookResponse {
|
|
|
163
163
|
*/
|
|
164
164
|
publicKey?: string | null;
|
|
165
165
|
}
|
|
166
|
+
/** Request to cancel a subscription. */
|
|
167
|
+
interface CancelSubscriptionRequest {
|
|
168
|
+
/**
|
|
169
|
+
* Ecom subscription contract ID used to resolve the billing subscription.
|
|
170
|
+
* @format GUID
|
|
171
|
+
*/
|
|
172
|
+
subscriptionContractId: string;
|
|
173
|
+
/**
|
|
174
|
+
* Optional reason for cancellation.
|
|
175
|
+
* @maxLength 500
|
|
176
|
+
*/
|
|
177
|
+
reason?: string | null;
|
|
178
|
+
}
|
|
179
|
+
/** Response after canceling a subscription. */
|
|
180
|
+
interface CancelSubscriptionResponse {
|
|
181
|
+
}
|
|
166
182
|
/**
|
|
167
183
|
* Constructs a new checkout session.
|
|
168
184
|
* @param cart - Cart details including line items to be checked out.
|
|
@@ -186,5 +202,12 @@ interface ConstructCheckoutSessionOptions {
|
|
|
186
202
|
/** Callback URLs for redirecting the user after checkout flow. */
|
|
187
203
|
callbackUrls: CallbackUrls;
|
|
188
204
|
}
|
|
205
|
+
interface CancelSubscriptionOptions {
|
|
206
|
+
/**
|
|
207
|
+
* Optional reason for cancellation.
|
|
208
|
+
* @maxLength 500
|
|
209
|
+
*/
|
|
210
|
+
reason?: string | null;
|
|
211
|
+
}
|
|
189
212
|
|
|
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 };
|
|
213
|
+
export { type CallbackUrls, type CancelSubscriptionOptions, type CancelSubscriptionRequest, type CancelSubscriptionResponse, 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 };
|
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_typings_exports = {};
|
|
22
22
|
__export(index_typings_exports, {
|
|
23
23
|
SubscriptionFrequency: () => SubscriptionFrequency,
|
|
24
|
+
cancelSubscription: () => cancelSubscription2,
|
|
24
25
|
constructCheckoutSession: () => constructCheckoutSession2
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_typings_exports);
|
|
@@ -64,6 +65,27 @@ function constructCheckoutSession(payload) {
|
|
|
64
65
|
}
|
|
65
66
|
return __constructCheckoutSession;
|
|
66
67
|
}
|
|
68
|
+
function cancelSubscription(payload) {
|
|
69
|
+
function __cancelSubscription({ host }) {
|
|
70
|
+
const metadata = {
|
|
71
|
+
entityFqdn: "wix.payments.platform.v1.checkout_session",
|
|
72
|
+
method: "POST",
|
|
73
|
+
methodFqn: "wix.payments.platform.v1.CheckoutSessions.CancelSubscription",
|
|
74
|
+
packageName: PACKAGE_NAME,
|
|
75
|
+
migrationOptions: {
|
|
76
|
+
optInTransformResponse: true
|
|
77
|
+
},
|
|
78
|
+
url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({
|
|
79
|
+
protoPath: "/v1/checkout-sessions/cancel-subscription",
|
|
80
|
+
data: payload,
|
|
81
|
+
host
|
|
82
|
+
}),
|
|
83
|
+
data: payload
|
|
84
|
+
};
|
|
85
|
+
return metadata;
|
|
86
|
+
}
|
|
87
|
+
return __cancelSubscription;
|
|
88
|
+
}
|
|
67
89
|
|
|
68
90
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
69
91
|
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
@@ -105,9 +127,38 @@ async function constructCheckoutSession2(cart, options) {
|
|
|
105
127
|
throw transformedError;
|
|
106
128
|
}
|
|
107
129
|
}
|
|
130
|
+
async function cancelSubscription2(subscriptionContractId, options) {
|
|
131
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
132
|
+
const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
|
|
133
|
+
subscriptionContractId,
|
|
134
|
+
reason: options?.reason
|
|
135
|
+
});
|
|
136
|
+
const reqOpts = cancelSubscription(payload);
|
|
137
|
+
sideEffects?.onSiteCall?.();
|
|
138
|
+
try {
|
|
139
|
+
const result = await httpClient.request(reqOpts);
|
|
140
|
+
sideEffects?.onSuccess?.(result);
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const transformedError = (0, import_transform_error.transformError)(
|
|
143
|
+
err,
|
|
144
|
+
{
|
|
145
|
+
spreadPathsToArguments: {},
|
|
146
|
+
explicitPathsToArguments: {
|
|
147
|
+
subscriptionContractId: "$[0]",
|
|
148
|
+
reason: "$[1].reason"
|
|
149
|
+
},
|
|
150
|
+
singleArgumentUnchanged: false
|
|
151
|
+
},
|
|
152
|
+
["subscriptionContractId", "options"]
|
|
153
|
+
);
|
|
154
|
+
sideEffects?.onError?.(err);
|
|
155
|
+
throw transformedError;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
108
158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
159
|
0 && (module.exports = {
|
|
110
160
|
SubscriptionFrequency,
|
|
161
|
+
cancelSubscription,
|
|
111
162
|
constructCheckoutSession
|
|
112
163
|
});
|
|
113
164
|
//# 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\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"]}
|
|
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/** Request to cancel a subscription. */\nexport interface CancelSubscriptionRequest {\n /**\n * Ecom subscription contract ID used to resolve the billing subscription.\n * @format GUID\n */\n subscriptionContractId: string;\n /**\n * Optional reason for cancellation.\n * @maxLength 500\n */\n reason?: string | null;\n}\n\n/** Response after canceling a subscription. */\nexport interface CancelSubscriptionResponse {}\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\n/**\n * Cancels a subscription by resolving the billing subscription from the Ecom subscription contract.\n * @param subscriptionContractId - Ecom subscription contract ID used to resolve the billing subscription.\n * @internal\n * @documentationMaturity preview\n * @requiredField subscriptionContractId\n * @permissionId payments:platform:v1:checkout_session:cancel_subscription\n * @returns Response after canceling a subscription.\n * @fqn wix.payments.platform.v1.CheckoutSessions.CancelSubscription\n */\nexport async function cancelSubscription(\n subscriptionContractId: string,\n options?: CancelSubscriptionOptions\n): Promise<void> {\n // @ts-ignore\n const { httpClient, sideEffects } = arguments[2] as {\n httpClient: HttpClient;\n sideEffects?: any;\n };\n\n const payload = renameKeysFromSDKRequestToRESTRequest({\n subscriptionContractId: subscriptionContractId,\n reason: options?.reason,\n });\n\n const reqOpts =\n ambassadorWixPaymentsPlatformV1CheckoutSession.cancelSubscription(payload);\n\n sideEffects?.onSiteCall?.();\n try {\n const result = await httpClient.request(reqOpts);\n sideEffects?.onSuccess?.(result);\n } catch (err: any) {\n const transformedError = sdkTransformError(\n err,\n {\n spreadPathsToArguments: {},\n explicitPathsToArguments: {\n subscriptionContractId: '$[0]',\n reason: '$[1].reason',\n },\n singleArgumentUnchanged: false,\n },\n ['subscriptionContractId', 'options']\n );\n sideEffects?.onError?.(err);\n\n throw transformedError;\n }\n}\n\nexport interface CancelSubscriptionOptions {\n /**\n * Optional reason for cancellation.\n * @maxLength 500\n */\n reason?: string | null;\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\n/** Cancels a subscription by resolving the billing subscription from the Ecom subscription contract. */\nexport function cancelSubscription(\n payload: object\n): RequestOptionsFactory<any> {\n function __cancelSubscription({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn: 'wix.payments.platform.v1.CheckoutSessions.CancelSubscription',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/cancel-subscription',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __cancelSubscription;\n}\n"],"mappings":"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","names":["cancelSubscription","constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession","sdkTransformError","cancelSubscription"]}
|
package/build/cjs/meta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequest$1, ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponse$1 } from './index.typings.js';
|
|
1
|
+
import { ConstructCheckoutSessionRequest as ConstructCheckoutSessionRequest$1, ConstructCheckoutSessionResponse as ConstructCheckoutSessionResponse$1, CancelSubscriptionRequest as CancelSubscriptionRequest$1, CancelSubscriptionResponse as CancelSubscriptionResponse$1 } from './index.typings.js';
|
|
2
2
|
import '@wix/sdk-types';
|
|
3
3
|
|
|
4
4
|
/** A CheckoutSession is a simple entity used for demonstration purposes. */
|
|
@@ -164,6 +164,22 @@ interface RegisterCheckoutSessionWebhookResponse {
|
|
|
164
164
|
*/
|
|
165
165
|
publicKey?: string | null;
|
|
166
166
|
}
|
|
167
|
+
/** Request to cancel a subscription. */
|
|
168
|
+
interface CancelSubscriptionRequest {
|
|
169
|
+
/**
|
|
170
|
+
* Ecom subscription contract ID used to resolve the billing subscription.
|
|
171
|
+
* @format GUID
|
|
172
|
+
*/
|
|
173
|
+
subscriptionContractId: string;
|
|
174
|
+
/**
|
|
175
|
+
* Optional reason for cancellation.
|
|
176
|
+
* @maxLength 500
|
|
177
|
+
*/
|
|
178
|
+
reason?: string | null;
|
|
179
|
+
}
|
|
180
|
+
/** Response after canceling a subscription. */
|
|
181
|
+
interface CancelSubscriptionResponse {
|
|
182
|
+
}
|
|
167
183
|
|
|
168
184
|
type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q = unknown, R = unknown> = {
|
|
169
185
|
getUrl: (context: any) => string;
|
|
@@ -176,5 +192,6 @@ type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q
|
|
|
176
192
|
__originalResponseType: R;
|
|
177
193
|
};
|
|
178
194
|
declare function constructCheckoutSession(): __PublicMethodMetaInfo<'POST', {}, ConstructCheckoutSessionRequest$1, ConstructCheckoutSessionRequest, ConstructCheckoutSessionResponse$1, ConstructCheckoutSessionResponse>;
|
|
195
|
+
declare function cancelSubscription(): __PublicMethodMetaInfo<'POST', {}, CancelSubscriptionRequest$1, CancelSubscriptionRequest, CancelSubscriptionResponse$1, CancelSubscriptionResponse>;
|
|
179
196
|
|
|
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 };
|
|
197
|
+
export { type CallbackUrls as CallbackUrlsOriginal, type CancelSubscriptionRequest as CancelSubscriptionRequestOriginal, type CancelSubscriptionResponse as CancelSubscriptionResponseOriginal, 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, cancelSubscription, constructCheckoutSession };
|
package/build/cjs/meta.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var meta_exports = {};
|
|
22
22
|
__export(meta_exports, {
|
|
23
23
|
SubscriptionFrequencyOriginal: () => SubscriptionFrequency,
|
|
24
|
+
cancelSubscription: () => cancelSubscription2,
|
|
24
25
|
constructCheckoutSession: () => constructCheckoutSession2
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(meta_exports);
|
|
@@ -60,6 +61,27 @@ function constructCheckoutSession(payload) {
|
|
|
60
61
|
}
|
|
61
62
|
return __constructCheckoutSession;
|
|
62
63
|
}
|
|
64
|
+
function cancelSubscription(payload) {
|
|
65
|
+
function __cancelSubscription({ host }) {
|
|
66
|
+
const metadata = {
|
|
67
|
+
entityFqdn: "wix.payments.platform.v1.checkout_session",
|
|
68
|
+
method: "POST",
|
|
69
|
+
methodFqn: "wix.payments.platform.v1.CheckoutSessions.CancelSubscription",
|
|
70
|
+
packageName: PACKAGE_NAME,
|
|
71
|
+
migrationOptions: {
|
|
72
|
+
optInTransformResponse: true
|
|
73
|
+
},
|
|
74
|
+
url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({
|
|
75
|
+
protoPath: "/v1/checkout-sessions/cancel-subscription",
|
|
76
|
+
data: payload,
|
|
77
|
+
host
|
|
78
|
+
}),
|
|
79
|
+
data: payload
|
|
80
|
+
};
|
|
81
|
+
return metadata;
|
|
82
|
+
}
|
|
83
|
+
return __cancelSubscription;
|
|
84
|
+
}
|
|
63
85
|
|
|
64
86
|
// src/payments-platform-v1-checkout-session-checkout-sessions.types.ts
|
|
65
87
|
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
@@ -92,9 +114,28 @@ function constructCheckoutSession2() {
|
|
|
92
114
|
__originalResponseType: null
|
|
93
115
|
};
|
|
94
116
|
}
|
|
117
|
+
function cancelSubscription2() {
|
|
118
|
+
const payload = {};
|
|
119
|
+
const getRequestOptions = cancelSubscription(payload);
|
|
120
|
+
const getUrl = (context) => {
|
|
121
|
+
const { url } = getRequestOptions(context);
|
|
122
|
+
return url;
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
getUrl,
|
|
126
|
+
httpMethod: "POST",
|
|
127
|
+
path: "/v1/checkout-sessions/cancel-subscription",
|
|
128
|
+
pathParams: {},
|
|
129
|
+
__requestType: null,
|
|
130
|
+
__originalRequestType: null,
|
|
131
|
+
__responseType: null,
|
|
132
|
+
__originalResponseType: null
|
|
133
|
+
};
|
|
134
|
+
}
|
|
95
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
136
|
0 && (module.exports = {
|
|
97
137
|
SubscriptionFrequencyOriginal,
|
|
138
|
+
cancelSubscription,
|
|
98
139
|
constructCheckoutSession
|
|
99
140
|
});
|
|
100
141
|
//# 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.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"]}
|
|
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\n/** Cancels a subscription by resolving the billing subscription from the Ecom subscription contract. */\nexport function cancelSubscription(\n payload: object\n): RequestOptionsFactory<any> {\n function __cancelSubscription({ host }: any) {\n const metadata = {\n entityFqdn: 'wix.payments.platform.v1.checkout_session',\n method: 'POST' as any,\n methodFqn: 'wix.payments.platform.v1.CheckoutSessions.CancelSubscription',\n packageName: PACKAGE_NAME,\n migrationOptions: {\n optInTransformResponse: true,\n },\n url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({\n protoPath: '/v1/checkout-sessions/cancel-subscription',\n data: payload,\n host,\n }),\n data: payload,\n };\n\n return metadata;\n }\n\n return __cancelSubscription;\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/** Request to cancel a subscription. */\nexport interface CancelSubscriptionRequest {\n /**\n * Ecom subscription contract ID used to resolve the billing subscription.\n * @format GUID\n */\n subscriptionContractId: string;\n /**\n * Optional reason for cancellation.\n * @maxLength 500\n */\n reason?: string | null;\n}\n\n/** Response after canceling a subscription. */\nexport interface CancelSubscriptionResponse {}\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 function cancelSubscription(): __PublicMethodMetaInfo<\n 'POST',\n {},\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.CancelSubscriptionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.CancelSubscriptionRequest,\n ambassadorWixPaymentsPlatformV1CheckoutSessionUniversalTypes.CancelSubscriptionResponse,\n ambassadorWixPaymentsPlatformV1CheckoutSessionTypes.CancelSubscriptionResponse\n> {\n const payload = {} as any;\n\n const getRequestOptions =\n ambassadorWixPaymentsPlatformV1CheckoutSession.cancelSubscription(payload);\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/cancel-subscription',\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 CancelSubscriptionRequest as CancelSubscriptionRequestOriginal,\n CancelSubscriptionResponse as CancelSubscriptionResponseOriginal,\n} from './payments-platform-v1-checkout-session-checkout-sessions.types.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA,gCAAAC;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;AAGO,SAAS,mBACd,SAC4B;AAC5B,WAAS,qBAAqB,EAAE,KAAK,GAAQ;AAC3C,UAAM,WAAW;AAAA,MACf,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,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;;;ACbO,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;AAEO,SAASC,sBAOd;AACA,QAAM,UAAU,CAAC;AAEjB,QAAM,oBAC2C,mBAAmB,OAAO;AAE3E,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":["cancelSubscription","constructCheckoutSession","SubscriptionFrequency","constructCheckoutSession","cancelSubscription"]}
|
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, FreeTrialPeriod, LineItem, RegisterCheckoutSessionWebhookRequest, RegisterCheckoutSessionWebhookResponse, SubscriptionFrequency, SubscriptionFrequencyWithLiterals, SubscriptionInfo, SubscriptionSettings } from './index.typings.mjs';
|
|
3
|
+
export { CallbackUrls, CancelSubscriptionOptions, CancelSubscriptionRequest, CancelSubscriptionResponse, 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
|
@@ -40,6 +40,27 @@ function constructCheckoutSession(payload) {
|
|
|
40
40
|
}
|
|
41
41
|
return __constructCheckoutSession;
|
|
42
42
|
}
|
|
43
|
+
function cancelSubscription(payload) {
|
|
44
|
+
function __cancelSubscription({ host }) {
|
|
45
|
+
const metadata = {
|
|
46
|
+
entityFqdn: "wix.payments.platform.v1.checkout_session",
|
|
47
|
+
method: "POST",
|
|
48
|
+
methodFqn: "wix.payments.platform.v1.CheckoutSessions.CancelSubscription",
|
|
49
|
+
packageName: PACKAGE_NAME,
|
|
50
|
+
migrationOptions: {
|
|
51
|
+
optInTransformResponse: true
|
|
52
|
+
},
|
|
53
|
+
url: resolveWixPaymentsPlatformV1CheckoutSessionsUrl({
|
|
54
|
+
protoPath: "/v1/checkout-sessions/cancel-subscription",
|
|
55
|
+
data: payload,
|
|
56
|
+
host
|
|
57
|
+
}),
|
|
58
|
+
data: payload
|
|
59
|
+
};
|
|
60
|
+
return metadata;
|
|
61
|
+
}
|
|
62
|
+
return __cancelSubscription;
|
|
63
|
+
}
|
|
43
64
|
|
|
44
65
|
// src/payments-platform-v1-checkout-session-checkout-sessions.universal.ts
|
|
45
66
|
var SubscriptionFrequency = /* @__PURE__ */ ((SubscriptionFrequency2) => {
|
|
@@ -81,6 +102,34 @@ async function constructCheckoutSession2(cart, options) {
|
|
|
81
102
|
throw transformedError;
|
|
82
103
|
}
|
|
83
104
|
}
|
|
105
|
+
async function cancelSubscription2(subscriptionContractId, options) {
|
|
106
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
107
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
108
|
+
subscriptionContractId,
|
|
109
|
+
reason: options?.reason
|
|
110
|
+
});
|
|
111
|
+
const reqOpts = cancelSubscription(payload);
|
|
112
|
+
sideEffects?.onSiteCall?.();
|
|
113
|
+
try {
|
|
114
|
+
const result = await httpClient.request(reqOpts);
|
|
115
|
+
sideEffects?.onSuccess?.(result);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
const transformedError = sdkTransformError(
|
|
118
|
+
err,
|
|
119
|
+
{
|
|
120
|
+
spreadPathsToArguments: {},
|
|
121
|
+
explicitPathsToArguments: {
|
|
122
|
+
subscriptionContractId: "$[0]",
|
|
123
|
+
reason: "$[1].reason"
|
|
124
|
+
},
|
|
125
|
+
singleArgumentUnchanged: false
|
|
126
|
+
},
|
|
127
|
+
["subscriptionContractId", "options"]
|
|
128
|
+
);
|
|
129
|
+
sideEffects?.onError?.(err);
|
|
130
|
+
throw transformedError;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
84
133
|
|
|
85
134
|
// src/payments-platform-v1-checkout-session-checkout-sessions.public.ts
|
|
86
135
|
function constructCheckoutSession3(httpClient) {
|
|
@@ -91,12 +140,22 @@ function constructCheckoutSession3(httpClient) {
|
|
|
91
140
|
{ httpClient }
|
|
92
141
|
);
|
|
93
142
|
}
|
|
143
|
+
function cancelSubscription3(httpClient) {
|
|
144
|
+
return (subscriptionContractId, options) => cancelSubscription2(
|
|
145
|
+
subscriptionContractId,
|
|
146
|
+
options,
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
{ httpClient }
|
|
149
|
+
);
|
|
150
|
+
}
|
|
94
151
|
|
|
95
152
|
// src/payments-platform-v1-checkout-session-checkout-sessions.context.ts
|
|
96
153
|
import { createRESTModule } from "@wix/sdk-runtime/rest-modules";
|
|
97
154
|
var constructCheckoutSession4 = /* @__PURE__ */ createRESTModule(constructCheckoutSession3);
|
|
155
|
+
var cancelSubscription4 = /* @__PURE__ */ createRESTModule(cancelSubscription3);
|
|
98
156
|
export {
|
|
99
157
|
SubscriptionFrequency,
|
|
158
|
+
cancelSubscription4 as cancelSubscription,
|
|
100
159
|
constructCheckoutSession4 as constructCheckoutSession
|
|
101
160
|
};
|
|
102
161
|
//# sourceMappingURL=index.mjs.map
|