@wix/auto_sdk_pricing-plans_orders 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 +1 -0
- package/build/cjs/index.js +18 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/index.typings.d.ts +1 -0
- package/build/cjs/index.typings.js +18 -0
- package/build/cjs/index.typings.js.map +1 -0
- package/build/cjs/meta.d.ts +1 -0
- package/build/cjs/meta.js +18 -0
- package/build/cjs/meta.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.context.js +126 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.http.js +877 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.meta.js +313 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.public.js +373 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.types.d.ts +1331 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.types.js +145 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +2015 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.universal.js +889 -0
- package/build/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +2 -0
- package/build/es/index.js.map +1 -0
- package/build/es/index.typings.d.ts +1 -0
- package/build/es/index.typings.js +2 -0
- package/build/es/index.typings.js.map +1 -0
- package/build/es/meta.d.ts +1 -0
- package/build/es/meta.js +2 -0
- package/build/es/meta.js.map +1 -0
- package/build/es/package.json +3 -0
- package/build/es/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
- package/build/es/src/pricing-plans-v2-order-orders.context.js +111 -0
- package/build/es/src/pricing-plans-v2-order-orders.context.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
- package/build/es/src/pricing-plans-v2-order-orders.http.js +859 -0
- package/build/es/src/pricing-plans-v2-order-orders.http.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
- package/build/es/src/pricing-plans-v2-order-orders.meta.js +272 -0
- package/build/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
- package/build/es/src/pricing-plans-v2-order-orders.public.js +343 -0
- package/build/es/src/pricing-plans-v2-order-orders.public.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order-orders.types.d.ts +1331 -0
- package/build/es/src/pricing-plans-v2-order-orders.types.js +142 -0
- package/build/es/src/pricing-plans-v2-order-orders.types.js.map +1 -0
- package/build/es/src/pricing-plans-v2-order-orders.universal.d.ts +2015 -0
- package/build/es/src/pricing-plans-v2-order-orders.universal.js +848 -0
- package/build/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
- package/build/internal/cjs/index.d.ts +1 -0
- package/build/internal/cjs/index.js +18 -0
- package/build/internal/cjs/index.js.map +1 -0
- package/build/internal/cjs/index.typings.d.ts +1 -0
- package/build/internal/cjs/index.typings.js +18 -0
- package/build/internal/cjs/index.typings.js.map +1 -0
- package/build/internal/cjs/meta.d.ts +1 -0
- package/build/internal/cjs/meta.js +18 -0
- package/build/internal/cjs/meta.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js +126 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.context.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js +877 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.http.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js +313 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js +373 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.public.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.d.ts +1333 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js +145 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.types.js.map +1 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.d.ts +2034 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js +889 -0
- package/build/internal/cjs/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
- package/build/internal/es/index.d.ts +1 -0
- package/build/internal/es/index.js +2 -0
- package/build/internal/es/index.js.map +1 -0
- package/build/internal/es/index.typings.d.ts +1 -0
- package/build/internal/es/index.typings.js +2 -0
- package/build/internal/es/index.typings.js.map +1 -0
- package/build/internal/es/meta.d.ts +1 -0
- package/build/internal/es/meta.js +2 -0
- package/build/internal/es/meta.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.context.d.ts +111 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.context.js +111 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.context.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.http.d.ts +149 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.http.js +859 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.http.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.meta.d.ts +43 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js +272 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.meta.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.public.d.ts +249 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.public.js +343 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.public.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.types.d.ts +1333 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.types.js +142 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.types.js.map +1 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.universal.d.ts +2034 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js +848 -0
- package/build/internal/es/src/pricing-plans-v2-order-orders.universal.js.map +1 -0
- package/meta/package.json +3 -0
- package/package.json +52 -0
|
@@ -0,0 +1,848 @@
|
|
|
1
|
+
import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
|
|
2
|
+
import { renameKeysFromSDKRequestToRESTRequest, renameKeysFromRESTResponseToSDKResponse, } from '@wix/sdk-runtime/rename-all-nested-keys';
|
|
3
|
+
import * as ambassadorWixPricingPlansV2Order from './pricing-plans-v2-order-orders.http.js';
|
|
4
|
+
export var PeriodUnit;
|
|
5
|
+
(function (PeriodUnit) {
|
|
6
|
+
/** Not defined. */
|
|
7
|
+
PeriodUnit["UNDEFINED"] = "UNDEFINED";
|
|
8
|
+
/** Time unit is a day. */
|
|
9
|
+
PeriodUnit["DAY"] = "DAY";
|
|
10
|
+
/** Time unit is a week. */
|
|
11
|
+
PeriodUnit["WEEK"] = "WEEK";
|
|
12
|
+
/** Time unit is a month. */
|
|
13
|
+
PeriodUnit["MONTH"] = "MONTH";
|
|
14
|
+
/** Time unit is a year. */
|
|
15
|
+
PeriodUnit["YEAR"] = "YEAR";
|
|
16
|
+
})(PeriodUnit || (PeriodUnit = {}));
|
|
17
|
+
export var OrderType;
|
|
18
|
+
(function (OrderType) {
|
|
19
|
+
/** Undefined order type. */
|
|
20
|
+
OrderType["UNDEFINED"] = "UNDEFINED";
|
|
21
|
+
/** The buyer purchased the plan using the site. */
|
|
22
|
+
OrderType["ONLINE"] = "ONLINE";
|
|
23
|
+
/** The buyer made a manual, offline purchase without using the site. */
|
|
24
|
+
OrderType["OFFLINE"] = "OFFLINE";
|
|
25
|
+
/** The buyer made a purchase through an external payment provider. */
|
|
26
|
+
OrderType["EXTERNAL"] = "EXTERNAL";
|
|
27
|
+
})(OrderType || (OrderType = {}));
|
|
28
|
+
export var OrderMethod;
|
|
29
|
+
(function (OrderMethod) {
|
|
30
|
+
/** Unknown order method. */
|
|
31
|
+
OrderMethod["UNKNOWN"] = "UNKNOWN";
|
|
32
|
+
/** Mail Order / Telephone Order transaction. */
|
|
33
|
+
OrderMethod["MOTO"] = "MOTO";
|
|
34
|
+
/** Point of Sale transaction. */
|
|
35
|
+
OrderMethod["POS"] = "POS";
|
|
36
|
+
})(OrderMethod || (OrderMethod = {}));
|
|
37
|
+
export var OrderStatus;
|
|
38
|
+
(function (OrderStatus) {
|
|
39
|
+
/** Undefined order status. */
|
|
40
|
+
OrderStatus["UNDEFINED"] = "UNDEFINED";
|
|
41
|
+
/** Order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use to the buyer. */
|
|
42
|
+
OrderStatus["DRAFT"] = "DRAFT";
|
|
43
|
+
/** Order has been purchased and its start date is set in the future. */
|
|
44
|
+
OrderStatus["PENDING"] = "PENDING";
|
|
45
|
+
/** Order has been processed. The plan is available for use. */
|
|
46
|
+
OrderStatus["ACTIVE"] = "ACTIVE";
|
|
47
|
+
/** Order, and use of the plan, is paused. The order, and use of the plan, can be resumed. */
|
|
48
|
+
OrderStatus["PAUSED"] = "PAUSED";
|
|
49
|
+
/** Order has completed its duration and is no longer available for use. */
|
|
50
|
+
OrderStatus["ENDED"] = "ENDED";
|
|
51
|
+
/** Order has been canceled. */
|
|
52
|
+
OrderStatus["CANCELED"] = "CANCELED";
|
|
53
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
54
|
+
export var CancellationCause;
|
|
55
|
+
(function (CancellationCause) {
|
|
56
|
+
/** Undefined cancellation cause. */
|
|
57
|
+
CancellationCause["UNDEFINED"] = "UNDEFINED";
|
|
58
|
+
/** Wix user canceled the order. */
|
|
59
|
+
CancellationCause["OWNER_ACTION"] = "OWNER_ACTION";
|
|
60
|
+
/** Buyer initiated the cancellation. */
|
|
61
|
+
CancellationCause["MEMBER_ACTION"] = "MEMBER_ACTION";
|
|
62
|
+
/** Payment transaction failed. */
|
|
63
|
+
CancellationCause["PAYMENT_FAILURE"] = "PAYMENT_FAILURE";
|
|
64
|
+
/** Buyer's payment details weren't set up correctly. */
|
|
65
|
+
CancellationCause["PAYMENT_SETUP_FAILURE"] = "PAYMENT_SETUP_FAILURE";
|
|
66
|
+
/** Reason for the cancellation is unknown. */
|
|
67
|
+
CancellationCause["UNKNOWN"] = "UNKNOWN";
|
|
68
|
+
})(CancellationCause || (CancellationCause = {}));
|
|
69
|
+
export var CancellationEffectiveAt;
|
|
70
|
+
(function (CancellationEffectiveAt) {
|
|
71
|
+
/** Undefined cancellation time. */
|
|
72
|
+
CancellationEffectiveAt["UNDEFINED"] = "UNDEFINED";
|
|
73
|
+
/** Cancellation occurs immediately and the buyer can no longer use the plan. */
|
|
74
|
+
CancellationEffectiveAt["IMMEDIATELY"] = "IMMEDIATELY";
|
|
75
|
+
/** Cancellation occurs at the next payment date and time. Buyer can continue to use the plan until that date and time. */
|
|
76
|
+
CancellationEffectiveAt["NEXT_PAYMENT_DATE"] = "NEXT_PAYMENT_DATE";
|
|
77
|
+
})(CancellationEffectiveAt || (CancellationEffectiveAt = {}));
|
|
78
|
+
export var PaymentStatus;
|
|
79
|
+
(function (PaymentStatus) {
|
|
80
|
+
/** Undefined payment status. */
|
|
81
|
+
PaymentStatus["UNDEFINED"] = "UNDEFINED";
|
|
82
|
+
/** Payment has been paid. */
|
|
83
|
+
PaymentStatus["PAID"] = "PAID";
|
|
84
|
+
/** Payment has been refunded. */
|
|
85
|
+
PaymentStatus["REFUNDED"] = "REFUNDED";
|
|
86
|
+
/** Payment transaction didn't complete. */
|
|
87
|
+
PaymentStatus["FAILED"] = "FAILED";
|
|
88
|
+
/** Payment has not been paid. */
|
|
89
|
+
PaymentStatus["UNPAID"] = "UNPAID";
|
|
90
|
+
/** Billing has been initialized, but actual charge is yet to be made. This can happen for free trials and payments made with PayPal. */
|
|
91
|
+
PaymentStatus["PENDING"] = "PENDING";
|
|
92
|
+
/** No payment was necessary. For example, for free plans or free trials. */
|
|
93
|
+
PaymentStatus["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
94
|
+
})(PaymentStatus || (PaymentStatus = {}));
|
|
95
|
+
export var Status;
|
|
96
|
+
(function (Status) {
|
|
97
|
+
/** Undefined status. */
|
|
98
|
+
Status["UNDEFINED"] = "UNDEFINED";
|
|
99
|
+
/** Status while the order is paused. */
|
|
100
|
+
Status["ACTIVE"] = "ACTIVE";
|
|
101
|
+
/** Status when the order is resumed. */
|
|
102
|
+
Status["ENDED"] = "ENDED";
|
|
103
|
+
})(Status || (Status = {}));
|
|
104
|
+
export var Set;
|
|
105
|
+
(function (Set) {
|
|
106
|
+
/** Same behavior as `BASIC`.` */
|
|
107
|
+
Set["UNKNOWN_SET"] = "UNKNOWN_SET";
|
|
108
|
+
/** Doesn't return any order form submission data. */
|
|
109
|
+
Set["BASIC"] = "BASIC";
|
|
110
|
+
/** Returns all order form submission data. */
|
|
111
|
+
Set["FULL"] = "FULL";
|
|
112
|
+
})(Set || (Set = {}));
|
|
113
|
+
export var SortOrder;
|
|
114
|
+
(function (SortOrder) {
|
|
115
|
+
SortOrder["ASC"] = "ASC";
|
|
116
|
+
SortOrder["DESC"] = "DESC";
|
|
117
|
+
})(SortOrder || (SortOrder = {}));
|
|
118
|
+
export var WebhookIdentityType;
|
|
119
|
+
(function (WebhookIdentityType) {
|
|
120
|
+
WebhookIdentityType["UNKNOWN"] = "UNKNOWN";
|
|
121
|
+
WebhookIdentityType["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
|
|
122
|
+
WebhookIdentityType["MEMBER"] = "MEMBER";
|
|
123
|
+
WebhookIdentityType["WIX_USER"] = "WIX_USER";
|
|
124
|
+
WebhookIdentityType["APP"] = "APP";
|
|
125
|
+
})(WebhookIdentityType || (WebhookIdentityType = {}));
|
|
126
|
+
export var ReasonNotSuspendable;
|
|
127
|
+
(function (ReasonNotSuspendable) {
|
|
128
|
+
/** Undefined reason. */
|
|
129
|
+
ReasonNotSuspendable["UNDEFINED"] = "UNDEFINED";
|
|
130
|
+
/** Saved in the database but is awaiting payment. Non-active orders can't be suspended. */
|
|
131
|
+
ReasonNotSuspendable["PENDING"] = "PENDING";
|
|
132
|
+
/** Trial orders can't be suspended. */
|
|
133
|
+
ReasonNotSuspendable["TRIAL"] = "TRIAL";
|
|
134
|
+
/** Canceled orders can't be suspended. */
|
|
135
|
+
ReasonNotSuspendable["CANCELED"] = "CANCELED";
|
|
136
|
+
/** Ended orders can't be suspended. */
|
|
137
|
+
ReasonNotSuspendable["ENDED"] = "ENDED";
|
|
138
|
+
/** Paid for orders with future start dates can't be suspended. */
|
|
139
|
+
ReasonNotSuspendable["NOT_STARTED"] = "NOT_STARTED";
|
|
140
|
+
/** Order is already suspended. */
|
|
141
|
+
ReasonNotSuspendable["ALREADY_SUSPENDED"] = "ALREADY_SUSPENDED";
|
|
142
|
+
/** Orders based on recurring payments using older stripe versions can't be suspended. */
|
|
143
|
+
ReasonNotSuspendable["OLD_STRIPE"] = "OLD_STRIPE";
|
|
144
|
+
})(ReasonNotSuspendable || (ReasonNotSuspendable = {}));
|
|
145
|
+
/**
|
|
146
|
+
* Retrieves an order for the currently logged-in member by ID.
|
|
147
|
+
* @param _id - Order ID.
|
|
148
|
+
* @public
|
|
149
|
+
* @requiredField _id
|
|
150
|
+
* @param options - Options for getting a logged-in member's order.
|
|
151
|
+
* @permissionId PRICING_PLANS.READ_OWN_ORDERS
|
|
152
|
+
* @applicableIdentity MEMBER
|
|
153
|
+
* @returns Requested order.
|
|
154
|
+
* @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.GetOrder
|
|
155
|
+
*/
|
|
156
|
+
export async function memberGetOrder(_id, options) {
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
159
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
160
|
+
id: _id,
|
|
161
|
+
fieldSet: options?.fieldSet,
|
|
162
|
+
});
|
|
163
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.memberGetOrder(payload);
|
|
164
|
+
sideEffects?.onSiteCall?.();
|
|
165
|
+
try {
|
|
166
|
+
const result = await httpClient.request(reqOpts);
|
|
167
|
+
sideEffects?.onSuccess?.(result);
|
|
168
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data)?.order;
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
const transformedError = sdkTransformError(err, {
|
|
172
|
+
spreadPathsToArguments: {},
|
|
173
|
+
explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
|
|
174
|
+
singleArgumentUnchanged: false,
|
|
175
|
+
}, ['_id', 'options']);
|
|
176
|
+
sideEffects?.onError?.(err);
|
|
177
|
+
throw transformedError;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves a list of up to 100 pricing plan orders for currently logged-in member.
|
|
182
|
+
* @public
|
|
183
|
+
* @param options - Filtering, sorting, and pagination options.
|
|
184
|
+
* @permissionId PRICING_PLANS.READ_OWN_ORDERS
|
|
185
|
+
* @applicableIdentity MEMBER
|
|
186
|
+
* @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.ListOrders
|
|
187
|
+
*/
|
|
188
|
+
export async function memberListOrders(options) {
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
191
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
192
|
+
planIds: options?.planIds,
|
|
193
|
+
autoRenewCanceled: options?.autoRenewCanceled,
|
|
194
|
+
orderStatuses: options?.orderStatuses,
|
|
195
|
+
paymentStatuses: options?.paymentStatuses,
|
|
196
|
+
limit: options?.limit,
|
|
197
|
+
offset: options?.offset,
|
|
198
|
+
sorting: options?.sorting,
|
|
199
|
+
fieldSet: options?.fieldSet,
|
|
200
|
+
});
|
|
201
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.memberListOrders(payload);
|
|
202
|
+
sideEffects?.onSiteCall?.();
|
|
203
|
+
try {
|
|
204
|
+
const result = await httpClient.request(reqOpts);
|
|
205
|
+
sideEffects?.onSuccess?.(result);
|
|
206
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
const transformedError = sdkTransformError(err, {
|
|
210
|
+
spreadPathsToArguments: {},
|
|
211
|
+
explicitPathsToArguments: {
|
|
212
|
+
planIds: '$[0].planIds',
|
|
213
|
+
autoRenewCanceled: '$[0].autoRenewCanceled',
|
|
214
|
+
orderStatuses: '$[0].orderStatuses',
|
|
215
|
+
paymentStatuses: '$[0].paymentStatuses',
|
|
216
|
+
limit: '$[0].limit',
|
|
217
|
+
offset: '$[0].offset',
|
|
218
|
+
sorting: '$[0].sorting',
|
|
219
|
+
fieldSet: '$[0].fieldSet',
|
|
220
|
+
},
|
|
221
|
+
singleArgumentUnchanged: false,
|
|
222
|
+
}, ['options']);
|
|
223
|
+
sideEffects?.onError?.(err);
|
|
224
|
+
throw transformedError;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Cancels an order. Recurring orders can be canceled either immediately or at the next payment date. One time orders can only be canceled immediately.
|
|
229
|
+
*
|
|
230
|
+
* 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.
|
|
231
|
+
*
|
|
232
|
+
* Canceling during the free trial period: 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.
|
|
233
|
+
*
|
|
234
|
+
* >**Note:**
|
|
235
|
+
* >This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions).
|
|
236
|
+
* @param _id - Order ID.
|
|
237
|
+
* @param effectiveAt - Required. Whether to cancel the order effective immediately or at the next payment date. One-time orders can only be canceled immediately.
|
|
238
|
+
* @public
|
|
239
|
+
* @requiredField _id
|
|
240
|
+
* @requiredField effectiveAt
|
|
241
|
+
* @param options - Options for requesting a cancellation.
|
|
242
|
+
* @permissionId PRICING_PLANS.MANAGE_OWN_ORDERS
|
|
243
|
+
* @applicableIdentity MEMBER
|
|
244
|
+
* @fqn com.wixpress.membership.v2.orders.member.MemberOrdersService.RequestCancellation
|
|
245
|
+
*/
|
|
246
|
+
export async function requestCancellation(_id, effectiveAt) {
|
|
247
|
+
// @ts-ignore
|
|
248
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
249
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
250
|
+
id: _id,
|
|
251
|
+
effectiveAt: effectiveAt,
|
|
252
|
+
});
|
|
253
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.requestCancellation(payload);
|
|
254
|
+
sideEffects?.onSiteCall?.();
|
|
255
|
+
try {
|
|
256
|
+
const result = await httpClient.request(reqOpts);
|
|
257
|
+
sideEffects?.onSuccess?.(result);
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
const transformedError = sdkTransformError(err, {
|
|
261
|
+
spreadPathsToArguments: {},
|
|
262
|
+
explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
|
|
263
|
+
singleArgumentUnchanged: false,
|
|
264
|
+
}, ['_id', 'effectiveAt']);
|
|
265
|
+
sideEffects?.onError?.(err);
|
|
266
|
+
throw transformedError;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates an online order for a site member.
|
|
271
|
+
*
|
|
272
|
+
* If this method is called by a site member ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)), the plan is automatically ordered on behalf of that site member. Otherwise, you must specify `onBehalf.memberId` in your call.
|
|
273
|
+
*
|
|
274
|
+
* When an online order is created, but payment hasn't been processed, its status is set to `DRAFT`. After the payment has been processed, if the start date is in the future the order's status is set to `PENDING`. Otherwise, it's set to `ACTIVE`.
|
|
275
|
+
* @param planId - Plan ID.
|
|
276
|
+
* @public
|
|
277
|
+
* @requiredField options.onBehalf.memberId
|
|
278
|
+
* @requiredField planId
|
|
279
|
+
* @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOnlineOrder
|
|
280
|
+
*/
|
|
281
|
+
export async function createOnlineOrder(planId, options) {
|
|
282
|
+
// @ts-ignore
|
|
283
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
284
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
285
|
+
planId: planId,
|
|
286
|
+
startDate: options?.startDate,
|
|
287
|
+
couponCode: options?.couponCode,
|
|
288
|
+
onBehalf: options?.onBehalf,
|
|
289
|
+
submissionId: options?.submissionId,
|
|
290
|
+
});
|
|
291
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.createOnlineOrder(payload);
|
|
292
|
+
sideEffects?.onSiteCall?.();
|
|
293
|
+
try {
|
|
294
|
+
const result = await httpClient.request(reqOpts);
|
|
295
|
+
sideEffects?.onSuccess?.(result);
|
|
296
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
297
|
+
}
|
|
298
|
+
catch (err) {
|
|
299
|
+
const transformedError = sdkTransformError(err, {
|
|
300
|
+
spreadPathsToArguments: {},
|
|
301
|
+
explicitPathsToArguments: {
|
|
302
|
+
planId: '$[0]',
|
|
303
|
+
startDate: '$[1].startDate',
|
|
304
|
+
couponCode: '$[1].couponCode',
|
|
305
|
+
onBehalf: '$[1].onBehalf',
|
|
306
|
+
submissionId: '$[1].submissionId',
|
|
307
|
+
},
|
|
308
|
+
singleArgumentUnchanged: false,
|
|
309
|
+
}, ['planId', 'options']);
|
|
310
|
+
sideEffects?.onError?.(err);
|
|
311
|
+
throw transformedError;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Creates an order for a buyer who purchased the plan with an offline transaction.
|
|
316
|
+
*
|
|
317
|
+
* An offline order is handled off of the Wix site and is marked as `type`: `offline`. If a pricing plan
|
|
318
|
+
* has a limit on the amount of purchases per buyer, that limit is ignored for offline orders.
|
|
319
|
+
* Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
|
|
320
|
+
*
|
|
321
|
+
* When creating a free offline order:
|
|
322
|
+
* The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
|
|
323
|
+
* The order's last payment status is set to `"NOT_APPLICABLE"`. "
|
|
324
|
+
*
|
|
325
|
+
* When creating a non-free offline order:
|
|
326
|
+
* The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
|
|
327
|
+
* The order's last payment status is set to `"UNPAID"` or `"PAID"` based on the data passed in the `paid` boolean in the request.
|
|
328
|
+
*
|
|
329
|
+
* Payment for an offline order can be set in 1 of 2 ways:
|
|
330
|
+
* + During order creation, set `paid`: `true`.
|
|
331
|
+
* + After creation, call Mark As Paid.
|
|
332
|
+
* @param planId - ID of the plan being ordered, from the Plans API.
|
|
333
|
+
* @param memberId - ID of the member ordering the plan, from the Members API.
|
|
334
|
+
* @public
|
|
335
|
+
* @requiredField memberId
|
|
336
|
+
* @requiredField planId
|
|
337
|
+
* @param options - Options for creating an offline order.
|
|
338
|
+
* @permissionId PRICING_PLANS.REGISTER_OFFLINE_ORDERS
|
|
339
|
+
* @permissionScope Manage Orders
|
|
340
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
341
|
+
* @applicableIdentity APP
|
|
342
|
+
* @fqn com.wixpress.membership.v2.orders.CheckoutService.CreateOfflineOrder
|
|
343
|
+
*/
|
|
344
|
+
export async function createOfflineOrder(planId, memberId, options) {
|
|
345
|
+
// @ts-ignore
|
|
346
|
+
const { httpClient, sideEffects } = arguments[3];
|
|
347
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
348
|
+
planId: planId,
|
|
349
|
+
memberId: memberId,
|
|
350
|
+
startDate: options?.startDate,
|
|
351
|
+
paid: options?.paid,
|
|
352
|
+
couponCode: options?.couponCode,
|
|
353
|
+
submissionId: options?.submissionId,
|
|
354
|
+
});
|
|
355
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.createOfflineOrder(payload);
|
|
356
|
+
sideEffects?.onSiteCall?.();
|
|
357
|
+
try {
|
|
358
|
+
const result = await httpClient.request(reqOpts);
|
|
359
|
+
sideEffects?.onSuccess?.(result);
|
|
360
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
const transformedError = sdkTransformError(err, {
|
|
364
|
+
spreadPathsToArguments: {},
|
|
365
|
+
explicitPathsToArguments: {
|
|
366
|
+
planId: '$[0]',
|
|
367
|
+
memberId: '$[1]',
|
|
368
|
+
startDate: '$[2].startDate',
|
|
369
|
+
paid: '$[2].paid',
|
|
370
|
+
couponCode: '$[2].couponCode',
|
|
371
|
+
submissionId: '$[2].submissionId',
|
|
372
|
+
},
|
|
373
|
+
singleArgumentUnchanged: false,
|
|
374
|
+
}, ['planId', 'memberId', 'options']);
|
|
375
|
+
sideEffects?.onError?.(err);
|
|
376
|
+
throw transformedError;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Returns an `order` object that represents a potential online order for a site member.
|
|
381
|
+
*
|
|
382
|
+
* You can use this method to show a site member a preview of an online order before [creating](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/orders/create-online-order) it.
|
|
383
|
+
*
|
|
384
|
+
* This method must be called using the site member identity ([SDK](https://dev.wix.com/docs/sdk/articles/get-started/about-identities#site-member) | [REST](https://dev.wix.com/docs/rest/articles/getting-started/about-identities#site-member)). Therefore, [Wix apps](https://dev.wix.com/docs/build-apps) can't currently call this method using REST.
|
|
385
|
+
* @param planId - Plan ID.
|
|
386
|
+
* @public
|
|
387
|
+
* @requiredField planId
|
|
388
|
+
* @permissionId PRICING_PLANS.PURCHASE_PLANS
|
|
389
|
+
* @permissionScope Manage Bookings Services and Settings
|
|
390
|
+
* @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
|
|
391
|
+
* @permissionScope Manage Portfolio
|
|
392
|
+
* @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
|
|
393
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
394
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
395
|
+
* @applicableIdentity APP
|
|
396
|
+
* @applicableIdentity MEMBER
|
|
397
|
+
* @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOnlineOrderPreview
|
|
398
|
+
*/
|
|
399
|
+
export async function getOnlineOrderPreview(planId, options) {
|
|
400
|
+
// @ts-ignore
|
|
401
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
402
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
403
|
+
planId: planId,
|
|
404
|
+
startDate: options?.startDate,
|
|
405
|
+
couponCode: options?.couponCode,
|
|
406
|
+
});
|
|
407
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.getOnlineOrderPreview(payload);
|
|
408
|
+
sideEffects?.onSiteCall?.();
|
|
409
|
+
try {
|
|
410
|
+
const result = await httpClient.request(reqOpts);
|
|
411
|
+
sideEffects?.onSuccess?.(result);
|
|
412
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
const transformedError = sdkTransformError(err, {
|
|
416
|
+
spreadPathsToArguments: {},
|
|
417
|
+
explicitPathsToArguments: {
|
|
418
|
+
planId: '$[0]',
|
|
419
|
+
startDate: '$[1].startDate',
|
|
420
|
+
couponCode: '$[1].couponCode',
|
|
421
|
+
},
|
|
422
|
+
singleArgumentUnchanged: false,
|
|
423
|
+
}, ['planId', 'options']);
|
|
424
|
+
sideEffects?.onError?.(err);
|
|
425
|
+
throw transformedError;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Performs a dry run of a purchase and provides an order preview.
|
|
430
|
+
*
|
|
431
|
+
* The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually
|
|
432
|
+
* created, the preview order's `orderId` and `subscriptionId` are displayed as a string of multiple zero characters
|
|
433
|
+
* (`000000-0000`). Tax is only calculated if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection).
|
|
434
|
+
* <br>
|
|
435
|
+
* If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview.
|
|
436
|
+
* But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then
|
|
437
|
+
* `purchaseLimitExceeded` will return as `true`.
|
|
438
|
+
*
|
|
439
|
+
* To get a general price preview for a plan that's not buyer-specific, call Get Price Preview.
|
|
440
|
+
* @param memberId - Member ID of the buyer the previewed order is for, from the Members API.
|
|
441
|
+
* @public
|
|
442
|
+
* @requiredField memberId
|
|
443
|
+
* @requiredField planId
|
|
444
|
+
* @param options - Options for previewing the offline order.
|
|
445
|
+
* @param planId - ID of the plan of the previewed order.
|
|
446
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
447
|
+
* @permissionScope Manage Orders
|
|
448
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
449
|
+
* @applicableIdentity APP
|
|
450
|
+
* @fqn com.wixpress.membership.v2.orders.CheckoutService.GetOfflineOrderPreview
|
|
451
|
+
*/
|
|
452
|
+
export async function getOfflineOrderPreview(planId, memberId, options) {
|
|
453
|
+
// @ts-ignore
|
|
454
|
+
const { httpClient, sideEffects } = arguments[3];
|
|
455
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
456
|
+
planId: planId,
|
|
457
|
+
memberId: memberId,
|
|
458
|
+
startDate: options?.startDate,
|
|
459
|
+
couponCode: options?.couponCode,
|
|
460
|
+
});
|
|
461
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.getOfflineOrderPreview(payload);
|
|
462
|
+
sideEffects?.onSiteCall?.();
|
|
463
|
+
try {
|
|
464
|
+
const result = await httpClient.request(reqOpts);
|
|
465
|
+
sideEffects?.onSuccess?.(result);
|
|
466
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
const transformedError = sdkTransformError(err, {
|
|
470
|
+
spreadPathsToArguments: {},
|
|
471
|
+
explicitPathsToArguments: {
|
|
472
|
+
planId: '$[0]',
|
|
473
|
+
memberId: '$[1]',
|
|
474
|
+
startDate: '$[2].startDate',
|
|
475
|
+
couponCode: '$[2].couponCode',
|
|
476
|
+
},
|
|
477
|
+
singleArgumentUnchanged: false,
|
|
478
|
+
}, ['planId', 'memberId', 'options']);
|
|
479
|
+
sideEffects?.onError?.(err);
|
|
480
|
+
throw transformedError;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Retrieves a plan's pricing.
|
|
485
|
+
*
|
|
486
|
+
* The price preview uses the same logic as purchasing a plan, but the preview is not saved. Tax is only applied if
|
|
487
|
+
* the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). The price is returned
|
|
488
|
+
* in the pricing model format used for orders. Learn more about pricing models ([REST](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/introduction#wix-pricing-plans_pricing-plans_introduction_pricing-models)|[SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/introduction#pricing-models)).
|
|
489
|
+
*
|
|
490
|
+
* Buyers do not have to be logged in to preview the price, and as such, the details returned are not buyer-specific. To
|
|
491
|
+
* generate a preview of a purchase for a specific buyer, call Get Offline Order Preview.
|
|
492
|
+
* @param planId - ID of plan to preview.
|
|
493
|
+
* @public
|
|
494
|
+
* @requiredField planId
|
|
495
|
+
* @param options - Options for getting a price preview.
|
|
496
|
+
* @permissionId PRICING_PLANS.READ_PUBLIC_PLANS
|
|
497
|
+
* @permissionScope Read Pricing Plans
|
|
498
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-PLANS
|
|
499
|
+
* @permissionScope Manage Orders
|
|
500
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
501
|
+
* @permissionScope Manage Bookings Services and Settings
|
|
502
|
+
* @permissionScopeId SCOPE.BOOKINGS.CONFIGURATION
|
|
503
|
+
* @permissionScope Read Orders
|
|
504
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
|
|
505
|
+
* @permissionScope Manage Portfolio
|
|
506
|
+
* @permissionScopeId SCOPE.PORTFOLIO.MANAGE-PORTFOLIO
|
|
507
|
+
* @permissionScope Manage Pricing Plans
|
|
508
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-PLANS
|
|
509
|
+
* @permissionScope Manage Restaurants - all permissions
|
|
510
|
+
* @permissionScopeId SCOPE.RESTAURANTS.MEGA-SCOPES
|
|
511
|
+
* @applicableIdentity APP
|
|
512
|
+
* @applicableIdentity VISITOR
|
|
513
|
+
* @fqn com.wixpress.membership.v2.orders.CheckoutService.GetPricePreview
|
|
514
|
+
*/
|
|
515
|
+
export async function getPricePreview(planId, options) {
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
518
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
519
|
+
planId: planId,
|
|
520
|
+
couponCode: options?.couponCode,
|
|
521
|
+
});
|
|
522
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.getPricePreview(payload);
|
|
523
|
+
sideEffects?.onSiteCall?.();
|
|
524
|
+
try {
|
|
525
|
+
const result = await httpClient.request(reqOpts);
|
|
526
|
+
sideEffects?.onSuccess?.(result);
|
|
527
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
528
|
+
}
|
|
529
|
+
catch (err) {
|
|
530
|
+
const transformedError = sdkTransformError(err, {
|
|
531
|
+
spreadPathsToArguments: {},
|
|
532
|
+
explicitPathsToArguments: {
|
|
533
|
+
planId: '$[0]',
|
|
534
|
+
couponCode: '$[1].couponCode',
|
|
535
|
+
},
|
|
536
|
+
singleArgumentUnchanged: false,
|
|
537
|
+
}, ['planId', 'options']);
|
|
538
|
+
sideEffects?.onError?.(err);
|
|
539
|
+
throw transformedError;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Retrieves an order by ID.
|
|
544
|
+
* @param _id - Order ID.
|
|
545
|
+
* @public
|
|
546
|
+
* @requiredField _id
|
|
547
|
+
* @param options - Options to use when getting an order.
|
|
548
|
+
* @permissionId PRICING_PLANS.READ_ORDERS
|
|
549
|
+
* @permissionScope Manage Orders
|
|
550
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
551
|
+
* @permissionScope Read Orders
|
|
552
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
|
|
553
|
+
* @applicableIdentity APP
|
|
554
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.GetOrder
|
|
555
|
+
*/
|
|
556
|
+
export async function managementGetOrder(_id, options) {
|
|
557
|
+
// @ts-ignore
|
|
558
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
559
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
560
|
+
id: _id,
|
|
561
|
+
fieldSet: options?.fieldSet,
|
|
562
|
+
});
|
|
563
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.managementGetOrder(payload);
|
|
564
|
+
sideEffects?.onSiteCall?.();
|
|
565
|
+
try {
|
|
566
|
+
const result = await httpClient.request(reqOpts);
|
|
567
|
+
sideEffects?.onSuccess?.(result);
|
|
568
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
569
|
+
}
|
|
570
|
+
catch (err) {
|
|
571
|
+
const transformedError = sdkTransformError(err, {
|
|
572
|
+
spreadPathsToArguments: {},
|
|
573
|
+
explicitPathsToArguments: { id: '$[0]', fieldSet: '$[1].fieldSet' },
|
|
574
|
+
singleArgumentUnchanged: false,
|
|
575
|
+
}, ['_id', 'options']);
|
|
576
|
+
sideEffects?.onError?.(err);
|
|
577
|
+
throw transformedError;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Retrieves a list of up to 50 pricing plan orders and details, given the specified sorting and filtering.
|
|
582
|
+
*
|
|
583
|
+
* By default, this endpoint will retrieve all orders and return them sorted by `createdDate` in `DESC`, descending order.
|
|
584
|
+
* `sort.fieldName` supports `endDate` and `createdDate` fields and defaults to `ASC`, ascending order.
|
|
585
|
+
* @public
|
|
586
|
+
* @param options - Filtering, sorting, and pagination options.
|
|
587
|
+
* @permissionId PRICING_PLANS.READ_ORDERS
|
|
588
|
+
* @permissionScope Manage Orders
|
|
589
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
590
|
+
* @permissionScope Read Orders
|
|
591
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.READ-ORDERS
|
|
592
|
+
* @applicableIdentity APP
|
|
593
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.ListOrders
|
|
594
|
+
*/
|
|
595
|
+
export async function managementListOrders(options) {
|
|
596
|
+
// @ts-ignore
|
|
597
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
598
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
599
|
+
buyerIds: options?.buyerIds,
|
|
600
|
+
planIds: options?.planIds,
|
|
601
|
+
autoRenewCanceled: options?.autoRenewCanceled,
|
|
602
|
+
orderStatuses: options?.orderStatuses,
|
|
603
|
+
paymentStatuses: options?.paymentStatuses,
|
|
604
|
+
limit: options?.limit,
|
|
605
|
+
offset: options?.offset,
|
|
606
|
+
sorting: options?.sorting,
|
|
607
|
+
fieldSet: options?.fieldSet,
|
|
608
|
+
});
|
|
609
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.managementListOrders(payload);
|
|
610
|
+
sideEffects?.onSiteCall?.();
|
|
611
|
+
try {
|
|
612
|
+
const result = await httpClient.request(reqOpts);
|
|
613
|
+
sideEffects?.onSuccess?.(result);
|
|
614
|
+
return renameKeysFromRESTResponseToSDKResponse(result.data);
|
|
615
|
+
}
|
|
616
|
+
catch (err) {
|
|
617
|
+
const transformedError = sdkTransformError(err, {
|
|
618
|
+
spreadPathsToArguments: {},
|
|
619
|
+
explicitPathsToArguments: {
|
|
620
|
+
buyerIds: '$[0].buyerIds',
|
|
621
|
+
planIds: '$[0].planIds',
|
|
622
|
+
autoRenewCanceled: '$[0].autoRenewCanceled',
|
|
623
|
+
orderStatuses: '$[0].orderStatuses',
|
|
624
|
+
paymentStatuses: '$[0].paymentStatuses',
|
|
625
|
+
limit: '$[0].limit',
|
|
626
|
+
offset: '$[0].offset',
|
|
627
|
+
sorting: '$[0].sorting',
|
|
628
|
+
fieldSet: '$[0].fieldSet',
|
|
629
|
+
},
|
|
630
|
+
singleArgumentUnchanged: false,
|
|
631
|
+
}, ['options']);
|
|
632
|
+
sideEffects?.onError?.(err);
|
|
633
|
+
throw transformedError;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Extends the duration of a pricing plan order by postponing the order's `endDate`. Postponing the end date of an order does not impact payments.
|
|
638
|
+
*
|
|
639
|
+
* New `endDate` must be later than the order's current `endDate`. Can't postpone orders that are unlimited.
|
|
640
|
+
* Can't postpone an order with `status`: `PAUSED`.
|
|
641
|
+
* @param _id - Order ID.
|
|
642
|
+
* @param endDate - New end date and time.
|
|
643
|
+
*
|
|
644
|
+
* Must be later than the current end date and time.
|
|
645
|
+
* @public
|
|
646
|
+
* @requiredField _id
|
|
647
|
+
* @requiredField endDate
|
|
648
|
+
* @param options - Options for postponing the end date of an order.
|
|
649
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
650
|
+
* @permissionScope Manage Orders
|
|
651
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
652
|
+
* @applicableIdentity APP
|
|
653
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.PostponeEndDate
|
|
654
|
+
*/
|
|
655
|
+
export async function postponeEndDate(_id, endDate) {
|
|
656
|
+
// @ts-ignore
|
|
657
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
658
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
659
|
+
id: _id,
|
|
660
|
+
endDate: endDate,
|
|
661
|
+
});
|
|
662
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.postponeEndDate(payload);
|
|
663
|
+
sideEffects?.onSiteCall?.();
|
|
664
|
+
try {
|
|
665
|
+
const result = await httpClient.request(reqOpts);
|
|
666
|
+
sideEffects?.onSuccess?.(result);
|
|
667
|
+
}
|
|
668
|
+
catch (err) {
|
|
669
|
+
const transformedError = sdkTransformError(err, {
|
|
670
|
+
spreadPathsToArguments: {},
|
|
671
|
+
explicitPathsToArguments: { id: '$[0]', endDate: '$[1]' },
|
|
672
|
+
singleArgumentUnchanged: false,
|
|
673
|
+
}, ['_id', 'endDate']);
|
|
674
|
+
sideEffects?.onError?.(err);
|
|
675
|
+
throw transformedError;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Cancels an existing order.
|
|
680
|
+
*
|
|
681
|
+
* For orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.
|
|
682
|
+
* For orders with one-time payments, a cancellation can only be set for `IMMEDIATELY`.
|
|
683
|
+
*
|
|
684
|
+
* #### Canceling during the free trial period.
|
|
685
|
+
*
|
|
686
|
+
* When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end
|
|
687
|
+
* of the free trial period and they will not be billed. The buyer may continue using the benefits until the end
|
|
688
|
+
* of the free trial period.
|
|
689
|
+
*
|
|
690
|
+
* When a Wix user cancels an ordered plan during the free trial period, they choose whether to apply the cancellation
|
|
691
|
+
* `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. Canceling `IMMEDIATELY` will end the subscription for the buyer
|
|
692
|
+
* immediately, even during the free trial period and the buyer won't be billed. Canceling at the
|
|
693
|
+
* `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period.
|
|
694
|
+
* Then, the subscription ends and the buyer is not billed.
|
|
695
|
+
* @param _id - Order ID.
|
|
696
|
+
* @param effectiveAt - __Required.__ When the order will be canceled. One-time orders can only be canceled `IMMEDIATELY`.
|
|
697
|
+
* @public
|
|
698
|
+
* @requiredField _id
|
|
699
|
+
* @requiredField effectiveAt
|
|
700
|
+
* @param options - Options for canceling orders.
|
|
701
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
702
|
+
* @permissionScope Manage Orders
|
|
703
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
704
|
+
* @applicableIdentity APP
|
|
705
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.CancelOrder
|
|
706
|
+
*/
|
|
707
|
+
export async function cancelOrder(_id, effectiveAt) {
|
|
708
|
+
// @ts-ignore
|
|
709
|
+
const { httpClient, sideEffects } = arguments[2];
|
|
710
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({
|
|
711
|
+
id: _id,
|
|
712
|
+
effectiveAt: effectiveAt,
|
|
713
|
+
});
|
|
714
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.cancelOrder(payload);
|
|
715
|
+
sideEffects?.onSiteCall?.();
|
|
716
|
+
try {
|
|
717
|
+
const result = await httpClient.request(reqOpts);
|
|
718
|
+
sideEffects?.onSuccess?.(result);
|
|
719
|
+
}
|
|
720
|
+
catch (err) {
|
|
721
|
+
const transformedError = sdkTransformError(err, {
|
|
722
|
+
spreadPathsToArguments: {},
|
|
723
|
+
explicitPathsToArguments: { id: '$[0]', effectiveAt: '$[1]' },
|
|
724
|
+
singleArgumentUnchanged: false,
|
|
725
|
+
}, ['_id', 'effectiveAt']);
|
|
726
|
+
sideEffects?.onError?.(err);
|
|
727
|
+
throw transformedError;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Marks an offline order as paid.
|
|
732
|
+
* > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments.
|
|
733
|
+
*
|
|
734
|
+
* Marking an offline order as paid causes the following changes:
|
|
735
|
+
* - The order's `lastPaymentStatus` changes to `"PAID"`.
|
|
736
|
+
* - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`.
|
|
737
|
+
*
|
|
738
|
+
* An error occurs if you attempt to:
|
|
739
|
+
* - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice.
|
|
740
|
+
* - Mark an online order as paid. The Mark as Paid method is supported for offline orders only.
|
|
741
|
+
* @param _id - Order ID.
|
|
742
|
+
* @public
|
|
743
|
+
* @requiredField _id
|
|
744
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
745
|
+
* @permissionScope Manage Orders
|
|
746
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
747
|
+
* @applicableIdentity APP
|
|
748
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.MarkAsPaid
|
|
749
|
+
*/
|
|
750
|
+
export async function markAsPaid(_id) {
|
|
751
|
+
// @ts-ignore
|
|
752
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
753
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
754
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.markAsPaid(payload);
|
|
755
|
+
sideEffects?.onSiteCall?.();
|
|
756
|
+
try {
|
|
757
|
+
const result = await httpClient.request(reqOpts);
|
|
758
|
+
sideEffects?.onSuccess?.(result);
|
|
759
|
+
}
|
|
760
|
+
catch (err) {
|
|
761
|
+
const transformedError = sdkTransformError(err, {
|
|
762
|
+
spreadPathsToArguments: {},
|
|
763
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
764
|
+
singleArgumentUnchanged: false,
|
|
765
|
+
}, ['_id']);
|
|
766
|
+
sideEffects?.onError?.(err);
|
|
767
|
+
throw transformedError;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Pauses an order. Calling this method changes the order status to `"PAUSED"` and updates the `pausePeriods` array.
|
|
772
|
+
*
|
|
773
|
+
* Only orders with `status`: `ACTIVE` can be paused.
|
|
774
|
+
* For orders with recurring payments, it also pauses the payment schedule. Buyers are not charged when an order is paused.
|
|
775
|
+
* Pausing an order affects the end date of the order by adding the time the order is paused to the `endDate`.
|
|
776
|
+
* The `endDate` and the `earliestEndDate` for the order are adjusted to include the pause period when the order is resumed.
|
|
777
|
+
*
|
|
778
|
+
* To resume a paused order, call Resume Order.
|
|
779
|
+
* @param _id - Order ID.
|
|
780
|
+
* @public
|
|
781
|
+
* @requiredField _id
|
|
782
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
783
|
+
* @permissionScope Manage Orders
|
|
784
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
785
|
+
* @applicableIdentity APP
|
|
786
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.PauseOrder
|
|
787
|
+
*/
|
|
788
|
+
export async function pauseOrder(_id) {
|
|
789
|
+
// @ts-ignore
|
|
790
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
791
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
792
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.pauseOrder(payload);
|
|
793
|
+
sideEffects?.onSiteCall?.();
|
|
794
|
+
try {
|
|
795
|
+
const result = await httpClient.request(reqOpts);
|
|
796
|
+
sideEffects?.onSuccess?.(result);
|
|
797
|
+
}
|
|
798
|
+
catch (err) {
|
|
799
|
+
const transformedError = sdkTransformError(err, {
|
|
800
|
+
spreadPathsToArguments: {},
|
|
801
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
802
|
+
singleArgumentUnchanged: false,
|
|
803
|
+
}, ['_id']);
|
|
804
|
+
sideEffects?.onError?.(err);
|
|
805
|
+
throw transformedError;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Resumes a paused order. For orders with recurring payments, it also restarts the payment schedule.
|
|
810
|
+
*
|
|
811
|
+
* Resuming an order causes the following changes:
|
|
812
|
+
* - The order status changes to `"ACTIVE"`.
|
|
813
|
+
* - The `pausePeriods` array is updated.
|
|
814
|
+
* - The `endDate` for the order is adjusted to include the pause period.
|
|
815
|
+
* - For orders with recurring payments, the payment schedule is restarted.
|
|
816
|
+
* - The `earliestEndDate` is adjusted to include the pause period. (This property is reserved for future use).
|
|
817
|
+
*
|
|
818
|
+
* To pause an order, call Pause Order.
|
|
819
|
+
* @param _id - Order ID.
|
|
820
|
+
* @public
|
|
821
|
+
* @requiredField _id
|
|
822
|
+
* @permissionId PRICING_PLANS.MANAGE_ORDERS
|
|
823
|
+
* @permissionScope Manage Orders
|
|
824
|
+
* @permissionScopeId SCOPE.DC-PAIDPLANS.MANAGE-ORDERS
|
|
825
|
+
* @applicableIdentity APP
|
|
826
|
+
* @fqn com.wixpress.membership.v2.orders.OrderManagementService.ResumeOrder
|
|
827
|
+
*/
|
|
828
|
+
export async function resumeOrder(_id) {
|
|
829
|
+
// @ts-ignore
|
|
830
|
+
const { httpClient, sideEffects } = arguments[1];
|
|
831
|
+
const payload = renameKeysFromSDKRequestToRESTRequest({ id: _id });
|
|
832
|
+
const reqOpts = ambassadorWixPricingPlansV2Order.resumeOrder(payload);
|
|
833
|
+
sideEffects?.onSiteCall?.();
|
|
834
|
+
try {
|
|
835
|
+
const result = await httpClient.request(reqOpts);
|
|
836
|
+
sideEffects?.onSuccess?.(result);
|
|
837
|
+
}
|
|
838
|
+
catch (err) {
|
|
839
|
+
const transformedError = sdkTransformError(err, {
|
|
840
|
+
spreadPathsToArguments: {},
|
|
841
|
+
explicitPathsToArguments: { id: '$[0]' },
|
|
842
|
+
singleArgumentUnchanged: false,
|
|
843
|
+
}, ['_id']);
|
|
844
|
+
sideEffects?.onError?.(err);
|
|
845
|
+
throw transformedError;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
//# sourceMappingURL=pricing-plans-v2-order-orders.universal.js.map
|