@wix/pricing-plans 1.0.53 → 1.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/build/cjs/context.d.ts +2 -2
  2. package/build/cjs/context.js +2 -2
  3. package/build/cjs/context.js.map +1 -1
  4. package/build/cjs/index.d.ts +2 -2
  5. package/build/cjs/index.js +2 -2
  6. package/build/cjs/index.js.map +1 -1
  7. package/build/cjs/meta.d.ts +2 -2
  8. package/build/cjs/meta.js +2 -2
  9. package/build/cjs/meta.js.map +1 -1
  10. package/build/es/context.d.ts +2 -2
  11. package/build/es/context.js +2 -2
  12. package/build/es/context.js.map +1 -1
  13. package/build/es/index.d.ts +2 -2
  14. package/build/es/index.js +2 -2
  15. package/build/es/index.js.map +1 -1
  16. package/build/es/meta.d.ts +2 -2
  17. package/build/es/meta.js +2 -2
  18. package/build/es/meta.js.map +1 -1
  19. package/package.json +12 -9
  20. package/build/cjs/index.typings.d.ts +0 -2
  21. package/build/cjs/index.typings.js +0 -29
  22. package/build/cjs/index.typings.js.map +0 -1
  23. package/build/cjs/src/pricing-plans-v2-order.context.d.ts +0 -15
  24. package/build/cjs/src/pricing-plans-v2-order.context.js +0 -148
  25. package/build/cjs/src/pricing-plans-v2-order.context.js.map +0 -1
  26. package/build/cjs/src/pricing-plans-v2-order.http.d.ts +0 -165
  27. package/build/cjs/src/pricing-plans-v2-order.http.js +0 -818
  28. package/build/cjs/src/pricing-plans-v2-order.http.js.map +0 -1
  29. package/build/cjs/src/pricing-plans-v2-order.meta.d.ts +0 -41
  30. package/build/cjs/src/pricing-plans-v2-order.meta.js +0 -275
  31. package/build/cjs/src/pricing-plans-v2-order.meta.js.map +0 -1
  32. package/build/cjs/src/pricing-plans-v2-order.public.d.ts +0 -103
  33. package/build/cjs/src/pricing-plans-v2-order.public.js +0 -96
  34. package/build/cjs/src/pricing-plans-v2-order.public.js.map +0 -1
  35. package/build/cjs/src/pricing-plans-v2-order.types.d.ts +0 -1801
  36. package/build/cjs/src/pricing-plans-v2-order.types.js +0 -135
  37. package/build/cjs/src/pricing-plans-v2-order.types.js.map +0 -1
  38. package/build/cjs/src/pricing-plans-v2-order.universal.d.ts +0 -2203
  39. package/build/cjs/src/pricing-plans-v2-order.universal.js +0 -1137
  40. package/build/cjs/src/pricing-plans-v2-order.universal.js.map +0 -1
  41. package/build/cjs/src/pricing-plans-v2-plan.context.d.ts +0 -14
  42. package/build/cjs/src/pricing-plans-v2-plan.context.js +0 -137
  43. package/build/cjs/src/pricing-plans-v2-plan.context.js.map +0 -1
  44. package/build/cjs/src/pricing-plans-v2-plan.http.d.ts +0 -134
  45. package/build/cjs/src/pricing-plans-v2-plan.http.js +0 -544
  46. package/build/cjs/src/pricing-plans-v2-plan.http.js.map +0 -1
  47. package/build/cjs/src/pricing-plans-v2-plan.meta.d.ts +0 -34
  48. package/build/cjs/src/pricing-plans-v2-plan.meta.js +0 -256
  49. package/build/cjs/src/pricing-plans-v2-plan.meta.js.map +0 -1
  50. package/build/cjs/src/pricing-plans-v2-plan.public.d.ts +0 -85
  51. package/build/cjs/src/pricing-plans-v2-plan.public.js +0 -84
  52. package/build/cjs/src/pricing-plans-v2-plan.public.js.map +0 -1
  53. package/build/cjs/src/pricing-plans-v2-plan.types.d.ts +0 -732
  54. package/build/cjs/src/pricing-plans-v2-plan.types.js +0 -41
  55. package/build/cjs/src/pricing-plans-v2-plan.types.js.map +0 -1
  56. package/build/cjs/src/pricing-plans-v2-plan.universal.d.ts +0 -1163
  57. package/build/cjs/src/pricing-plans-v2-plan.universal.js +0 -908
  58. package/build/cjs/src/pricing-plans-v2-plan.universal.js.map +0 -1
  59. package/build/es/index.typings.d.ts +0 -2
  60. package/build/es/index.typings.js +0 -3
  61. package/build/es/index.typings.js.map +0 -1
  62. package/build/es/src/pricing-plans-v2-order.context.d.ts +0 -15
  63. package/build/es/src/pricing-plans-v2-order.context.js +0 -132
  64. package/build/es/src/pricing-plans-v2-order.context.js.map +0 -1
  65. package/build/es/src/pricing-plans-v2-order.http.d.ts +0 -165
  66. package/build/es/src/pricing-plans-v2-order.http.js +0 -802
  67. package/build/es/src/pricing-plans-v2-order.http.js.map +0 -1
  68. package/build/es/src/pricing-plans-v2-order.meta.d.ts +0 -41
  69. package/build/es/src/pricing-plans-v2-order.meta.js +0 -236
  70. package/build/es/src/pricing-plans-v2-order.meta.js.map +0 -1
  71. package/build/es/src/pricing-plans-v2-order.public.d.ts +0 -103
  72. package/build/es/src/pricing-plans-v2-order.public.js +0 -69
  73. package/build/es/src/pricing-plans-v2-order.public.js.map +0 -1
  74. package/build/es/src/pricing-plans-v2-order.types.d.ts +0 -1801
  75. package/build/es/src/pricing-plans-v2-order.types.js +0 -132
  76. package/build/es/src/pricing-plans-v2-order.types.js.map +0 -1
  77. package/build/es/src/pricing-plans-v2-order.universal.d.ts +0 -2203
  78. package/build/es/src/pricing-plans-v2-order.universal.js +0 -1098
  79. package/build/es/src/pricing-plans-v2-order.universal.js.map +0 -1
  80. package/build/es/src/pricing-plans-v2-plan.context.d.ts +0 -14
  81. package/build/es/src/pricing-plans-v2-plan.context.js +0 -122
  82. package/build/es/src/pricing-plans-v2-plan.context.js.map +0 -1
  83. package/build/es/src/pricing-plans-v2-plan.http.d.ts +0 -134
  84. package/build/es/src/pricing-plans-v2-plan.http.js +0 -529
  85. package/build/es/src/pricing-plans-v2-plan.http.js.map +0 -1
  86. package/build/es/src/pricing-plans-v2-plan.meta.d.ts +0 -34
  87. package/build/es/src/pricing-plans-v2-plan.meta.js +0 -218
  88. package/build/es/src/pricing-plans-v2-plan.meta.js.map +0 -1
  89. package/build/es/src/pricing-plans-v2-plan.public.d.ts +0 -85
  90. package/build/es/src/pricing-plans-v2-plan.public.js +0 -64
  91. package/build/es/src/pricing-plans-v2-plan.public.js.map +0 -1
  92. package/build/es/src/pricing-plans-v2-plan.types.d.ts +0 -732
  93. package/build/es/src/pricing-plans-v2-plan.types.js +0 -38
  94. package/build/es/src/pricing-plans-v2-plan.types.js.map +0 -1
  95. package/build/es/src/pricing-plans-v2-plan.universal.d.ts +0 -1163
  96. package/build/es/src/pricing-plans-v2-plan.universal.js +0 -870
  97. package/build/es/src/pricing-plans-v2-plan.universal.js.map +0 -1
@@ -1,1098 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { serializer } from '@wix/metro-runtime/velo';
11
- import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
12
- import * as ambassadorWixPricingPlansV2Order from './pricing-plans-v2-order.http';
13
- // @ts-ignore
14
- const _toVeloEntity = '$';
15
- const _fromVeloEntity = '$';
16
- export var PeriodUnit;
17
- (function (PeriodUnit) {
18
- PeriodUnit["UNDEFINED"] = "UNDEFINED";
19
- PeriodUnit["DAY"] = "DAY";
20
- PeriodUnit["WEEK"] = "WEEK";
21
- PeriodUnit["MONTH"] = "MONTH";
22
- PeriodUnit["YEAR"] = "YEAR";
23
- })(PeriodUnit || (PeriodUnit = {}));
24
- export var OrderType;
25
- (function (OrderType) {
26
- OrderType["UNDEFINED"] = "UNDEFINED";
27
- /** Payments made by the buyer */
28
- OrderType["ONLINE"] = "ONLINE";
29
- /** Payments managed manually by the site owner */
30
- OrderType["OFFLINE"] = "OFFLINE";
31
- /** Payments managed externally */
32
- OrderType["EXTERNAL"] = "EXTERNAL";
33
- })(OrderType || (OrderType = {}));
34
- export var OrderMethod;
35
- (function (OrderMethod) {
36
- OrderMethod["UNKNOWN"] = "UNKNOWN";
37
- /** Mail Order / Telephone Order transaction */
38
- OrderMethod["MOTO"] = "MOTO";
39
- /** Point of Sale transaction */
40
- OrderMethod["POS"] = "POS";
41
- })(OrderMethod || (OrderMethod = {}));
42
- export var OrderStatus;
43
- (function (OrderStatus) {
44
- /** Order status undefined */
45
- OrderStatus["UNDEFINED"] = "UNDEFINED";
46
- /** Order created, but hasn't been paid for yet. Filtered out in ListOrders response by default. */
47
- OrderStatus["DRAFT"] = "DRAFT";
48
- /** Order has been paid for, but the start date is in the future */
49
- OrderStatus["PENDING"] = "PENDING";
50
- /** Order is active */
51
- OrderStatus["ACTIVE"] = "ACTIVE";
52
- /** Order is paused until site owner resumes it */
53
- OrderStatus["PAUSED"] = "PAUSED";
54
- /** Order has ended */
55
- OrderStatus["ENDED"] = "ENDED";
56
- /** Order has been canceled */
57
- OrderStatus["CANCELED"] = "CANCELED";
58
- })(OrderStatus || (OrderStatus = {}));
59
- export var CancellationCause;
60
- (function (CancellationCause) {
61
- /** Cancellation initiator undefined */
62
- CancellationCause["UNDEFINED"] = "UNDEFINED";
63
- /** Order was canceled by site owner (default if canceled by user or service identity) */
64
- CancellationCause["OWNER_ACTION"] = "OWNER_ACTION";
65
- /** Order was canceled by member (default if canceled by member identity) */
66
- CancellationCause["MEMBER_ACTION"] = "MEMBER_ACTION";
67
- /** Order was canceled because of payment failure */
68
- CancellationCause["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
69
- /** Order was canceled because of payment setup failure */
70
- CancellationCause["PAYMENT_SETUP_FAILURE"] = "PAYMENT_SETUP_FAILURE";
71
- /** Order was cancelled because of an unknown reason. It's not possible to know with certain payment providers (e.g. paypal) */
72
- CancellationCause["UNKNOWN"] = "UNKNOWN";
73
- })(CancellationCause || (CancellationCause = {}));
74
- export var CancellationEffectiveAt;
75
- (function (CancellationEffectiveAt) {
76
- /** Cancellation time undefined */
77
- CancellationEffectiveAt["UNDEFINED"] = "UNDEFINED";
78
- /** Will cancel the order now, i.e. update validUntil to the current date */
79
- CancellationEffectiveAt["IMMEDIATELY"] = "IMMEDIATELY";
80
- /** Will cancel the order at the date when next payment should have been made */
81
- CancellationEffectiveAt["NEXT_PAYMENT_DATE"] = "NEXT_PAYMENT_DATE";
82
- })(CancellationEffectiveAt || (CancellationEffectiveAt = {}));
83
- export var PaymentStatus;
84
- (function (PaymentStatus) {
85
- /** Payment status undefined */
86
- PaymentStatus["UNDEFINED"] = "UNDEFINED";
87
- /** Payment has been paid */
88
- PaymentStatus["PAID"] = "PAID";
89
- /** Payment has been refunded */
90
- PaymentStatus["REFUNDED"] = "REFUNDED";
91
- /** Recurring payment has failed */
92
- PaymentStatus["FAILED"] = "FAILED";
93
- /** Payment has not been paid */
94
- PaymentStatus["UNPAID"] = "UNPAID";
95
- /** Billing has been initialized, but actual charge is yet to be made. Can happen for free trial and PayPal */
96
- PaymentStatus["PENDING"] = "PENDING";
97
- /** Used in cases where the plan is free */
98
- PaymentStatus["NOT_APPLICABLE"] = "NOT_APPLICABLE";
99
- })(PaymentStatus || (PaymentStatus = {}));
100
- export var Status;
101
- (function (Status) {
102
- Status["UNDEFINED"] = "UNDEFINED";
103
- /** Order suspension is active */
104
- Status["ACTIVE"] = "ACTIVE";
105
- /** Order suspension has ended */
106
- Status["ENDED"] = "ENDED";
107
- })(Status || (Status = {}));
108
- export var Set;
109
- (function (Set) {
110
- /** Same behavior as BASIC */
111
- Set["UNKNOWN_SET"] = "UNKNOWN_SET";
112
- /**
113
- * Returns fields of the entity that are available in the database.
114
- * By default a field is available in the database unless explicitly specified in the documentation
115
- */
116
- Set["BASIC"] = "BASIC";
117
- /**
118
- * Returns all fields in the entity.
119
- * This might make additional calls to gather the full entity
120
- */
121
- Set["FULL"] = "FULL";
122
- })(Set || (Set = {}));
123
- export var SortOrder;
124
- (function (SortOrder) {
125
- SortOrder["ASC"] = "ASC";
126
- SortOrder["DESC"] = "DESC";
127
- })(SortOrder || (SortOrder = {}));
128
- export var ReasonNotSuspendable;
129
- (function (ReasonNotSuspendable) {
130
- /** Reason unknown */
131
- ReasonNotSuspendable["UNDEFINED"] = "UNDEFINED";
132
- /** Saved in the database but is awaiting payment. Non-active orders cannot be suspended */
133
- ReasonNotSuspendable["PENDING"] = "PENDING";
134
- /** Trial orders cannot be suspended */
135
- ReasonNotSuspendable["TRIAL"] = "TRIAL";
136
- /** Canceled orders cannot be suspended */
137
- ReasonNotSuspendable["CANCELED"] = "CANCELED";
138
- /** Ended orders cannot be suspended */
139
- ReasonNotSuspendable["ENDED"] = "ENDED";
140
- /** Paid for orders with future start dates cannot be suspended */
141
- ReasonNotSuspendable["NOT_STARTED"] = "NOT_STARTED";
142
- /** Order is already suspended */
143
- ReasonNotSuspendable["ALREADY_SUSPENDED"] = "ALREADY_SUSPENDED";
144
- /** Orders based on recurring payments using older Stripe versions cannot be suspended */
145
- ReasonNotSuspendable["OLD_STRIPE"] = "OLD_STRIPE";
146
- })(ReasonNotSuspendable || (ReasonNotSuspendable = {}));
147
- const _cancelOrderRequest = {};
148
- const _cancelOrderResponse = {};
149
- const _createOfflineOrderRequest = {};
150
- const _createOfflineOrderResponse = {};
151
- const _getOfflineOrderPreviewRequest = {};
152
- const _getOfflineOrderPreviewResponse = {};
153
- const _getOrderRequest = {};
154
- const _getOrderResponse = {};
155
- const _getPricePreviewRequest = {};
156
- const _getPricePreviewResponse = {};
157
- const _listOrdersRequest = {};
158
- const _listOrdersResponse = {};
159
- const _markAsPaidRequest = {};
160
- const _markAsPaidResponse = {};
161
- const _memberGetOrderRequest = {};
162
- const _memberGetOrderResponse = {};
163
- const _memberListOrdersRequest = {};
164
- const _memberListOrdersResponse = {};
165
- const _pauseOrderRequest = {};
166
- const _pauseOrderResponse = {};
167
- const _postponeEndDateRequest = {};
168
- const _postponeEndDateResponse = {};
169
- const _requestCancellationRequest = {};
170
- const _requestCancellationResponse = {};
171
- const _resumeOrderRequest = {};
172
- const _resumeOrderResponse = {};
173
- /**
174
- * Gets an order by ID for the currently logged-in member.
175
- *
176
- * The `memberGetOrder()` function returns a Promise that resolves to information about a specified order for the currently logged-in member.
177
- * @param _id - Order ID.
178
- * @public
179
- * @requiredField _id
180
- * @param options - Options for getting a logged-in member's order.
181
- * @applicableIdentity MEMBER
182
- * @returns Requested order.
183
- */
184
- export function memberGetOrder(_id, options) {
185
- var _a, _b, _c;
186
- return __awaiter(this, arguments, void 0, function* () {
187
- const requestTransformation = { id: '$[0]', fieldSet: '$[1].fieldSet' };
188
- const responseTransformation = '$.order';
189
- // @ts-ignore
190
- const { httpClient, sideEffects } = arguments[2];
191
- const { toAmbassadorRequest } = serializer({
192
- rootSchema: _memberGetOrderRequest,
193
- depSchemas: {},
194
- fqdnTransformation: {
195
- paths: [],
196
- transformation: _fromVeloEntity,
197
- },
198
- customTransformation: requestTransformation,
199
- });
200
- const { fromJSON } = serializer({
201
- rootSchema: _memberGetOrderResponse,
202
- depSchemas: {},
203
- fqdnTransformation: {
204
- paths: [...['order']],
205
- transformation: _toVeloEntity,
206
- },
207
- customTransformation: responseTransformation,
208
- });
209
- const payload = toAmbassadorRequest([_id, options]);
210
- const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
211
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
212
- try {
213
- const result = yield httpClient.request(reqOpts);
214
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
215
- return fromJSON(result.data);
216
- }
217
- catch (err) {
218
- const transformedError = sdkTransformError(err, {
219
- spreadPathsToArguments: {},
220
- explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
221
- singleArgumentUnchanged: false,
222
- }, ['_id', 'options']);
223
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
224
- throw transformedError;
225
- }
226
- });
227
- }
228
- /**
229
- * Lists orders for the currently logged-in member.
230
- *
231
- * The `memberListOrders()` function returns a Promise that resolves to a list of up to 100 pricing plan orders.
232
- * @public
233
- * @documentationMaturity preview
234
- * @param options - Filtering, sorting, and pagination options.
235
- * @applicableIdentity MEMBER
236
- */
237
- export function memberListOrders(options) {
238
- var _a, _b, _c;
239
- return __awaiter(this, arguments, void 0, function* () {
240
- const requestTransformation = {
241
- planIds: '$[0].planIds',
242
- autoRenewCanceled: '$[0].autoRenewCanceled',
243
- orderStatuses: '$[0].orderStatuses',
244
- paymentStatuses: '$[0].paymentStatuses',
245
- limit: '$[0].limit',
246
- offset: '$[0].offset',
247
- sorting: '$[0].sorting',
248
- fieldSet: '$[0].fieldSet',
249
- };
250
- const responseTransformation = '$';
251
- // @ts-ignore
252
- const { httpClient, sideEffects } = arguments[1];
253
- const { toAmbassadorRequest } = serializer({
254
- rootSchema: _memberListOrdersRequest,
255
- depSchemas: {},
256
- fqdnTransformation: {
257
- paths: [],
258
- transformation: _fromVeloEntity,
259
- },
260
- customTransformation: requestTransformation,
261
- });
262
- const { fromJSON } = serializer({
263
- rootSchema: _memberListOrdersResponse,
264
- depSchemas: {},
265
- fqdnTransformation: {
266
- paths: [...['Array#orders']],
267
- transformation: _toVeloEntity,
268
- },
269
- customTransformation: responseTransformation,
270
- });
271
- const payload = toAmbassadorRequest([options]);
272
- const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
273
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
274
- try {
275
- const result = yield httpClient.request(reqOpts);
276
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
277
- return fromJSON(result.data);
278
- }
279
- catch (err) {
280
- const transformedError = sdkTransformError(err, {
281
- spreadPathsToArguments: {},
282
- explicitPathsToArguments: {
283
- planIds: '$[0].planIds',
284
- autoRenewCanceled: '$[0].autoRenewCanceled',
285
- orderStatuses: '$[0].orderStatuses',
286
- paymentStatuses: '$[0].paymentStatuses',
287
- limit: '$[0].limit',
288
- offset: '$[0].offset',
289
- sorting: '$[0].sorting',
290
- fieldSet: '$[0].fieldSet',
291
- },
292
- singleArgumentUnchanged: false,
293
- }, ['options']);
294
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
295
- throw transformedError;
296
- }
297
- });
298
- }
299
- /**
300
- * Starts the process of canceling an order.
301
- *
302
- *
303
- * The `requestCancellation()` function returns a Promise that resolves when the order cancellation is successfully requested.
304
- *
305
- * For orders with recurring payments, a cancellation can be set to occur either immediately or at the next payment date. For orders with one-time payments, a cancellation occurs immediately after the request is processed.
306
- *
307
- * Requesting an order cancellation starts the cancellation process. There may be some operations that continue to be processed before the status of the order is changed to `"CANCELED"`. For example, payments might need to be refunded before the order is fully canceled.
308
- *
309
- * #### Canceling during the free trial period.
310
- *
311
- * When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end of the free trial period and they won't be billed. The buyer may continue using the benefits until the end of the free trial period.
312
- *
313
- * @param _id - Order ID.
314
- * @param effectiveAt - Whether to cancel the order immediately or at the next payment date.
315
- * One-time payment orders can only be canceled immediately.
316
- *
317
- * Supported values:
318
- * - `"IMMEDIATELY"`: Indicates that the order should be canceled immediately.
319
- * - `"NEXT_PAYMENT_DATE"`: Indicates that the order be canceled at the next payment date.
320
- * @public
321
- * @documentationMaturity preview
322
- * @requiredField _id
323
- * @requiredField effectiveAt
324
- * @param options - Options for requesting a cancellation.
325
- * @applicableIdentity MEMBER
326
- * @returns Fulfilled - When the cancellation process is started.
327
- */
328
- export function requestCancellation(_id, effectiveAt) {
329
- var _a, _b, _c;
330
- return __awaiter(this, arguments, void 0, function* () {
331
- const requestTransformation = { id: '$[0]', effectiveAt: '$[1]' };
332
- const responseTransformation = '$';
333
- // @ts-ignore
334
- const { httpClient, sideEffects } = arguments[2];
335
- const { toAmbassadorRequest } = serializer({
336
- rootSchema: _requestCancellationRequest,
337
- depSchemas: {},
338
- fqdnTransformation: {
339
- paths: [],
340
- transformation: _fromVeloEntity,
341
- },
342
- customTransformation: requestTransformation,
343
- });
344
- const { fromJSON } = serializer({
345
- rootSchema: _requestCancellationResponse,
346
- depSchemas: {},
347
- fqdnTransformation: {
348
- paths: [],
349
- transformation: _toVeloEntity,
350
- },
351
- customTransformation: responseTransformation,
352
- });
353
- const payload = toAmbassadorRequest([_id, effectiveAt]);
354
- const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
355
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
356
- try {
357
- const result = yield httpClient.request(reqOpts);
358
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
359
- }
360
- catch (err) {
361
- const transformedError = sdkTransformError(err, {
362
- spreadPathsToArguments: {},
363
- explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
364
- singleArgumentUnchanged: false,
365
- }, ['_id', 'effectiveAt']);
366
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
367
- throw transformedError;
368
- }
369
- });
370
- }
371
- /**
372
- * Creates an order for a buyer who purchased the plan with an offline transaction.
373
- *
374
- * The `createOfflineOrder()` function returns a Promise that resolves to an `order` object when the order has been created.
375
- *
376
- * Payment of an offline order is handled in 1 of 2 ways.
377
- * - When creating the order, select `true` in the `paid` request parameter.
378
- * - After creation, with the [`markAsPaid()`](#markaspaid) function.
379
- *
380
- * When creating a non-free offline order:
381
- * - The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
382
- * The order's last payment status is set to `"UNPAID"` or `"PAID"`.
383
- *
384
- * When creating a free offline order:
385
- * - The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
386
- * - The order's last payment status is set to `"NOT_APPLICABLE"`.
387
- * @param memberId - ID of the member ordering the plan.
388
- * @public
389
- * @documentationMaturity preview
390
- * @requiredField memberId
391
- * @requiredField planId
392
- * @param options - Options for creating an offline order.
393
- * @param planId - ID of the plan being ordered. See [Plans for more information about plan IDs](plans)
394
- * @permissionScope Manage Orders
395
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
396
- * @applicableIdentity APP
397
- * @returns Fulfilled - The order of the plan.
398
- */
399
- export function createOfflineOrder(planId, memberId, options) {
400
- var _a, _b, _c;
401
- return __awaiter(this, arguments, void 0, function* () {
402
- const requestTransformation = {
403
- planId: '$[0]',
404
- memberId: '$[1]',
405
- startDate: '$[2].startDate',
406
- paid: '$[2].paid',
407
- couponCode: '$[2].couponCode',
408
- submissionId: '$[2].submissionId',
409
- };
410
- const responseTransformation = '$';
411
- // @ts-ignore
412
- const { httpClient, sideEffects } = arguments[3];
413
- const { toAmbassadorRequest } = serializer({
414
- rootSchema: _createOfflineOrderRequest,
415
- depSchemas: {},
416
- fqdnTransformation: {
417
- paths: [],
418
- transformation: _fromVeloEntity,
419
- },
420
- customTransformation: requestTransformation,
421
- });
422
- const { fromJSON } = serializer({
423
- rootSchema: _createOfflineOrderResponse,
424
- depSchemas: {},
425
- fqdnTransformation: {
426
- paths: [...['order']],
427
- transformation: _toVeloEntity,
428
- },
429
- customTransformation: responseTransformation,
430
- });
431
- const payload = toAmbassadorRequest([planId, memberId, options]);
432
- const reqOpts = ambassadorWixPricingPlansV2Order.createOfflineOrder(payload);
433
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
434
- try {
435
- const result = yield httpClient.request(reqOpts);
436
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
437
- return fromJSON(result.data);
438
- }
439
- catch (err) {
440
- const transformedError = sdkTransformError(err, {
441
- spreadPathsToArguments: {},
442
- explicitPathsToArguments: {
443
- planId: '$[0]',
444
- memberId: '$[1]',
445
- startDate: '$[2].startDate',
446
- paid: '$[2].paid',
447
- couponCode: '$[2].couponCode',
448
- submissionId: '$[2].submissionId',
449
- },
450
- singleArgumentUnchanged: false,
451
- }, ['planId', 'memberId', 'options']);
452
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
453
- throw transformedError;
454
- }
455
- });
456
- }
457
- /**
458
- * Provides a preview of an offline order as if it was purchased.
459
- *
460
- * The `getOfflineOrderPreview()` function returns a Promise that resolves to a temporary preview of the offline order.
461
- *
462
- * The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually created, the preview's `_id` and `subscriptionId` properties are displayed as a string of multiple zero characters (`000000-0000`).
463
- *
464
- * If [taxes are configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection) for the site, taxes are applied to the preview. If not, `tax` previews as `null`.
465
- *
466
- * You can preview the order to check purchase limitations, but the limitations are not enforced for the preview. If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview. But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then `purchaseLimitExceeded` will return as `true`. Thus function is not available to the buyer. You specify the member ID for the buyer whose order should be previewed. To get a general price preview for a plan that's not buyer-specific, use the [`getPricePreview()`](#getpricepreview) function.
467
- * @param memberId - Member ID of the buyer the previewed order is for.
468
- * @public
469
- * @documentationMaturity preview
470
- * @requiredField memberId
471
- * @requiredField planId
472
- * @param options - Options for previewing the offline order.
473
- * @param planId - ID of the plan of the previewed order.
474
- * @permissionScope Manage Orders
475
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
476
- * @applicableIdentity APP
477
- * @returns Fulfilled - A preview of the order.
478
- */
479
- export function getOfflineOrderPreview(planId, memberId, options) {
480
- var _a, _b, _c;
481
- return __awaiter(this, arguments, void 0, function* () {
482
- const requestTransformation = {
483
- planId: '$[0]',
484
- memberId: '$[1]',
485
- startDate: '$[2].startDate',
486
- couponCode: '$[2].couponCode',
487
- };
488
- const responseTransformation = '$';
489
- // @ts-ignore
490
- const { httpClient, sideEffects } = arguments[3];
491
- const { toAmbassadorRequest } = serializer({
492
- rootSchema: _getOfflineOrderPreviewRequest,
493
- depSchemas: {},
494
- fqdnTransformation: {
495
- paths: [],
496
- transformation: _fromVeloEntity,
497
- },
498
- customTransformation: requestTransformation,
499
- });
500
- const { fromJSON } = serializer({
501
- rootSchema: _getOfflineOrderPreviewResponse,
502
- depSchemas: {},
503
- fqdnTransformation: {
504
- paths: [...['order']],
505
- transformation: _toVeloEntity,
506
- },
507
- customTransformation: responseTransformation,
508
- });
509
- const payload = toAmbassadorRequest([planId, memberId, options]);
510
- const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
511
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
512
- try {
513
- const result = yield httpClient.request(reqOpts);
514
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
515
- return fromJSON(result.data);
516
- }
517
- catch (err) {
518
- const transformedError = sdkTransformError(err, {
519
- spreadPathsToArguments: {},
520
- explicitPathsToArguments: {
521
- planId: '$[0]',
522
- memberId: '$[1]',
523
- startDate: '$[2].startDate',
524
- couponCode: '$[2].couponCode',
525
- },
526
- singleArgumentUnchanged: false,
527
- }, ['planId', 'memberId', 'options']);
528
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
529
- throw transformedError;
530
- }
531
- });
532
- }
533
- /**
534
- * Retrieves a preview of an order's pricing as if it was purchased.
535
- *
536
- * The `getPricePreview()` function returns a Promise that resolves to a temporary preview of the order's price.
537
- *
538
- * The price preview uses the same logic for calculating prices as used when purchasing a plan, but the preview is not saved. If [taxes are configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection) for the site, taxes are applied to the preview. If not, the `tax` previews as `null`.
539
- *
540
- * Buyers do not have to be logged in to preview the price, as such, the details returned by this function are not buyer-specific. To generate a preview of a purchase for a specific-buyer, use the [`getOfflineOrderPreview()`](#getofflineorderpreview).
541
- * @param planId - ID of plan to preview.
542
- * @public
543
- * @documentationMaturity preview
544
- * @requiredField planId
545
- * @param options - Options for getting a price preview.
546
- * @permissionScope Read Pricing Plans
547
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
548
- * @permissionScope Manage Orders
549
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
550
- * @permissionScope Manage Bookings Services and Settings
551
- * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
552
- * @permissionScope Read Orders
553
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
554
- * @permissionScope Manage Pricing Plans
555
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
556
- * @applicableIdentity APP
557
- * @applicableIdentity MEMBER
558
- * @applicableIdentity VISITOR
559
- * @returns Fulfilled - A preview of the pricing for the order.
560
- */
561
- export function getPricePreview(planId, options) {
562
- var _a, _b, _c;
563
- return __awaiter(this, arguments, void 0, function* () {
564
- const requestTransformation = {
565
- planId: '$[0]',
566
- couponCode: '$[1].couponCode',
567
- };
568
- const responseTransformation = '$';
569
- // @ts-ignore
570
- const { httpClient, sideEffects } = arguments[2];
571
- const { toAmbassadorRequest } = serializer({
572
- rootSchema: _getPricePreviewRequest,
573
- depSchemas: {},
574
- fqdnTransformation: {
575
- paths: [],
576
- transformation: _fromVeloEntity,
577
- },
578
- customTransformation: requestTransformation,
579
- });
580
- const { fromJSON } = serializer({
581
- rootSchema: _getPricePreviewResponse,
582
- depSchemas: {},
583
- fqdnTransformation: {
584
- paths: [],
585
- transformation: _toVeloEntity,
586
- },
587
- customTransformation: responseTransformation,
588
- });
589
- const payload = toAmbassadorRequest([planId, options]);
590
- const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
591
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
592
- try {
593
- const result = yield httpClient.request(reqOpts);
594
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
595
- return fromJSON(result.data);
596
- }
597
- catch (err) {
598
- const transformedError = sdkTransformError(err, {
599
- spreadPathsToArguments: {},
600
- explicitPathsToArguments: {
601
- planId: '$[0]',
602
- couponCode: '$[1].couponCode',
603
- },
604
- singleArgumentUnchanged: false,
605
- }, ['planId', 'options']);
606
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
607
- throw transformedError;
608
- }
609
- });
610
- }
611
- /**
612
- * Retrieves an order by ID.
613
- *
614
- * The `managementGetOrder()` function returns a Promise that resolves to information about the specified order.
615
- * @param _id - Order ID.
616
- * @public
617
- * @documentationMaturity preview
618
- * @requiredField _id
619
- * @param options - Options to use when getting an order.
620
- * @permissionScope Manage Orders
621
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
622
- * @permissionScope Manage Bookings Services and Settings
623
- * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
624
- * @permissionScope Read Orders
625
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
626
- * @applicableIdentity APP
627
- */
628
- export function managementGetOrder(_id, options) {
629
- var _a, _b, _c;
630
- return __awaiter(this, arguments, void 0, function* () {
631
- const requestTransformation = { id: '$[0]', fieldSet: '$[1].fieldSet' };
632
- const responseTransformation = '$';
633
- // @ts-ignore
634
- const { httpClient, sideEffects } = arguments[2];
635
- const { toAmbassadorRequest } = serializer({
636
- rootSchema: _getOrderRequest,
637
- depSchemas: {},
638
- fqdnTransformation: {
639
- paths: [],
640
- transformation: _fromVeloEntity,
641
- },
642
- customTransformation: requestTransformation,
643
- });
644
- const { fromJSON } = serializer({
645
- rootSchema: _getOrderResponse,
646
- depSchemas: {},
647
- fqdnTransformation: {
648
- paths: [...['order']],
649
- transformation: _toVeloEntity,
650
- },
651
- customTransformation: responseTransformation,
652
- });
653
- const payload = toAmbassadorRequest([_id, options]);
654
- const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
655
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
656
- try {
657
- const result = yield httpClient.request(reqOpts);
658
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
659
- return fromJSON(result.data);
660
- }
661
- catch (err) {
662
- const transformedError = sdkTransformError(err, {
663
- spreadPathsToArguments: {},
664
- explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
665
- singleArgumentUnchanged: false,
666
- }, ['_id', 'options']);
667
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
668
- throw transformedError;
669
- }
670
- });
671
- }
672
- /**
673
- * Lists pricing plan orders.
674
- *
675
- * The `managementListOrders()` function returns a Promise that resolves to a list of up to 50 pricing plan orders. You can specify options for filtering, sorting, and paginating the results.
676
- *
677
- * This function returns the orders on the site. To list orders for the currently logged-in member, use [`memberListOrders()`](#memberlistorders).
678
- * @public
679
- * @documentationMaturity preview
680
- * @param options - Filtering, sorting, and pagination options.
681
- * @permissionScope Manage Orders
682
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
683
- * @permissionScope Manage Bookings Services and Settings
684
- * @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
685
- * @permissionScope Read Orders
686
- * @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
687
- * @applicableIdentity APP
688
- */
689
- export function managementListOrders(options) {
690
- var _a, _b, _c;
691
- return __awaiter(this, arguments, void 0, function* () {
692
- const requestTransformation = {
693
- buyerIds: '$[0].buyerIds',
694
- planIds: '$[0].planIds',
695
- autoRenewCanceled: '$[0].autoRenewCanceled',
696
- orderStatuses: '$[0].orderStatuses',
697
- paymentStatuses: '$[0].paymentStatuses',
698
- limit: '$[0].limit',
699
- offset: '$[0].offset',
700
- sorting: '$[0].sorting',
701
- fieldSet: '$[0].fieldSet',
702
- };
703
- const responseTransformation = '$';
704
- // @ts-ignore
705
- const { httpClient, sideEffects } = arguments[1];
706
- const { toAmbassadorRequest } = serializer({
707
- rootSchema: _listOrdersRequest,
708
- depSchemas: {},
709
- fqdnTransformation: {
710
- paths: [],
711
- transformation: _fromVeloEntity,
712
- },
713
- customTransformation: requestTransformation,
714
- });
715
- const { fromJSON } = serializer({
716
- rootSchema: _listOrdersResponse,
717
- depSchemas: {},
718
- fqdnTransformation: {
719
- paths: [...['Array#orders']],
720
- transformation: _toVeloEntity,
721
- },
722
- customTransformation: responseTransformation,
723
- });
724
- const payload = toAmbassadorRequest([options]);
725
- const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
726
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
727
- try {
728
- const result = yield httpClient.request(reqOpts);
729
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
730
- return fromJSON(result.data);
731
- }
732
- catch (err) {
733
- const transformedError = sdkTransformError(err, {
734
- spreadPathsToArguments: {},
735
- explicitPathsToArguments: {
736
- buyerIds: '$[0].buyerIds',
737
- planIds: '$[0].planIds',
738
- autoRenewCanceled: '$[0].autoRenewCanceled',
739
- orderStatuses: '$[0].orderStatuses',
740
- paymentStatuses: '$[0].paymentStatuses',
741
- limit: '$[0].limit',
742
- offset: '$[0].offset',
743
- sorting: '$[0].sorting',
744
- fieldSet: '$[0].fieldSet',
745
- },
746
- singleArgumentUnchanged: false,
747
- }, ['options']);
748
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
749
- throw transformedError;
750
- }
751
- });
752
- }
753
- /**
754
- * Extends the duration of a pricing plan order by postponing the order's `endDate`.
755
- *
756
- * The `postponeEndDate()` function returns a Promise that resolves when the order's end date is successfully changed.
757
- *
758
- * The new end date and time must be later than the order's current `endDate`.
759
- *
760
- * Postponing the end date of an order does not impact payments. For example, if the pricing plan is for a membership to an online lecture series, and you want to extend the duration of the series because the lecturer could not attend some sessions, you can postpone the end date of the orders for all relevant participants. The participants will not be billed additionally.
761
- *
762
- * Postponing an order causes the following changes:
763
- * - The `endDate` for the order is adjusted to the new end date.
764
- * @param _id - Order ID.
765
- * @param endDate - New end date and time.
766
- *
767
- * Must be later than the current end date and time.
768
- * @public
769
- * @documentationMaturity preview
770
- * @requiredField _id
771
- * @requiredField endDate
772
- * @param options - Options for postponing the end date of an order.
773
- * @permissionScope Manage Orders
774
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
775
- * @applicableIdentity APP
776
- * @returns Fulfilled - When the order's end date has been postponed or made earlier.
777
- *
778
- *
779
- */
780
- export function postponeEndDate(_id, endDate) {
781
- var _a, _b, _c;
782
- return __awaiter(this, arguments, void 0, function* () {
783
- const requestTransformation = { id: '$[0]', endDate: '$[1]' };
784
- const responseTransformation = '$';
785
- // @ts-ignore
786
- const { httpClient, sideEffects } = arguments[2];
787
- const { toAmbassadorRequest } = serializer({
788
- rootSchema: _postponeEndDateRequest,
789
- depSchemas: {},
790
- fqdnTransformation: {
791
- paths: [],
792
- transformation: _fromVeloEntity,
793
- },
794
- customTransformation: requestTransformation,
795
- });
796
- const { fromJSON } = serializer({
797
- rootSchema: _postponeEndDateResponse,
798
- depSchemas: {},
799
- fqdnTransformation: {
800
- paths: [],
801
- transformation: _toVeloEntity,
802
- },
803
- customTransformation: responseTransformation,
804
- });
805
- const payload = toAmbassadorRequest([_id, endDate]);
806
- const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
807
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
808
- try {
809
- const result = yield httpClient.request(reqOpts);
810
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
811
- }
812
- catch (err) {
813
- const transformedError = sdkTransformError(err, {
814
- spreadPathsToArguments: {},
815
- explicitPathsToArguments: { id: '$[0]', endDate: '$[1]' },
816
- singleArgumentUnchanged: false,
817
- }, ['_id', 'endDate']);
818
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
819
- throw transformedError;
820
- }
821
- });
822
- }
823
- /**
824
- * Cancels an existing order.
825
- *
826
- * The `cancelOrder()` function returns a Promise that resolves when the order is successfully canceled.
827
- *
828
- * For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
829
- * For orders with one-time payments, a cancellation occurs `IMMEDIATELY`.
830
- *
831
- * Canceling an order changes the order status to `CANCELED`.
832
- *
833
- * #### Canceling during the free trial period.
834
- *
835
- * When a site owner cancels an ordered plan during the free trial period, they choose to apply the cancellation `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
836
- *
837
- * Canceling `IMMEDIATELY` will end the subscription for the buyer
838
- * immediately, even during the free trial period and the buyer won't be billed.
839
- *
840
- * Canceling at the `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period. Then, the subscription ends and the buyer is not billed.
841
- * @param _id - Order ID.
842
- * @param effectiveAt - When the order is canceled.
843
- *
844
- * One time orders can only be canceled immediately. Supported values:
845
- * - `"IMMEDIATELY"`: The order is canceled immediately.
846
- * - `"NEXT_PAYMENT_DATE"`: The order is canceled at the next payment date.
847
- * @public
848
- * @documentationMaturity preview
849
- * @requiredField _id
850
- * @requiredField effectiveAt
851
- * @param options - Options for canceling orders.
852
- * @permissionScope Manage Orders
853
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
854
- * @applicableIdentity APP
855
- * @returns Fulfilled - When the order is canceled.
856
- */
857
- export function cancelOrder(_id, effectiveAt) {
858
- var _a, _b, _c;
859
- return __awaiter(this, arguments, void 0, function* () {
860
- const requestTransformation = { id: '$[0]', effectiveAt: '$[1]' };
861
- const responseTransformation = '$';
862
- // @ts-ignore
863
- const { httpClient, sideEffects } = arguments[2];
864
- const { toAmbassadorRequest } = serializer({
865
- rootSchema: _cancelOrderRequest,
866
- depSchemas: {},
867
- fqdnTransformation: {
868
- paths: [],
869
- transformation: _fromVeloEntity,
870
- },
871
- customTransformation: requestTransformation,
872
- });
873
- const { fromJSON } = serializer({
874
- rootSchema: _cancelOrderResponse,
875
- depSchemas: {},
876
- fqdnTransformation: {
877
- paths: [],
878
- transformation: _toVeloEntity,
879
- },
880
- customTransformation: responseTransformation,
881
- });
882
- const payload = toAmbassadorRequest([_id, effectiveAt]);
883
- const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
884
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
885
- try {
886
- const result = yield httpClient.request(reqOpts);
887
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
888
- }
889
- catch (err) {
890
- const transformedError = sdkTransformError(err, {
891
- spreadPathsToArguments: {},
892
- explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
893
- singleArgumentUnchanged: false,
894
- }, ['_id', 'effectiveAt']);
895
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
896
- throw transformedError;
897
- }
898
- });
899
- }
900
- /**
901
- * Marks an offline order as paid.
902
- *
903
- * The `markAsPaid()` function returns a Promise that resolves when the offline order is successfully marked as paid.
904
- *
905
- * The entire order is marked as paid, even if the order's payments are recurring.
906
- *
907
- * >**Note:** Marking separate payment cycles as paid is not yet supported. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments.
908
- *
909
- * Marking an offline order as paid causes the following changes:
910
- * - The order's `lastPaymentStatus` changes to `"PAID"`.
911
- * - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`.
912
- *
913
- * An error occurs if you attempt to:
914
- * - Mark an already-paid, offline order as paid. You cannot make an offline order as paid twice.
915
- * - Mark an online order as paid. The `markAsPaid()` function is supported for offline orders only.
916
- * @param _id - Order ID.
917
- * @public
918
- * @documentationMaturity preview
919
- * @requiredField _id
920
- * @permissionScope Manage Orders
921
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
922
- * @applicableIdentity APP
923
- * @returns Fulfilled - When the order is marked as paid.
924
- */
925
- export function markAsPaid(_id) {
926
- var _a, _b, _c;
927
- return __awaiter(this, arguments, void 0, function* () {
928
- const requestTransformation = { id: '$[0]' };
929
- const responseTransformation = '$';
930
- // @ts-ignore
931
- const { httpClient, sideEffects } = arguments[1];
932
- const { toAmbassadorRequest } = serializer({
933
- rootSchema: _markAsPaidRequest,
934
- depSchemas: {},
935
- fqdnTransformation: {
936
- paths: [],
937
- transformation: _fromVeloEntity,
938
- },
939
- customTransformation: requestTransformation,
940
- });
941
- const { fromJSON } = serializer({
942
- rootSchema: _markAsPaidResponse,
943
- depSchemas: {},
944
- fqdnTransformation: {
945
- paths: [],
946
- transformation: _toVeloEntity,
947
- },
948
- customTransformation: responseTransformation,
949
- });
950
- const payload = toAmbassadorRequest([_id]);
951
- const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
952
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
953
- try {
954
- const result = yield httpClient.request(reqOpts);
955
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
956
- }
957
- catch (err) {
958
- const transformedError = sdkTransformError(err, {
959
- spreadPathsToArguments: {},
960
- explicitPathsToArguments: { id: '$[0]' },
961
- singleArgumentUnchanged: false,
962
- }, ['_id']);
963
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
964
- throw transformedError;
965
- }
966
- });
967
- }
968
- /**
969
- * Pauses a pricing plan order.
970
- *
971
- * The `pauseOrder()` function returns a Promise that resolves when the order is successfully paused.
972
- *
973
- * For orders with recurring payments, `pauseOrder()` also pauses the payment schedule. Buyers are not charged when an order is paused. Use `pauseOrder()`, for example, if the buyer is away and would like to put their pricing plan membership on hold until they return. Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`. You can only pause orders with an `"ACTIVE`" status.
974
- *
975
- * Pausing an order causes the following changes:
976
- * - The order status changes to `"PAUSED"`.
977
- * - The `pausePeriods` array is updated.
978
- *
979
- * The `endDate` and the `earliestEndDate` for the order are adjusted to include the pause period when the order is resumed.
980
- *
981
- * Paused orders can be continued with the [`resumeOrder()`](#resumeorder) function.
982
- * @param _id - Order ID.
983
- * @public
984
- * @documentationMaturity preview
985
- * @requiredField _id
986
- * @permissionScope Manage Orders
987
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
988
- * @applicableIdentity APP
989
- * @returns Fulfilled - When the order is paused.
990
- */
991
- export function pauseOrder(_id) {
992
- var _a, _b, _c;
993
- return __awaiter(this, arguments, void 0, function* () {
994
- const requestTransformation = { id: '$[0]' };
995
- const responseTransformation = '$';
996
- // @ts-ignore
997
- const { httpClient, sideEffects } = arguments[1];
998
- const { toAmbassadorRequest } = serializer({
999
- rootSchema: _pauseOrderRequest,
1000
- depSchemas: {},
1001
- fqdnTransformation: {
1002
- paths: [],
1003
- transformation: _fromVeloEntity,
1004
- },
1005
- customTransformation: requestTransformation,
1006
- });
1007
- const { fromJSON } = serializer({
1008
- rootSchema: _pauseOrderResponse,
1009
- depSchemas: {},
1010
- fqdnTransformation: {
1011
- paths: [],
1012
- transformation: _toVeloEntity,
1013
- },
1014
- customTransformation: responseTransformation,
1015
- });
1016
- const payload = toAmbassadorRequest([_id]);
1017
- const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
1018
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1019
- try {
1020
- const result = yield httpClient.request(reqOpts);
1021
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1022
- }
1023
- catch (err) {
1024
- const transformedError = sdkTransformError(err, {
1025
- spreadPathsToArguments: {},
1026
- explicitPathsToArguments: { id: '$[0]' },
1027
- singleArgumentUnchanged: false,
1028
- }, ['_id']);
1029
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1030
- throw transformedError;
1031
- }
1032
- });
1033
- }
1034
- /**
1035
- * Resumes a paused pricing plan order.
1036
- *
1037
- * The `resumeOrder()` function returns a Promise that resolves when a paused order is successfully resumed.
1038
- *
1039
- * For orders with recurring payments, `resumeOrder()` also restarts the payment schedule.
1040
- *
1041
- * Resuming an order causes the following changes:
1042
- * - The order status changes to `"ACTIVE"`.
1043
- * - The `pausePeriods` array is updated.
1044
- * - The `endDate` for the order is adjusted to include the pause period.
1045
- * - The `earliestEndDate` is adjusted to include the pause period. (This property is reserved for future use).
1046
- * @param _id - Order ID.
1047
- * @public
1048
- * @documentationMaturity preview
1049
- * @requiredField _id
1050
- * @permissionScope Manage Orders
1051
- * @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
1052
- * @applicableIdentity APP
1053
- * @returns Fulfilled - When the order is resumed.
1054
- */
1055
- export function resumeOrder(_id) {
1056
- var _a, _b, _c;
1057
- return __awaiter(this, arguments, void 0, function* () {
1058
- const requestTransformation = { id: '$[0]' };
1059
- const responseTransformation = '$';
1060
- // @ts-ignore
1061
- const { httpClient, sideEffects } = arguments[1];
1062
- const { toAmbassadorRequest } = serializer({
1063
- rootSchema: _resumeOrderRequest,
1064
- depSchemas: {},
1065
- fqdnTransformation: {
1066
- paths: [],
1067
- transformation: _fromVeloEntity,
1068
- },
1069
- customTransformation: requestTransformation,
1070
- });
1071
- const { fromJSON } = serializer({
1072
- rootSchema: _resumeOrderResponse,
1073
- depSchemas: {},
1074
- fqdnTransformation: {
1075
- paths: [],
1076
- transformation: _toVeloEntity,
1077
- },
1078
- customTransformation: responseTransformation,
1079
- });
1080
- const payload = toAmbassadorRequest([_id]);
1081
- const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
1082
- (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
1083
- try {
1084
- const result = yield httpClient.request(reqOpts);
1085
- (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
1086
- }
1087
- catch (err) {
1088
- const transformedError = sdkTransformError(err, {
1089
- spreadPathsToArguments: {},
1090
- explicitPathsToArguments: { id: '$[0]' },
1091
- singleArgumentUnchanged: false,
1092
- }, ['_id']);
1093
- (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
1094
- throw transformedError;
1095
- }
1096
- });
1097
- }
1098
- //# sourceMappingURL=pricing-plans-v2-order.universal.js.map