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