@wix/pricing-plans 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +25 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order.http.d.ts +105 -0
- package/build/cjs/src/pricing-plans-v2-order.http.js +751 -0
- package/build/cjs/src/pricing-plans-v2-order.http.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order.public.d.ts +17 -0
- package/build/cjs/src/pricing-plans-v2-order.public.js +95 -0
- package/build/cjs/src/pricing-plans-v2-order.public.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order.types.d.ts +1071 -0
- package/build/cjs/src/pricing-plans-v2-order.types.js +133 -0
- package/build/cjs/src/pricing-plans-v2-order.types.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order.universal.d.ts +1346 -0
- package/build/cjs/src/pricing-plans-v2-order.universal.js +962 -0
- package/build/cjs/src/pricing-plans-v2-order.universal.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-plan.http.d.ts +44 -0
- package/build/cjs/src/pricing-plans-v2-plan.http.js +453 -0
- package/build/cjs/src/pricing-plans-v2-plan.http.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-plan.public.d.ts +16 -0
- package/build/cjs/src/pricing-plans-v2-plan.public.js +82 -0
- package/build/cjs/src/pricing-plans-v2-plan.public.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-plan.types.d.ts +357 -0
- package/build/cjs/src/pricing-plans-v2-plan.types.js +35 -0
- package/build/cjs/src/pricing-plans-v2-plan.types.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-plan.universal.d.ts +554 -0
- package/build/cjs/src/pricing-plans-v2-plan.universal.js +728 -0
- package/build/cjs/src/pricing-plans-v2-plan.universal.js.map +1 -0
- package/build/es/index.d.ts +2 -0
- package/build/es/index.js +3 -0
- package/build/es/index.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order.http.d.ts +105 -0
- package/build/es/src/pricing-plans-v2-order.http.js +735 -0
- package/build/es/src/pricing-plans-v2-order.http.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order.public.d.ts +17 -0
- package/build/es/src/pricing-plans-v2-order.public.js +68 -0
- package/build/es/src/pricing-plans-v2-order.public.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order.types.d.ts +1071 -0
- package/build/es/src/pricing-plans-v2-order.types.js +130 -0
- package/build/es/src/pricing-plans-v2-order.types.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order.universal.d.ts +1346 -0
- package/build/es/src/pricing-plans-v2-order.universal.js +927 -0
- package/build/es/src/pricing-plans-v2-order.universal.js.map +1 -0
- package/build/es/src/pricing-plans-v2-plan.http.d.ts +44 -0
- package/build/es/src/pricing-plans-v2-plan.http.js +438 -0
- package/build/es/src/pricing-plans-v2-plan.http.js.map +1 -0
- package/build/es/src/pricing-plans-v2-plan.public.d.ts +16 -0
- package/build/es/src/pricing-plans-v2-plan.public.js +63 -0
- package/build/es/src/pricing-plans-v2-plan.public.js.map +1 -0
- package/build/es/src/pricing-plans-v2-plan.types.d.ts +357 -0
- package/build/es/src/pricing-plans-v2-plan.types.js +32 -0
- package/build/es/src/pricing-plans-v2-plan.types.js.map +1 -0
- package/build/es/src/pricing-plans-v2-plan.universal.d.ts +554 -0
- package/build/es/src/pricing-plans-v2-plan.universal.js +694 -0
- package/build/es/src/pricing-plans-v2-plan.universal.js.map +1 -0
- package/package.json +37 -0
@@ -0,0 +1,962 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28
|
+
});
|
29
|
+
};
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
31
|
+
exports.resumeOrder = exports.pauseOrder = exports.markAsPaid = exports.cancelOrder = exports.postponeEndDate = exports.managementListOrders = exports.managementGetOrder = exports.getPricePreview = exports.getOfflineOrderPreview = exports.createOfflineOrder = exports.requestCancellation = exports.memberListOrders = exports.memberGetOrder = exports.ReasonNotSuspendable = exports.SortOrder = exports.Set = exports.Status = exports.PaymentStatus = exports.CancellationEffectiveAt = exports.CancellationCause = exports.OrderStatus = exports.OrderMethod = exports.OrderType = exports.PeriodUnit = exports.__debug = void 0;
|
32
|
+
const velo_1 = require("@wix/metro-runtime/velo");
|
33
|
+
const ambassadorWixPricingPlansV2Order = __importStar(require("./pricing-plans-v2-order.http"));
|
34
|
+
let __verbose = false;
|
35
|
+
function __log(...args) {
|
36
|
+
__verbose && console.log(...args);
|
37
|
+
}
|
38
|
+
function __inspect(obj) {
|
39
|
+
return obj;
|
40
|
+
}
|
41
|
+
exports.__debug = {
|
42
|
+
verboseLogging: {
|
43
|
+
on: () => (__verbose = true),
|
44
|
+
off: () => (__verbose = false),
|
45
|
+
},
|
46
|
+
};
|
47
|
+
const _toVeloEntity = '$';
|
48
|
+
const _fromVeloEntity = '$';
|
49
|
+
var PeriodUnit;
|
50
|
+
(function (PeriodUnit) {
|
51
|
+
PeriodUnit["UNDEFINED"] = "UNDEFINED";
|
52
|
+
PeriodUnit["DAY"] = "DAY";
|
53
|
+
PeriodUnit["WEEK"] = "WEEK";
|
54
|
+
PeriodUnit["MONTH"] = "MONTH";
|
55
|
+
PeriodUnit["YEAR"] = "YEAR";
|
56
|
+
})(PeriodUnit = exports.PeriodUnit || (exports.PeriodUnit = {}));
|
57
|
+
var OrderType;
|
58
|
+
(function (OrderType) {
|
59
|
+
OrderType["UNDEFINED"] = "UNDEFINED";
|
60
|
+
/** Payments made by the buyer */
|
61
|
+
OrderType["ONLINE"] = "ONLINE";
|
62
|
+
/** Payments managed manually by the site owner */
|
63
|
+
OrderType["OFFLINE"] = "OFFLINE";
|
64
|
+
})(OrderType = exports.OrderType || (exports.OrderType = {}));
|
65
|
+
var OrderMethod;
|
66
|
+
(function (OrderMethod) {
|
67
|
+
OrderMethod["UNKNOWN"] = "UNKNOWN";
|
68
|
+
/** Mail Order / Telephone Order transaction */
|
69
|
+
OrderMethod["MOTO"] = "MOTO";
|
70
|
+
/** Point of Sale transaction */
|
71
|
+
OrderMethod["POS"] = "POS";
|
72
|
+
})(OrderMethod = exports.OrderMethod || (exports.OrderMethod = {}));
|
73
|
+
var OrderStatus;
|
74
|
+
(function (OrderStatus) {
|
75
|
+
/** Order status undefined */
|
76
|
+
OrderStatus["UNDEFINED"] = "UNDEFINED";
|
77
|
+
/** Order created, but hasn't been paid for yet. Filtered out in ListOrders response by default. */
|
78
|
+
OrderStatus["DRAFT"] = "DRAFT";
|
79
|
+
/** Order has been paid for, but the start date is in the future */
|
80
|
+
OrderStatus["PENDING"] = "PENDING";
|
81
|
+
/** Order is active */
|
82
|
+
OrderStatus["ACTIVE"] = "ACTIVE";
|
83
|
+
/** Order is paused until site owner resumes it */
|
84
|
+
OrderStatus["PAUSED"] = "PAUSED";
|
85
|
+
/** Order has ended */
|
86
|
+
OrderStatus["ENDED"] = "ENDED";
|
87
|
+
/** Order has been canceled */
|
88
|
+
OrderStatus["CANCELED"] = "CANCELED";
|
89
|
+
})(OrderStatus = exports.OrderStatus || (exports.OrderStatus = {}));
|
90
|
+
var CancellationCause;
|
91
|
+
(function (CancellationCause) {
|
92
|
+
/** Cancellation initiator undefined */
|
93
|
+
CancellationCause["UNDEFINED"] = "UNDEFINED";
|
94
|
+
/** Order was canceled by site owner (default if canceled by user or service identity) */
|
95
|
+
CancellationCause["OWNER_ACTION"] = "OWNER_ACTION";
|
96
|
+
/** Order was canceled by member (default if canceled by member identity) */
|
97
|
+
CancellationCause["MEMBER_ACTION"] = "MEMBER_ACTION";
|
98
|
+
/** Order was canceled because of payment failure */
|
99
|
+
CancellationCause["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
|
100
|
+
/** Order was canceled because of payment setup failure */
|
101
|
+
CancellationCause["PAYMENT_SETUP_FAILURE"] = "PAYMENT_SETUP_FAILURE";
|
102
|
+
/** Order was cancelled because of an unknown reason. It's not possible to know with certain payment providers (e.g. paypal) */
|
103
|
+
CancellationCause["UNKNOWN"] = "UNKNOWN";
|
104
|
+
})(CancellationCause = exports.CancellationCause || (exports.CancellationCause = {}));
|
105
|
+
var CancellationEffectiveAt;
|
106
|
+
(function (CancellationEffectiveAt) {
|
107
|
+
/** Cancellation time undefined */
|
108
|
+
CancellationEffectiveAt["UNDEFINED"] = "UNDEFINED";
|
109
|
+
/** Will cancel the order now, i.e. update validUntil to the current date */
|
110
|
+
CancellationEffectiveAt["IMMEDIATELY"] = "IMMEDIATELY";
|
111
|
+
/** Will cancel the order at the date when next payment should have been made */
|
112
|
+
CancellationEffectiveAt["NEXT_PAYMENT_DATE"] = "NEXT_PAYMENT_DATE";
|
113
|
+
})(CancellationEffectiveAt = exports.CancellationEffectiveAt || (exports.CancellationEffectiveAt = {}));
|
114
|
+
var PaymentStatus;
|
115
|
+
(function (PaymentStatus) {
|
116
|
+
/** Payment status undefined */
|
117
|
+
PaymentStatus["UNDEFINED"] = "UNDEFINED";
|
118
|
+
/** Payment has been paid */
|
119
|
+
PaymentStatus["PAID"] = "PAID";
|
120
|
+
/** Payment has been refunded */
|
121
|
+
PaymentStatus["REFUNDED"] = "REFUNDED";
|
122
|
+
/** Recurring payment has failed */
|
123
|
+
PaymentStatus["FAILED"] = "FAILED";
|
124
|
+
/** Payment has not been paid */
|
125
|
+
PaymentStatus["UNPAID"] = "UNPAID";
|
126
|
+
/** Billing has been initialized, but actual charge is yet to be made. Can happen for free trial and PayPal */
|
127
|
+
PaymentStatus["PENDING"] = "PENDING";
|
128
|
+
/** Used in cases where the plan is free */
|
129
|
+
PaymentStatus["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
130
|
+
})(PaymentStatus = exports.PaymentStatus || (exports.PaymentStatus = {}));
|
131
|
+
var Status;
|
132
|
+
(function (Status) {
|
133
|
+
Status["UNDEFINED"] = "UNDEFINED";
|
134
|
+
/** Order suspension is active */
|
135
|
+
Status["ACTIVE"] = "ACTIVE";
|
136
|
+
/** Order suspension has ended */
|
137
|
+
Status["ENDED"] = "ENDED";
|
138
|
+
})(Status = exports.Status || (exports.Status = {}));
|
139
|
+
var Set;
|
140
|
+
(function (Set) {
|
141
|
+
/** Same behavior as BASIC */
|
142
|
+
Set["UNKNOWN_SET"] = "UNKNOWN_SET";
|
143
|
+
/**
|
144
|
+
* Returns fields of the entity that are available in the database.
|
145
|
+
* By default a field is available in the database unless explicitly specified in the documentation
|
146
|
+
*/
|
147
|
+
Set["BASIC"] = "BASIC";
|
148
|
+
/**
|
149
|
+
* Returns all fields in the entity.
|
150
|
+
* This might make additional calls to gather the full entity
|
151
|
+
*/
|
152
|
+
Set["FULL"] = "FULL";
|
153
|
+
})(Set = exports.Set || (exports.Set = {}));
|
154
|
+
var SortOrder;
|
155
|
+
(function (SortOrder) {
|
156
|
+
SortOrder["ASC"] = "ASC";
|
157
|
+
SortOrder["DESC"] = "DESC";
|
158
|
+
})(SortOrder = exports.SortOrder || (exports.SortOrder = {}));
|
159
|
+
var ReasonNotSuspendable;
|
160
|
+
(function (ReasonNotSuspendable) {
|
161
|
+
/** Reason unknown */
|
162
|
+
ReasonNotSuspendable["UNDEFINED"] = "UNDEFINED";
|
163
|
+
/** Saved in the database but is awaiting payment. Non-active orders cannot be suspended */
|
164
|
+
ReasonNotSuspendable["PENDING"] = "PENDING";
|
165
|
+
/** Trial orders cannot be suspended */
|
166
|
+
ReasonNotSuspendable["TRIAL"] = "TRIAL";
|
167
|
+
/** Canceled orders cannot be suspended */
|
168
|
+
ReasonNotSuspendable["CANCELED"] = "CANCELED";
|
169
|
+
/** Ended orders cannot be suspended */
|
170
|
+
ReasonNotSuspendable["ENDED"] = "ENDED";
|
171
|
+
/** Paid for orders with future start dates cannot be suspended */
|
172
|
+
ReasonNotSuspendable["NOT_STARTED"] = "NOT_STARTED";
|
173
|
+
/** Order is already suspended */
|
174
|
+
ReasonNotSuspendable["ALREADY_SUSPENDED"] = "ALREADY_SUSPENDED";
|
175
|
+
/** Orders based on recurring payments using older Stripe versions cannot be suspended */
|
176
|
+
ReasonNotSuspendable["OLD_STRIPE"] = "OLD_STRIPE";
|
177
|
+
})(ReasonNotSuspendable = exports.ReasonNotSuspendable || (exports.ReasonNotSuspendable = {}));
|
178
|
+
const _cancelOrderRequest = {};
|
179
|
+
const _cancelOrderResponse = {};
|
180
|
+
const _createOfflineOrderRequest = {};
|
181
|
+
const _createOfflineOrderResponse = {};
|
182
|
+
const _getOfflineOrderPreviewRequest = {};
|
183
|
+
const _getOfflineOrderPreviewResponse = {};
|
184
|
+
const _getOrderRequest = {};
|
185
|
+
const _getOrderResponse = {};
|
186
|
+
const _getPricePreviewRequest = {};
|
187
|
+
const _getPricePreviewResponse = {};
|
188
|
+
const _listOrdersRequest = {};
|
189
|
+
const _listOrdersResponse = {};
|
190
|
+
const _markAsPaidRequest = {};
|
191
|
+
const _markAsPaidResponse = {};
|
192
|
+
const _memberGetOrderRequest = {};
|
193
|
+
const _memberGetOrderResponse = {};
|
194
|
+
const _memberListOrdersRequest = {};
|
195
|
+
const _memberListOrdersResponse = {};
|
196
|
+
const _pauseOrderRequest = {};
|
197
|
+
const _pauseOrderResponse = {};
|
198
|
+
const _postponeEndDateRequest = {};
|
199
|
+
const _postponeEndDateResponse = {};
|
200
|
+
const _requestCancellationRequest = {};
|
201
|
+
const _requestCancellationResponse = {};
|
202
|
+
const _resumeOrderRequest = {};
|
203
|
+
const _resumeOrderResponse = {};
|
204
|
+
/**
|
205
|
+
* Retrieves an order by ID.
|
206
|
+
* @param _id - Order ID.
|
207
|
+
* @public
|
208
|
+
* @documentationMaturity preview
|
209
|
+
* @requiredField _id
|
210
|
+
*/
|
211
|
+
function memberGetOrder(_id, options) {
|
212
|
+
var _a, _b, _c;
|
213
|
+
return __awaiter(this, arguments, void 0, function* () {
|
214
|
+
const requestTransformation = { id: '$[0]', fieldSet: '$[1].fieldSet' };
|
215
|
+
const responseTransformation = '$';
|
216
|
+
// @ts-ignore
|
217
|
+
const { httpClient, sideEffects } = arguments[2];
|
218
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
219
|
+
rootSchema: _memberGetOrderRequest,
|
220
|
+
depSchemas: {},
|
221
|
+
fqdnTransformation: {
|
222
|
+
paths: [],
|
223
|
+
transformation: _fromVeloEntity,
|
224
|
+
},
|
225
|
+
customTransformation: requestTransformation,
|
226
|
+
});
|
227
|
+
const { fromJSON } = velo_1.serializer({
|
228
|
+
rootSchema: _memberGetOrderResponse,
|
229
|
+
depSchemas: {},
|
230
|
+
fqdnTransformation: {
|
231
|
+
paths: [...['order']],
|
232
|
+
transformation: _toVeloEntity,
|
233
|
+
},
|
234
|
+
customTransformation: responseTransformation,
|
235
|
+
});
|
236
|
+
const payload = toAmbassadorRequest([_id, options]);
|
237
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
|
238
|
+
__log(`"GetOrder" sending request with: ${__inspect(reqOpts)}`);
|
239
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
240
|
+
try {
|
241
|
+
const result = yield httpClient.request(reqOpts);
|
242
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
243
|
+
return fromJSON(result.data);
|
244
|
+
}
|
245
|
+
catch (err) {
|
246
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
247
|
+
'_id',
|
248
|
+
'options',
|
249
|
+
]);
|
250
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
251
|
+
throw transformedError;
|
252
|
+
}
|
253
|
+
});
|
254
|
+
}
|
255
|
+
exports.memberGetOrder = memberGetOrder;
|
256
|
+
/**
|
257
|
+
* Returns orders for currently logged in member.
|
258
|
+
* @public
|
259
|
+
* @documentationMaturity preview
|
260
|
+
*/
|
261
|
+
function memberListOrders(options) {
|
262
|
+
var _a, _b, _c;
|
263
|
+
return __awaiter(this, arguments, void 0, function* () {
|
264
|
+
const requestTransformation = {
|
265
|
+
planIds: '$[0].planIds',
|
266
|
+
autoRenewCanceled: '$[0].autoRenewCanceled',
|
267
|
+
orderStatuses: '$[0].orderStatuses',
|
268
|
+
paymentStatuses: '$[0].paymentStatuses',
|
269
|
+
limit: '$[0].limit',
|
270
|
+
offset: '$[0].offset',
|
271
|
+
sorting: '$[0].sorting',
|
272
|
+
};
|
273
|
+
const responseTransformation = '$';
|
274
|
+
// @ts-ignore
|
275
|
+
const { httpClient, sideEffects } = arguments[1];
|
276
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
277
|
+
rootSchema: _memberListOrdersRequest,
|
278
|
+
depSchemas: {},
|
279
|
+
fqdnTransformation: {
|
280
|
+
paths: [],
|
281
|
+
transformation: _fromVeloEntity,
|
282
|
+
},
|
283
|
+
customTransformation: requestTransformation,
|
284
|
+
});
|
285
|
+
const { fromJSON } = velo_1.serializer({
|
286
|
+
rootSchema: _memberListOrdersResponse,
|
287
|
+
depSchemas: {},
|
288
|
+
fqdnTransformation: {
|
289
|
+
paths: [...['Array#orders']],
|
290
|
+
transformation: _toVeloEntity,
|
291
|
+
},
|
292
|
+
customTransformation: responseTransformation,
|
293
|
+
});
|
294
|
+
const payload = toAmbassadorRequest([options]);
|
295
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
|
296
|
+
__log(`"ListOrders" sending request with: ${__inspect(reqOpts)}`);
|
297
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
298
|
+
try {
|
299
|
+
const result = yield httpClient.request(reqOpts);
|
300
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
301
|
+
return fromJSON(result.data);
|
302
|
+
}
|
303
|
+
catch (err) {
|
304
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
305
|
+
'options',
|
306
|
+
]);
|
307
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
308
|
+
throw transformedError;
|
309
|
+
}
|
310
|
+
});
|
311
|
+
}
|
312
|
+
exports.memberListOrders = memberListOrders;
|
313
|
+
/**
|
314
|
+
* Cancels an order. Recurring orders can be canceled either immediately or at the next payment date.
|
315
|
+
* One time orders can only be canceled immediately.
|
316
|
+
* @param _id - Order ID.
|
317
|
+
* @public
|
318
|
+
* @documentationMaturity preview
|
319
|
+
* @requiredField _id
|
320
|
+
*/
|
321
|
+
function requestCancellation(_id, options) {
|
322
|
+
var _a, _b, _c;
|
323
|
+
return __awaiter(this, arguments, void 0, function* () {
|
324
|
+
const requestTransformation = { id: '$[0]', effectiveAt: '$[1].effectiveAt' };
|
325
|
+
const responseTransformation = '$';
|
326
|
+
// @ts-ignore
|
327
|
+
const { httpClient, sideEffects } = arguments[2];
|
328
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
329
|
+
rootSchema: _requestCancellationRequest,
|
330
|
+
depSchemas: {},
|
331
|
+
fqdnTransformation: {
|
332
|
+
paths: [],
|
333
|
+
transformation: _fromVeloEntity,
|
334
|
+
},
|
335
|
+
customTransformation: requestTransformation,
|
336
|
+
});
|
337
|
+
const { fromJSON } = velo_1.serializer({
|
338
|
+
rootSchema: _requestCancellationResponse,
|
339
|
+
depSchemas: {},
|
340
|
+
fqdnTransformation: {
|
341
|
+
paths: [],
|
342
|
+
transformation: _toVeloEntity,
|
343
|
+
},
|
344
|
+
customTransformation: responseTransformation,
|
345
|
+
});
|
346
|
+
const payload = toAmbassadorRequest([_id, options]);
|
347
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
|
348
|
+
__log(`"RequestCancellation" sending request with: ${__inspect(reqOpts)}`);
|
349
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
350
|
+
try {
|
351
|
+
const result = yield httpClient.request(reqOpts);
|
352
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
353
|
+
return fromJSON(result.data);
|
354
|
+
}
|
355
|
+
catch (err) {
|
356
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
357
|
+
'_id',
|
358
|
+
'options',
|
359
|
+
]);
|
360
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
361
|
+
throw transformedError;
|
362
|
+
}
|
363
|
+
});
|
364
|
+
}
|
365
|
+
exports.requestCancellation = requestCancellation;
|
366
|
+
/**
|
367
|
+
* Creates an order for a buyer who purchased the plan with an offline transaction.
|
368
|
+
*
|
369
|
+
* An offline order is handled off of the Wix site and is marked as `offline` in `type`. If a pricing plan
|
370
|
+
* has a limit on the amount of purchases per buyer, that limit is ignored for offline orders.
|
371
|
+
* Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
|
372
|
+
*
|
373
|
+
* Handle payment for an offline order in 1 of 2 ways:
|
374
|
+
* + When creating the order, select `true` in the `paid` request parameter.
|
375
|
+
* + After creation, use [Mark As Paid to mark the order as paid](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/mark-as-paid).
|
376
|
+
* @param planId - ID of the plan being ordered. See [Plans for more information about plan IDs](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/plans).
|
377
|
+
* @public
|
378
|
+
* @documentationMaturity preview
|
379
|
+
* @requiredField options.memberId
|
380
|
+
* @requiredField planId
|
381
|
+
*/
|
382
|
+
function createOfflineOrder(planId, options) {
|
383
|
+
var _a, _b, _c;
|
384
|
+
return __awaiter(this, arguments, void 0, function* () {
|
385
|
+
const requestTransformation = {
|
386
|
+
planId: '$[0]',
|
387
|
+
memberId: '$[1].memberId',
|
388
|
+
startDate: '$[1].startDate',
|
389
|
+
paid: '$[1].paid',
|
390
|
+
couponCode: '$[1].couponCode',
|
391
|
+
submissionId: '$[1].submissionId',
|
392
|
+
};
|
393
|
+
const responseTransformation = '$';
|
394
|
+
// @ts-ignore
|
395
|
+
const { httpClient, sideEffects } = arguments[2];
|
396
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
397
|
+
rootSchema: _createOfflineOrderRequest,
|
398
|
+
depSchemas: {},
|
399
|
+
fqdnTransformation: {
|
400
|
+
paths: [],
|
401
|
+
transformation: _fromVeloEntity,
|
402
|
+
},
|
403
|
+
customTransformation: requestTransformation,
|
404
|
+
});
|
405
|
+
const { fromJSON } = velo_1.serializer({
|
406
|
+
rootSchema: _createOfflineOrderResponse,
|
407
|
+
depSchemas: {},
|
408
|
+
fqdnTransformation: {
|
409
|
+
paths: [...['order']],
|
410
|
+
transformation: _toVeloEntity,
|
411
|
+
},
|
412
|
+
customTransformation: responseTransformation,
|
413
|
+
});
|
414
|
+
const payload = toAmbassadorRequest([planId, options]);
|
415
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.createOfflineOrder(payload);
|
416
|
+
__log(`"CreateOfflineOrder" sending request with: ${__inspect(reqOpts)}`);
|
417
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
418
|
+
try {
|
419
|
+
const result = yield httpClient.request(reqOpts);
|
420
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
421
|
+
return fromJSON(result.data);
|
422
|
+
}
|
423
|
+
catch (err) {
|
424
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
425
|
+
'planId',
|
426
|
+
'options',
|
427
|
+
]);
|
428
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
429
|
+
throw transformedError;
|
430
|
+
}
|
431
|
+
});
|
432
|
+
}
|
433
|
+
exports.createOfflineOrder = createOfflineOrder;
|
434
|
+
/**
|
435
|
+
* Performs a dry run of a purchase and provides an order preview.
|
436
|
+
*
|
437
|
+
* The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually
|
438
|
+
* created, the preview order's `orderId` and `subscriptionId` are displayed as a string of multiple zero characters
|
439
|
+
* (`000000-0000`). Tax is only calculated if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
|
440
|
+
* <br>
|
441
|
+
* If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview.
|
442
|
+
* But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then
|
443
|
+
* `purchaseLimitExceeded` will return as `true`.
|
444
|
+
*
|
445
|
+
* To get a general price preview for a plan that's not buyer-specific, use [Get Price Preview](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/get-price-preview).
|
446
|
+
* @param planId - ID of the plan of the previewed order. See [Plans for more information about plan IDs](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/plans).
|
447
|
+
* @public
|
448
|
+
* @documentationMaturity preview
|
449
|
+
* @requiredField options.memberId
|
450
|
+
* @requiredField planId
|
451
|
+
*/
|
452
|
+
function getOfflineOrderPreview(planId, options) {
|
453
|
+
var _a, _b, _c;
|
454
|
+
return __awaiter(this, arguments, void 0, function* () {
|
455
|
+
const requestTransformation = {
|
456
|
+
planId: '$[0]',
|
457
|
+
memberId: '$[1].memberId',
|
458
|
+
startDate: '$[1].startDate',
|
459
|
+
couponCode: '$[1].couponCode',
|
460
|
+
};
|
461
|
+
const responseTransformation = '$';
|
462
|
+
// @ts-ignore
|
463
|
+
const { httpClient, sideEffects } = arguments[2];
|
464
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
465
|
+
rootSchema: _getOfflineOrderPreviewRequest,
|
466
|
+
depSchemas: {},
|
467
|
+
fqdnTransformation: {
|
468
|
+
paths: [],
|
469
|
+
transformation: _fromVeloEntity,
|
470
|
+
},
|
471
|
+
customTransformation: requestTransformation,
|
472
|
+
});
|
473
|
+
const { fromJSON } = velo_1.serializer({
|
474
|
+
rootSchema: _getOfflineOrderPreviewResponse,
|
475
|
+
depSchemas: {},
|
476
|
+
fqdnTransformation: {
|
477
|
+
paths: [...['order']],
|
478
|
+
transformation: _toVeloEntity,
|
479
|
+
},
|
480
|
+
customTransformation: responseTransformation,
|
481
|
+
});
|
482
|
+
const payload = toAmbassadorRequest([planId, options]);
|
483
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
|
484
|
+
__log(`"GetOfflineOrderPreview" sending request with: ${__inspect(reqOpts)}`);
|
485
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
486
|
+
try {
|
487
|
+
const result = yield httpClient.request(reqOpts);
|
488
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
489
|
+
return fromJSON(result.data);
|
490
|
+
}
|
491
|
+
catch (err) {
|
492
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
493
|
+
'planId',
|
494
|
+
'options',
|
495
|
+
]);
|
496
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
497
|
+
throw transformedError;
|
498
|
+
}
|
499
|
+
});
|
500
|
+
}
|
501
|
+
exports.getOfflineOrderPreview = getOfflineOrderPreview;
|
502
|
+
/**
|
503
|
+
* Retrieves a plan's pricing.
|
504
|
+
*
|
505
|
+
* The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
|
506
|
+
* the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
|
507
|
+
* in the [pricing model](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models) format used for orders.
|
508
|
+
*
|
509
|
+
* Buyers do not have to be logged in to preview the price, as such, the details returned are not buyer-specific. To
|
510
|
+
* generate a preview of a purchase for a specific buyer, use [Get Offline Order Preview](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/get-offline-order-preview).
|
511
|
+
* @param planId - ID of plan to preview.
|
512
|
+
* @public
|
513
|
+
* @documentationMaturity preview
|
514
|
+
* @requiredField planId
|
515
|
+
*/
|
516
|
+
function getPricePreview(planId, options) {
|
517
|
+
var _a, _b, _c;
|
518
|
+
return __awaiter(this, arguments, void 0, function* () {
|
519
|
+
const requestTransformation = {
|
520
|
+
planId: '$[0]',
|
521
|
+
couponCode: '$[1].couponCode',
|
522
|
+
};
|
523
|
+
const responseTransformation = '$';
|
524
|
+
// @ts-ignore
|
525
|
+
const { httpClient, sideEffects } = arguments[2];
|
526
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
527
|
+
rootSchema: _getPricePreviewRequest,
|
528
|
+
depSchemas: {},
|
529
|
+
fqdnTransformation: {
|
530
|
+
paths: [],
|
531
|
+
transformation: _fromVeloEntity,
|
532
|
+
},
|
533
|
+
customTransformation: requestTransformation,
|
534
|
+
});
|
535
|
+
const { fromJSON } = velo_1.serializer({
|
536
|
+
rootSchema: _getPricePreviewResponse,
|
537
|
+
depSchemas: {},
|
538
|
+
fqdnTransformation: {
|
539
|
+
paths: [],
|
540
|
+
transformation: _toVeloEntity,
|
541
|
+
},
|
542
|
+
customTransformation: responseTransformation,
|
543
|
+
});
|
544
|
+
const payload = toAmbassadorRequest([planId, options]);
|
545
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
|
546
|
+
__log(`"GetPricePreview" sending request with: ${__inspect(reqOpts)}`);
|
547
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
548
|
+
try {
|
549
|
+
const result = yield httpClient.request(reqOpts);
|
550
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
551
|
+
return fromJSON(result.data);
|
552
|
+
}
|
553
|
+
catch (err) {
|
554
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
555
|
+
'planId',
|
556
|
+
'options',
|
557
|
+
]);
|
558
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
559
|
+
throw transformedError;
|
560
|
+
}
|
561
|
+
});
|
562
|
+
}
|
563
|
+
exports.getPricePreview = getPricePreview;
|
564
|
+
/**
|
565
|
+
* Retrieves an order by ID.
|
566
|
+
* @param _id - Order ID.
|
567
|
+
* @public
|
568
|
+
* @documentationMaturity preview
|
569
|
+
* @requiredField _id
|
570
|
+
*/
|
571
|
+
function managementGetOrder(_id, options) {
|
572
|
+
var _a, _b, _c;
|
573
|
+
return __awaiter(this, arguments, void 0, function* () {
|
574
|
+
const requestTransformation = { id: '$[0]', fieldSet: '$[1].fieldSet' };
|
575
|
+
const responseTransformation = '$';
|
576
|
+
// @ts-ignore
|
577
|
+
const { httpClient, sideEffects } = arguments[2];
|
578
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
579
|
+
rootSchema: _getOrderRequest,
|
580
|
+
depSchemas: {},
|
581
|
+
fqdnTransformation: {
|
582
|
+
paths: [],
|
583
|
+
transformation: _fromVeloEntity,
|
584
|
+
},
|
585
|
+
customTransformation: requestTransformation,
|
586
|
+
});
|
587
|
+
const { fromJSON } = velo_1.serializer({
|
588
|
+
rootSchema: _getOrderResponse,
|
589
|
+
depSchemas: {},
|
590
|
+
fqdnTransformation: {
|
591
|
+
paths: [...['order']],
|
592
|
+
transformation: _toVeloEntity,
|
593
|
+
},
|
594
|
+
customTransformation: responseTransformation,
|
595
|
+
});
|
596
|
+
const payload = toAmbassadorRequest([_id, options]);
|
597
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
|
598
|
+
__log(`"GetOrder" sending request with: ${__inspect(reqOpts)}`);
|
599
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
600
|
+
try {
|
601
|
+
const result = yield httpClient.request(reqOpts);
|
602
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
603
|
+
return fromJSON(result.data);
|
604
|
+
}
|
605
|
+
catch (err) {
|
606
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
607
|
+
'_id',
|
608
|
+
'options',
|
609
|
+
]);
|
610
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
611
|
+
throw transformedError;
|
612
|
+
}
|
613
|
+
});
|
614
|
+
}
|
615
|
+
exports.managementGetOrder = managementGetOrder;
|
616
|
+
/**
|
617
|
+
* Retrieves a list of orders and details, given the provided sorting and filtering.
|
618
|
+
*
|
619
|
+
* By default, this endpoint will retrieve all orders and return them sorted by `createdDate` in `DESC`, descending order.
|
620
|
+
* `sort.fieldName` supports `endDate` and `createdDate` fields and defaults to `ASC`, ascending order.
|
621
|
+
* @public
|
622
|
+
* @documentationMaturity preview
|
623
|
+
*/
|
624
|
+
function managementListOrders(options) {
|
625
|
+
var _a, _b, _c;
|
626
|
+
return __awaiter(this, arguments, void 0, function* () {
|
627
|
+
const requestTransformation = {
|
628
|
+
buyerIds: '$[0].buyerIds',
|
629
|
+
planIds: '$[0].planIds',
|
630
|
+
autoRenewCanceled: '$[0].autoRenewCanceled',
|
631
|
+
orderStatuses: '$[0].orderStatuses',
|
632
|
+
paymentStatuses: '$[0].paymentStatuses',
|
633
|
+
limit: '$[0].limit',
|
634
|
+
offset: '$[0].offset',
|
635
|
+
sorting: '$[0].sorting',
|
636
|
+
};
|
637
|
+
const responseTransformation = '$';
|
638
|
+
// @ts-ignore
|
639
|
+
const { httpClient, sideEffects } = arguments[1];
|
640
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
641
|
+
rootSchema: _listOrdersRequest,
|
642
|
+
depSchemas: {},
|
643
|
+
fqdnTransformation: {
|
644
|
+
paths: [],
|
645
|
+
transformation: _fromVeloEntity,
|
646
|
+
},
|
647
|
+
customTransformation: requestTransformation,
|
648
|
+
});
|
649
|
+
const { fromJSON } = velo_1.serializer({
|
650
|
+
rootSchema: _listOrdersResponse,
|
651
|
+
depSchemas: {},
|
652
|
+
fqdnTransformation: {
|
653
|
+
paths: [...['Array#orders']],
|
654
|
+
transformation: _toVeloEntity,
|
655
|
+
},
|
656
|
+
customTransformation: responseTransformation,
|
657
|
+
});
|
658
|
+
const payload = toAmbassadorRequest([options]);
|
659
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
|
660
|
+
__log(`"ListOrders" sending request with: ${__inspect(reqOpts)}`);
|
661
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
662
|
+
try {
|
663
|
+
const result = yield httpClient.request(reqOpts);
|
664
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
665
|
+
return fromJSON(result.data);
|
666
|
+
}
|
667
|
+
catch (err) {
|
668
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
669
|
+
'options',
|
670
|
+
]);
|
671
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
672
|
+
throw transformedError;
|
673
|
+
}
|
674
|
+
});
|
675
|
+
}
|
676
|
+
exports.managementListOrders = managementListOrders;
|
677
|
+
/**
|
678
|
+
* Extends the duration of a pricing plan order by postponing the order's `endDate`.
|
679
|
+
*
|
680
|
+
* New `endDate` must be later than the order's current `endDate`. Can't postpone orders that are unlimited.
|
681
|
+
* Can't postpone an order while it is [`PAUSED`](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/pause-order).
|
682
|
+
* @param _id - Order ID.
|
683
|
+
* @public
|
684
|
+
* @documentationMaturity preview
|
685
|
+
* @requiredField _id
|
686
|
+
*/
|
687
|
+
function postponeEndDate(_id, options) {
|
688
|
+
var _a, _b, _c;
|
689
|
+
return __awaiter(this, arguments, void 0, function* () {
|
690
|
+
const requestTransformation = { id: '$[0]', endDate: '$[1].endDate' };
|
691
|
+
const responseTransformation = '$';
|
692
|
+
// @ts-ignore
|
693
|
+
const { httpClient, sideEffects } = arguments[2];
|
694
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
695
|
+
rootSchema: _postponeEndDateRequest,
|
696
|
+
depSchemas: {},
|
697
|
+
fqdnTransformation: {
|
698
|
+
paths: [],
|
699
|
+
transformation: _fromVeloEntity,
|
700
|
+
},
|
701
|
+
customTransformation: requestTransformation,
|
702
|
+
});
|
703
|
+
const { fromJSON } = velo_1.serializer({
|
704
|
+
rootSchema: _postponeEndDateResponse,
|
705
|
+
depSchemas: {},
|
706
|
+
fqdnTransformation: {
|
707
|
+
paths: [],
|
708
|
+
transformation: _toVeloEntity,
|
709
|
+
},
|
710
|
+
customTransformation: responseTransformation,
|
711
|
+
});
|
712
|
+
const payload = toAmbassadorRequest([_id, options]);
|
713
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
|
714
|
+
__log(`"PostponeEndDate" sending request with: ${__inspect(reqOpts)}`);
|
715
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
716
|
+
try {
|
717
|
+
const result = yield httpClient.request(reqOpts);
|
718
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
719
|
+
return fromJSON(result.data);
|
720
|
+
}
|
721
|
+
catch (err) {
|
722
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
723
|
+
'_id',
|
724
|
+
'options',
|
725
|
+
]);
|
726
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
727
|
+
throw transformedError;
|
728
|
+
}
|
729
|
+
});
|
730
|
+
}
|
731
|
+
exports.postponeEndDate = postponeEndDate;
|
732
|
+
/**
|
733
|
+
* Cancels an existing order.
|
734
|
+
*
|
735
|
+
* For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
|
736
|
+
* For orders with one-time payments, a cancellation can only be set for `IMMEDIATELY`.
|
737
|
+
*
|
738
|
+
* #### Canceling during the free trial period.
|
739
|
+
*
|
740
|
+
* When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end
|
741
|
+
* of the free trial period and they will not be billed. The buyer may continue using the benefits until the end
|
742
|
+
* of the free trial period.
|
743
|
+
*
|
744
|
+
* When a site owner cancels an ordered plan during the free trial period, they choose to apply the cancellation
|
745
|
+
* `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. Canceling `IMMEDIATELY` will end the subscription for the buyer
|
746
|
+
* immediately, even during the free trial period and the buyer won't be billed. Canceling at the
|
747
|
+
* `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period.
|
748
|
+
* Then, the subscription ends and the buyer is not billed.
|
749
|
+
* @param _id - Order ID.
|
750
|
+
* @public
|
751
|
+
* @documentationMaturity preview
|
752
|
+
* @requiredField _id
|
753
|
+
*/
|
754
|
+
function cancelOrder(_id, options) {
|
755
|
+
var _a, _b, _c;
|
756
|
+
return __awaiter(this, arguments, void 0, function* () {
|
757
|
+
const requestTransformation = { id: '$[0]', effectiveAt: '$[1].effectiveAt' };
|
758
|
+
const responseTransformation = '$';
|
759
|
+
// @ts-ignore
|
760
|
+
const { httpClient, sideEffects } = arguments[2];
|
761
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
762
|
+
rootSchema: _cancelOrderRequest,
|
763
|
+
depSchemas: {},
|
764
|
+
fqdnTransformation: {
|
765
|
+
paths: [],
|
766
|
+
transformation: _fromVeloEntity,
|
767
|
+
},
|
768
|
+
customTransformation: requestTransformation,
|
769
|
+
});
|
770
|
+
const { fromJSON } = velo_1.serializer({
|
771
|
+
rootSchema: _cancelOrderResponse,
|
772
|
+
depSchemas: {},
|
773
|
+
fqdnTransformation: {
|
774
|
+
paths: [],
|
775
|
+
transformation: _toVeloEntity,
|
776
|
+
},
|
777
|
+
customTransformation: responseTransformation,
|
778
|
+
});
|
779
|
+
const payload = toAmbassadorRequest([_id, options]);
|
780
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
|
781
|
+
__log(`"CancelOrder" sending request with: ${__inspect(reqOpts)}`);
|
782
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
783
|
+
try {
|
784
|
+
const result = yield httpClient.request(reqOpts);
|
785
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
786
|
+
return fromJSON(result.data);
|
787
|
+
}
|
788
|
+
catch (err) {
|
789
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
790
|
+
'_id',
|
791
|
+
'options',
|
792
|
+
]);
|
793
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
794
|
+
throw transformedError;
|
795
|
+
}
|
796
|
+
});
|
797
|
+
}
|
798
|
+
exports.cancelOrder = cancelOrder;
|
799
|
+
/**
|
800
|
+
* Marks an offline order as paid.
|
801
|
+
* > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid.
|
802
|
+
* @param _id - Order ID.
|
803
|
+
* @public
|
804
|
+
* @documentationMaturity preview
|
805
|
+
* @requiredField _id
|
806
|
+
*/
|
807
|
+
function markAsPaid(_id) {
|
808
|
+
var _a, _b, _c;
|
809
|
+
return __awaiter(this, arguments, void 0, function* () {
|
810
|
+
const requestTransformation = { id: '$[0]' };
|
811
|
+
const responseTransformation = '$';
|
812
|
+
// @ts-ignore
|
813
|
+
const { httpClient, sideEffects } = arguments[1];
|
814
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
815
|
+
rootSchema: _markAsPaidRequest,
|
816
|
+
depSchemas: {},
|
817
|
+
fqdnTransformation: {
|
818
|
+
paths: [],
|
819
|
+
transformation: _fromVeloEntity,
|
820
|
+
},
|
821
|
+
customTransformation: requestTransformation,
|
822
|
+
});
|
823
|
+
const { fromJSON } = velo_1.serializer({
|
824
|
+
rootSchema: _markAsPaidResponse,
|
825
|
+
depSchemas: {},
|
826
|
+
fqdnTransformation: {
|
827
|
+
paths: [],
|
828
|
+
transformation: _toVeloEntity,
|
829
|
+
},
|
830
|
+
customTransformation: responseTransformation,
|
831
|
+
});
|
832
|
+
const payload = toAmbassadorRequest([_id]);
|
833
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
|
834
|
+
__log(`"MarkAsPaid" sending request with: ${__inspect(reqOpts)}`);
|
835
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
836
|
+
try {
|
837
|
+
const result = yield httpClient.request(reqOpts);
|
838
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
839
|
+
return fromJSON(result.data);
|
840
|
+
}
|
841
|
+
catch (err) {
|
842
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
843
|
+
'_id',
|
844
|
+
]);
|
845
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
846
|
+
throw transformedError;
|
847
|
+
}
|
848
|
+
});
|
849
|
+
}
|
850
|
+
exports.markAsPaid = markAsPaid;
|
851
|
+
/**
|
852
|
+
* Pauses an order.
|
853
|
+
*
|
854
|
+
* For orders with recurring payments, it also pauses the payment schedule. Buyers are not charged when an order is paused.
|
855
|
+
* Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`. Can only pause orders with an `ACTIVE` status.
|
856
|
+
*
|
857
|
+
* Use [Resume Order to resume a paused order](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/resume-order/).
|
858
|
+
* @param _id - Order ID.
|
859
|
+
* @public
|
860
|
+
* @documentationMaturity preview
|
861
|
+
* @requiredField _id
|
862
|
+
*/
|
863
|
+
function pauseOrder(_id) {
|
864
|
+
var _a, _b, _c;
|
865
|
+
return __awaiter(this, arguments, void 0, function* () {
|
866
|
+
const requestTransformation = { id: '$[0]' };
|
867
|
+
const responseTransformation = '$';
|
868
|
+
// @ts-ignore
|
869
|
+
const { httpClient, sideEffects } = arguments[1];
|
870
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
871
|
+
rootSchema: _pauseOrderRequest,
|
872
|
+
depSchemas: {},
|
873
|
+
fqdnTransformation: {
|
874
|
+
paths: [],
|
875
|
+
transformation: _fromVeloEntity,
|
876
|
+
},
|
877
|
+
customTransformation: requestTransformation,
|
878
|
+
});
|
879
|
+
const { fromJSON } = velo_1.serializer({
|
880
|
+
rootSchema: _pauseOrderResponse,
|
881
|
+
depSchemas: {},
|
882
|
+
fqdnTransformation: {
|
883
|
+
paths: [],
|
884
|
+
transformation: _toVeloEntity,
|
885
|
+
},
|
886
|
+
customTransformation: responseTransformation,
|
887
|
+
});
|
888
|
+
const payload = toAmbassadorRequest([_id]);
|
889
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
|
890
|
+
__log(`"PauseOrder" sending request with: ${__inspect(reqOpts)}`);
|
891
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
892
|
+
try {
|
893
|
+
const result = yield httpClient.request(reqOpts);
|
894
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
895
|
+
return fromJSON(result.data);
|
896
|
+
}
|
897
|
+
catch (err) {
|
898
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
899
|
+
'_id',
|
900
|
+
]);
|
901
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
902
|
+
throw transformedError;
|
903
|
+
}
|
904
|
+
});
|
905
|
+
}
|
906
|
+
exports.pauseOrder = pauseOrder;
|
907
|
+
/**
|
908
|
+
* Resumes a paused order.
|
909
|
+
*
|
910
|
+
* Updates `endDate` by adding the time the plan was paused.
|
911
|
+
* For orders with recurring payments, it also restarts the payment schedule.
|
912
|
+
* Use [Pause Order to pause an order](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/pause-order/).
|
913
|
+
* @param _id - Order ID.
|
914
|
+
* @public
|
915
|
+
* @documentationMaturity preview
|
916
|
+
* @requiredField _id
|
917
|
+
*/
|
918
|
+
function resumeOrder(_id) {
|
919
|
+
var _a, _b, _c;
|
920
|
+
return __awaiter(this, arguments, void 0, function* () {
|
921
|
+
const requestTransformation = { id: '$[0]' };
|
922
|
+
const responseTransformation = '$';
|
923
|
+
// @ts-ignore
|
924
|
+
const { httpClient, sideEffects } = arguments[1];
|
925
|
+
const { toAmbassadorRequest } = velo_1.serializer({
|
926
|
+
rootSchema: _resumeOrderRequest,
|
927
|
+
depSchemas: {},
|
928
|
+
fqdnTransformation: {
|
929
|
+
paths: [],
|
930
|
+
transformation: _fromVeloEntity,
|
931
|
+
},
|
932
|
+
customTransformation: requestTransformation,
|
933
|
+
});
|
934
|
+
const { fromJSON } = velo_1.serializer({
|
935
|
+
rootSchema: _resumeOrderResponse,
|
936
|
+
depSchemas: {},
|
937
|
+
fqdnTransformation: {
|
938
|
+
paths: [],
|
939
|
+
transformation: _toVeloEntity,
|
940
|
+
},
|
941
|
+
customTransformation: responseTransformation,
|
942
|
+
});
|
943
|
+
const payload = toAmbassadorRequest([_id]);
|
944
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
|
945
|
+
__log(`"ResumeOrder" sending request with: ${__inspect(reqOpts)}`);
|
946
|
+
(_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
|
947
|
+
try {
|
948
|
+
const result = yield httpClient.request(reqOpts);
|
949
|
+
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
950
|
+
return fromJSON(result.data);
|
951
|
+
}
|
952
|
+
catch (err) {
|
953
|
+
const transformedError = velo_1.transformError(err, requestTransformation, [
|
954
|
+
'_id',
|
955
|
+
]);
|
956
|
+
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
957
|
+
throw transformedError;
|
958
|
+
}
|
959
|
+
});
|
960
|
+
}
|
961
|
+
exports.resumeOrder = resumeOrder;
|
962
|
+
//# sourceMappingURL=pricing-plans-v2-order.universal.js.map
|