From 1195bc24329f6d936d39055587e6c112d080dda9 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Thu, 25 Jan 2024 14:08:59 +0000 Subject: [PATCH 01/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 122 +++++++++---- .../wix-pricing-plans-v2/Plans.service.json | 64 ++++++- .../Plans/PlansQueryBuilder.service.json | 170 ++++++++++++++++++ .../Plans/PlansQueryResult.service.json | 9 + 4 files changed, 332 insertions(+), 33 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index cda14d15fe..26f17de2c8 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -319,7 +319,7 @@ "referenceType": "wix-pricing-plans-v2.Orders.ManagementGetOrderOptions" } ], - "doc": "Options to use when getting an order.\n", + "doc": "Options to use when getting an order.", "required": false } ], @@ -381,7 +381,7 @@ "referenceType": "wix-pricing-plans-v2.Orders.ManagementListOrdersOptions" } ], - "doc": "Filtering, sorting, and pagination options.\n", + "doc": "Filtering, sorting, and pagination options.", "required": false } ], @@ -1506,6 +1506,75 @@ ] } }, + { + "name": "CreateExternalOrderOptions", + "members": [ + { + "name": "submissionId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Form submission id that was submitted together with the order" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "CreateExternalOrderRequest", + "members": [ + { + "name": "planId", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Plan ID." + }, + { + "name": "submissionId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Form submission id that was submitted together with the order" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "CreateExternalOrderResponse", + "members": [ + { + "name": "order", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Orders.Order" + } + ], + "doc": "Created order" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "CreateGuestOnlineOrderOptions", "members": [ @@ -1978,7 +2047,7 @@ "nativeType": "string" } ], - "doc": "Pointer to the next or previous page in the list of results.\n\nYou can get the relevant cursor token\nfrom the `pagingMetadata` object in the previous call's response.\nNot relevant for the first request.\n" + "doc": "Pointer to the next or previous page in the list of results.\n\nPass the relevant cursor token from the `pagingMetadata` object in the previous call's response.\nNot relevant for the first request.\n" }, { "name": "limit", @@ -1988,7 +2057,7 @@ "nativeType": "number" } ], - "doc": "Number of items to load." + "doc": "Maximum number of items to return in the results." } ], "docs": { @@ -2008,7 +2077,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to next page in the list of results." + "doc": "Cursor string pointing to the next page in the list of results." }, { "name": "prev", @@ -2018,7 +2087,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Cursor pointing to the previous page in the list of results." } ], "docs": { @@ -2038,7 +2107,7 @@ "nativeType": "string" } ], - "doc": "random GUID so clients can tell if event was already handled" + "doc": "Unique event ID.\nAllows clients to ignore duplicate webhooks." }, { "name": "actionEvent", @@ -2098,7 +2167,7 @@ "nativeType": "string" } ], - "doc": "Assuming that all messages including Actions have id\nExample: The id of the specific order, the id of a specific campaign" + "doc": "ID of the entity associated with the event." }, { "name": "eventTime", @@ -2108,7 +2177,7 @@ "nativeType": "Date" } ], - "doc": "The time of the event. Useful if there was a delay in dispatching" + "doc": "Event timestamp." }, { "name": "originatedFrom", @@ -2138,7 +2207,7 @@ "nativeType": "boolean" } ], - "doc": "A field that should be set if this event was triggered by an anonymize request.\nFor example you must set it to true when sending an event as a result of a GDPR right to be forgotten request.\nNOTE: This field is not relevant for `EntityCreatedEvent` but is located here for better ergonomics of consumers." + "doc": "Whether the event was triggered as a result of a privacy regulation application\n(for example, GDPR)." }, { "name": "updatedEvent", @@ -2281,7 +2350,18 @@ }, { "name": "EntityDeletedEvent", - "members": [], + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], "docs": { "description": [ "" @@ -3694,26 +3774,6 @@ ] } }, - { - "name": "MemberQueryOrdersOptions", - "members": [ - { - "name": "query", - "optional": true, - "type": [ - { - "referenceType": "wix-pricing-plans-v2.Orders.QueryV2" - } - ], - "doc": "" - } - ], - "docs": { - "description": [ - "" - ] - } - }, { "name": "OnBehalf", "members": [ diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 5aa0656e45..91006490a7 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -2470,7 +2470,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to next page in the list of results." + "doc": "Cursor string pointing to the next page in the list of results." }, { "name": "prev", @@ -2480,7 +2480,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Cursor pointing to the previous page in the list of results." } ], "docs": { @@ -2519,7 +2519,67 @@ ] } }, + { + "name": "Fee", + "members": [ { + "name": "amount", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Amount of fee to be charged" + }, + { + "name": "name", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Fee name" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "FeeConfig", + "members": [ + { + "name": "appliedAt", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "The time this fee will be charged" + }, + { + "name": "fee", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.Fee" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { "name": "GetPlanRequest", "members": [ { diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryBuilder.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryBuilder.service.json index b6d2b8d6db..37885e6deb 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryBuilder.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryBuilder.service.json @@ -391,6 +391,91 @@ "isVeloEvent": false, "syntaxName": "find" }, + { + "name": "ge", + "params": [ + { + "name": "propertyName", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Property whose value is compared with `value`.", + "required": false + }, + { + "name": "value", + "type": [ + { + "nativeType": "any" + } + ], + "doc": "Value to compare against.\n", + "required": false + } + ], + "requiredFields": [], + "ret": { + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.PlansQueryBuilder" + } + ], + "doc": null + }, + "docs": { + "summary": "Refines a query to match items where the specified property is greater than or equal to the specified value.", + "description": [ + "The `ge()` function refines a `PlansQueryBuilder` to match only items where the value of the specified `propertyName` is greater than or equal to the specified `value`.", + "`ge()` matches only values of the same type. For example, `0` stored as a number doesn't match `'0'` stored as a string.", + "If a property contains a number stored as a string (for example, `'0'`), that value is compared alphabetically and not numerically. If a property doesn't have a value, that value is ranked lowest.", + "The following types of properties can be compared:", + "- Number: Compares numerically.", + "- Date: Compares JavaScript Date objects. ", + "- String: Compares lexicographically, so `'abc'` is greater than `'ABC'`." + ], + "examples": [ + { + "title": "Add a `ge` filter to a query", + "body": [ + "const query = plans.queryPublicPlans.ge('_createdDate', '2021-03-01');", + "" + ] + }, + { + "title": "Create a query, add a `ge` filter, and run it", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "", + "export async function myQueryFunction() {", + " const results = await plans", + " .queryPublicPlans()", + " .ge('_createdDate', '2021-03-01')", + " .find();", + "", + " if (results.items.length > 0) {", + " const items = results.items;", + " const firstItem = items[0];", + " const pageSize = results.pageSize;", + " const hasNext = results.hasNext();", + " const hasPrev = results.hasPrev();", + " const length = results.length;", + " const query = results.query;", + "", + " return items;", + " } else {", + " // Handle if no matching items found", + " }", + "}", + "" + ] + } + ] + }, + "isVeloEvent": false, + "syntaxName": "ge" + }, { "name": "gt", "params": [ @@ -651,6 +736,91 @@ "isVeloEvent": false, "syntaxName": "in" }, + { + "name": "le", + "params": [ + { + "name": "propertyName", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Property whose value is compared with `value`.", + "required": false + }, + { + "name": "value", + "type": [ + { + "nativeType": "any" + } + ], + "doc": "Value to compare against.\n", + "required": false + } + ], + "requiredFields": [], + "ret": { + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.PlansQueryBuilder" + } + ], + "doc": null + }, + "docs": { + "summary": "Refines a query to match items where the specified property is less than or equal to the specified value.", + "description": [ + "The `le()` function refines a `PlansQueryBuilder` to match only items where the value of the specified `propertyName` is less than or equal to the specified `value`.", + "`le()` matches only values of the same type. For example, `0` stored as a number doesn't match `'0'` stored as a string.", + "If a property contains a number stored as a string (for example, `'0'`), that value is compared alphabetically and not numerically. If a property doesn't have a value, that value is ranked lowest.", + "The following types of properties can be compared:", + "- Number: Compares numerically.", + "- Date: Compares JavaScript Date objects. ", + "- String: Compares lexicographically, so `'ABC'` is less than `'abc'`." + ], + "examples": [ + { + "title": "Add an `le` filter to a query", + "body": [ + "const query = plans.queryPublicPlans.le('_createdDate', '2021-03-01');", + "" + ] + }, + { + "title": "Create a query, add an `le` filter, and run it", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "", + "export async function myQueryFunction() {", + " const results = await plans", + " .queryPublicPlans()", + " .le('_createdDate', '2021-03-01')", + " .find();", + "", + " if (results.items.length > 0) {", + " const items = results.items;", + " const firstItem = items[0];", + " const pageSize = results.pageSize;", + " const hasNext = results.hasNext();", + " const hasPrev = results.hasPrev();", + " const length = results.length;", + " const query = results.query;", + "", + " return items;", + " } else {", + " // Handle if no matching items found", + " }", + "}", + "" + ] + } + ] + }, + "isVeloEvent": false, + "syntaxName": "le" + }, { "name": "limit", "params": [ diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryResult.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryResult.service.json index 471bc722f2..b617452ca6 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryResult.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/PlansQueryResult.service.json @@ -11,6 +11,9 @@ { "name": "currentPage", "type": [ + { + "nativeType": "undefined" + }, { "nativeType": "number" } @@ -209,6 +212,9 @@ { "name": "totalCount", "type": [ + { + "nativeType": "undefined" + }, { "nativeType": "number" } @@ -245,6 +251,9 @@ { "name": "totalPages", "type": [ + { + "nativeType": "undefined" + }, { "nativeType": "number" } From bfb7ea423cad3d00f7577ca97306119e3c5232e0 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Thu, 25 Jan 2024 14:37:21 +0000 Subject: [PATCH 02/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 103 ++++++++++++++++-- 1 file changed, 94 insertions(+), 9 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index ef33bd499d..c3f90c3559 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -646,7 +646,7 @@ "docs": { "summary": "Triggered when an order is updated.", "description": [ - "This is a general webhook that is triggered when any update is made to an order. More specific webhooks are also triggered for the same originating events.\n| Order event | Also triggered |\n| ----------------------------------- | ------------------------------------------|\n| Order is paid for. | [Order Purchased Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-purchased-webhook) |\n| Free or offline order is created. | [Order Purchased Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-purchased-webhook) |\n| Order reaches its `startDate`. | [Order Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-started-webhook) |\n| Order reaches its `endDate`. | [Order Ended Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-ended-webhook) |\n| New payment cycle of an order starts. | [Order Cycle Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-cycle-started-webhook) |\n| Offline order is marked as paid. | [Order Marked As Paid Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-marked-as-paid-webhook) |\n| `endDate` of the order is postponed. | [Order End Date Postponed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-end-date-postponed-webhook) |\n| Order is paused. | [Order Paused Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-paused-webhook) |\n| Paused order is resumed. | [Order Resumed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-resumed-webhook) |\n| Order is canceled. | [Order Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-canceled-webhook) |\n| Order is canceled and `effectiveAt` is set to `NEXT_PAYMENT_DATE`. | [Order Auto Renew Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-auto-renew-canceled-webhook) |" + "Order Updated Webhook is triggered when any of the following happens:\n+ Order is paid for. [Order Purchased Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-purchased-webhook) is also triggered.\n+ Order reaches its start date or end date. [Order Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-started-webhook) and [Order Ended Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-ended-webhook), respectively, are also triggered.\n+ New payment cycle of an order starts. [Order Cycle Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-cycle-started-webhook) is also triggered.\n+ Offline order is marked as paid. [Order Marked As Paid Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-marked-as-paid-webhook) is also triggered.\n+ End date of the order is postponed. [Order End Date Postponed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-end-date-postponed-webhook) is also triggered\n+ Order is paused, or a paused order is resumed. [Order Paused Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-paused-webhook)\nand [Order Resumed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-resumed-webhook), respectively, are also triggered.\n+ Order is canceled, either immediately or at the end of the payment cycle. [Order Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-canceled-webhook)\nand [Order Auto Renew Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-auto-renew-canceled-webhook) are also triggered." ], "examples": [ { @@ -811,7 +811,12 @@ ] }, "isVeloEvent": true, - "syntaxName": "wixPricingPlans_onPlanArchived" + "customLabels": [ + { + "id": "maturity-beta" + } + ], + "syntaxName": "wixPricingPlans_onPlanBuyerCanCancelUpdated" }, { "name": "onPlanCreated", @@ -1630,7 +1635,57 @@ ] } }, + { + "name": "pricingPlansV2OrderCreateExternalOrderRequest", + "members": [ + { + "name": "planId", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Plan ID." + }, + { + "name": "submissionId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Form submission id that was submitted together with the order" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2OrderCreateExternalOrderResponse", + "members": [ { + "name": "order", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2OrderOrder", + "displayName": "Order" + } + ], + "doc": "Created order" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { "name": "pricingPlansV2OrderCreateGuestOnlineOrderRequest", "members": [ { @@ -2001,7 +2056,7 @@ "nativeType": "string" } ], - "doc": "random GUID so clients can tell if event was already handled" + "doc": "Unique event ID.\nAllows clients to ignore duplicate webhooks." }, { "name": "actionEvent", @@ -2064,7 +2119,7 @@ "nativeType": "string" } ], - "doc": "Assuming that all messages including Actions have id\nExample: The id of the specific order, the id of a specific campaign" + "doc": "ID of the entity associated with the event." }, { "name": "eventTime", @@ -2074,7 +2129,7 @@ "nativeType": "Date" } ], - "doc": "The time of the event. Useful if there was a delay in dispatching" + "doc": "Event timestamp." }, { "name": "originatedFrom", @@ -2104,7 +2159,7 @@ "nativeType": "boolean" } ], - "doc": "A field that should be set if this event was triggered by an anonymize request.\nFor example you must set it to true when sending an event as a result of a GDPR right to be forgotten request.\nNOTE: This field is not relevant for `EntityCreatedEvent` but is located here for better ergonomics of consumers." + "doc": "Whether the event was triggered as a result of a privacy regulation application\n(for example, GDPR)." }, { "name": "updatedEvent", @@ -3560,7 +3615,7 @@ "nativeType": "string" } ], - "doc": "How the order was processed. One of:\n+ `ONLINE`: The buyer purchased the plan using the site.\n+ `OFFLINE`: The buyer made a manual, offline purchase without using the site." + "doc": "How the order was processed. One of:\n+ `ONLINE`: The buyer purchased the plan using the site.\n+ `OFFLINE`: The buyer made a manual, offline purchase without using the site.\n+ `EXTERNAL`: The buyer made a purchase through an external payment provider." }, { "name": "wixPayOrderId", @@ -5765,7 +5820,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to next page in the list of results." + "doc": "Cursor string pointing to the next page in the list of results." }, { "name": "prev", @@ -5775,7 +5830,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Cursor pointing to the previous page in the list of results." } ], "docs": { @@ -6588,7 +6643,37 @@ ] } }, + { + "name": "pricingPlansV2PlanPlanBuyerCanCancelUpdated", + "members": [ + { + "name": "data", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanBuyerCanCancelUpdated", + "displayName": "BuyerCanCancelUpdated" + } + ], + "doc": "" + }, { + "name": "metadata", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanBackendEventMetadata", + "displayName": "BackendEventMetadata" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { "name": "pricingPlansV2PlanPlanCreated", "members": [ { From 9870037a3b2e1679639fdb1c98fec9c19675bff9 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Sat, 27 Jan 2024 09:20:19 +0000 Subject: [PATCH 03/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Plans.service.json | 502 ++++++++++++++++++ 1 file changed, 502 insertions(+) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 91006490a7..56c215cfff 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -184,6 +184,67 @@ "/* Promise resolves to void */", "" ] + }, + { + "title": "Sort plans alphabetically ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedArrangePlans = elevate(plans.arrangePlans);", + "", + "export async function sortPlansBySlug(direction) {", + " let publicPlansQuery = plans.queryPublicPlans();", + "", + " if (direction === 'ascending') {", + " publicPlansQuery = publicPlansQuery.ascending('slug');", + " console.log('ascending logic');", + " } else {", + " publicPlansQuery = publicPlansQuery.descending('slug');", + " console.log('descending logic');", + " }", + "", + " const sortedPlans = await publicPlansQuery.find();", + " const planIds = sortedPlans.items.map(item => item._id);", + "", + " return await elevatedArrangePlans(planIds);", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { sortPlansBySlug } from 'backend/plan-functions';", + "import wixLocationFrontend from 'wix-location-frontend';", + "", + "$w.onReady(function () {", + " $w('#dropdownSort').options =", + " [", + " {", + " label: 'Ascending',", + " value: 'ascending'", + " },", + " {", + " label: 'Decending',", + " value: 'descending'", + " }", + " ];", + "", + " $w('#dropdownSort').onChange(async () => {", + " const direction = $w('#dropdownSort').value;", + " sortPlansBySlug(direction);", + " const url = wixLocationFrontend.url;", + " wixLocationFrontend.to(url);", + " })", + "});" + ], + "extra": { + "description": "Select a sorting option to arranage plans in ascending or disending order by plan slug. " + } } ] }, @@ -440,6 +501,90 @@ " */ ", "" ] + }, + { + "title": "Create a plan from existing plans ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export async function listPlansFunction() {", + " try {", + " const elevatedListPlans = elevate(plans.listPlans);", + " const response = await elevatedListPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function getPlan(_id) {", + " try {", + " const elevatedGetPlan = elevate(plans.getPlan);", + " const myPlan = await elevatedGetPlan(_id);", + "", + " return myPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function createPlan(plan) {", + " try {", + " const elevatedCreatePlan = elevate(plans.createPlan);", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import planFunctions from 'backend/plan-functions';", + "", + "$w.onReady(async function () {", + " const plans = await planFunctions.listPlansFunction();", + " populatePlansDropdown(plans);", + " let selectedPlan;", + "", + " $w('#plansList').onChange(async () => {", + " const planId = $w('#plansList').value;", + " selectedPlan = await planFunctions.myGetPlanFunction(planId);", + "", + " $w('#newPlan').onClick(async () => {", + " let newPlan = selectedPlan;", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + " await planFunctions.myCreatePlanFunction(newPlan);", + " })", + " });", + "});", + "", + "function populatePlansDropdown(plans) {", + "\t$w('#plansList').options = plans.items.map(item => (", + "\t\t{", + "\t\tlabel: item.name,", + "\t\tvalue: item._id", + "\t\t} ", + "\t));", + "}" + ], + "extra": { + "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + } } ] }, @@ -545,6 +690,90 @@ " * } ", " */" ] + }, + { + "title": "Create a plan from existing plans ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export async function listPlansFunction() {", + " try {", + " const elevatedListPlans = elevate(plans.listPlans);", + " const response = await elevatedListPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function getPlan(_id) {", + " try {", + " const elevatedGetPlan = elevate(plans.getPlan);", + " const myPlan = await elevatedGetPlan(_id);", + "", + " return myPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function createPlan(plan) {", + " try {", + " const elevatedCreatePlan = elevate(plans.createPlan);", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import planFunctions from 'backend/plan-functions';", + "", + "$w.onReady(async function () {", + " const plans = await planFunctions.listPlansFunction();", + " populatePlansDropdown(plans);", + " let selectedPlan;", + "", + " $w('#plansList').onChange(async () => {", + " const planId = $w('#plansList').value;", + " selectedPlan = await planFunctions.myGetPlanFunction(planId);", + "", + " $w('#newPlan').onClick(async () => {", + " let newPlan = selectedPlan;", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + " await planFunctions.myCreatePlanFunction(newPlan);", + " })", + " });", + "});", + "", + "function populatePlansDropdown(plans) {", + "\t$w('#plansList').options = plans.items.map(item => (", + "\t\t{", + "\t\tlabel: item.name,", + "\t\tvalue: item._id", + "\t\t} ", + "\t));", + "}" + ], + "extra": { + "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + } } ] }, @@ -943,6 +1172,90 @@ " * }", " */" ] + }, + { + "title": "Create a plan from existing plans ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export async function listPlansFunction() {", + " try {", + " const elevatedListPlans = elevate(plans.listPlans);", + " const response = await elevatedListPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function getPlan(_id) {", + " try {", + " const elevatedGetPlan = elevate(plans.getPlan);", + " const myPlan = await elevatedGetPlan(_id);", + "", + " return myPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function createPlan(plan) {", + " try {", + " const elevatedCreatePlan = elevate(plans.createPlan);", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import planFunctions from 'backend/plan-functions';", + "", + "$w.onReady(async function () {", + " const plans = await planFunctions.listPlansFunction();", + " populatePlansDropdown(plans);", + " let selectedPlan;", + "", + " $w('#plansList').onChange(async () => {", + " const planId = $w('#plansList').value;", + " selectedPlan = await planFunctions.myGetPlanFunction(planId);", + "", + " $w('#newPlan').onClick(async () => {", + " let newPlan = selectedPlan;", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + " await planFunctions.myCreatePlanFunction(newPlan);", + " })", + " });", + "});", + "", + "function populatePlansDropdown(plans) {", + "\t$w('#plansList').options = plans.items.map(item => (", + "\t\t{", + "\t\tlabel: item.name,", + "\t\tvalue: item._id", + "\t\t} ", + "\t));", + "}" + ], + "extra": { + "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + } } ] }, @@ -1338,6 +1651,70 @@ " */ ", "" ] + }, + { + "title": "Make a plan primary ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + "const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", + "", + "export async function listPublicPlans() {", + " try {", + " const response = await elevatedListPublicPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function makePlanPrimaryFunction(_id) {", + " try {", + " const primaryPlan = await elevatedMakePlanPrimary(_id);", + "", + " return primaryPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import planFunctions from 'backend/plan-functions';", + "", + "$w.onReady(function () {", + " populateDropdown();", + " $w('#plansList').onChange(async () => {", + " await planFunctions.makePlanPrimaryFunction(", + " $w('#plansList').value", + " )", + " });", + "});", + "", + "async function populateDropdown() {", + " const plans = await planFunctions.listPublicPlans();", + " $w('#plansList').options = plans.map(item => ({", + " label: item.name,", + " value: item._id", + " })", + " )", + "}" + ], + "extra": { + "description": "Select a public plan from the dropdown to make it appear as a primary plan on the business site. " + } } ] }, @@ -1435,6 +1812,70 @@ " * }", " */" ] + }, + { + "title": "Make a plan primary ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + "const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", + "", + "export async function listPublicPlans() {", + " try {", + " const response = await elevatedListPublicPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function makePlanPrimaryFunction(_id) {", + " try {", + " const primaryPlan = await elevatedMakePlanPrimary(_id);", + "", + " return primaryPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import planFunctions from 'backend/plan-functions';", + "", + "$w.onReady(function () {", + " populateDropdown();", + " $w('#plansList').onChange(async () => {", + " await planFunctions.makePlanPrimaryFunction(", + " $w('#plansList').value", + " )", + " });", + "});", + "", + "async function populateDropdown() {", + " const plans = await planFunctions.listPublicPlans();", + " $w('#plansList').options = plans.map(item => ({", + " label: item.name,", + " value: item._id", + " })", + " )", + "}" + ], + "extra": { + "description": "Select a public plan from the dropdown to make it appear as a primary plan on the business site. " + } } ] }, @@ -1764,6 +2205,67 @@ "", "/* Returned item: '7a3375ce-18a9-42cb-8e39-47918ade45ec' */" ] + }, + { + "title": "Sort plans alphabetically ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedArrangePlans = elevate(plans.arrangePlans);", + "", + "export async function sortPlansBySlug(direction) {", + " let publicPlansQuery = plans.queryPublicPlans();", + "", + " if (direction === 'ascending') {", + " publicPlansQuery = publicPlansQuery.ascending('slug');", + " console.log('ascending logic');", + " } else {", + " publicPlansQuery = publicPlansQuery.descending('slug');", + " console.log('descending logic');", + " }", + "", + " const sortedPlans = await publicPlansQuery.find();", + " const planIds = sortedPlans.items.map(item => item._id);", + "", + " return await elevatedArrangePlans(planIds);", + "}", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { sortPlansBySlug } from 'backend/plan-functions';", + "import wixLocationFrontend from 'wix-location-frontend';", + "", + "$w.onReady(function () {", + " $w('#dropdownSort').options =", + " [", + " {", + " label: 'Ascending',", + " value: 'ascending'", + " },", + " {", + " label: 'Decending',", + " value: 'descending'", + " }", + " ];", + "", + " $w('#dropdownSort').onChange(async () => {", + " const direction = $w('#dropdownSort').value;", + " sortPlansBySlug(direction);", + " const url = wixLocationFrontend.url;", + " wixLocationFrontend.to(url);", + " })", + "});" + ], + "extra": { + "description": "Select a sorting option to arranage plans in ascending or disending order by plan slug. " + } } ] }, From b74f60d81a871afee079666c2deb9b4529273f1e Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Sun, 28 Jan 2024 16:35:22 +0000 Subject: [PATCH 04/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index c3f90c3559..d8c88ee9a5 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -1996,7 +1996,7 @@ "nativeType": "string" } ], - "doc": "Pointer to the next or previous page in the list of results.\n\nYou can get the relevant cursor token\nfrom the `pagingMetadata` object in the previous call's response.\nNot relevant for the first request.\n" + "doc": "Pointer to the next or previous page in the list of results.\n\nPass the relevant cursor token from the `pagingMetadata` object in the previous call's response.\nNot relevant for the first request.\n" }, { "name": "limit", @@ -2006,7 +2006,7 @@ "nativeType": "number" } ], - "doc": "Number of items to load." + "doc": "Maximum number of items to return in the results." } ], "docs": { @@ -2026,7 +2026,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to next page in the list of results." + "doc": "Cursor string pointing to the next page in the list of results." }, { "name": "prev", @@ -2036,7 +2036,7 @@ "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Cursor pointing to the previous page in the list of results." } ], "docs": { @@ -2307,7 +2307,18 @@ }, { "name": "pricingPlansV2OrderEntityDeletedEvent", - "members": [], + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], "docs": { "description": [ "" From 3a6e7f82eebae2096c353e3e7229250f8da0c416 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 5 Feb 2024 10:38:54 +0000 Subject: [PATCH 05/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Plans.service.json | 229 ++++++++++-------- 1 file changed, 131 insertions(+), 98 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 56c215cfff..158d3c7d74 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -243,7 +243,7 @@ "});" ], "extra": { - "description": "Select a sorting option to arranage plans in ascending or disending order by plan slug. " + "description": "Select a sorting option to arranage plans in ascending or descending order by plan slug. " } } ] @@ -503,7 +503,7 @@ ] }, { - "title": "Create a plan from existing plans ", + "title": "Duplicate a plan ", "body": [ "/*************************************", " * Backend code - plan-functions.jsw *", @@ -512,25 +512,27 @@ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "export async function listPlansFunction() {", + "const elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export async function listPlans() {", " try {", - " const elevatedListPlans = elevate(plans.listPlans);", " const response = await elevatedListPlans();", - " const plansList = response.plans;", + " const allPlans = response.plans;", "", - " return plansList;", + " return allPlans;", " } catch (error) {", " console.error(error);", " // Handle the error", " }", "}", "", - "export async function getPlan(_id) {", + "export async function getPlan(planId) {", " try {", - " const elevatedGetPlan = elevate(plans.getPlan);", - " const myPlan = await elevatedGetPlan(_id);", + " const selectedPlan = await elevatedGetPlan(planId);", "", - " return myPlan;", + " return selectedPlan;", " } catch (error) {", " console.error(error);", " // Handle the error", @@ -539,7 +541,6 @@ "", "export async function createPlan(plan) {", " try {", - " const elevatedCreatePlan = elevate(plans.createPlan);", " const newPlan = await elevatedCreatePlan(plan);", "", " return newPlan;", @@ -549,41 +550,51 @@ " }", "}", "", + "", "/*************", " * Page code *", " *************/", "", - "import planFunctions from 'backend/plan-functions';", - "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", "$w.onReady(async function () {", - " const plans = await planFunctions.listPlansFunction();", - " populatePlansDropdown(plans);", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", " let selectedPlan;", "", - " $w('#plansList').onChange(async () => {", - " const planId = $w('#plansList').value;", - " selectedPlan = await planFunctions.myGetPlanFunction(planId);", - "", - " $w('#newPlan').onClick(async () => {", - " let newPlan = selectedPlan;", - " newPlan.name = $w('#planName').value;", - " newPlan.pricing.price.value = $w('#price').value;", - " await planFunctions.myCreatePlanFunction(newPlan);", - " })", + " $w('#plansDropdown').onChange(async () => {", + " const planId = $w('#plansDropdown').value;", + " selectedPlan = await getPlan(planId);", + "", + " // Set default value for the new plan name", + " $w('#planName').value = `${selectedPlan.name}-duplicate`", + " $w('#clonePlanBtn').enable();", + " });", + " ", + " $w('#clonePlanBtn').onClick(async () => {", + " const newPlan = selectedPlan;", + " // Use inputs to set the new plan name and price", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + "", + " await createPlan(newPlan);", " });", "});", "", - "function populatePlansDropdown(plans) {", - "\t$w('#plansList').options = plans.items.map(item => (", - "\t\t{", - "\t\tlabel: item.name,", - "\t\tvalue: item._id", - "\t\t} ", - "\t));", + "async function populatePlansDropdown() {", + " const plans = await listPlans();", + " $w('#plansDropdown').options = plans.map((plan) => {", + " return {", + " label: plan.name,", + " value: plan._id", + " }", + " });", + " $w('#plansDropdown').enable();", "}" ], "extra": { - "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + "description": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " } } ] @@ -692,7 +703,7 @@ ] }, { - "title": "Create a plan from existing plans ", + "title": "Duplicate a plan ", "body": [ "/*************************************", " * Backend code - plan-functions.jsw *", @@ -701,25 +712,27 @@ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "export async function listPlansFunction() {", + "const elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export async function listPlans() {", " try {", - " const elevatedListPlans = elevate(plans.listPlans);", " const response = await elevatedListPlans();", - " const plansList = response.plans;", + " const allPlans = response.plans;", "", - " return plansList;", + " return allPlans;", " } catch (error) {", " console.error(error);", " // Handle the error", " }", "}", "", - "export async function getPlan(_id) {", + "export async function getPlan(planId) {", " try {", - " const elevatedGetPlan = elevate(plans.getPlan);", - " const myPlan = await elevatedGetPlan(_id);", + " const selectedPlan = await elevatedGetPlan(planId);", "", - " return myPlan;", + " return selectedPlan;", " } catch (error) {", " console.error(error);", " // Handle the error", @@ -728,7 +741,6 @@ "", "export async function createPlan(plan) {", " try {", - " const elevatedCreatePlan = elevate(plans.createPlan);", " const newPlan = await elevatedCreatePlan(plan);", "", " return newPlan;", @@ -738,41 +750,51 @@ " }", "}", "", + "", "/*************", " * Page code *", " *************/", "", - "import planFunctions from 'backend/plan-functions';", - "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", "$w.onReady(async function () {", - " const plans = await planFunctions.listPlansFunction();", - " populatePlansDropdown(plans);", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", " let selectedPlan;", "", - " $w('#plansList').onChange(async () => {", - " const planId = $w('#plansList').value;", - " selectedPlan = await planFunctions.myGetPlanFunction(planId);", - "", - " $w('#newPlan').onClick(async () => {", - " let newPlan = selectedPlan;", - " newPlan.name = $w('#planName').value;", - " newPlan.pricing.price.value = $w('#price').value;", - " await planFunctions.myCreatePlanFunction(newPlan);", - " })", + " $w('#plansDropdown').onChange(async () => {", + " const planId = $w('#plansDropdown').value;", + " selectedPlan = await getPlan(planId);", + "", + " // Set default value for the new plan name", + " $w('#planName').value = `${selectedPlan.name}-duplicate`", + " $w('#clonePlanBtn').enable();", + " });", + " ", + " $w('#clonePlanBtn').onClick(async () => {", + " const newPlan = selectedPlan;", + " // Use inputs to set the new plan name and price", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + "", + " await createPlan(newPlan);", " });", "});", "", - "function populatePlansDropdown(plans) {", - "\t$w('#plansList').options = plans.items.map(item => (", - "\t\t{", - "\t\tlabel: item.name,", - "\t\tvalue: item._id", - "\t\t} ", - "\t));", + "async function populatePlansDropdown() {", + " const plans = await listPlans();", + " $w('#plansDropdown').options = plans.map((plan) => {", + " return {", + " label: plan.name,", + " value: plan._id", + " }", + " });", + " $w('#plansDropdown').enable();", "}" ], "extra": { - "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + "description": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " } } ] @@ -1174,7 +1196,7 @@ ] }, { - "title": "Create a plan from existing plans ", + "title": "Duplicate a plan ", "body": [ "/*************************************", " * Backend code - plan-functions.jsw *", @@ -1183,25 +1205,27 @@ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "export async function listPlansFunction() {", + "const elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export async function listPlans() {", " try {", - " const elevatedListPlans = elevate(plans.listPlans);", " const response = await elevatedListPlans();", - " const plansList = response.plans;", + " const allPlans = response.plans;", "", - " return plansList;", + " return allPlans;", " } catch (error) {", " console.error(error);", " // Handle the error", " }", "}", "", - "export async function getPlan(_id) {", + "export async function getPlan(planId) {", " try {", - " const elevatedGetPlan = elevate(plans.getPlan);", - " const myPlan = await elevatedGetPlan(_id);", + " const selectedPlan = await elevatedGetPlan(planId);", "", - " return myPlan;", + " return selectedPlan;", " } catch (error) {", " console.error(error);", " // Handle the error", @@ -1210,7 +1234,6 @@ "", "export async function createPlan(plan) {", " try {", - " const elevatedCreatePlan = elevate(plans.createPlan);", " const newPlan = await elevatedCreatePlan(plan);", "", " return newPlan;", @@ -1220,41 +1243,51 @@ " }", "}", "", + "", "/*************", " * Page code *", " *************/", "", - "import planFunctions from 'backend/plan-functions';", - "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", "$w.onReady(async function () {", - " const plans = await planFunctions.listPlansFunction();", - " populatePlansDropdown(plans);", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", " let selectedPlan;", "", - " $w('#plansList').onChange(async () => {", - " const planId = $w('#plansList').value;", - " selectedPlan = await planFunctions.myGetPlanFunction(planId);", - "", - " $w('#newPlan').onClick(async () => {", - " let newPlan = selectedPlan;", - " newPlan.name = $w('#planName').value;", - " newPlan.pricing.price.value = $w('#price').value;", - " await planFunctions.myCreatePlanFunction(newPlan);", - " })", + " $w('#plansDropdown').onChange(async () => {", + " const planId = $w('#plansDropdown').value;", + " selectedPlan = await getPlan(planId);", + "", + " // Set default value for the new plan name", + " $w('#planName').value = `${selectedPlan.name}-duplicate`", + " $w('#clonePlanBtn').enable();", + " });", + " ", + " $w('#clonePlanBtn').onClick(async () => {", + " const newPlan = selectedPlan;", + " // Use inputs to set the new plan name and price", + " newPlan.name = $w('#planName').value;", + " newPlan.pricing.price.value = $w('#price').value;", + "", + " await createPlan(newPlan);", " });", "});", "", - "function populatePlansDropdown(plans) {", - "\t$w('#plansList').options = plans.items.map(item => (", - "\t\t{", - "\t\tlabel: item.name,", - "\t\tvalue: item._id", - "\t\t} ", - "\t));", + "async function populatePlansDropdown() {", + " const plans = await listPlans();", + " $w('#plansDropdown').options = plans.map((plan) => {", + " return {", + " label: plan.name,", + " value: plan._id", + " }", + " });", + " $w('#plansDropdown').enable();", "}" ], "extra": { - "description": "Select an existing plan from a dropdown list, and input a new name and price to create a new plan. " + "description": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " } } ] @@ -2264,7 +2297,7 @@ "});" ], "extra": { - "description": "Select a sorting option to arranage plans in ascending or disending order by plan slug. " + "description": "Select a sorting option to arranage plans in ascending or descending order by plan slug. " } } ] From a5a2ba102c7dfaeadb981c436dcc30a6d83abff8 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 5 Feb 2024 21:07:21 +0000 Subject: [PATCH 06/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 158d3c7d74..22b20687ac 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -202,10 +202,8 @@ "", " if (direction === 'ascending') {", " publicPlansQuery = publicPlansQuery.ascending('slug');", - " console.log('ascending logic');", " } else {", " publicPlansQuery = publicPlansQuery.descending('slug');", - " console.log('descending logic');", " }", "", " const sortedPlans = await publicPlansQuery.find();", @@ -2256,10 +2254,8 @@ "", " if (direction === 'ascending') {", " publicPlansQuery = publicPlansQuery.ascending('slug');", - " console.log('ascending logic');", " } else {", " publicPlansQuery = publicPlansQuery.descending('slug');", - " console.log('descending logic');", " }", "", " const sortedPlans = await publicPlansQuery.find();", From 1730568d2d4d0a4920df1ddcfb909f657b4dbd7e Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Wed, 7 Feb 2024 07:13:59 +0000 Subject: [PATCH 07/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index 26f17de2c8..1cc29fee9c 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -95,6 +95,16 @@ "doc": "ID of the plan being ordered. See [Plans for more information about plan IDs](plans)", "required": true }, + { + "name": "memberId", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of the member ordering the plan.", + "required": true + }, { "name": "options", "type": [ @@ -107,7 +117,7 @@ } ], "requiredFields": [ - "options.memberId", + "memberId", "planId" ], "ret": { @@ -136,9 +146,9 @@ "body": [ "import { orders } from 'wix-pricing-plans.v2';", " ", - " async function createOfflineOrder(planId, options) {", + " async function createOfflineOrder(planId, memberId, options) {", " try {", - " const result = await orders.createOfflineOrder(planId, options);", + " const result = await orders.createOfflineOrder(planId, memberId, options);", "", " return result;", " } catch (error) {", @@ -168,6 +178,16 @@ "doc": "ID of the plan of the previewed order.", "required": true }, + { + "name": "memberId", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Member ID of the buyer the previewed order is for.", + "required": true + }, { "name": "options", "type": [ @@ -180,7 +200,7 @@ } ], "requiredFields": [ - "options.memberId", + "memberId", "planId" ], "ret": { @@ -209,9 +229,9 @@ "body": [ "import { orders } from 'wix-pricing-plans.v2';", " ", - " async function getOfflineOrderPreview(planId, options) {", + " async function getOfflineOrderPreview(planId, memberId, options) {", " try {", - " const result = await orders.getOfflineOrderPreview(planId, options);", + " const result = await orders.getOfflineOrderPreview(planId, memberId, options);", "", " return result;", " } catch (error) {", @@ -1733,15 +1753,6 @@ ], "doc": "Coupon code to apply." }, - { - "name": "memberId", - "type": [ - { - "nativeType": "string" - } - ], - "doc": "ID of the member ordering the plan.\nThis field is required when creating an offline order." - }, { "name": "paid", "optional": true, @@ -2648,15 +2659,6 @@ ], "doc": "Coupon code to apply." }, - { - "name": "memberId", - "type": [ - { - "nativeType": "string" - } - ], - "doc": "Member ID for the buyer who might order the plan offline.\nThis field is required to get an offline order preview." - }, { "name": "startDate", "optional": true, From 14464be0688902bd069649716ad4d6cf6cdb931a Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Thu, 8 Feb 2024 08:25:41 +0000 Subject: [PATCH 08/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 1572 +++++++++++++++-- 1 file changed, 1428 insertions(+), 144 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index 1cc29fee9c..52c451d875 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -59,26 +59,41 @@ ], "examples": [ { - "title": "cancelOrder example", + "title": "Cancel an order immediately ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function cancelOrder(id, effectiveAt) {", - " try {", - " const result = await orders.cancelOrder(id, effectiveAt);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: 'e6f12ae0-2618-41e7-a643-31ca2ee51e2b'", + " *", + " * Sample effectiveAt value: 'IMMEDIATELY'", + " */", + "", + "const elevatedCancelOrder = elevate(orders.cancelOrder);", + "", + "export async function myCancelOrderFunction(_id, effectiveAt) {", + "\ttry {", + "\t\tawait elevatedCancelOrder(_id, effectiveAt);", + "", + "\t\treturn;", + "\t} catch (error) {", + "\t\tconsole.error(error);", + "\t\t// Handle the error", + "\t}", + "}", + "", + "/* Promise resolves to void */", + " " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "cancelOrder", "isAdminMethod": true }, @@ -142,26 +157,215 @@ ], "examples": [ { - "title": "createOfflineOrder example", + "title": "Create an offline order ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function createOfflineOrder(planId, memberId, options) {", - " try {", - " const result = await orders.createOfflineOrder(planId, memberId, options);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' ", + " *", + " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", + " */", + "", + "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", + "", + "export async function myCreateOfflineOrderFunction(planId, memberId) {", + " try {", + " const newOrder = await elevatedCreateOfflineOrder(planId, memberId);", + "", + " return newOrder;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"endDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * },", + " * \"freeTrialDays\": 90,", + " * \"lastPaymentStatus\": \"UNPAID\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " */ ", + "" + ] + }, + { + "title": "Create an offline order with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", + " *", + " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", + " * ", + " * Sample options value: ", + " * {", + " * couponCode: 'e4ddd93a-5601-4696-99dd-3356f0e558c0',", + " * paid: true,", + " * startDate: '2024-01-29T11:50:21.041Z',", + " * submissionId: '9e128ddb-f62f-4a4a-adb5-064af40f18db'", + " * }", + " */", + "", + "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", + "", + "export async function myCreateOfflineOrderFunctionWithOptions(planId, memberId, options) {", + " try {", + " const newOrder = await elevatedCreateOfflineOrder(planId, memberId, options);", + "", + " return newOrder;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * order: {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"endDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * \"freeTrialDays\": 90,", + " * \"lastPaymentStatus\": \"UNPAID\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " * }", + " */ " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "createOfflineOrder", "isAdminMethod": true }, @@ -225,26 +429,319 @@ ], "examples": [ { - "title": "getOfflineOrderPreview example", + "title": "Create an offline order preview ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function getOfflineOrderPreview(planId, memberId, options) {", - " try {", - " const result = await orders.getOfflineOrderPreview(planId, memberId, options);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", + " *", + " * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b'", + " */", + "", + "const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);", + "", + "export async function myGetOfflineOrderPreviewFunction(planId, memberId) {", + " try {", + " const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId);", + "", + " return orderPreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * order: {", + " * \"_createdDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"_id\": \"00000000-0000-0000-0000-000000000000\",", + " * \"_updatedDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * }", + " * ],", + " * \"endDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"earliestEndDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 30,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"order\": {", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * }", + " * ],", + " * \"endDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"earliestEndDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 30,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"orderType\": \"OFFLINE\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Complete with all features. One month free trial.\",", + " * \"planId\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"planName\": \"Premium Plan - annual - 30 day trial\",", + " * \"planPrice\": \"500\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"freeTrialDays\": 30,", + " * \"planPrice\": \"500\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\",", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"seller\": {", + " * \"subscriptionId\": \"00000000-0000-0000-0000-000000000000\"", + " * },", + " * \"startDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"type\": \"OFFLINE\"", + " * },", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Complete with all features. One month free trial.\",", + " * \"planId\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"planName\": \"Premium Plan - annual - 30 day trial\",", + " * \"planPrice\": \"500\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"00000000-0000-0000-0000-000000000000\",", + " * \"type\": \"OFFLINE\"", + " * }", + " * \"purchaseLimitExceeded\": false", + " * }", + " */ ", + "" + ] + }, + { + "title": "Create an offline order preview with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample planId value: 'd2fa5805-0d1a-4cfb-9b43-e683cf5fa990'", + " *", + " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", + " * ", + " * Sample options value:", + " * {", + " * couponCode: 'seasonal',", + " * startDate: new Date()", + " * } ", + " */", + "", + "const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);", + "", + "export async function myGetOfflineOrderPreviewFunction(planId, memberId, options) {", + " try {", + " const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId, options);", + "", + " return orderPreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-01T07:58:49.777Z\",", + " * \"_id\": \"00000000-0000-0000-0000-000000000000\",", + " * \"_updatedDate\": \"2024-02-01T07:58:49.777Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-02-15T07:58:49.387Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-02-01T07:58:49.387Z\"", + " * },", + " * \"formData\": {", + " * \"fomrId\": ", + " * \"submissionData\": {", + " * \"email_0fd2\": \"Jboss@email.com\",", + " * \"form_field_aa30\": false,", + " * \"first_name_c551\": \"Jason\",", + " * \"last_name_78e9\": \"Bollinger\",", + " * \"phone_8cf1\": \"212-909-2222\"", + " * },", + " * \"submissionId\": \"10206732-e789-40e9-957d-2c7f3398efc6\" ", + " * },", + " * \"freeTrialDays\": 14,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"The value plan\",", + " * \"planId\": \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", + " * \"planName\": \"Silver Membership - Monthly\",", + " * \"planPrice\": \"100\",", + " * \"status\": \"ACTIVE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"coupon\": {", + " * \"code\": \"seasonal\",", + " * \"amount\": \"95.00\",", + " * \"_id\": \"8673834a-a5c6-4e77-af9c-83f9bf609659\"", + " * },", + " * \"total\": \"30.00\",", + " * \"proration\": \"0\",", + " * \"fees\": [", + " * {", + " * \"name\": \"Setup Fee\",", + " * \"amount\": \"25\"", + " * }", + " * ],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"125.00\",", + " * \"discount\": \"95.00\"", + " * }", + " * },", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 2", + " * },", + " * \"price\": {", + " * \"coupon\": {", + " * \"code\": \"seasonal\",", + " * \"amount\": \"95.00\",", + " * \"_id\": \"8673834a-a5c6-4e77-af9c-83f9bf609659\"", + " * },", + " * \"total\": \"5.00\",", + " * \"proration\": \"0\",", + " * \"fees\": [],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"100.00\",", + " * \"discount\": \"95.00\"", + " * }", + " * }", + " * ]", + " * \"subscription\": {", + " * \"cycleCount\": 0,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-02-01T07:58:49.387Z\",", + " * \"status\": \"ACTIVE\",", + " * \"subscriptionId\": \"00000000-0000-0000-0000-000000000000\",", + " * \"type\": \"OFFLINE\",", + " * },", + " * \"purchaseLimitExceeded\": false", + " * }", + " */ " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "getOfflineOrderPreview", "isAdminMethod": true }, @@ -297,26 +794,140 @@ ], "examples": [ { - "title": "getPricePreview example", + "title": "Get a price preview for an order ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function getPricePreview(planId, options) {", - " try {", - " const result = await orders.getPricePreview(planId, options);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", + "", + "const elevatedGetPricePreview = elevate(orders.getPricePreview);", + "", + "export async function myGetPricePreviewFunction(planId) {", + " try {", + " const pricePreview = await elevatedGetPricePreview(planId)", + "", + " return pricePreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "/* Promise resolves to:", + " * {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\"", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"32.50\"", + " * },", + " * \"total\": \"532.50\"", + " * }", + " * }", + " * ]", + " * }", + " */ " + ] + }, + { + "title": "Get a price preview for an order with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", + " *", + " * Sample options value:", + " * {", + " * couponCode: 'SUMMERSALE'", + " * }", + " */ ", + "", + "const elevatedGetPricePreview = elevate(orders.getPricePreview);", + "", + "export async function myGetPricePreviewFunction(planId, options) {", + " try {", + " const pricePreview = await elevatedGetPricePreview(planId, options)", + "", + " return pricePreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"coupon\": {", + " * \"code\": \"SUMMERSALE\",", + " * \"amount\": \"90.00\",", + " * \"_id\": \"271d5fe4-2105-47b8-81c1-b24201d1be68\"", + " * },", + " * \"discount\": \"90.00\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"125.00\",", + " * \"tax\": {", + " * \"amount\": \"2.28\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\",", + " * },", + " * \"total\": \"37.28\"", + " * }", + " * },", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 2", + " * },", + " * \"price\": {", + " * \"coupon\": {", + " * \"code\": \"SUMMERSALE\",", + " * \"amount\": \"90.00\",", + " * \"_id\": \"271d5fe4-2105-47b8-81c1-b24201d1be68\"", + " * },", + " * \"discount\": \"90.00\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"100.00\",", + " * \"tax\": {", + " * \"amount\": \"0.65\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"10.65\",", + " * }", + " * }", + " * ]", + " * }", + " */ " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "getPricePreview" }, { @@ -368,26 +979,262 @@ ], "examples": [ { - "title": "managementGetOrder example", + "title": "Get an order ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function managementGetOrder(id, options) {", - " try {", - " const result = await orders.managementGetOrder(id, options);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' */", + "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", + "", + "export async function myManagementGetOrderFunction(_id) {", + " try {", + " const order = await elevatedManagementGetOrder(_id);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * order: {", + " * \"_createdDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"_id\": \"12178428-36b7-4cf5-bfb5-0ba8c83c4e8c\",", + " * \"_updatedDate\": \"2024-01-31T10:59:17.495Z\",", + " * \"buyer\": {", + " * \"contactId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\",", + " * \"memberId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"b1e7d751-7727-4c07-a0b5-0ab017ef7d1b\",", + " * \"type\": \"ONLINE\"", + " * }", + " * }", + " */ " + ] + }, + { + "title": "Get an order with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c'", + " *", + " * Sample options value: ", + " * {", + " * fieldSet: 'FULL'", + " * }", + " * ", + "*/", + "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", + "", + "export async function myManagementGetOrderFunction(_id) {", + " try {", + " const order = await elevatedManagementGetOrder(_id);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"_id\": \"12178428-36b7-4cf5-bfb5-0ba8c83c4e8c\",", + " * \"_updatedDate\": \"2024-01-31T10:59:17.495Z\",", + " * \"buyer\": {", + " * \"contactId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\",", + " * \"memberId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {", + " * \"email_7b7a\": \"Sgray@email.com\",", + " * \"first_name_e841\": \"Stanley\",", + " * \"form_field_1b5e\": true,", + " * \"last_name_3347\": \"Grayson\"", + " * },", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"order\": {", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {", + " * \"email_7b7a\": \"Sgray@email.com\",", + " * \"first_name_e841\": \"Stanley\",", + " * \"form_field_1b5e\": true,", + " * \"last_name_3347\": \"Grayson\"", + " * },", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"b1e7d751-7727-4c07-a0b5-0ab017ef7d1b\",", + " * \"type\": \"ONLINE\"", + " * },", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"b1e7d751-7727-4c07-a0b5-0ab017ef7d1b\",", + " * \"type\": \"ONLINE\"", + " * }", + " */ ", + "" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "managementGetOrder", "isAdminMethod": true }, @@ -428,26 +1275,256 @@ ], "examples": [ { - "title": "managementListOrders example", + "title": "List pricing plan orders ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function managementListOrders(options) {", - " try {", - " const result = await orders.managementListOrders(options);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", + "", + "export async function myManagementListOrdersFunction() {", + " try {", + " const ordersList = await elevatedManagementListOrders();", + "", + " return ordersList;", + " } catch (error){", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"orders\": [", + " * {", + " * \"_createdDate\": \"2024-01-22T14:00:53.904Z\",", + " * \"_id\": \"14fac8ae-506e-4e7b-84d4-e9b094d0ddca\",", + " * \"_updatedDate\": \"2024-01-22T14:00:54.772Z\",", + " * \"buyer\": {", + " * \"contactId\": \"f5691fc2-0674-4eee-92c5-da06a05981a5\",", + " * \"memberId\": \"f5691fc2-0674-4eee-92c5-da06a05981a5\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-22T14:00:53.904Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-22T14:00:53.904Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"startDate\": \"2024-01-22T14:00:53.904Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"19276032-d06f-4931-962f-79486d8b6bc0\",", + " * \"type\": \"ONLINE\"", + " * }", + " * ],", + " * \"pagingMetadata\": {", + " * \"count\": 1,", + " * \"hasNext\": false,", + " * \"offset\": 0,", + " * \"total\": 1", + " * }", + " * }", + " */ ", + "", + "" + ] + }, + { + "title": "List pricing plan orders with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample options value:", + " * {", + " * autoRenewCanceled: false,", + " * buyerIds: [", + " * '402ec90c-235a-45c4-b4cc-52204d5f6b00',", + " * '3fc889f6-18e8-4fd9-a509-27db9f037f26',", + " * 'fa16f1dc-0fbd-41c0-8efc-53333e3fce1e',", + " * '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4',", + " * '695568ff-1dc2-49ff-83db-2b518d35692b',", + " * '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4',", + " * 'f5691fc2-0674-4eee-92c5-da06a05981a5'", + " * ],", + " * fieldSet: 'BASIC',", + " * limit: 3,", + " * offset: 0,", + " * orderStatuses: [", + " * 'ACTIVE'", + " * ],", + " * paymentStatus: [", + " * 'PAID',", + " * 'NOT_APPLICABLE'", + " * ],", + " * planIds: [", + " * '0da57ac8-c3d0-4687-8aea-4100781b6386',", + " * 'df83348a-777d-46ab-8d62-a43c415bdb11', ", + " * '3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b', ", + " * 'cb4a8c57-273a-4567-94e3-cc43d5d339f2', ", + " * 'df83348a-777d-46ab-8d62-a43c415bdb11', ", + " * 'aa0d8e0e-99ad-4c95-ac48-4955e37956c5', ", + " * 'aa0d8e0e-99ad-4c95-ac48-4955e37956c5'", + " * ],", + " * sorting: {", + " * fieldName: 'createdDate',", + " * order: 'ASC'", + " * };", + " */", + "", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", + "", + "export async function myManagementListOrdersFunction(options) {", + " try {", + " const ordersList = await elevatedManagementListOrders(options);", + "", + " return ordersList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"orders\": [", + " * {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-02-04T10:42:58.888Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"endDate\": \"2026-07-29T09:49:21.041Z\",", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 90,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"freeTrialDays\": 90,", + " * \"planPrice\": \"50\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " * ],", + " * \"pagingMetadata\": {", + " * \"count\": 1,", + " * \"hasNext\": false,", + " * \"offset\": 0,", + " * \"total\": 1", + " * }", + " * }", + " */ ", " " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "managementListOrders", "isAdminMethod": true }, @@ -490,26 +1567,37 @@ ], "examples": [ { - "title": "markAsPaid example", + "title": "Mark an order as paid ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function markAsPaid(id) {", - " try {", - " const result = await orders.markAsPaid(id);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5' */", + "", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export async function myMarkAsPaidFunction(_id) {", + " try {", + " await elevatedMarkAsPaid(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to void */" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "markAsPaid", "isAdminMethod": true }, @@ -621,26 +1709,174 @@ ], "examples": [ { - "title": "memberListOrders example", + "title": "Get orders for currently logged in members ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function memberListOrders(options) {", - " try {", - " const result = await orders.memberListOrders(options);", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "export async function myMemberListOrdersFunction() {", + " try {", + " const ordersList = await orders.memberListOrders();", + " return ordersList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"orders\": [", + " * {", + " * \"planPrice\": \"0\",", + " * \"_id\": \"292c6b6b-81ec-4c10-b067-78b1a1b2fada\",", + " * \"_createdDate\": \"2024-02-05T17:26:23.348Z\",", + " * \"subscriptionId\": \"973e0e0b-85c2-4d2b-9693-fc8f1140d958\",", + " * \"pausePeriods\": [],", + " * \"_updatedDate\": \"2024-02-05T17:26:24.129Z\",", + " * \"planName\": \"Free Plan\",", + " * \"buyer\": {", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"status\": \"ACTIVE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"\",", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionId\": \"6d68798b-b5ea-4471-b029-dea6e4ac043a\",", + " * \"submissionData\": {}", + " * },", + " * \"statusNew\": \"ACTIVE\",", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-05T17:26:23.348Z\"", + " * }", + " * ],", + " * \"type\": \"ONLINE\",", + " * \"planId\": \"3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b\",", + " * \"startDate\": \"2024-02-05T17:26:23.348Z\",", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-05T17:26:23.348Z\"", + " * },", + " * \"pricing\": {", + " * \"singlePaymentUnlimited\": true,", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"0\"", + " * },", + " * \"total\": \"0\",", + " * \"proration\": \"0\",", + " * \"fees\": [],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\"", + " * }", + " * }", + " * ]", + " * },", + " * \"priceDetails\": {", + " * \"planPrice\": \"0\",", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"0\"", + " * },", + " * \"total\": \"0\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\",", + " * \"singlePaymentUnlimited\": true", + " * }", + " * },", + " * {", + " * \"planPrice\": \"0\",", + " * \"_id\": \"7b4ec42c-582a-4e2f-874b-09e66e0ae09d\",", + " * \"_createdDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", + " * \"pausePeriods\": [],", + " * \"_updatedDate\": \"2024-01-28T08:35:16.080Z\",", + " * \"planName\": \"Standard Plan\",", + " * \"buyer\": {", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"status\": \"ACTIVE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionId\": \"2cf62c7a-d3ed-4dd9-816d-01919aaf2170\",", + " * \"submissionData\": {}", + " * },", + " * \"statusNew\": \"ACTIVE\",", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * }", + " * ],", + " * \"type\": \"ONLINE\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"startDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * },", + " * \"pricing\": {", + " * \"singlePaymentUnlimited\": true,", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"total\": \"0\",", + " * \"proration\": \"0\",", + " * \"fees\": [],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\"", + " * }", + " * }", + " * ]", + " * },", + " * \"priceDetails\": {", + " * \"planPrice\": \"0\",", + " * \"total\": \"0\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\",", + " * \"singlePaymentUnlimited\": true", + " * }", + " * }", + " * ]", + " * }", + " */ " ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "memberListOrders" }, { @@ -682,26 +1918,37 @@ ], "examples": [ { - "title": "pauseOrder example", + "title": "Pause a pricing plan order ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function pauseOrder(id) {", - " try {", - " const result = await orders.pauseOrder(id);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", + "", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", + "", + "export async function pauseOrder(_id) {", + " try {", + " await elevatedPauseOrder(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to void */" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "pauseOrder", "isAdminMethod": true }, @@ -755,26 +2002,40 @@ ], "examples": [ { - "title": "postponeEndDate example", + "title": "Postpone an order's end date ", "body": [ - "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function postponeEndDate(id, endDate) {", - " try {", - " const result = await orders.postponeEndDate(id, endDate);", + "import { orders } from 'wix-pricing-plans-backend';", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5'", + " * ", + " * Sample endDate value: new Date('June 30, 2026 04:00:00')", + " */", + "", + "const elevatedPostoponeEndDate = elevate(orders.postponeEndDate);", + "", + "export async function myPostponeEndDateFunction(_id, endDate) {", + " try {", + " await orders.postponeEndDate(_id, endDate);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise that resolves to void */" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "postponeEndDate", "isAdminMethod": true }, @@ -828,26 +2089,37 @@ ], "examples": [ { - "title": "requestCancellation example", + "title": "Cancel an order immediately ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function requestCancellation(id, effectiveAt) {", - " try {", - " const result = await orders.requestCancellation(id, effectiveAt);", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", + " *", + " * Sample effectiveAt value: 'IMMEDIATELY'", + " */", + "", + "export async function myRequestCancellationFunction(_id, effectiveAt) {", + " try {", + " await orders.requestCancellation(_id, effectiveAt);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to void */" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "requestCancellation" }, { @@ -889,26 +2161,38 @@ ], "examples": [ { - "title": "resumeOrder example", + "title": "Resume an order ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function resumeOrder(id) {", - " try {", - " const result = await orders.resumeOrder(id);", + "import { elevate } from 'wix-auth';", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", + "", + "const elevatedResumeOrder = elevate(orders.resumeOrder);", + "", + "export async function myResumeOrderFunction(_id) {", + " try {", + " await elevatedResumeOrder(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to void */", + "" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "resumeOrder", "isAdminMethod": true } From 5b4c69fe5361ee26609ee88363d78b0e3412ab9c Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Thu, 8 Feb 2024 14:57:37 +0000 Subject: [PATCH 09/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 566 +++++++++++++++++- 1 file changed, 535 insertions(+), 31 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index d8c88ee9a5..04effafb42 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -94,13 +94,113 @@ { "title": "onOrderCanceled example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderCanceled(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", "", - " " + "export function wixPricingPlans_onOrderCanceled(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const planName = event.data.planName;", + " const endDate = event.data.endDate;", + " console.log(`The order with and ID of ${orderId} was cancelled by buyer ID ${buyerContactId}, for the ${planName} plan on ${endDate}. Full event object:`, event);", + "}", + "", + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"IMMEDIATELY\"", + " * },", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-04T09:02:48.592Z\",", + " * \"_id\": \"e6f12ae0-2618-41e7-a643-31ca2ee51e2b\",", + " * \"_updatedDate\": \"2024-02-06T07:31:59.180Z\",", + " * \"buyer\": {", + " * \"contactId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\",", + " * \"memberId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-02-06T07:31:59.123Z\",", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-04T09:02:48.592Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-02-06T07:31:59.123Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full feature enablement - lifetime plan\",", + " * \"planId\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"planName\": \"Premium Plan - Lifetime Membership\",", + " * \"planPrice\": \"1000\",", + " * \"priceDetails\": {", + " * \"coupon\": {", + " * \"_id\": \"07de4c3a-536b-4c30-adb9-991935da1681\",", + " * \"amount\": \"1000.00\",", + " * \"code\": \"sale-day\"", + " * },", + " * \"currency\": \"USD\",", + " * \"discount\": \"1000.00\",", + " * \"planPrice\": \"1000\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"1000.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"1000.00\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"1000.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-02-04T09:02:48.592Z\",", + " * \"status\": \"CANCELED\",", + " * \"statusNew\": \"CANCELED\",", + " * \"subscriptionId\": \"02e297ba-c270-4415-9f77-748507bb7b9d\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"8f012204-4d60-457b-8772-b0cf92a11d84\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"e6f12ae0-2618-41e7-a643-31ca2ee51e2b\",", + " * \"eventTime\": \"2024-02-06T07:31:59.288259731Z\",", + " * \"id\": \"85a7ec5f-2ab4-4582-9a1d-5845c5f38e87\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */", + "" ] } ] @@ -144,13 +244,84 @@ { "title": "onOrderCreated example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderCreated(event) {", - " const eventId = event.metadata.id", - " const entityId = event.entity._id;", - " }", + "export function wixPricingPlans_onOrderCreated(event) {", + " const orderId = event.entity._id;", + " const createdDate = event.entity._createdDate;", + " const buyer = event.entity.buyer;", "", - " " + " console.log(`The order with ID ${event.orderId} to purchase the ${event.plan.name} plan was created on ${createdDate} by the buyer ${buyer}. The full event object:`, event);", + "}", + "", + "/* Full event object:", + " * {", + " * \"entity\": {", + " * \"_createdDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"_id\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"_updatedDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"1b282868-0a1e-42c6-9123-3a611b0014bf\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"e9fff457-bc89-4c8c-94c0-1d162711c9a6\",", + " * \"type\": \"ONLINE\"", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"eventTime\": \"2024-01-25T11:45:06.457639259Z\",", + " * \"id\": \"6a0b2d17-6211-4394-b3e4-9c1a1bb1b1cc\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -196,13 +367,95 @@ { "title": "onOrderCycleStarted example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderCycleStarted(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", - "", - " " + "export function wixPricingPlans_onOrderCycleStarted(event) {", + " const orderId = event.data.order._id;", + " const wixPayId = event.data.transactionId;", + " const eventId = event.metadata.id;", + " const eventTime = event.metadata.eventTime;", + "}", + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"cycleNumber\": 1,", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"_id\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"_updatedDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"1b282868-0a1e-42c6-9123-3a611b0014bf\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"planPrice\": \"0\",", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"e9fff457-bc89-4c8c-94c0-1d162711c9a6\",", + " * \"type\": \"ONLINE\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"eventTime\": \"2024-01-25T11:45:06.852478956Z\",", + " * \"id\": \"9481d95b-3fd6-423c-af43-5198bed9691c\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + " ", + "" ] } ] @@ -450,13 +703,93 @@ { "title": "onOrderPurchased example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderPurchased(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderPurchased(event) {", + " const orderId = event.data.order._id;", + " const eventId = event.metadata.id;", + " const eventTime = event.metadata.eventTime;", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"_id\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"_updatedDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"1b282868-0a1e-42c6-9123-3a611b0014bf\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"planPrice\": \"0\",", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"e9fff457-bc89-4c8c-94c0-1d162711c9a6\",", + " * \"type\": \"ONLINE\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"eventTime\": \"2024-01-25T11:45:06.792096634Z\",", + " * \"id\": \"0f740093-c77c-4f3e-a307-3e86f659ec74\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -600,13 +933,91 @@ { "title": "onOrderStarted example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderStarted(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderStarted(event) {", + " const eventId = event.metadata.id", + " const entityId = event.data.order._id;", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"_id\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"_updatedDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-25T11:45:05.036Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"1b282868-0a1e-42c6-9123-3a611b0014bf\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-25T11:45:05.036Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"e9fff457-bc89-4c8c-94c0-1d162711c9a6\",", + " * \"type\": \"ONLINE\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"3b620f8b-33f3-4e29-b1db-c21d7a6afa01\",", + " * \"eventTime\": \"2024-01-25T11:45:05.860485075Z\",", + " * \"id\": \"f02f2b76-5044-4f82-b6de-82548a65b37a\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -652,13 +1063,106 @@ { "title": "onOrderUpdated example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderUpdated(event) {", - " const eventId = event.metadata.id", - " const entityId = event.entity._id;", - " }", + "export function wixPricingPlans_onOrderUpdated(event) {", + "\tconst eventId = event.metadata.id", + "\tconst entityId = event.entity._id;", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"entity\": {", + " * \"_createdDate\": \"2024-02-06T06:56:57.193Z\",", + " * \"_id\": \"537a3f44-57bf-4658-9833-47357198d88d\",", + " * \"_updatedDate\": \"2024-02-06T06:57:24.932Z\",", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-06T06:56:57.193Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-06T06:56:57.193Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full feature enablement - lifetime plan\",", + " * \"planId\": \"e901222b-c137-4bc7-adc3-c1efa3c880a2\",", + " * \"planName\": \"Quality Plan - Lifetime\",", + " * \"planPrice\": \"1500\",", + " * \"priceDetails\": {", + " * \"coupon\": {", + " * \"_id\": \"07de4c3a-536b-4c30-adb9-991935da1681\",", + " * \"amount\": \"1500.00\",", + " * \"code\": \"sale-day\"", + " * },", + " * \"currency\": \"USD\",", + " * \"discount\": \"1500.00\",", + " * \"planPrice\": \"1500\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"1500.00\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-02-06T06:56:57.193Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"24bd018a-a4a2-4ca4-b83b-b4af9d6d8eb4\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"2e0c2738-8541-43f5-842b-37c7e94e9f4c\"", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"537a3f44-57bf-4658-9833-47357198d88d\",", + " * \"eventTime\": \"2024-02-06T06:57:26.229867928Z\",", + " * \"id\": \"5212464e-f2c6-423f-b768-05401295b94d\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */", + "", + "" ] } ] From 27fee30dcdb9c08dd879ef7cb505bbeb599c8a2d Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Fri, 9 Feb 2024 09:09:27 +0000 Subject: [PATCH 10/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 195 ++++++++++++++++-- 1 file changed, 183 insertions(+), 12 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index 52c451d875..fc54a3257f 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -1650,21 +1650,192 @@ ], "examples": [ { - "title": "memberGetOrder example", + "title": "Get an order for logged-in member ", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function memberGetOrder(id, options) {", - " try {", - " const result = await orders.memberGetOrder(id, options);", "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "/* Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d' */", + "", + "export async function memberGetOrder(_id) {", + " try {", + " const order = await orders.memberGetOrder(_id);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"_id\": \"7b4ec42c-582a-4e2f-874b-09e66e0ae09d\",", + " * \"_updatedDate\": \"2024-01-28T08:35:16.080Z\",", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"2cf62c7a-d3ed-4dd9-816d-01919aaf2170\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", + " * \"type\": \"ONLINE\"", + " * }", + " */ " + ] + }, + { + "title": "Get an order for a logged-in member with options ", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", + " *", + " * Sample options value:", + " * {", + " * fieldSet: 'FULL'", + " * }", + " */", + "", + "const elevatedMemberGetOrder = elevate(orders.memberGetOrder);", + "", + "export async function memberGetOrder(_id, options) {", + " try {", + " const order = await elevatedMemberGetOrder(_id, options);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-31T10:20:31.602Z\",", + " * \"_id\": \"b14e3821-868f-4aa6-b874-e9240100985c\",", + " * \"_updatedDate\": \"2024-01-31T10:20:32.819Z\",", + " * \"buyer\": {", + " * \"contactId\": \"fa16f1dc-0fbd-41c0-8efc-53333e3fce1e\",", + " * \"memberId\": \"fa16f1dc-0fbd-41c0-8efc-53333e3fce1e\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:20:31.602Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:20:31.602Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {", + " * \"email_0fd2\": \"JV@email.com\",", + " * \"first_name_c551\": \"Jonathan\",", + " * \"form_field_aa30\": false,", + " * \"last_name_78e9\": \"Vernes\",", + " * \"phone_8cf1\": \"918-455-2587\"", + " * },", + " * \"submissionId\": \"9e128ddb-f62f-4a4a-adb5-064af40f18db\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b\",", + " * \"planName\": \"Free Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-31T10:20:31.602Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"1c36ad20-fbc1-4857-8fda-efb8d2cd1a5c\",", + " * \"type\": \"ONLINE\"", + " * }", + " */ ", + "", + "", + "", + "" ] } ] From 869823f91d4cfa61850750a18dedb09ff6cc2cac Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Sun, 11 Feb 2024 09:40:39 +0000 Subject: [PATCH 11/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index 04effafb42..ddcb250063 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -4182,7 +4182,7 @@ "displayName": "OrderAutoRenewCanceled" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4192,7 +4192,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4233,7 +4233,7 @@ "displayName": "OrderCanceled" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4243,7 +4243,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4263,7 +4263,7 @@ "displayName": "Order" } ], - "doc": "" + "doc": "Created Order." }, { "name": "metadata", @@ -4273,7 +4273,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4364,7 +4364,7 @@ "displayName": "OrderCycleStarted" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4374,7 +4374,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4415,7 +4415,7 @@ "displayName": "OrderEndDatePostponed" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4425,7 +4425,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4466,7 +4466,7 @@ "displayName": "OrderEnded" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4476,7 +4476,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4517,7 +4517,7 @@ "displayName": "OrderMarkedAsPaid" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4527,7 +4527,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4568,7 +4568,7 @@ "displayName": "OrderPaused" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4578,7 +4578,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4619,7 +4619,7 @@ "displayName": "OrderPurchased" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4629,7 +4629,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4670,7 +4670,7 @@ "displayName": "OrderResumed" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4680,7 +4680,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4721,7 +4721,7 @@ "displayName": "OrderStartDateChanged" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4731,7 +4731,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4772,7 +4772,7 @@ "displayName": "OrderStarted" } ], - "doc": "" + "doc": "event data." }, { "name": "metadata", @@ -4782,7 +4782,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4802,7 +4802,7 @@ "displayName": "Order" } ], - "doc": "" + "doc": "Updated Order." }, { "name": "metadata", @@ -4812,7 +4812,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { From 9c4239a0494176af7ac37105af6c89bb9aa69b2a Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 12 Feb 2024 09:45:58 +0000 Subject: [PATCH 12/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index fc54a3257f..3efe5a8170 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -72,18 +72,19 @@ "const elevatedCancelOrder = elevate(orders.cancelOrder);", "", "export async function myCancelOrderFunction(_id, effectiveAt) {", - "\ttry {", - "\t\tawait elevatedCancelOrder(_id, effectiveAt);", + " try {", + " await elevatedCancelOrder(_id, effectiveAt);", "", - "\t\treturn;", - "\t} catch (error) {", - "\t\tconsole.error(error);", - "\t\t// Handle the error", - "\t}", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", "}", "", "/* Promise resolves to void */", - " " + " ", + "" ] } ] @@ -2098,7 +2099,7 @@ "", "const elevatedPauseOrder = elevate(orders.pauseOrder);", "", - "export async function pauseOrder(_id) {", + "export async function myPauseOrderFunction(_id) {", " try {", " await elevatedPauseOrder(_id);", "", From c4278f68e8395ae29a03ab1a9a95b021e53ae763 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 12 Feb 2024 09:50:51 +0000 Subject: [PATCH 13/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index ddcb250063..8904227fc9 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -4182,7 +4182,7 @@ "displayName": "OrderAutoRenewCanceled" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4233,7 +4233,7 @@ "displayName": "OrderCanceled" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4263,7 +4263,7 @@ "displayName": "Order" } ], - "doc": "Created Order." + "doc": "Created order." }, { "name": "metadata", @@ -4364,7 +4364,7 @@ "displayName": "OrderCycleStarted" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4415,7 +4415,7 @@ "displayName": "OrderEndDatePostponed" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4466,7 +4466,7 @@ "displayName": "OrderEnded" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4517,7 +4517,7 @@ "displayName": "OrderMarkedAsPaid" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4568,7 +4568,7 @@ "displayName": "OrderPaused" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4619,7 +4619,7 @@ "displayName": "OrderPurchased" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4670,7 +4670,7 @@ "displayName": "OrderResumed" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4721,7 +4721,7 @@ "displayName": "OrderStartDateChanged" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4772,7 +4772,7 @@ "displayName": "OrderStarted" } ], - "doc": "event data." + "doc": "Event data." }, { "name": "metadata", @@ -4802,7 +4802,7 @@ "displayName": "Order" } ], - "doc": "Updated Order." + "doc": "Updated order." }, { "name": "metadata", From 7f629843a0e1b01c40852df1585a4fff639e62aa Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 12 Feb 2024 21:26:03 +0000 Subject: [PATCH 14/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 10 +- .../wix-pricing-plans-v2/Plans.service.json | 273 ++++++++++++++++++ 2 files changed, 278 insertions(+), 5 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index 3efe5a8170..d7f00ab5c7 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -76,14 +76,14 @@ " await elevatedCancelOrder(_id, effectiveAt);", "", " return;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", "}", "", "/* Promise resolves to void */", - " ", + "", "" ] } diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 22b20687ac..e1412e9078 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -2636,6 +2636,26 @@ } ], "messages": [ + { + "name": "ActionEvent", + "members": [ + { + "name": "bodyAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "ApplicationError", "members": [ @@ -3020,6 +3040,199 @@ ] } }, + { + "name": "DomainEvent", + "members": [ + { + "name": "_id", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Unique event ID.\nAllows clients to ignore duplicate webhooks." + }, + { + "name": "actionEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.ActionEvent" + } + ], + "doc": "" + }, + { + "name": "createdEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityCreatedEvent" + } + ], + "doc": "" + }, + { + "name": "deletedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityDeletedEvent" + } + ], + "doc": "" + }, + { + "name": "entityEventSequence", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "A sequence number defining the order of updates to the underlying entity.\nFor example, given that some entity was updated at 16:00 and than again at 16:01,\nit is guaranteed that the sequence number of the second update is strictly higher than the first.\nAs the consumer, you can use this value to ensure that you handle messages in the correct order.\nTo do so, you will need to persist this number on your end, and compare the sequence number from the\nmessage against the one you have stored. Given that the stored number is higher, you should ignore the message." + }, + { + "name": "entityFqdn", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Assumes actions are also always typed to an entity_type\nExample: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction" + }, + { + "name": "entityId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of the entity associated with the event." + }, + { + "name": "eventTime", + "optional": true, + "type": [ + { + "nativeType": "Date" + } + ], + "doc": "Event timestamp." + }, + { + "name": "originatedFrom", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "If present, indicates the action that triggered the event." + }, + { + "name": "slug", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)\nThis is although the created/updated/deleted notion is duplication of the oneof types\nExample: created/updated/deleted/started/completed/email_opened" + }, + { + "name": "triggeredByAnonymizeRequest", + "optional": true, + "type": [ + { + "nativeType": "boolean" + } + ], + "doc": "Whether the event was triggered as a result of a privacy regulation application\n(for example, GDPR)." + }, + { + "name": "updatedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityUpdatedEvent" + } + ], + "doc": "" + } + ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfDomainEventBodyOneOf", + "members": [ + "actionEvent", + "createdEvent", + "deletedEvent", + "updatedEvent" + ] + } + ] + }, + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "DomainEventBodyOneOf", + "members": [ + { + "name": "actionEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.ActionEvent" + } + ], + "doc": "" + }, + { + "name": "createdEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityCreatedEvent" + } + ], + "doc": "" + }, + { + "name": "deletedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityDeletedEvent" + } + ], + "doc": "" + }, + { + "name": "updatedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.EntityUpdatedEvent" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "Duration", "members": [ @@ -3050,6 +3263,66 @@ ] } }, + { + "name": "EntityCreatedEvent", + "members": [ + { + "name": "entityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "EntityDeletedEvent", + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "EntityUpdatedEvent", + "members": [ + { + "name": "currentEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff.\nThis means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects.\nWe don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "Fee", "members": [ From 402738e341149bc990219f68d43be5f395aa4646 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 19 Feb 2024 08:32:23 +0000 Subject: [PATCH 15/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 1037 ++++++++++++++- .../wix-pricing-plans-v2/Plans.service.json | 1114 +++++++++++++++-- 2 files changed, 2005 insertions(+), 146 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index d7f00ab5c7..f55ac7ca3b 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -59,7 +59,7 @@ ], "examples": [ { - "title": "Cancel an order immediately ", + "title": "Cancel an order immediately (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -86,6 +86,36 @@ "", "" ] + }, + { + "title": "Cancel an order immediately (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* ", + " * Sample _id value: 'e6f12ae0-2618-41e7-a643-31ca2ee51e2b'", + " *", + " * Sample effectiveAt value: 'IMMEDIATELY'", + " */", + "", + "const elevatedCancelOrder = elevate(orders.cancelOrder);", + "", + "export const myCancelOrderFunction = webMethod(Permissions.Anyone, async (_id, effectiveAt) => {", + " try {", + " await elevatedCancelOrder(_id, effectiveAt);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, @@ -158,7 +188,7 @@ ], "examples": [ { - "title": "Create an offline order ", + "title": "Create an offline order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -254,13 +284,114 @@ "" ] }, + { + "title": "Create an offline order (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* ", + " * Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' ", + " *", + " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", + " */", + "", + "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", + "", + "export const myCreateOfflineOrderFunction = webMethod(Permissions.Anyone, async (planId, memberId) => {", + " try {", + " const newOrder = await elevatedCreateOfflineOrder(planId, memberId);", + "", + " return newOrder;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"endDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * },", + " * \"freeTrialDays\": 90,", + " * \"lastPaymentStatus\": \"UNPAID\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " */", + "" + ] + }, { "title": "Create an offline order with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "/* Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", + "/* ", + " * Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", " *", " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", " * ", @@ -275,7 +406,7 @@ "", "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", "", - "export async function myCreateOfflineOrderFunctionWithOptions(planId, memberId, options) {", + "export const myCreateOfflineOrderFunctionWithOptions = webMethod(Permissions.Anyone, async (planId, memberId, options) => {", " try {", " const newOrder = await elevatedCreateOfflineOrder(planId, memberId, options);", "", @@ -284,7 +415,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -356,7 +487,8 @@ " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", " * }", " * }", - " */ " + " */ ", + "" ] } ] @@ -430,7 +562,7 @@ ], "examples": [ { - "title": "Create an offline order preview ", + "title": "Create an offline order preview (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -606,9 +738,188 @@ "" ] }, + { + "title": "Create an offline order preview (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", + " *", + " * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b'", + " */", + "", + "const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);", + "", + "export const myGetOfflineOrderPreviewFunction = webMethod(Permissions.Anyone, async (planId, memberId) => {", + " try {", + " const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId);", + "", + " return orderPreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * order: {", + " * \"_createdDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"_id\": \"00000000-0000-0000-0000-000000000000\",", + " * \"_updatedDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * }", + " * ],", + " * \"endDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"earliestEndDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 30,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"order\": {", + " * \"autoRenewCanceled\": false,", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-03-01T08:51:46.516Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-31T08:51:46.516Z\"", + " * }", + " * ],", + " * \"endDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"earliestEndDate\": \"2026-03-01T08:51:46.516Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 30,", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"orderType\": \"OFFLINE\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Complete with all features. One month free trial.\",", + " * \"planId\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"planName\": \"Premium Plan - annual - 30 day trial\",", + " * \"planPrice\": \"500\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"freeTrialDays\": 30,", + " * \"planPrice\": \"500\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\",", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"seller\": {", + " * \"subscriptionId\": \"00000000-0000-0000-0000-000000000000\"", + " * },", + " * \"startDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"type\": \"OFFLINE\"", + " * },", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Complete with all features. One month free trial.\",", + " * \"planId\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"planName\": \"Premium Plan - annual - 30 day trial\",", + " * \"planPrice\": \"500\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"total\": \"500.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-31T08:51:46.516Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"00000000-0000-0000-0000-000000000000\",", + " * \"type\": \"OFFLINE\"", + " * }", + " * \"purchaseLimitExceeded\": false", + " * }", + " */ ", + "" + ] + }, { "title": "Create an offline order preview with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -625,7 +936,7 @@ "", "const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);", "", - "export async function myGetOfflineOrderPreviewFunction(planId, memberId, options) {", + "export const myGetOfflineOrderPreviewFunction = webMethod(Permissions.Anyone, async (planId, memberId, options) => {", " try {", " const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId, options);", "", @@ -634,7 +945,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -732,7 +1043,8 @@ " * },", " * \"purchaseLimitExceeded\": false", " * }", - " */ " + " */ ", + "" ] } ] @@ -795,7 +1107,7 @@ ], "examples": [ { - "title": "Get a price preview for an order ", + "title": "Get a price preview for an order", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -841,9 +1153,59 @@ " */ " ] }, + { + "title": "Get a price preview for an order (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "// Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' ", + "", + "const elevatedGetPricePreview = elevate(orders.getPricePreview);", + "", + "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId) => {", + " try {", + " const pricePreview = await elevatedGetPricePreview(planId)", + "", + " return pricePreview;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "/* Promise resolves to:", + " * {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\"", + " * \"proration\": \"0\",", + " * \"subtotal\": \"500.00\",", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"32.50\"", + " * },", + " * \"total\": \"532.50\"", + " * }", + " * }", + " * ]", + " * }", + " */", + "" + ] + }, { "title": "Get a price preview for an order with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -857,7 +1219,7 @@ "", "const elevatedGetPricePreview = elevate(orders.getPricePreview);", "", - "export async function myGetPricePreviewFunction(planId, options) {", + "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId, options) => {", " try {", " const pricePreview = await elevatedGetPricePreview(planId, options)", "", @@ -866,7 +1228,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -918,7 +1280,8 @@ " * }", " * ]", " * }", - " */ " + " */ ", + "" ] } ] @@ -980,16 +1343,106 @@ ], "examples": [ { - "title": "Get an order ", + "title": "Get an order (dashboard page code)", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' */", + "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", + "", + "export async function myManagementGetOrderFunction(_id) {", + " try {", + " const order = await elevatedManagementGetOrder(_id);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * order: {", + " * \"_createdDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"_id\": \"12178428-36b7-4cf5-bfb5-0ba8c83c4e8c\",", + " * \"_updatedDate\": \"2024-01-31T10:59:17.495Z\",", + " * \"buyer\": {", + " * \"contactId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\",", + " * \"memberId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-31T10:59:16.422Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"e65d5d60-7e07-4d2f-971f-e471dcebd0d2\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-31T10:59:16.422Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"b1e7d751-7727-4c07-a0b5-0ab017ef7d1b\",", + " * \"type\": \"ONLINE\"", + " * }", + " * }", + " */ " + ] + }, + { + "title": "Get an order (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' */", + "// Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' ", "", - "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder);", "", - "export async function myManagementGetOrderFunction(_id) {", + "export const myManagementGetOrderFunction = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const order = await elevatedManagementGetOrder(_id);", "", @@ -998,7 +1451,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1065,12 +1518,14 @@ " * \"type\": \"ONLINE\"", " * }", " * }", - " */ " + " */", + "" ] }, { "title": "Get an order with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -1081,11 +1536,11 @@ " * fieldSet: 'FULL'", " * }", " * ", - "*/", + " */", "", - "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder);", "", - "export async function myManagementGetOrderFunction(_id) {", + "export const myManagementGetOrderFunction = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const order = await elevatedManagementGetOrder(_id);", "", @@ -1094,7 +1549,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1276,7 +1731,7 @@ ], "examples": [ { - "title": "List pricing plan orders ", + "title": "List pricing plan orders (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -1379,9 +1834,114 @@ "" ] }, + { + "title": "List pricing plan orders (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", + "", + "export const myManagementListOrdersFunction = webMethod(Permissions.Anyone, async () => {", + " try {", + " const ordersList = await elevatedManagementListOrders();", + "", + " return ordersList;", + " } catch (error){", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"orders\": [", + " * {", + " * \"_createdDate\": \"2024-01-22T14:00:53.904Z\",", + " * \"_id\": \"14fac8ae-506e-4e7b-84d4-e9b094d0ddca\",", + " * \"_updatedDate\": \"2024-01-22T14:00:54.772Z\",", + " * \"buyer\": {", + " * \"contactId\": \"f5691fc2-0674-4eee-92c5-da06a05981a5\",", + " * \"memberId\": \"f5691fc2-0674-4eee-92c5-da06a05981a5\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-22T14:00:53.904Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-22T14:00:53.904Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"\",", + " * \"planId\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"planName\": \"Default\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"priceDetails\": {", + " * \"currency\": \"EUR\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"startDate\": \"2024-01-22T14:00:53.904Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"19276032-d06f-4931-962f-79486d8b6bc0\",", + " * \"type\": \"ONLINE\"", + " * }", + " * ],", + " * \"pagingMetadata\": {", + " * \"count\": 1,", + " * \"hasNext\": false,", + " * \"offset\": 0,", + " * \"total\": 1", + " * }", + " * }", + " */ ", + "" + ] + }, { "title": "List pricing plan orders with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -1424,7 +1984,7 @@ "", "const elevatedManagementListOrders = elevate(orders.managementListOrders);", "", - "export async function myManagementListOrdersFunction(options) {", + "export const myManagementListOrdersFunction = webMethod(Permissions.Anyone, async (options) => {", " try {", " const ordersList = await elevatedManagementListOrders(options);", "", @@ -1433,7 +1993,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1515,7 +2075,8 @@ " * }", " * }", " */ ", - " " + " ", + "" ] } ] @@ -1568,7 +2129,7 @@ ], "examples": [ { - "title": "Mark an order as paid ", + "title": "Mark an order as paid (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -1590,6 +2151,32 @@ "", "/* Promise resolves to void */" ] + }, + { + "title": "Mark an order as paid (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "// Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5'", + "", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export const myMarkAsPaidFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " await elevatedMarkAsPaid(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, @@ -1651,13 +2238,99 @@ ], "examples": [ { - "title": "Get an order for logged-in member ", + "title": "Get an order for logged-in member", + "body": [ + "import { orders } from 'wix-pricing-plans.v2';", + "", + "/* Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d' */", + "", + "export async function memberGetOrder(_id) {", + " try {", + " const order = await orders.memberGetOrder(_id);", + "", + " return order;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"_id\": \"7b4ec42c-582a-4e2f-874b-09e66e0ae09d\",", + " * \"_updatedDate\": \"2024-01-28T08:35:16.080Z\",", + " * \"buyer\": {", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"2cf62c7a-d3ed-4dd9-816d-01919aaf2170\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"planName\": \"Standard Plan\",", + " * \"planPrice\": \"0\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"0\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"0.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", + " * \"type\": \"ONLINE\"", + " * }", + " */ " + ] + }, + { + "title": "Get an order for logged-in member (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "", - "/* Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d' */", + "// Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", "", - "export async function memberGetOrder(_id) {", + "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const order = await orders.memberGetOrder(_id);", "", @@ -1666,7 +2339,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1732,16 +2405,19 @@ " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", " * \"type\": \"ONLINE\"", " * }", - " */ " + " */", + "" ] }, { "title": "Get an order for a logged-in member with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "/* Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", + "/* ", + " * Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", " *", " * Sample options value:", " * {", @@ -1751,7 +2427,7 @@ "", "const elevatedMemberGetOrder = elevate(orders.memberGetOrder);", "", - "export async function memberGetOrder(_id, options) {", + "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id, options) => {", " try {", " const order = await elevatedMemberGetOrder(_id, options);", "", @@ -1760,7 +2436,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1832,10 +2508,7 @@ " * \"subscriptionId\": \"1c36ad20-fbc1-4857-8fda-efb8d2cd1a5c\",", " * \"type\": \"ONLINE\"", " * }", - " */ ", - "", - "", - "", + " */", "" ] } @@ -1881,7 +2554,7 @@ ], "examples": [ { - "title": "Get orders for currently logged in members ", + "title": "Get orders for currently logged in members", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "", @@ -2040,6 +2713,169 @@ " * }", " */ " ] + }, + { + "title": "Get orders for currently logged in members (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "", + "export const myMemberListOrdersFunction = webMethod(Permissions.Anyone, async () => {", + " try {", + " const ordersList = await orders.memberListOrders();", + " return ordersList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"orders\": [", + " * {", + " * \"planPrice\": \"0\",", + " * \"_id\": \"292c6b6b-81ec-4c10-b067-78b1a1b2fada\",", + " * \"_createdDate\": \"2024-02-05T17:26:23.348Z\",", + " * \"subscriptionId\": \"973e0e0b-85c2-4d2b-9693-fc8f1140d958\",", + " * \"pausePeriods\": [],", + " * \"_updatedDate\": \"2024-02-05T17:26:24.129Z\",", + " * \"planName\": \"Free Plan\",", + " * \"buyer\": {", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"status\": \"ACTIVE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"\",", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionId\": \"6d68798b-b5ea-4471-b029-dea6e4ac043a\",", + " * \"submissionData\": {}", + " * },", + " * \"statusNew\": \"ACTIVE\",", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-05T17:26:23.348Z\"", + " * }", + " * ],", + " * \"type\": \"ONLINE\",", + " * \"planId\": \"3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b\",", + " * \"startDate\": \"2024-02-05T17:26:23.348Z\",", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-05T17:26:23.348Z\"", + " * },", + " * \"pricing\": {", + " * \"singlePaymentUnlimited\": true,", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"0\"", + " * },", + " * \"total\": \"0\",", + " * \"proration\": \"0\",", + " * \"fees\": [],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\"", + " * }", + " * }", + " * ]", + " * },", + " * \"priceDetails\": {", + " * \"planPrice\": \"0\",", + " * \"tax\": {", + " * \"name\": \"Tax\",", + " * \"includedInPrice\": false,", + " * \"rate\": \"6.5\",", + " * \"amount\": \"0\"", + " * },", + " * \"total\": \"0\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\",", + " * \"singlePaymentUnlimited\": true", + " * }", + " * },", + " * {", + " * \"planPrice\": \"0\",", + " * \"_id\": \"7b4ec42c-582a-4e2f-874b-09e66e0ae09d\",", + " * \"_createdDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", + " * \"pausePeriods\": [],", + " * \"_updatedDate\": \"2024-01-28T08:35:16.080Z\",", + " * \"planName\": \"Standard Plan\",", + " * \"buyer\": {", + " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", + " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * },", + " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", + " * \"status\": \"ACTIVE\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"planDescription\": \"Full functionality for new users\",", + " * \"formData\": {", + " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", + " * \"submissionId\": \"2cf62c7a-d3ed-4dd9-816d-01919aaf2170\",", + " * \"submissionData\": {}", + " * },", + " * \"statusNew\": \"ACTIVE\",", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * }", + " * ],", + " * \"type\": \"ONLINE\",", + " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", + " * \"startDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * },", + " * \"pricing\": {", + " * \"singlePaymentUnlimited\": true,", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"total\": \"0\",", + " * \"proration\": \"0\",", + " * \"fees\": [],", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\"", + " * }", + " * }", + " * ]", + " * },", + " * \"priceDetails\": {", + " * \"planPrice\": \"0\",", + " * \"total\": \"0\",", + " * \"currency\": \"USD\",", + " * \"subtotal\": \"0.00\",", + " * \"discount\": \"0\",", + " * \"singlePaymentUnlimited\": true", + " * }", + " * }", + " * ]", + " * }", + " */ ", + "" + ] } ] }, @@ -2090,7 +2926,7 @@ ], "examples": [ { - "title": "Pause a pricing plan order ", + "title": "Pause a pricing plan order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -2112,6 +2948,32 @@ "", "/* Promise resolves to void */" ] + }, + { + "title": "Pause a pricing plan order (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "// Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22'", + "", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", + "", + "export const myPauseOrderFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " await elevatedPauseOrder(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, @@ -2174,7 +3036,7 @@ ], "examples": [ { - "title": "Postpone an order's end date ", + "title": "Postpone an order's end date (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans-backend';", "import { elevate } from 'wix-auth';", @@ -2199,6 +3061,36 @@ "", "/* Promise that resolves to void */" ] + }, + { + "title": "Postpone an order's end date (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans-backend';", + "import { elevate } from 'wix-auth';", + "", + "/* ", + " * Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5'", + " * ", + " * Sample endDate value: new Date('June 30, 2026 04:00:00')", + " */", + "", + "const elevatedPostponeEndDate = elevate(orders.postponeEndDate);", + "", + "export const myPostponeEndDateFunction = webMethod(Permissions.Anyone, async (_id, endDate) => {", + " try {", + " await elevatedPostponeEndDate(_id, endDate);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise that resolves to void */", + "" + ] } ] }, @@ -2261,7 +3153,7 @@ ], "examples": [ { - "title": "Cancel an order immediately ", + "title": "Cancel an order immediately", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "", @@ -2283,6 +3175,33 @@ "", "/* Promise resolves to void */" ] + }, + { + "title": "Cancel an order immediately (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "", + "/* ", + " * Sample _id value: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", + " *", + " * Sample effectiveAt value: 'IMMEDIATELY'", + " */", + "", + "export const myRequestCancellationFunction = webMethod(Permissions.Anyone, async (_id, effectiveAt) => {", + " try {", + " await orders.requestCancellation(_id, effectiveAt);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, @@ -2333,7 +3252,7 @@ ], "examples": [ { - "title": "Resume an order ", + "title": "Resume an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -2356,6 +3275,32 @@ "/* Promise resolves to void */", "" ] + }, + { + "title": "Resume an order (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "// Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22'", + "", + "const elevatedResumeOrder = elevate(orders.resumeOrder);", + "", + "export const myResumeOrderFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " await elevatedResumeOrder(_id);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index e1412e9078..7501f1fd86 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -48,7 +48,7 @@ ], "examples": [ { - "title": "Archive a plan ", + "title": "Archive a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -101,6 +101,61 @@ " */", "" ] + }, + { + "title": "Archive a plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */", + "", + "export const myArchivePlanFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " const elevatedArchivePlan = elevate(plans.archivePlan);", + " const archivedPlan = await elevatedArchivePlan(_id);", + "", + " return archivedPlan;", + " } catch(error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2023-12-31T11:23:01.664Z\",", + " * \"_id\": \"1421abaa-44c7-42ae-8a75-960fe7a8aa55\",", + " * \"_updatedDate\": \"2024-01-08T11:24:18.561Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": true,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Free Plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Basic\",", + " * \"perks\": {", + " * \"values\": []", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"0\"", + " * },", + " * \"singlePaymentForDuration\": {", + " * \"count\": 3,", + " * \"unit\": \"MONTH\"", + " * }", + " * },", + " * \"primary\": false,", + " * \"public\": false,", + " * \"slug\": \"basic\",", + " * \"termsAndConditions\": \"After 90 day free trial ends, your plan will end and you will need to purchase a paid plan.\"", + " * } ", + " */" + ] } ] }, @@ -154,7 +209,7 @@ ], "examples": [ { - "title": "Arrange plans ", + "title": "Arrange plans (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -185,19 +240,52 @@ "" ] }, + { + "title": "Arrange plans (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample ids value:", + " * [", + " * \"7a3375ce-18a9-42cb-8e39-47918ade45ec\",", + " * \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990 \"", + " * ]", + " */", + "", + "export const myArrangePlansFunction = webMethod(Permissions.Anyone, async (ids) => {", + " try {", + " const elevatedArrangePlans = elevate(plans.arrangePlans);", + " const arranged = await elevatedArrangePlans(ids);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */" + ] + }, { "title": "Sort plans alphabetically ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", "const elevatedArrangePlans = elevate(plans.arrangePlans);", "", - "export async function sortPlansBySlug(direction) {", + "export const sortPlansBySlug = webMethod(Permissions.Anyone, async (direction) => {", " let publicPlansQuery = plans.queryPublicPlans();", "", " if (direction === 'ascending') {", @@ -210,13 +298,13 @@ " const planIds = sortedPlans.items.map(item => item._id);", "", " return await elevatedArrangePlans(planIds);", - "}", + "});", "", "/*************", " * Page code *", " *************/", "", - "import { sortPlansBySlug } from 'backend/plan-functions';", + "import { sortPlansBySlug } from 'backend/plan-functions.web';", "import wixLocationFrontend from 'wix-location-frontend';", "", "$w.onReady(function () {", @@ -238,7 +326,8 @@ " const url = wixLocationFrontend.url;", " wixLocationFrontend.to(url);", " })", - "});" + "});", + "" ], "extra": { "description": "Select a sorting option to arranage plans in ascending or descending order by plan slug. " @@ -276,7 +365,7 @@ ], "examples": [ { - "title": "Clear the primary plan ", + "title": "Clear the primary plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -295,6 +384,29 @@ "", "/* Promise resolves to void */" ] + }, + { + "title": "Clear the primary plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export const myClearPrimaryFunction = webMethod(Permissions.Anyone, async () => {", + " try {", + " const elevatedClearPrimary = elevate(plans.clearPrimary);", + " const clearedPrimary = await elevatedClearPrimary();", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to void */", + "" + ] } ] }, @@ -347,17 +459,42 @@ ], "examples": [ { - "title": "Create a simple plan ", + "title": "Create a plan with optional fields (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "/* Sample plan object:", + "/* Sample plan value:", " * {", - " * name: 'Default',", + " * allowFutureStartDate: true,", + " * buyerCanCancel: true,", + " * description: 'Fun content for our younger users',", + " * formId: 'ee62cefa-bdc2-4b5d-baab-6faeef83cecb',", + " * maxPurchasesPerBuyer: 1,", + " * name: 'Junior',", + " * perks: {", + " * values: [", + " * 'Multiplayer',", + " * 'Multiple devices',", + " * 'No ads\",", + " * 'Unlimited access'", + " * ]", + " * },", " * pricing: {", - " * singlePaymentUnlimited: true", - " * }", + " * price: {", + " * currency: 'USD',", + " * value: '10.00\"", + " * },", + " * subscription: {", + " * cycleCount: 12,", + " * cycleDuration: {", + " * count: 1,", + " * unit: 'MONTH'", + " * }", + " * }", + " * },", + " * public: true,", + " * termsAndConditions: 'No sharing access with others!'", " * }", " */", "", @@ -366,6 +503,10 @@ " const elevatedCreatePlan = elevate(plans.createPlan);", " const newPlan = await elevatedCreatePlan(plan);", "", + " const planId = newPlan._id;", + " const pricingObject = newPlan.pricing;", + " const perks = newPlan.perks;", + "", " return newPlan;", " } catch (error) {", " console.error(error);", @@ -375,36 +516,50 @@ "", "/* Promise resolves to:", " * {", - " * \"_createdDate\": \"2024-01-16T10:32:05.818Z\",", - " * \"_id\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", - " * \"_updatedDate\": \"2024-01-16T10:32:05.818Z\",", - " * \"allowFutureStartDate\": false,", + " * \"_createdDate\": \"2024-01-21T07:06:06.993Z\",", + " * \"_id\": \"046371ff-7e5d-4bdb-a01d-a00ff462bed8\",", + " * \"_updatedDate\": \"2024-01-21T07:06:06.993Z\",", + " * \"allowFutureStartDate\": true,", " * \"archived\": false,", " * \"buyerCanCancel\": true,", - " * \"description\": \"\",", + " * \"description\": \"Fun content for our younger users\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", " * \"hasOrders\": false,", - " * \"name\": \"Default\",", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Junior\",", " * \"perks\": {", - " * \"values\": []", + " * \"values\": [", + " * \"Multiplayer\",", + " * \"Multiple devices\",", + " * \"No ads\",", + " * \"Unlimited access\"", + " * ]", " * },", " * \"pricing\": {", " * \"price\": {", - " * \"currency\": \"EUR\",", - " * \"value\": \"0\"", + " * \"currency\": \"USD\",", + " * \"value\": \"10.00\"", " * },", - " * \"singlePaymentUnlimited\": true", - " * },", - " * \"primary\": false,", - " * \"public\": true,", - " * \"slug\": \"default\"", + " * \"public\": true,", + " * \"slug\": \"junior\",", + " * \"subscription\": {", + " * \"cycleCount\": 12,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * },", + " * \"termsAndConditions\": \"No sharing access with others!\"", + " * }", " * }", " */ ", "" ] }, { - "title": "Create a plan with optional fields ", + "title": "Create a plan with optional fields (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -442,7 +597,7 @@ " * }", " */", "", - "export async function myCreatePlanFunction(plan) {", + "export const myCreatePlanFunction = webMethod(Permissions.Anyone, async (plan) => {", " try {", " const elevatedCreatePlan = elevate(plans.createPlan);", " const newPlan = await elevatedCreatePlan(plan);", @@ -456,7 +611,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -500,13 +655,70 @@ "" ] }, + { + "title": "Create a simple plan ", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample plan object:", + " * {", + " * name: 'Default',", + " * pricing: {", + " * singlePaymentUnlimited: true", + " * }", + " * }", + " */", + "", + "export const myCreatePlanFunction = webMethod(Permissions.Anyone, async (plan) => {", + " try {", + " const elevatedCreatePlan = elevate(plans.createPlan);", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-16T10:32:05.818Z\",", + " * \"_id\": \"aa0d8e0e-99ad-4c95-ac48-4955e37956c5\",", + " * \"_updatedDate\": \"2024-01-16T10:32:05.818Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"\",", + " * \"hasOrders\": false,", + " * \"name\": \"Default\",", + " * \"perks\": {", + " * \"values\": []", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"0\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"primary\": false,", + " * \"public\": true,", + " * \"slug\": \"default\"", + " * }", + " */" + ] + }, { "title": "Duplicate a plan ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -514,7 +726,7 @@ "const elevatedGetPlan = elevate(plans.getPlan);", "const elevatedCreatePlan = elevate(plans.createPlan);", "", - "export async function listPlans() {", + "export const listPlans = webMethod(Permissions.Anyone, async () => {", " try {", " const response = await elevatedListPlans();", " const allPlans = response.plans;", @@ -524,9 +736,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function getPlan(planId) {", + "export const getPlan = webMethod(Permissions.Anyone, async (planId) => {", " try {", " const selectedPlan = await elevatedGetPlan(planId);", "", @@ -535,9 +747,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function createPlan(plan) {", + "export const createPlan = webMethod(Permissions.Anyone, async (plan) => {", " try {", " const newPlan = await elevatedCreatePlan(plan);", "", @@ -546,14 +758,14 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "", "/*************", " * Page code *", " *************/", "", - "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions.web';", "$w.onReady(async function () {", " $w('#plansDropdown').disable();", " $w('#clonePlanBtn').disable();", @@ -640,7 +852,7 @@ ], "examples": [ { - "title": "Get a plan ", + "title": "Get a plan (dashboard page code)", "body": [ "import { plans} from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -700,13 +912,76 @@ " */" ] }, + { + "title": "Get a plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", + "", + "export const myGetPlanFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " const elevatedGetPlan = elevate(plans.getPlan);", + " const myPlan = await elevatedGetPlan(_id);", + "", + " return myPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-07T07:28:42.863Z\",", + " * \"_id\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"_updatedDate\": \"2024-01-07T08:36:07.520Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Complete with all features. One month free trial.\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - annual - 30 day trial\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Unlimited video library streaming access\",", + " * \"File sharing enabled for all channels\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"freeTrialDays\": 30,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"500\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"primary\": false,", + " * \"public\": true,", + " * \"slug\": \"premium-plan-annual-30-day-trial-1\",", + " * \"termsAndConditions\": \"Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.\"", + " * } ", + " */" + ] + }, { "title": "Duplicate a plan ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -714,7 +989,7 @@ "const elevatedGetPlan = elevate(plans.getPlan);", "const elevatedCreatePlan = elevate(plans.createPlan);", "", - "export async function listPlans() {", + "export const listPlans = webMethod(Permissions.Anyone, async () => {", " try {", " const response = await elevatedListPlans();", " const allPlans = response.plans;", @@ -724,9 +999,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function getPlan(planId) {", + "export const getPlan = webMethod(Permissions.Anyone, async (planId) => {", " try {", " const selectedPlan = await elevatedGetPlan(planId);", "", @@ -735,9 +1010,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function createPlan(plan) {", + "export const createPlan = webMethod(Permissions.Anyone, async (plan) => {", " try {", " const newPlan = await elevatedCreatePlan(plan);", "", @@ -746,14 +1021,14 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "", "/*************", " * Page code *", " *************/", "", - "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions.web';", "$w.onReady(async function () {", " $w('#plansDropdown').disable();", " $w('#clonePlanBtn').disable();", @@ -827,7 +1102,7 @@ ], "examples": [ { - "title": "Get number of plans ", + "title": "Get number of plans (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -850,6 +1125,33 @@ " * }", " */" ] + }, + { + "title": "Get number of plans (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export const myGetPlanStatsFunction = webMethod(Permissions.Anyone, async () => {", + " try {", + " const elevatedGetPlanStats = elevate(plans.getPlanStats);", + " const planStats = elevatedGetPlanStats();", + "", + " return planStats;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"totalPlans\": 8 ", + " * }", + " */", + "" + ] } ] }, @@ -896,10 +1198,11 @@ { "title": "List plans ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "export async function myListPlansFunction() {", + "export const myListPlansFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const elevatedListPlans = elevate(plans.listPlans);", " const plansList = await elevatedListPlans();", @@ -909,7 +1212,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1026,12 +1329,14 @@ " * }", " * ]", " * } ", - " */ " + " */", + "" ] }, { "title": "List plans with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -1042,7 +1347,7 @@ " * }", " */", "", - "export async function myListPlansFunction(options) {", + "export const myListPlansFunction = webMethod(Permissions.Anyone, async (options) => {", " try {", " const elevatedListPlans = elevate(plans.listPlans);", " const plansList = await elevatedListPlans(options);", @@ -1052,7 +1357,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1190,7 +1495,8 @@ " * }", " * ]", " * }", - " */" + " */", + "" ] }, { @@ -1331,12 +1637,217 @@ ], "examples": [ { - "title": "List public plans ", + "title": "List public plans", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export async function myListPublicPlansFunction() {", + " try {", + " const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + " const plansList = await elevatedListPublicPlans();", + "", + " return plansList;", + " } catch(error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * { ", + " * \"pagingMetadata\": {", + " * \"count\": 5,", + " * \"hasNext\": false,", + " * \"offset\": 0,", + " * \"total\": 5", + " * },", + " * \"plans\": [", + " * {", + " * \"_createdDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"_id\": \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", + " * \"_updatedDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"The value plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Silver Membership - Monthly\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Full site access\",", + " * \"Full video access\",", + " * \"Consultation booking\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"freeTrialDays\": 14,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"100\"", + " * },", + " * \"slug\": \"silver-membership-monthly\",", + " * \"subscription\": {", + " * \"cycleCount\": 0,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * }", + " * },", + " * \"termsAndConditions\": \"\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", + " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"_updatedDate\": \"2024-01-09T09:08:05.665Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Full feature enablement - lifetime plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - Lifetime Membership\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Cloud drive and file upload services\",", + " * \"Unlimited video content access\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"1000\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"slug\": \"premium-plan-lifetime-membership\",", + " * \"termsAndConditions\": \"This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.\",", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:28:42.863Z\",", + " * \"_id\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"_updatedDate\": \"2024-01-07T08:36:07.520Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Complete with all features. One month free trial.\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - annual - 30 day trial\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Unlimited video library streaming access\",", + " * \"File sharing enabled for all channels\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * },", + " * \"freeTrialDays\": 30,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"500\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"slug\": \"premium-plan-annual-30-day-trial-1\",", + " * \"termsAndConditions\": \"Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.\",", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:10:30.074Z\",", + " * \"_id\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"_updatedDate\": \"2024-01-07T07:10:30.074Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"3 mo free trial with discount for 1 year\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Beginner's Plan\",", + " * \"perks\": {", + " * \"values\": []", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * },", + " * \"freeTrialDays\": 90,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"50\"", + " * }", + " * },", + " * \"slug\": \"beginners-plan\",", + " * \"termsAndConditions\": \"\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T08:18:16.411Z\",", + " * \"_id\": \"7a3375ce-18a9-42cb-8e39-47918ade45ec\",", + " * \"_updatedDate\": \"2024-01-07T08:18:16.411Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Affordable with great functionality. Expires after 1 year\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Basic Plan - monthly subscription\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Access to select video channels\",", + " * \"Access to rich site content\",", + " * \"Access to designated file store\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 12,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"5\"", + " * },", + " * \"slug\": \"basic-plan-monthly-subscription\"", + " * },", + " * \"termsAndConditions\": \"\"", + " * }", + " * ],", + " * }", + " */" + ] + }, + { + "title": "List public plans (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", - "export async function myListPublicPlansFunction() {", + "export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const elevatedListPublicPlans = elevate(plans.listPublicPlans);", " const plansList = await elevatedListPublicPlans();", @@ -1346,7 +1857,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * { ", @@ -1531,12 +2042,14 @@ " * }", " * ],", " * }", - " */" + " */", + "" ] }, { "title": "List public plans with options ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -1555,7 +2068,7 @@ " * }", " */", "", - "export async function myListPublicPlansFunction(options) {", + "export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async (options) => {", " try {", " const elevatedListPublicPlans = elevate(plans.listPublicPlans);", " const plansList = await elevatedListPublicPlans(options);", @@ -1565,7 +2078,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1679,24 +2192,24 @@ " * }", " * ]", " * }", - " */ ", - "" + " */" ] }, { "title": "Make a plan primary ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", "const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", "", - "export async function listPublicPlans() {", + "export const listPublicPlans = webMethod(Permissions.Anyone, async () => {", " try {", " const response = await elevatedListPublicPlans();", " const plansList = response.plans;", @@ -1706,9 +2219,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function makePlanPrimaryFunction(_id) {", + "export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const primaryPlan = await elevatedMakePlanPrimary(_id);", "", @@ -1717,25 +2230,25 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/*************", " * Page code *", " *************/", "", - "import planFunctions from 'backend/plan-functions';", + "import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';", "", "$w.onReady(function () {", " populateDropdown();", " $w('#plansList').onChange(async () => {", - " await planFunctions.makePlanPrimaryFunction(", + " await makePlanPrimaryFunction(", " $w('#plansList').value", " )", " });", "});", "", "async function populateDropdown() {", - " const plans = await planFunctions.listPublicPlans();", + " const plans = await listPublicPlans();", " $w('#plansList').options = plans.map(item => ({", " label: item.name,", " value: item._id", @@ -1791,7 +2304,7 @@ ], "examples": [ { - "title": "Make a plan a primary plan ", + "title": "Make a plan a primary plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -1844,20 +2357,77 @@ " */" ] }, + { + "title": "Make a plan a primary plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' */", + "", + "export const myMakePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", + " const primaryPlan = await elevatedMakePlanPrimary(_id);", + "", + " return primaryPlan;", + " } catch(error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", + " * \"_updatedDate\": \"2024-01-07T13:32:11.263Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Full feature enablement - lifetime plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - Lifetime Membership\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Cloud drive and file upload services\",", + " * \"Unlimited video content access\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"1000\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"primary\": true,", + " * \"public\": true,", + " * \"slug\": \"premium-plan-lifetime-membership\",", + " * \"termsAndConditions\": \"This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.\"", + " * }", + " */", + "" + ] + }, { "title": "Make a plan primary ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", "const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", "", - "export async function listPublicPlans() {", + "export const listPublicPlans = webMethod(Permissions.Anyone, async () => {", " try {", " const response = await elevatedListPublicPlans();", " const plansList = response.plans;", @@ -1867,9 +2437,9 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "export async function makePlanPrimaryFunction(_id) {", + "export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const primaryPlan = await elevatedMakePlanPrimary(_id);", "", @@ -1878,25 +2448,25 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/*************", " * Page code *", " *************/", "", - "import planFunctions from 'backend/plan-functions';", + "import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';", "", "$w.onReady(function () {", " populateDropdown();", " $w('#plansList').onChange(async () => {", - " await planFunctions.makePlanPrimaryFunction(", + " await makePlanPrimaryFunction(", " $w('#plansList').value", " )", " });", "});", "", "async function populateDropdown() {", - " const plans = await planFunctions.listPublicPlans();", + " const plans = await listPublicPlans();", " $w('#plansList').options = plans.map(item => ({", " label: item.name,", " value: item._id", @@ -1956,11 +2526,215 @@ ], "examples": [ { - "title": "Build and execute a query to find all public plans ", + "title": "Build and execute a query to find all public plans", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "", + "export async function myQueryPublicPlansFunction() {", + " try {", + " const results = await plans.queryPublicPlans().find();", + " const items = results.items;", + " const firstItem = items[0];", + " const length = results.length;", + " const currentPage = results.currentPage;", + "", + " return items;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Returned items:", + " * [", + " * {", + " * \"_createdDate\": \"2024-01-07T08:18:16.411Z\",", + " * \"_id\": \"7a3375ce-18a9-42cb-8e39-47918ade45ec\",", + " * \"_updatedDate\": \"2024-01-07T08:18:16.411Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Affordable with great functionality. Expires after 1 year\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Basic Plan - monthly subscription\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Access to select video channels\",", + " * \"Access to rich site content\",", + " * \"Access to designated file store\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 12,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * },", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"5\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 12,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * }", + " * },", + " * \"slug\": \"basic-plan-monthly-subscription\",", + " * \"termsAndConditions\": \"\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:10:30.074Z\",", + " * \"_id\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"_updatedDate\": \"2024-01-07T07:10:30.074Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"3 mo free trial with discount for 1 year\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Beginner's Plan\",", + " * \"perks\": {", + " * \"values\": []", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * },", + " * \"freeTrialDays\": 90,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"50\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"slug\": \"beginners-plan\",", + " * \"termsAndConditions\": \"\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:28:42.863Z\",", + " * \"_id\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"_updatedDate\": \"2024-01-07T08:36:07.520Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Complete with all features. One month free trial.\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - annual - 30 day trial\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Unlimited video library streaming access\",", + " * \"File sharing enabled for all channels\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * },", + " * \"freeTrialDays\": 30,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"500\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"slug\": \"premium-plan-annual-30-day-trial-1\",", + " * \"termsAndConditions\": \"Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", + " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"_updatedDate\": \"2024-01-09T09:08:05.665Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Full feature enablement - lifetime plan\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - Lifetime Membership\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Cloud drive and file upload services\",", + " * \"Unlimited video content access\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"1000\",", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"slug\": \"premium-plan-lifetime-membership\",", + " * \"termsAndConditions\": \"This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"_id\": \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", + " * \"_updatedDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"The value plan\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Silver Membership - Monthly\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Full site access\",", + " * \"Full video access\",", + " * \"Consultation booking\"", + " * ]", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"100\",", + " * \"freeTrialDays\": 14,", + " * \"subscription\": {", + " * \"cycleCount\": 0,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * }", + " * },", + " * \"slug\": \"silver-membership-monthly\",", + " * \"termsAndConditions\": \"\"", + " * }", + " * ]", + " */" + ] + }, + { + "title": "Build and execute a query to find all public plans (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "", - "export async function myQueryPublicPlansFunction() {", + "export const myQueryPublicPlansFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const results = await plans.queryPublicPlans().find();", " const items = results.items;", @@ -1973,7 +2747,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Returned items:", " * [", @@ -2155,15 +2929,17 @@ " * \"termsAndConditions\": \"\"", " * }", " * ]", - " */" + " */", + "" ] }, { "title": "Build and execute query to retrieve primary plan ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "", - "export async function myQueryPublicPlansFunction() {", + "export const myQueryPublicPlansFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const results = ", " await plans.queryPublicPlans()", @@ -2176,7 +2952,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Returned item:", " * {", @@ -2211,15 +2987,17 @@ " * \"slug\": \"premium-plan-annual-30-day-trial-1\",", " * \"termsAndConditions\": \"Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.\"", " * }", - " */ " + " */ ", + "" ] }, { "title": "Build and execute a query for a specific plan ID given its slug ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "", - "export async function myQueryPublicPlansFunction4() {", + "export const myQueryPublicPlansFunction4 = webMethod(Permissions.Anyone, async () => {", " try {", " const results = ", " await plans.queryPublicPlans()", @@ -2232,24 +3010,26 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "/* Returned item: '7a3375ce-18a9-42cb-8e39-47918ade45ec' */" + "/* Returned item: '7a3375ce-18a9-42cb-8e39-47918ade45ec' */", + "" ] }, { "title": "Sort plans alphabetically ", "body": [ "/*************************************", - " * Backend code - plan-functions.jsw *", + " * Backend code - plan-functions.web.js *", " *************************************/", "", + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", "const elevatedArrangePlans = elevate(plans.arrangePlans);", "", - "export async function sortPlansBySlug(direction) {", + "export const sortPlansBySlug = webMethod(Permissions.Anyone, async (direction) => {", " let publicPlansQuery = plans.queryPublicPlans();", "", " if (direction === 'ascending') {", @@ -2262,13 +3042,13 @@ " const planIds = sortedPlans.items.map(item => item._id);", "", " return await elevatedArrangePlans(planIds);", - "}", + "});", "", "/*************", " * Page code *", " *************/", "", - "import { sortPlansBySlug } from 'backend/plan-functions';", + "import { sortPlansBySlug } from 'backend/plan-functions.web';", "import wixLocationFrontend from 'wix-location-frontend';", "", "$w.onReady(function () {", @@ -2290,7 +3070,8 @@ " const url = wixLocationFrontend.url;", " wixLocationFrontend.to(url);", " })", - "});" + "});", + "" ], "extra": { "description": "Select a sorting option to arranage plans in ascending or descending order by plan slug. " @@ -2351,7 +3132,7 @@ ], "examples": [ { - "title": "Hide a plan ", + "title": "Hide a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -2417,6 +3198,76 @@ " * }", " */ " ] + }, + { + "title": "Hide a plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", + " * ", + " * Sample visible value: false", + " */", + "", + "export const mySetPlanVisibilityFunction = webMethod(Permissions.Anyone, async (_id, visible) => {", + " try {", + " const elevatedSetPlanVisibility = elevate(plans.setPlanVisibility);", + " const hiddenPlan = elevatedSetPlanVisibility(_id,visible);", + "", + " return hiddenPlan;", + " } catch(error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + " ", + "/* Promise resolves to:", + " * {", + " * \"plan\": {", + " * \"_createdDate\": \"2024-01-07T07:10:30.074Z\",", + " * \"_id\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"_updatedDate\": \"2024-01-14T09:29:12.581Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"3 mo free trial with discount for 1 year\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Beginner's Plan\",", + " * \"perks\": {", + " * \"values\": []", + " * },", + " * \"primary\": false,", + " * \"pricing\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * },", + " * \"freeTrialDays\": 90,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"50\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"public\": false,", + " * \"slug\": \"beginners-plan\",", + " * \"termsAndConditions\": \"\"", + " * }", + " * }", + " */ ", + "" + ] } ] }, @@ -2474,7 +3325,7 @@ ], "examples": [ { - "title": "Update a plan ", + "title": "Update a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -2535,9 +3386,74 @@ " */" ] }, + { + "title": "Update a plan (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' ", + " * ", + " * Sample plan value: ", + " * {", + " * description: 'Bronze membership to the MyGame World of Online Gaming',", + " * name: 'Bronze Plan'", + " * }", + " */", + "", + "export const myUpdatePlanFunction = webMethod(Permissions.Anyone, async (_id, plan) => {", + " try {", + " const elevateUpdatePlan = elevate(plans.updatePlan);", + " const updatedPlan = await elevateUpdatePlan(_id, plan);", + "", + " return updatedPlan;", + " } catch(errors) {", + " console.error(errors);", + " // Handle the error", + " }", + "});", + "/* Promise resolves to:", + " * {", + " * \"_createdDate\": \"2024-01-04T12:51:42.249Z\",", + " * \"_id\": \"025a0d1f-7076-4e27-9696-4a67075dc2aa\",", + " * \"_updatedDate\": \"2024-01-07T12:53:53.562Z\",", + " * \"allowFutureStartDate\": true,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Bronze membership to the MyGame World of Online Gaming\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Bronze Plan\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Multiplayer\",", + " * \"Multiple devices\",", + " * \"No ads\",", + " * \"Unlimited access\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"value\": \"10.00\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"primary\": false,", + " * \"public\": false,", + " * \"slug\": \"bronze-plan-1\",", + " * \"termsAndConditions\": \"No sharing access with others!\"", + " * }", + " */", + "" + ] + }, { "title": "Update a plan with optional fields ", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", "", @@ -2575,7 +3491,7 @@ " * }", " */", "", - "export async function myUpdatePlanFunction(_id, plan) {", + "export const myUpdatePlanFunction = webMethod(Permissions.Anyone, async (_id, plan) => {", " try {", " const elevateUpdatePlan = elevate(plans.updatePlan);", " const updatedPlan = await elevateUpdatePlan(_id, plan);", @@ -2585,7 +3501,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -2623,8 +3539,6 @@ " * \"termsAndConditions\": \"I agree to refrain from sharing any of the exclusive content with non-members\"", " * }", " */", - "", - "", "" ] } From 1795dd6ae757ab16423fbb0e694fc212d84c77e5 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Wed, 21 Feb 2024 11:51:47 +0000 Subject: [PATCH 16/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 60 ++++--------------- .../wix-pricing-plans-v2/Plans.service.json | 45 ++++---------- 2 files changed, 25 insertions(+), 80 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index f55ac7ca3b..aab74e58a1 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -62,18 +62,15 @@ "title": "Cancel an order immediately (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: 'e6f12ae0-2618-41e7-a643-31ca2ee51e2b'", " *", " * Sample effectiveAt value: 'IMMEDIATELY'", " */", "", - "const elevatedCancelOrder = elevate(orders.cancelOrder);", - "", "export async function myCancelOrderFunction(_id, effectiveAt) {", " try {", - " await elevatedCancelOrder(_id, effectiveAt);", + " await orders.cancelOrder(_id, effectiveAt);", "", " return;", " } catch (error) {", @@ -82,9 +79,7 @@ " }", "}", "", - "/* Promise resolves to void */", - "", - "" + "/* Promise resolves to void */ " ] }, { @@ -191,18 +186,15 @@ "title": "Create an offline order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' ", " *", " * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'", " */", "", - "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", - "", "export async function myCreateOfflineOrderFunction(planId, memberId) {", " try {", - " const newOrder = await elevatedCreateOfflineOrder(planId, memberId);", + " const newOrder = await orders.createOfflineOrder(planId, memberId);", "", " return newOrder;", " } catch (error) {", @@ -280,8 +272,7 @@ " * \"type\": \"OFFLINE\",", " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", " * }", - " */ ", - "" + " */ " ] }, { @@ -565,18 +556,15 @@ "title": "Create an offline order preview (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", " *", " * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b'", " */", "", - "const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);", - "", "export async function myGetOfflineOrderPreviewFunction(planId, memberId) {", " try {", - " const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId);", + " const orderPreview = await orders.getOfflineOrderPreview(planId, memberId);", "", " return orderPreview;", " } catch (error) {", @@ -734,8 +722,7 @@ " * }", " * \"purchaseLimitExceeded\": false", " * }", - " */ ", - "" + " */ " ] }, { @@ -1346,15 +1333,12 @@ "title": "Get an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' */", "", - "const elevatedManagementGetOrder = elevate(orders.managementGetOrder)", - "", "export async function myManagementGetOrderFunction(_id) {", " try {", - " const order = await elevatedManagementGetOrder(_id);", + " const order = await orders.managementGetOrder(_id);", "", " return order;", " } catch (error) {", @@ -1734,13 +1718,10 @@ "title": "List pricing plan orders (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", - "", - "const elevatedManagementListOrders = elevate(orders.managementListOrders);", "", "export async function myManagementListOrdersFunction() {", " try {", - " const ordersList = await elevatedManagementListOrders();", + " const ordersList = await orders.managementListOrders();", "", " return ordersList;", " } catch (error){", @@ -1829,9 +1810,7 @@ " * \"total\": 1", " * }", " * }", - " */ ", - "", - "" + " */" ] }, { @@ -2132,15 +2111,12 @@ "title": "Mark an order as paid (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5' */", "", - "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", - "", "export async function myMarkAsPaidFunction(_id) {", " try {", - " await elevatedMarkAsPaid(_id);", + " await orders.markAsPaid(_id);", "", " return;", " } catch (error) {", @@ -2929,15 +2905,12 @@ "title": "Pause a pricing plan order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", "", - "const elevatedPauseOrder = elevate(orders.pauseOrder);", - "", "export async function myPauseOrderFunction(_id) {", " try {", - " await elevatedPauseOrder(_id);", + " await orders.pauseOrder(_id);", "", " return;", " } catch (error) {", @@ -3039,15 +3012,12 @@ "title": "Postpone an order's end date (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans-backend';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5'", " * ", " * Sample endDate value: new Date('June 30, 2026 04:00:00')", " */", "", - "const elevatedPostoponeEndDate = elevate(orders.postponeEndDate);", - "", "export async function myPostponeEndDateFunction(_id, endDate) {", " try {", " await orders.postponeEndDate(_id, endDate);", @@ -3255,15 +3225,12 @@ "title": "Resume an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", "", - "const elevatedResumeOrder = elevate(orders.resumeOrder);", - "", "export async function myResumeOrderFunction(_id) {", " try {", - " await elevatedResumeOrder(_id);", + " await orders.resumeOrder(_id);", "", " return;", " } catch (error) {", @@ -3272,8 +3239,7 @@ " }", "}", "", - "/* Promise resolves to void */", - "" + "/* Promise resolves to void */" ] }, { diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 7501f1fd86..b9ddbb4c1e 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -51,14 +51,12 @@ "title": "Archive a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */", "", "export async function myArchivePlanFunction(_id) {", " try {", - " const elevatedArchivePlan = elevate(plans.archivePlan);", - " const archivedPlan = await elevatedArchivePlan(_id);", + " const archivedPlan = await plans.archivePlan(_id);", "", " return archivedPlan;", " } catch(error) {", @@ -98,8 +96,7 @@ " * \"slug\": \"basic\",", " * \"termsAndConditions\": \"After 90 day free trial ends, your plan will end and you will need to purchase a paid plan.\"", " * } ", - " */", - "" + " */" ] }, { @@ -212,7 +209,6 @@ "title": "Arrange plans (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample ids value:", " * [", @@ -226,8 +222,7 @@ "", "export async function myArrangePlansFunction(ids) {", " try {", - " const elevatedArrangePlans = elevate(plans.arrangePlans);", - " const arranged = await elevatedArrangePlans(ids);", + " const arranged = await plans.arrangePlans(ids);", "", " return;", " } catch (error) {", @@ -236,8 +231,7 @@ " }", "}", "", - "/* Promise resolves to void */", - "" + "/* Promise resolves to void */" ] }, { @@ -368,12 +362,10 @@ "title": "Clear the primary plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "export async function myClearPrimaryFunction() {", " try {", - " const elevatedClearPrimary = elevate(plans.clearPrimary);", - " const clearedPrimary = await elevatedClearPrimary();", + " const clearedPrimary = await plans.clearPrimary();", "", " return;", " } catch (error) {", @@ -462,7 +454,6 @@ "title": "Create a plan with optional fields (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample plan value:", " * {", @@ -500,8 +491,7 @@ "", "export async function myCreatePlanFunction(plan) {", " try {", - " const elevatedCreatePlan = elevate(plans.createPlan);", - " const newPlan = await elevatedCreatePlan(plan);", + " const newPlan = await plans.createPlan(plan);", "", " const planId = newPlan._id;", " const pricingObject = newPlan.pricing;", @@ -552,8 +542,7 @@ " * \"termsAndConditions\": \"No sharing access with others!\"", " * }", " * }", - " */ ", - "" + " */ " ] }, { @@ -855,14 +844,12 @@ "title": "Get a plan (dashboard page code)", "body": [ "import { plans} from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", "", "export async function myGetPlanFunction(_id) {", " try {", - " const elevatedGetPlan = elevate(plans.getPlan);", - " const myPlan = await elevatedGetPlan(_id);", + " const myPlan = await plans.getPlan(_id);", "", " return myPlan;", " } catch (error) {", @@ -1105,12 +1092,10 @@ "title": "Get number of plans (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "export async function myGetPlanStatsFunction() {", " try {", - " const elevatedGetPlanStats = elevate(plans.getPlanStats);", - " const planStats = elevatedGetPlanStats();", + " const planStats = plans.getPlanStats();", "", " return planStats;", " } catch (error) {", @@ -2307,14 +2292,12 @@ "title": "Make a plan a primary plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' */", "", "export async function myMakePlanPrimaryFunction(_id) {", " try {", - " const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);", - " const primaryPlan = await elevatedMakePlanPrimary(_id);", + " const primaryPlan = await plans.makePlanPrimary(_id);", "", " return primaryPlan;", " } catch(error) {", @@ -3135,7 +3118,6 @@ "title": "Hide a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", " * ", @@ -3144,8 +3126,7 @@ "", "export async function mySetPlanVisibilityFunction(_id, visible) {", " try {", - " const elevatedSetPlanVisibility = elevate(plans.setPlanVisibility);", - " const hiddenPlan = elevatedSetPlanVisibility(_id,visible);", + " const hiddenPlan = plans.setPlanVisibility(_id,visible);", "", " return hiddenPlan;", " } catch(error) {", @@ -3328,7 +3309,6 @@ "title": "Update a plan (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' ", " * ", @@ -3341,8 +3321,7 @@ "", "export async function myUpdatePlanFunction(_id, plan) {", " try {", - " const elevateUpdatePlan = elevate(plans.updatePlan);", - " const updatedPlan = await elevateUpdatePlan(_id, plan);", + " const updatedPlan = await plans.updatePlan(_id, plan);", "", " return updatedPlan;", " } catch(errors) {", From c69d7001bb7de31daa0da801a866856ceabf539e Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Wed, 21 Feb 2024 23:19:15 +0000 Subject: [PATCH 17/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 289 +++++++++++++++++- 1 file changed, 285 insertions(+), 4 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index 8904227fc9..a52e6edef3 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -5936,6 +5936,26 @@ ] } }, + { + "name": "pricingPlansV2PlanActionEvent", + "members": [ + { + "name": "bodyAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanApplicationError", "members": [ @@ -6354,6 +6374,207 @@ ] } }, + { + "name": "pricingPlansV2PlanDomainEvent", + "members": [ + { + "name": "_id", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Unique event ID.\nAllows clients to ignore duplicate webhooks." + }, + { + "name": "actionEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanActionEvent", + "displayName": "ActionEvent" + } + ], + "doc": "" + }, + { + "name": "createdEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityCreatedEvent", + "displayName": "EntityCreatedEvent" + } + ], + "doc": "" + }, + { + "name": "deletedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityDeletedEvent", + "displayName": "EntityDeletedEvent" + } + ], + "doc": "" + }, + { + "name": "entityEventSequence", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "A sequence number defining the order of updates to the underlying entity.\nFor example, given that some entity was updated at 16:00 and than again at 16:01,\nit is guaranteed that the sequence number of the second update is strictly higher than the first.\nAs the consumer, you can use this value to ensure that you handle messages in the correct order.\nTo do so, you will need to persist this number on your end, and compare the sequence number from the\nmessage against the one you have stored. Given that the stored number is higher, you should ignore the message." + }, + { + "name": "entityFqdn", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Assumes actions are also always typed to an entity_type\nExample: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction" + }, + { + "name": "entityId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of the entity associated with the event." + }, + { + "name": "eventTime", + "optional": true, + "type": [ + { + "nativeType": "Date" + } + ], + "doc": "Event timestamp." + }, + { + "name": "originatedFrom", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "If present, indicates the action that triggered the event." + }, + { + "name": "slug", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)\nThis is although the created/updated/deleted notion is duplication of the oneof types\nExample: created/updated/deleted/started/completed/email_opened" + }, + { + "name": "triggeredByAnonymizeRequest", + "optional": true, + "type": [ + { + "nativeType": "boolean" + } + ], + "doc": "Whether the event was triggered as a result of a privacy regulation application\n(for example, GDPR)." + }, + { + "name": "updatedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityUpdatedEvent", + "displayName": "EntityUpdatedEvent" + } + ], + "doc": "" + } + ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfDomainEventBodyOneOf", + "members": [ + "actionEvent", + "createdEvent", + "deletedEvent", + "updatedEvent" + ] + } + ] + }, + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanDomainEventBodyOneOf", + "members": [ + { + "name": "actionEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanActionEvent", + "displayName": "ActionEvent" + } + ], + "doc": "" + }, + { + "name": "createdEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityCreatedEvent", + "displayName": "EntityCreatedEvent" + } + ], + "doc": "" + }, + { + "name": "deletedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityDeletedEvent", + "displayName": "EntityDeletedEvent" + } + ], + "doc": "" + }, + { + "name": "updatedEvent", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanEntityUpdatedEvent", + "displayName": "EntityUpdatedEvent" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanDuration", "members": [ @@ -6384,6 +6605,66 @@ ] } }, + { + "name": "pricingPlansV2PlanEntityCreatedEvent", + "members": [ + { + "name": "entityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanEntityDeletedEvent", + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanEntityUpdatedEvent", + "members": [ + { + "name": "currentEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff.\nThis means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects.\nWe don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanFee", "members": [ @@ -7169,7 +7450,7 @@ "displayName": "BuyerCanCancelUpdated" } ], - "doc": "" + "doc": "Event data." }, { "name": "metadata", @@ -7179,7 +7460,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -7229,7 +7510,7 @@ "displayName": "Plan" } ], - "doc": "" + "doc": "Updated plan." }, { "name": "metadata", @@ -7239,7 +7520,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { From 7934d92333804f712d67c5ebbca82f47a9f1d589 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 26 Feb 2024 16:19:37 +0000 Subject: [PATCH 18/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 1031 +++++++++++++++-- 1 file changed, 960 insertions(+), 71 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index aab74e58a1..a00a2cb82f 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -62,15 +62,18 @@ "title": "Cancel an order immediately (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value: 'e6f12ae0-2618-41e7-a643-31ca2ee51e2b'", " *", " * Sample effectiveAt value: 'IMMEDIATELY'", " */", "", + "const elevatedCancelOrder = elevate(orders.cancelOrder);", + "", "export async function myCancelOrderFunction(_id, effectiveAt) {", " try {", - " await orders.cancelOrder(_id, effectiveAt);", + " await elevatedCancelOrder(_id, effectiveAt);", "", " return;", " } catch (error) {", @@ -374,6 +377,114 @@ "" ] }, + { + "title": "Create an offline order for an existing member ", + "body": [ + "/*******************************", + " * Backend code - utils.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders, plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export const listPublicPlans = webMethod(", + " Permissions.Anyone, ", + " async () => {", + " try {", + " const plansResponse = await elevatedListPublicPlans();", + " const plans = plansResponse.plans;", + "", + " return plans;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const createOfflineOrder = webMethod(", + " Permissions.Anyone,", + " async (planId, memberId) => {", + " try {", + " const newOrder = await elevatedCreateOfflineOrder(planId, memberId);", + "", + " return newOrder;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const markAsPaid = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedMarkAsPaid(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { createOfflineOrder, listPublicPlans, markAsPaid } from 'backend/utils.web';", + "import { members } from 'wix-members.v2';", + "", + "$w.onReady(async function () {", + " $w('#newOrderBtn').disable();", + " await populatePlansDropdown();", + " let planId;", + " let memberId;", + "", + " // Populate #membersDropdown", + " const membersQueryResults = await members.queryMembers().find();", + " $w('#membersListDropdown').options = membersQueryResults.items.map(member => {", + " return {", + " label: member.profile.nickname,", + " value: member._id", + " }", + " });", + "", + " $w('#membersListDropdown').onChange(() => {", + " memberId = $w('#membersListDropdown').value;", + " });", + "", + " $w('#plansDropdown').onChange(() => {", + " planId = $w('#plansDropdown').value;", + " $w('#newOrderBtn').enable();", + " });", + "", + " $w('#newOrderBtn').onClick(async () => {", + " const newOrder = await createOfflineOrder(planId, memberId);", + " const orderId = newOrder.orders._id;", + " markAsPaid(orderId);", + " });", + "});", + "", + "async function populatePlansDropdown() {", + " const plans = await listPublicPlans();", + " $w('#plansListDropdown').options = plans.map((item) => {", + " return {", + " label: item.name,", + " value: item._id", + " }", + " });", + "}" + ], + "extra": { + "description": "This example provides a dropdown list of site members and public plans to complete a manual offline transaction." + } + }, { "title": "Create an offline order with options ", "body": [ @@ -1097,15 +1208,12 @@ "title": "Get a price preview for an order", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", "", - "const elevatedGetPricePreview = elevate(orders.getPricePreview);", - "", "export async function myGetPricePreviewFunction(planId) {", " try {", - " const pricePreview = await elevatedGetPricePreview(planId)", + " const pricePreview = await orders.getPricePreview(planId);", "", " return pricePreview;", " } catch (error) {", @@ -1145,15 +1253,13 @@ "body": [ "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "// Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' ", "", - "const elevatedGetPricePreview = elevate(orders.getPricePreview);", "", "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId) => {", " try {", - " const pricePreview = await elevatedGetPricePreview(planId)", + " const pricePreview = await orders.getPricePreview(planId);", "", " return pricePreview;", " } catch (error) {", @@ -1194,7 +1300,6 @@ "body": [ "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", " *", @@ -1204,11 +1309,9 @@ " * }", " */ ", "", - "const elevatedGetPricePreview = elevate(orders.getPricePreview);", - "", "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId, options) => {", " try {", - " const pricePreview = await elevatedGetPricePreview(planId, options)", + " const pricePreview = await orders.getPricePreview(planId, options);", "", " return pricePreview;", " } catch (error) {", @@ -1333,12 +1436,15 @@ "title": "Get an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value:'12178428-36b7-4cf5-bfb5-0ba8c83c4e8c' */", "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder);", + "", "export async function myManagementGetOrderFunction(_id) {", " try {", - " const order = await orders.managementGetOrder(_id);", + " const order = await elevatedManagementGetOrder(_id);", "", " return order;", " } catch (error) {", @@ -1718,10 +1824,13 @@ "title": "List pricing plan orders (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", "", "export async function myManagementListOrdersFunction() {", " try {", - " const ordersList = await orders.managementListOrders();", + " const ordersList = await elevatedManagementListOrders();", "", " return ordersList;", " } catch (error){", @@ -2057,6 +2166,115 @@ " ", "" ] + }, + { + "title": "Manager cancellation or updated payment status of multiple orders ", + "body": [ + "/*******************************", + " * Backend code - utils.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", + "const elevatedCancelOrder = elevate(orders.cancelOrder);", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export const getUnpaidOrders = webMethod(", + " Permissions.Anyone,", + " async () => {", + " const options = { paymentStatuses: 'UNPAID' };", + " try {", + " const ordersList = await elevatedManagementListOrders(options);", + "", + " return ordersList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const cancelOrder = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " const effectiveAt = 'NEXT_PAYMENT_DATE';", + " try {", + " await elevatedCancelOrder(orderId, effectiveAt);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const markAsPaid = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedMarkAsPaid(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { getUnpaidOrders, cancelOrder, markAsPaid } from 'backend/utils.web';", + "", + "$w.onReady(function () {", + " $w('#ordersCheckbox').hide();", + " $w('#markAsPaidBtn').disable();", + " $w('#cancelOrderBtn').disable();", + "", + "", + " populateOrdersCheckbox();", + " let orderValues;", + "", + " $w('#ordersCheckbox').onChange(() => {", + " orderValues = $w('#ordersCheckbox').value;", + " });", + "", + " // Cancel multiple orders ", + " $w('#cancelOrderBtn').onClick(() => {", + " orderValues.forEach(async (orderId) => {", + " await cancelOrder(orderId);", + " });", + " });", + "", + " // Mark multiple orders as paid", + " $w('#markAsPaidBtn').onClick(() => {", + " orderValues.forEach(async (orderId) => {", + " await markAsPaid(orderId);", + " });", + " });", + "});", + "", + "async function populateOrdersCheckbox() {", + " const unpaidOrders = await getUnpaidOrders();", + "", + " // Displays each order with its corresponding member ID", + " $w('#ordersCheckbox').options = unpaidOrders.orders.map(item => {", + " return {", + " label: `${item.planName} - memberId: ${item.buyer.memberId}`,", + " value: item._id", + " }", + " });", + " $w('#ordersCheckbox').show();", + " $w('#markAsPaidBtn').enable();", + " $w('#cancelOrderBtn').enable();", + "}" + ], + "extra": { + "description": "In this example, the page code provides a checkable list of unpaid customer orders. The site owner or admin selects the unpaid orders to be cancelled or updated to a `PAID` payment status." + } } ] }, @@ -2111,12 +2329,15 @@ "title": "Mark an order as paid (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5' */", "", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", "export async function myMarkAsPaidFunction(_id) {", " try {", - " await orders.markAsPaid(_id);", + " await elevatedMarkAsPaid(_id);", "", " return;", " } catch (error) {", @@ -2153,6 +2374,223 @@ "/* Promise resolves to void */", "" ] + }, + { + "title": "Manager cancellation or updated payment status of multiple orders ", + "body": [ + "/*******************************", + " * Backend code - utils.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedManagementListOrders = elevate(orders.managementListOrders);", + "const elevatedCancelOrder = elevate(orders.cancelOrder);", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export const getUnpaidOrders = webMethod(", + " Permissions.Anyone,", + " async () => {", + " const options = { paymentStatuses: 'UNPAID' };", + " try {", + " const ordersList = await elevatedManagementListOrders(options);", + "", + " return ordersList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const cancelOrder = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " const effectiveAt = 'NEXT_PAYMENT_DATE';", + " try {", + " await elevatedCancelOrder(orderId, effectiveAt);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const markAsPaid = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedMarkAsPaid(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { getUnpaidOrders, cancelOrder, markAsPaid } from 'backend/utils.web';", + "", + "$w.onReady(function () {", + " $w('#ordersCheckbox').hide();", + " $w('#markAsPaidBtn').disable();", + " $w('#cancelOrderBtn').disable();", + "", + "", + " populateOrdersCheckbox();", + " let orderValues;", + "", + " $w('#ordersCheckbox').onChange(() => {", + " orderValues = $w('#ordersCheckbox').value;", + " });", + "", + " // Cancel multiple orders ", + " $w('#cancelOrderBtn').onClick(() => {", + " orderValues.forEach(async (orderId) => {", + " await cancelOrder(orderId);", + " });", + " });", + "", + " // Mark multiple orders as paid", + " $w('#markAsPaidBtn').onClick(() => {", + " orderValues.forEach(async (orderId) => {", + " await markAsPaid(orderId);", + " });", + " });", + "});", + "", + "async function populateOrdersCheckbox() {", + " const unpaidOrders = await getUnpaidOrders();", + "", + " // Displays each order with its corresponding member ID", + " $w('#ordersCheckbox').options = unpaidOrders.orders.map(item => {", + " return {", + " label: `${item.planName} - memberId: ${item.buyer.memberId}`,", + " value: item._id", + " }", + " });", + " $w('#ordersCheckbox').show();", + " $w('#markAsPaidBtn').enable();", + " $w('#cancelOrderBtn').enable();", + "}" + ], + "extra": { + "description": "In this example, the page code provides a checkable list of unpaid customer orders. The site owner or admin selects the unpaid orders to be cancelled or updated to a `PAID` payment status." + } + }, + { + "title": "Create an offline order for an existing member ", + "body": [ + "/*******************************", + " * Backend code - utils.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders, plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + "const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder);", + "const elevatedMarkAsPaid = elevate(orders.markAsPaid);", + "", + "export const listPublicPlans = webMethod(", + " Permissions.Anyone, ", + " async () => {", + " try {", + " const plansResponse = await elevatedListPublicPlans();", + " const plans = plansResponse.plans;", + "", + " return plans;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const createOfflineOrder = webMethod(", + " Permissions.Anyone,", + " async (planId, memberId) => {", + " try {", + " const newOrder = await elevatedCreateOfflineOrder(planId, memberId);", + "", + " return newOrder;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const markAsPaid = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedMarkAsPaid(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { createOfflineOrder, listPublicPlans, markAsPaid } from 'backend/utils.web';", + "import { members } from 'wix-members.v2';", + "", + "$w.onReady(async function () {", + " $w('#newOrderBtn').disable();", + " await populatePlansDropdown();", + " let planId;", + " let memberId;", + "", + " // Populate #membersDropdown", + " const membersQueryResults = await members.queryMembers().find();", + " $w('#membersListDropdown').options = membersQueryResults.items.map(member => {", + " return {", + " label: member.profile.nickname,", + " value: member._id", + " }", + " });", + "", + " $w('#membersListDropdown').onChange(() => {", + " memberId = $w('#membersListDropdown').value;", + " });", + "", + " $w('#plansDropdown').onChange(() => {", + " planId = $w('#plansDropdown').value;", + " $w('#newOrderBtn').enable();", + " });", + "", + " $w('#newOrderBtn').onClick(async () => {", + " const newOrder = await createOfflineOrder(planId, memberId);", + " const orderId = newOrder.orders._id;", + " markAsPaid(orderId);", + " });", + "});", + "", + "async function populatePlansDropdown() {", + " const plans = await listPublicPlans();", + " $w('#plansListDropdown').options = plans.map((item) => {", + " return {", + " label: item.name,", + " value: item._id", + " }", + " });", + "}" + ], + "extra": { + "description": "This example provides a dropdown list of site members and public plans to complete a manual offline transaction." + } } ] }, @@ -2214,13 +2652,14 @@ ], "examples": [ { - "title": "Get an order for logged-in member", + "title": "Get an order for logged-in member (export from backend code)", "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "", - "/* Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d' */", + "// Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", "", - "export async function memberGetOrder(_id) {", + "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id) => {", " try {", " const order = await orders.memberGetOrder(_id);", "", @@ -2229,7 +2668,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -2295,58 +2734,70 @@ " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", " * \"type\": \"ONLINE\"", " * }", - " */ " + " */", + "" ] }, { - "title": "Get an order for logged-in member (export from backend code)", + "title": "Get an order for a logged-in member with options ", "body": [ - "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", "", - "// Sample _id: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", + "/* Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", + " *", + " * Sample options value:", + " * {", + " * fieldSet: 'FULL'", + " * }", + " */", "", - "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id) => {", + "export async function memberGetOrder(_id, options) {", " try {", - " const order = await orders.memberGetOrder(_id);", + " const order = await orders.memberGetOrder(_id, options);", "", " return order;", " } catch (error) {", " console.error(error);", " // Handle the error", " }", - "});", + "}", "", "/* Promise resolves to:", " * {", - " * \"_createdDate\": \"2024-01-28T08:35:15.230Z\",", - " * \"_id\": \"7b4ec42c-582a-4e2f-874b-09e66e0ae09d\",", - " * \"_updatedDate\": \"2024-01-28T08:35:16.080Z\",", + " * \"_createdDate\": \"2024-01-31T10:20:31.602Z\",", + " * \"_id\": \"b14e3821-868f-4aa6-b874-e9240100985c\",", + " * \"_updatedDate\": \"2024-01-31T10:20:32.819Z\",", " * \"buyer\": {", - " * \"contactId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\",", - " * \"memberId\": \"695568ff-1dc2-49ff-83db-2b518d35692b\"", + " * \"contactId\": \"fa16f1dc-0fbd-41c0-8efc-53333e3fce1e\",", + " * \"memberId\": \"fa16f1dc-0fbd-41c0-8efc-53333e3fce1e\"", " * },", " * \"currentCycle\": {", " * \"index\": 1,", - " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * \"startedDate\": \"2024-01-31T10:20:31.602Z\"", " * },", " * \"cycles\": [", " * {", " * \"index\": 1,", - " * \"startedDate\": \"2024-01-28T08:35:15.230Z\"", + " * \"startedDate\": \"2024-01-31T10:20:31.602Z\"", " * }", " * ],", " * \"formData\": {", - " * \"formId\": \"3ef36359-24bd-471a-aa8b-a5ca683b50f4\",", - " * \"submissionData\": {},", - " * \"submissionId\": \"2cf62c7a-d3ed-4dd9-816d-01919aaf2170\"", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {", + " * \"email_0fd2\": \"JV@email.com\",", + " * \"first_name_c551\": \"Jonathan\",", + " * \"form_field_aa30\": false,", + " * \"last_name_78e9\": \"Vernes\",", + " * \"phone_8cf1\": \"918-455-2587\"", + " * },", + " * \"submissionId\": \"9e128ddb-f62f-4a4a-adb5-064af40f18db\"", " * },", " * \"lastPaymentStatus\": \"NOT_APPLICABLE\",", " * \"orderMethod\": \"UNKNOWN\",", " * \"pausePeriods\": [],", - " * \"planDescription\": \"Full functionality for new users\",", - " * \"planId\": \"df83348a-777d-46ab-8d62-a43c415bdb11\",", - " * \"planName\": \"Standard Plan\",", + " * \"planDescription\": \"\",", + " * \"planId\": \"3a3e0ac2-a9e3-4bfd-ade3-bec3bab34d4b\",", + " * \"planName\": \"Free Plan\",", " * \"planPrice\": \"0\",", " * \"priceDetails\": {", " * \"currency\": \"USD\",", @@ -2375,13 +2826,16 @@ " * ],", " * \"singlePaymentUnlimited\": true", " * },", - " * \"startDate\": \"2024-01-28T08:35:15.230Z\",", + " * \"startDate\": \"2024-01-31T10:20:31.602Z\",", " * \"status\": \"ACTIVE\",", " * \"statusNew\": \"ACTIVE\",", - " * \"subscriptionId\": \"08bc02c5-7663-4578-948a-ff23370e07e5\",", + " * \"subscriptionId\": \"1c36ad20-fbc1-4857-8fda-efb8d2cd1a5c\",", " * \"type\": \"ONLINE\"", " * }", - " */", + " */ ", + "", + "", + "", "" ] }, @@ -2390,7 +2844,6 @@ "body": [ "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* ", " * Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", @@ -2401,11 +2854,9 @@ " * }", " */", "", - "const elevatedMemberGetOrder = elevate(orders.memberGetOrder);", - "", "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id, options) => {", " try {", - " const order = await elevatedMemberGetOrder(_id, options);", + " const order = await orders.memberGetOrder(_id, options);", "", " return order;", " } catch (error) {", @@ -2537,10 +2988,11 @@ "export async function myMemberListOrdersFunction() {", " try {", " const ordersList = await orders.memberListOrders();", + " ", " return ordersList;", " } catch (error) {", - " console.error(error);", - " // Handle the error", + " console.error(error);", + " // Handle the error", " }", "}", "", @@ -2699,10 +3151,11 @@ "export const myMemberListOrdersFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const ordersList = await orders.memberListOrders();", + "", " return ordersList;", " } catch (error) {", - " console.error(error);", - " // Handle the error", + " console.error(error);", + " // Handle the error", " }", "});", "", @@ -2849,9 +3302,187 @@ " * }", " * ]", " * }", - " */ ", + " */", "" ] + }, + { + "title": "Cancel or pause a member order ", + "body": [ + "/*******************************", + " * Backend code - order.web.js *", + "********************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", + "", + "export const listCurrentMemberOrders = webMethod(", + " Permissions.Anyone, ", + " async (orderStatuses) => {", + " try {", + " const result = await orders.memberListOrders(orderStatuses);", + "", + " return result;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const requestCancellation = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " const effectiveAt = 'NEXT_PAYMENT_DATE';", + " try {", + " await orders.requestCancellation(orderId, effectiveAt) ;", + " ", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const pauseOrder = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " try {", + " await elevatedPauseOrder(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listCurrentMemberOrders, requestCancellation, pauseOrder } from 'backend/order.web';", + "", + "$w.onReady(function () {", + " // Disabe UI elements on page load", + " $w('#requestCancelOrderBtn').disable();", + " $w('#pauseOrderBtn').disable();", + " $w('#ordersDropdown').disable();", + " ", + " let selectedOrderId;", + " populateOrdersDropdown();", + "", + " $w('#ordersDropdown').onChange( () => {", + " selectedOrderId = $w('#ordersDropdown').value;", + " $w('#requestCancelOrderBtn').enable();", + " $w('#pauseOrderBtn').enable(); ", + " });", + "", + " $w('#requestCancelOrderBtn').onClick(async () => {", + " await requestCancellation(selectedOrderId);", + " });", + "", + " $w('#pauseOrderBtn').onClick(async () => {", + " await pauseOrder(selectedOrderId);", + " });", + "});", + "", + "async function populateOrdersDropdown() {", + " const activeOrdersList = await listCurrentMemberOrders({orderStatuses: 'ACTIVE'});", + " $w('#ordersDropdown').options = activeOrdersList.orders.map((order) => {", + " return {", + " label: order.planName,", + " value: order._id", + " }", + " });", + " $w('#ordersDropdown').enable();", + "}" + ], + "extra": { + "description": "This example provides a dropdown list of active orders for a logged-in member. The member selects a plan from the `#ordersDropdown` and clicks the `#cancelOrderBtn` to cancel the plan or the `#pauseOrderBtn` to pause the plan. " + } + }, + { + "title": "Resume paused orders by a member ", + "body": [ + "/*******************************", + " * Backend code - order.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedResumeOrder = elevate(orders.resumeOrder);", + "", + "export const getPausedMemberOrders = webMethod(", + " Permissions.Anyone,", + " async () => {", + " try {", + " const options = {", + " orderStatuses: 'PAUSED'", + " };", + " const result = await orders.memberListOrders(options);", + " const getPausedMemberOrders = result.orders;", + "", + " return result;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const resumeOrder = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedResumeOrder(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { getPausedMemberOrders, resumeOrder } from 'backend/order.web';", + "", + "$w.onReady(function () {", + " let selectedOrderId;", + " populateOrderButtonList();", + "", + " $w('#orderSelection').onChange(() => {", + " selectedOrderId = $w('#orderSelection').value;", + " $w('#resumeOrderBtn').enable();", + " });", + "", + " $w('#resumeOrderBtn').onClick(async () => {", + " await resumeOrder(selectedOrderId);", + " });", + "", + "});", + "", + "async function populateOrderButtonList() {", + " const pausedOrders = await getPausedMemberOrders();", + " $w('#pausedOrders').options = pausedOrders.map(item => {", + " return {", + " label: item.planName,", + " value: item._id", + " }", + " });", + "", + " $w('#pausedOrders').show();", + "}" + ], + "extra": { + "description": "Page code provides button list of active orders for a logged-in member. Member selects paused plan and submits `#resumeOrderBtn` to resume the order. `#orderSelection` and `resumeOrderBtn` are initially disabled. " + } } ] }, @@ -2905,12 +3536,15 @@ "title": "Pause a pricing plan order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", "", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", + "", "export async function myPauseOrderFunction(_id) {", " try {", - " await orders.pauseOrder(_id);", + " await elevatedPauseOrder(_id);", "", " return;", " } catch (error) {", @@ -2947,6 +3581,104 @@ "/* Promise resolves to void */", "" ] + }, + { + "title": "Cancel or pause a member order ", + "body": [ + "/*******************************", + " * Backend code - order.web.js *", + "********************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", + "", + "export const listCurrentMemberOrders = webMethod(", + " Permissions.Anyone, ", + " async (orderStatuses) => {", + " try {", + " const result = await orders.memberListOrders(orderStatuses);", + "", + " return result;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const requestCancellation = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " const effectiveAt = 'NEXT_PAYMENT_DATE';", + " try {", + " await orders.requestCancellation(orderId, effectiveAt) ;", + " ", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const pauseOrder = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " try {", + " await elevatedPauseOrder(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listCurrentMemberOrders, requestCancellation, pauseOrder } from 'backend/order.web';", + "", + "$w.onReady(function () {", + " // Disabe UI elements on page load", + " $w('#requestCancelOrderBtn').disable();", + " $w('#pauseOrderBtn').disable();", + " $w('#ordersDropdown').disable();", + " ", + " let selectedOrderId;", + " populateOrdersDropdown();", + "", + " $w('#ordersDropdown').onChange( () => {", + " selectedOrderId = $w('#ordersDropdown').value;", + " $w('#requestCancelOrderBtn').enable();", + " $w('#pauseOrderBtn').enable(); ", + " });", + "", + " $w('#requestCancelOrderBtn').onClick(async () => {", + " await requestCancellation(selectedOrderId);", + " });", + "", + " $w('#pauseOrderBtn').onClick(async () => {", + " await pauseOrder(selectedOrderId);", + " });", + "});", + "", + "async function populateOrdersDropdown() {", + " const activeOrdersList = await listCurrentMemberOrders({orderStatuses: 'ACTIVE'});", + " $w('#ordersDropdown').options = activeOrdersList.orders.map((order) => {", + " return {", + " label: order.planName,", + " value: order._id", + " }", + " });", + " $w('#ordersDropdown').enable();", + "}" + ], + "extra": { + "description": "This example provides a dropdown list of active orders for a logged-in member. The member selects a plan from the `#ordersDropdown` and clicks the `#cancelOrderBtn` to cancel the plan or the `#pauseOrderBtn` to pause the plan. " + } } ] }, @@ -3012,15 +3744,18 @@ "title": "Postpone an order's end date (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans-backend';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5'", " * ", " * Sample endDate value: new Date('June 30, 2026 04:00:00')", " */", "", + "const elevatedPostponeEndDate = elevate(orders.postponeEndDate);", + "", "export async function myPostponeEndDateFunction(_id, endDate) {", " try {", - " await orders.postponeEndDate(_id, endDate);", + " await elevatedPostponeEndDate(_id, endDate);", "", " return;", " } catch (error) {", @@ -3147,31 +3882,102 @@ ] }, { - "title": "Cancel an order immediately (export from backend code)", + "title": "Cancel or pause a member order ", "body": [ + "/*******************************", + " * Backend code - order.web.js *", + "********************************/", + "", "import { Permissions, webMethod } from 'wix-web-module';", "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", - "/* ", - " * Sample _id value: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d'", - " *", - " * Sample effectiveAt value: 'IMMEDIATELY'", - " */", + "const elevatedPauseOrder = elevate(orders.pauseOrder);", "", - "export const myRequestCancellationFunction = webMethod(Permissions.Anyone, async (_id, effectiveAt) => {", - " try {", - " await orders.requestCancellation(_id, effectiveAt);", + "export const listCurrentMemberOrders = webMethod(", + " Permissions.Anyone, ", + " async (orderStatuses) => {", + " try {", + " const result = await orders.memberListOrders(orderStatuses);", "", - " return;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", + " return result;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const requestCancellation = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " const effectiveAt = 'NEXT_PAYMENT_DATE';", + " try {", + " await orders.requestCancellation(orderId, effectiveAt) ;", + " ", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const pauseOrder = webMethod(", + " Permissions.Anyone, ", + " async (orderId) => {", + " try {", + " await elevatedPauseOrder(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listCurrentMemberOrders, requestCancellation, pauseOrder } from 'backend/order.web';", + "", + "$w.onReady(function () {", + " // Disabe UI elements on page load", + " $w('#requestCancelOrderBtn').disable();", + " $w('#pauseOrderBtn').disable();", + " $w('#ordersDropdown').disable();", + " ", + " let selectedOrderId;", + " populateOrdersDropdown();", + "", + " $w('#ordersDropdown').onChange( () => {", + " selectedOrderId = $w('#ordersDropdown').value;", + " $w('#requestCancelOrderBtn').enable();", + " $w('#pauseOrderBtn').enable(); ", + " });", + "", + " $w('#requestCancelOrderBtn').onClick(async () => {", + " await requestCancellation(selectedOrderId);", + " });", + "", + " $w('#pauseOrderBtn').onClick(async () => {", + " await pauseOrder(selectedOrderId);", + " });", "});", "", - "/* Promise resolves to void */", - "" - ] + "async function populateOrdersDropdown() {", + " const activeOrdersList = await listCurrentMemberOrders({orderStatuses: 'ACTIVE'});", + " $w('#ordersDropdown').options = activeOrdersList.orders.map((order) => {", + " return {", + " label: order.planName,", + " value: order._id", + " }", + " });", + " $w('#ordersDropdown').enable();", + "}" + ], + "extra": { + "description": "This example provides a dropdown list of active orders for a logged-in member. The member selects a plan from the `#ordersDropdown` and clicks the `#cancelOrderBtn` to cancel the plan or the `#pauseOrderBtn` to pause the plan. " + } } ] }, @@ -3225,12 +4031,15 @@ "title": "Resume an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", "", "/* Sample _id value: '9af3cbe6-fe27-4fdb-a0b0-892289b03d22' */", "", + "const elevatedResumeOrder = elevate(orders.resumeOrder);", + "", "export async function myResumeOrderFunction(_id) {", " try {", - " await orders.resumeOrder(_id);", + " await elevatedResumeOrder(_id);", "", " return;", " } catch (error) {", @@ -3267,6 +4076,86 @@ "/* Promise resolves to void */", "" ] + }, + { + "title": "Resume paused orders by a member ", + "body": [ + "/*******************************", + " * Backend code - order.web.js *", + " *******************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedResumeOrder = elevate(orders.resumeOrder);", + "", + "export const getPausedMemberOrders = webMethod(", + " Permissions.Anyone,", + " async () => {", + " try {", + " const options = {", + " orderStatuses: 'PAUSED'", + " };", + " const result = await orders.memberListOrders(options);", + " const getPausedMemberOrders = result.orders;", + "", + " return result;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "export const resumeOrder = webMethod(", + " Permissions.Anyone,", + " async (orderId) => {", + " try {", + " await elevatedResumeOrder(orderId);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + " });", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { getPausedMemberOrders, resumeOrder } from 'backend/order.web';", + "", + "$w.onReady(function () {", + " let selectedOrderId;", + " populateOrderButtonList();", + "", + " $w('#orderSelection').onChange(() => {", + " selectedOrderId = $w('#orderSelection').value;", + " $w('#resumeOrderBtn').enable();", + " });", + "", + " $w('#resumeOrderBtn').onClick(async () => {", + " await resumeOrder(selectedOrderId);", + " });", + "", + "});", + "", + "async function populateOrderButtonList() {", + " const pausedOrders = await getPausedMemberOrders();", + " $w('#pausedOrders').options = pausedOrders.map(item => {", + " return {", + " label: item.planName,", + " value: item._id", + " }", + " });", + "", + " $w('#pausedOrders').show();", + "}" + ], + "extra": { + "description": "Page code provides button list of active orders for a logged-in member. Member selects paused plan and submits `#resumeOrderBtn` to resume the order. `#orderSelection` and `resumeOrderBtn` are initially disabled. " + } } ] }, From b63bcad8b02c0b84460f796136db577d74bb3e59 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 26 Feb 2024 16:33:13 +0000 Subject: [PATCH 19/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 791 +++++++++++++++++- 1 file changed, 746 insertions(+), 45 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index a52e6edef3..bf61869eb9 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -42,13 +42,117 @@ { "title": "onOrderAutoRenewCanceled example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderAutoRenewCanceled(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderAutoRenewCanceled(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + " const eventTime = event.metadata.eventTime;", "", - " " + " console.log(`Order autorenew was cancelled for order ID ${orderId} by buyer ID ${buyerContactId}, for plan ID ${planId} on ${eventTime}. Full event object:`, event)", + "}", + "", + "/* Full event object: ", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-02-07T13:22:47.459Z\",", + " * \"autoRenewCanceled\": true,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"NEXT_PAYMENT_DATE\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 90,", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"freeTrialDays\": 90,", + " * \"planPrice\": \"50\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\",", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"eventTime\": \"2024-02-07T13:22:47.641175778Z\",", + " * \"id\": \"ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */", + "" ] } ] @@ -102,9 +206,10 @@ "export function wixPricingPlans_onOrderCanceled(event) {", " const orderId = event.data.order._id;", " const buyerContactId = event.data.buyer.contactId;", - " const planName = event.data.planName;", - " const endDate = event.data.endDate;", - " console.log(`The order with and ID of ${orderId} was cancelled by buyer ID ${buyerContactId}, for the ${planName} plan on ${endDate}. Full event object:`, event);", + " const planId = event.data.planName;", + " const eventTime = event.metadata.endDate;", + " ", + " console.log(`Order ID ${orderId} was canceled by buyer ID ${buyerContactId}, for plan ID ${planId} at ${eventTime}. Full event object:`, event);", "}", "", "/* Full event object:", @@ -373,9 +478,10 @@ "", "export function wixPricingPlans_onOrderCycleStarted(event) {", " const orderId = event.data.order._id;", - " const wixPayId = event.data.transactionId;", - " const eventId = event.metadata.id;", + " const transactionId = event.data.transactionId;", " const eventTime = event.metadata.eventTime;", + "", + " console.log(`Order ID ${orderId} has started its order cycle with transaction ID ${transactionId} at ${eventTime}. The full event object:`, event);", "}", "/* Full event object:", " * {", @@ -499,13 +605,116 @@ { "title": "onOrderEndDatePostponed example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderEndDatePostponed(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderEndDatePostponed(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + " ", + " console.log(`Order ID of ${orderId} was postponed for plan ID ${planId} for buyer contact ID ${buyerContactId}. Full event object:`, event);", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-02-07T13:22:47.459Z\",", + " * \"autoRenewCanceled\": true,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"NEXT_PAYMENT_DATE\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 90,", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"freeTrialDays\": 90,", + " * \"planPrice\": \"50\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\",", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"eventTime\": \"2024-02-07T13:22:47.641175778Z\",", + " * \"id\": \"ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -551,13 +760,109 @@ { "title": "onOrderEnded example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderEnded(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderEnded(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + " const endDate = event.data.endDate;", "", - " " + " console.log(`Order ID ${orderId} with buyer ID ${buyerContactId}, ended for the plan ID ${planId} on ${endDate}. Full event object:`, event);", + "}", + "", + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-01T10:27:58.453Z\",", + " * \"_id\": \"9af3cbe6-fe27-4fdb-a0b0-892289b03d22\",", + " * \"_updatedDate\": \"2024-02-11T08:13:44.674Z\",", + " * \"buyer\": {", + " * \"contactId\": \"402ec90c-235a-45c4-b4cc-52204d5f6b00\",", + " * \"memberId\": \"402ec90c-235a-45c4-b4cc-52204d5f6b00\"", + " * },", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"IMMEDIATELY\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-02-11T08:13:44.588Z\",", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-01T10:27:58.453Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-02-11T08:13:44.588Z\",", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"10206732-e789-40e9-957d-2c7f3398efc6\"", + " * },", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [", + " * {", + " * \"pauseDate\": \"2024-02-04T10:02:03.726Z\",", + " * \"resumeDate\": \"2024-02-04T13:05:04.465Z\",", + " * \"status\": \"ENDED\"", + " * }", + " * ],", + " * \"planDescription\": \"\",", + " * \"planId\": \"0da57ac8-c3d0-4687-8aea-4100781b6386\",", + " * \"planName\": \"Expensive Plan\",", + " * \"planPrice\": \"10000\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"10000.00\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"10000.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"priceDetails\": {", + " * \"coupon\": {", + " * \"_id\": \"07de4c3a-536b-4c30-adb9-991935da1681\",", + " * \"amount\": \"10000.00\",", + " * \"code\": \"sale-day\"", + " * },", + " * \"currency\": \"USD\",", + " * \"discount\": \"10000.00\",", + " * \"planPrice\": \"10000\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"10000.00\",", + " * \"total\": \"0\"", + " * },", + " * \"startDate\": \"2024-02-01T10:27:58.453Z\",", + " * \"status\": \"CANCELED\",", + " * \"statusNew\": \"CANCELED\",", + " * \"subscriptionId\": \"0cd18587-a637-4327-a05c-ab4e86bd59fe\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"4012ab0c-f1cb-4632-917e-f611de27dcad\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"9af3cbe6-fe27-4fdb-a0b0-892289b03d22\",", + " * \"eventTime\": \"2024-02-11T08:13:44.817334927Z\",", + " * \"id\": \"601feaeb-7306-4428-b768-906f12938004\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */", + "" ] } ] @@ -601,13 +906,108 @@ { "title": "onOrderMarkedAsPaid example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderMarkedAsPaid(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderMarkedAsPaid(event) {", + " const orderId = event.entity._id;", + " const paidDate = event.metadata.eventTime;", + " const planId = event.data.planId;", + " const buyerContactId = event.entity.buyer.contactId;", "", - " " + " console.log(`Order ID ${event.orderId} to purchase plan ID ${planId} was paid on ${paidDate} by the buyer contact ID ${buyerContactId}. The full event object:`, event);", + "}", + "", + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-01T10:27:58.453Z\",", + " * \"_id\": \"9af3cbe6-fe27-4fdb-a0b0-892289b03d22\",", + " * \"_updatedDate\": \"2024-02-11T08:13:44.674Z\",", + " * \"buyer\": {", + " * \"contactId\": \"402ec90c-235a-45c4-b4cc-52204d5f6b00\",", + " * \"memberId\": \"402ec90c-235a-45c4-b4cc-52204d5f6b00\"", + " * },", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"IMMEDIATELY\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-02-11T08:13:44.588Z\",", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-01T10:27:58.453Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-02-11T08:13:44.588Z\",", + " * \"formData\": {", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"submissionData\": {},", + " * \"submissionId\": \"10206732-e789-40e9-957d-2c7f3398efc6\"", + " * },", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [", + " * {", + " * \"pauseDate\": \"2024-02-04T10:02:03.726Z\",", + " * \"resumeDate\": \"2024-02-04T13:05:04.465Z\",", + " * \"status\": \"ENDED\"", + " * }", + " * ],", + " * \"planDescription\": \"\",", + " * \"planId\": \"0da57ac8-c3d0-4687-8aea-4100781b6386\",", + " * \"planName\": \"Expensive Plan\",", + " * \"planPrice\": \"10000\",", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"10000.00\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"10000.00\",", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"priceDetails\": {", + " * \"coupon\": {", + " * \"_id\": \"07de4c3a-536b-4c30-adb9-991935da1681\",", + " * \"amount\": \"10000.00\",", + " * \"code\": \"sale-day\"", + " * },", + " * \"currency\": \"USD\",", + " * \"discount\": \"10000.00\",", + " * \"planPrice\": \"10000\",", + " * \"singlePaymentUnlimited\": true,", + " * \"subtotal\": \"10000.00\",", + " * \"total\": \"0\"", + " * },", + " * \"startDate\": \"2024-02-01T10:27:58.453Z\",", + " * \"status\": \"CANCELED\",", + " * \"statusNew\": \"CANCELED\",", + " * \"subscriptionId\": \"0cd18587-a637-4327-a05c-ab4e86bd59fe\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"4012ab0c-f1cb-4632-917e-f611de27dcad\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"9af3cbe6-fe27-4fdb-a0b0-892289b03d22\",", + " * \"eventTime\": \"2024-02-11T08:13:44.817334927Z\",", + " * \"id\": \"601feaeb-7306-4428-b768-906f12938004\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */" ] } ] @@ -651,13 +1051,116 @@ { "title": "onOrderPaused example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderPaused(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderPaused(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + " ", + " console.log(`Order ID of ${orderId} was paused for plan ID ${planId} for buyer contact ID ${buyerContactId}. Full event object:`, event);", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"_id\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"_updatedDate\": \"2024-02-07T13:22:47.459Z\",", + " * \"autoRenewCanceled\": true,", + " * \"buyer\": {", + " * \"contactId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\",", + " * \"memberId\": \"554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4\"", + " * },", + " * \"cancellation\": {", + " * \"cause\": \"OWNER_ACTION\",", + " * \"effectiveAt\": \"NEXT_PAYMENT_DATE\"", + " * },", + " * \"currentCycle\": {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"endedDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"index\": 0,", + " * \"startedDate\": \"2024-01-28T09:49:21.041Z\"", + " * }", + " * ],", + " * \"endDate\": \"2024-04-27T09:49:21.041Z\",", + " * \"earliestEndDate\": \"2026-04-27T09:49:21.041Z\",", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"freeTrialDays\": 90,", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"3 mo free trial with discount for 1 year\",", + " * \"planId\": \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"planName\": \"Beginner's Plan\",", + " * \"planPrice\": \"50\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"freeTrialDays\": 90,", + " * \"planPrice\": \"50\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\",", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 2", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"50.00\",", + " * \"total\": \"50.00\"", + " * }", + " * }", + " * ],", + " * \"subscription\": {", + " * \"cycleCount\": 2,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"YEAR\"", + " * }", + " * }", + " * },", + " * \"startDate\": \"2024-01-28T09:49:21.041Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"305f8fc9-3724-4cac-9f67-4e29f2c46def\",", + " * \"type\": \"OFFLINE\",", + " * \"wixPayOrderId\": \"2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"82d99338-5653-459a-a751-b57483f7cfb5\",", + " * \"eventTime\": \"2024-02-07T13:22:47.641175778Z\",", + " * \"id\": \"ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -709,8 +1212,11 @@ "", "export function wixPricingPlans_onOrderPurchased(event) {", " const orderId = event.data.order._id;", - " const eventId = event.metadata.id;", " const eventTime = event.metadata.eventTime;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + "", + " console.log(`Order ${orderId}: Buyer contact ID ${buyerContactId} purchased plan ${planId} at ${eventTime}. Full event object:`, event);", "}", "", "/* Full event object:", @@ -833,13 +1339,115 @@ { "title": "onOrderResumed example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderResumed(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderResumed(event) {", + " const orderId = event.data.order._id;", + " const planId = event.data.planId;", + " const eventTime = event.metadata.eventTime;", + " ", + " console.log(`Order ID ${orderId} was resumed for plan ID ${planId} at ${eventTime}. Full event object:`, event);", + "}", "", - " " + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-11T09:11:13.012Z\",", + " * \"_id\": \"3feb1cf5-bf38-47c4-81cb-06b61ca11c8a\",", + " * \"_updatedDate\": \"2024-02-11T09:14:57.750Z\",", + " * \"buyer\": {", + " * \"contactId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\",", + " * \"memberId\": \"3fc889f6-18e8-4fd9-a509-27db9f037f26\"", + " * },", + " * \"currentCycle\": {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-11T09:11:13.012Z\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-11T09:11:13.012Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"PAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [", + " * {", + " * \"pauseDate\": \"2024-02-11T09:14:57.750Z\",", + " * \"resumeDate\": \"2024-02-11T09:28:13.186Z\",", + " * \"status\": \"ENDED\"", + " * }", + " * ],", + " * \"planDescription\": \"Full feature enablement - lifetime plan\",", + " * \"planId\": \"e901222b-c137-4bc7-adc3-c1efa3c880a2\",", + " * \"planName\": \"Quality Plan - Lifetime\",", + " * \"planPrice\": \"1500\",", + " * \"priceDetails\": {", + " * \"coupon\": {", + " * \"_id\": \"07de4c3a-536b-4c30-adb9-991935da1681\",", + " * \"amount\": \"1500.00\",", + " * \"code\": \"sale-day\"", + " * },", + " * \"currency\": \"USD\",", + " * \"discount\": \"1500.00\",", + " * \"planPrice\": \"1500\",", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"1500.00\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"0\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"0\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-02-11T09:11:13.012Z\",", + " * \"status\": \"ACTIVE\",", + " * \"statusNew\": \"ACTIVE\",", + " * \"subscriptionId\": \"d3290015-f808-4f08-a4a0-6732acbf2a43\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"36a79fab-c436-4bf0-b3be-14e9f75cf263\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"3feb1cf5-bf38-47c4-81cb-06b61ca11c8a\",", + " * \"eventTime\": \"2024-02-11T09:28:13.343708694Z\",", + " * \"id\": \"c020a4af-1647-4301-b821-d6ee72b7a462\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ ", + "" ] } ] @@ -883,13 +1491,99 @@ { "title": "onOrderStartDateChanged example", "body": [ + "// Place this code in the events.js file", + "// of your site's Backend section.", + "// Add the file if it doesn't exist.", "", - " export function wixPricingPlans_onOrderStartDateChanged(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", - " }", + "export function wixPricingPlans_onOrderStartDateChanged(event) {", + " const orderId = event.data.order._id;", + " const buyerContactId = event.data.buyer.contactId;", + " const startDate = event.startDate;", "", - " " + " console.log(`Start date for order ID ${orderId} was changed to ${startDate} by contact ID ${buyerContactId}. Full event object:`, event);", + "}", + "", + "/* Full event object:", + " * {", + " * \"data\": {", + " * \"order\": {", + " * \"_createdDate\": \"2024-02-14T11:15:57.921Z\",", + " * \"_id\": \"a15b2fdf-f21c-4d3e-bae2-12a344cc4cad\",", + " * \"_updatedDate\": \"2024-02-14T11:16:45.641Z\",", + " * \"buyer\": {", + " * \"contactId\": \"600e2577-6414-42a5-b35b-839e166eaf5a\",", + " * \"memberId\": \"600e2577-6414-42a5-b35b-839e166eaf5a\"", + " * },", + " * \"cycles\": [", + " * {", + " * \"index\": 1,", + " * \"startedDate\": \"2024-02-16T22:00:00.000Z\"", + " * }", + " * ],", + " * \"formData\": {", + " * \"submissionData\": {}", + " * },", + " * \"lastPaymentStatus\": \"UNPAID\",", + " * \"orderMethod\": \"UNKNOWN\",", + " * \"pausePeriods\": [],", + " * \"planDescription\": \"Full feature enablement - lifetime plan\",", + " * \"planId\": \"e901222b-c137-4bc7-adc3-c1efa3c880a2\",", + " * \"planName\": \"Quality Plan - Lifetime\",", + " * \"planPrice\": \"1500\",", + " * \"priceDetails\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"planPrice\": \"1500\",", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"97.50\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"1597.50\"", + " * },", + " * \"pricing\": {", + " * \"prices\": [", + " * {", + " * \"duration\": {", + " * \"cycleFrom\": 1,", + " * \"numberOfCycles\": 1", + " * },", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"discount\": \"0\",", + " * \"fees\": [],", + " * \"proration\": \"0\",", + " * \"subtotal\": \"1500.00\",", + " * \"tax\": {", + " * \"amount\": \"97.50\",", + " * \"includedInPrice\": false,", + " * \"name\": \"Tax\",", + " * \"rate\": \"6.5\"", + " * },", + " * \"total\": \"1597.50\"", + " * }", + " * }", + " * ],", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"startDate\": \"2024-02-16T22:00:00.000Z\",", + " * \"status\": \"DRAFT\",", + " * \"statusNew\": \"DRAFT\",", + " * \"subscriptionId\": \"78933e41-6482-4545-a7e0-483ec74cfa97\",", + " * \"type\": \"ONLINE\",", + " * \"wixPayOrderId\": \"97aa019c-13f2-4e2a-a8a2-62cd9ffa6ef0\"", + " * }", + " * },", + " * \"metadata\": {", + " * \"entityId\": \"a15b2fdf-f21c-4d3e-bae2-12a344cc4cad\",", + " * \"eventTime\": \"2024-02-14T11:16:45.787406262Z\",", + " * \"id\": \"05924d5a-5f1e-4f9a-ba77-f3a784661d41\",", + " * \"triggeredByAnonymizeRequest\": false", + " * }", + " * }", + " */ " ] } ] @@ -938,8 +1632,12 @@ "// Add the file if it doesn't exist.", "", "export function wixPricingPlans_onOrderStarted(event) {", - " const eventId = event.metadata.id", - " const entityId = event.data.order._id;", + " const orderId = event.data.order._id;", + " const eventTime = event.metadata.eventTime;", + " const buyerContactId = event.data.buyer.contactId;", + " const planId = event.data.planId;", + "", + " console.log(`New order started: Order ID ${orderId} at ${eventTime} by contact ID ${buyerContactId} to purchase plan ${planId}. Full event object:`, event);", "}", "", "/* Full event object:", @@ -1068,8 +1766,11 @@ "// Add the file if it doesn't exist.", "", "export function wixPricingPlans_onOrderUpdated(event) {", - "\tconst eventId = event.metadata.id", - "\tconst entityId = event.entity._id;", + " const orderId = event.data.order._id;", + " const eventTime = event.metadata.eventTime;", + " const buyerContactId = event.data.buyer.contactId;", + "", + " console.log(`Order update: Order ID ${orderId} was updated at ${eventTime} by contact ID ${buyerContactId}. Full event object:`, event);", "}", "", "/* Full event object:", From a194212ba722e40d60e169fc48c83b963a2e7b44 Mon Sep 17 00:00:00 2001 From: ryangec Date: Sun, 3 Mar 2024 10:30:06 +0200 Subject: [PATCH 20/28] updated articles --- .../Orders/guides/orders-intro.md | 4 +- .../Plans/guides/plans-intro.md | 2 +- .../Plans/guides/pricing-models.md | 138 +++++++++++++++++ .../guides/pricing-plans-intro.md | 144 +----------------- 4 files changed, 147 insertions(+), 141 deletions(-) create mode 100644 wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/pricing-models.md diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders/guides/orders-intro.md b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders/guides/orders-intro.md index b6bb2fdcfc..314a2e7d49 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders/guides/orders-intro.md +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders/guides/orders-intro.md @@ -15,14 +15,14 @@ title: Introduction -The Pricing Plans Orders API allows you to manage orders for your pricing plans. +The Orders API allows you to manage orders for your pricing plans. With the Pricing Plans Orders API, you can: - [Get](wix-pricing-plans-v2/orders/managementgetorder) and [list](wix-pricing-plans-v2/orders/managementlistorders) orders. - [Create](wix-pricing-plans-v2/orders/createofflineorder) offline orders. - [Mark](wix-pricing-plans-v2/orders/markaspaid) offline orders as paid. - [Preview](wix-pricing-plans-v2/orders/getpricepreview) the pricing details of an order. -- [Pause](wix-pricing-plans-v2/orders/pauseorder), [resume](wix-pricing-plans-v2/orders/resumeorder), or [cancel](requestcancellation) orders. +- [Pause](wix-pricing-plans-v2/orders/pauseorder), [resume](wix-pricing-plans-v2/orders/resumeorder), or [cancel](wix-pricing-plans-v2/orders/cancelorder) orders. - [Extend the duration](wix-pricing-plans-v2/orders/postponeenddate) of orders. diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/plans-intro.md b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/plans-intro.md index a283c86cf2..a1c88c2427 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/plans-intro.md +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/plans-intro.md @@ -18,7 +18,7 @@ title: Introduction The Pricing Plans Plans API allows you to manage your pricing plans. With the Pricing Plans Plans API, you can: -- [Create](wix-pricing-plans-v2/plans/createplan) and [update](wix-pricing-plans-v2/plans/updateplans) orders. +- [Create](wix-pricing-plans-v2/plans/createplan) and [update](wix-pricing-plans-v2/plans/updateplan) plans. - [Get](wix-pricing-plans-v2/plans/getplan), [list](wix-pricing-plans-v2/plans/listplans) and [query](wix-pricing-plans-v2/plans/querypublicplans) plans. - [Set visibility](wix-pricing-plans-v2/plans/setplanvisibility) for which plans are public and which are hidden. - [Archive](archivePlan) plans. diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/pricing-models.md b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/pricing-models.md new file mode 100644 index 0000000000..10cbb07f53 --- /dev/null +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans/guides/pricing-models.md @@ -0,0 +1,138 @@ +--- +title: Pricing Models +--- + +# Pricing models +Pricing models contain the [pricing and duration options](https://support.wix.com/en/article/pricing-plans-creating-a-plan#step-3-setting-the-price-and-duration-of-your-plan) for a plan. + +Plans are based on a pricing model, which is defined with the plan's `pricing` property. A pricing model can be one of the following: ++ **A subscription:** A plan with recurring payment cycles. + +*Example:* A 1-year subscription with monthly, recurring payments. Each payment is $25, so the total price for the plan is $300. In this example, the subscription is in its third month. + +`cycleDuration` is the length of one payment cycle. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, `cycleDuration` only supports a value of `1`. + +`index` of `currentCycle` is the current payment cycle for the subscription. `index` is `0` when the order is in a free trial period. In all other cases, the `index` starts with `1` for the first payment cycle in the subscription. For orders with a single payment, the `index` will remain `1` throughout the duration. +```javascript + "pricing": { + "subscription": { + "cycleDuration": { + // Payment recurs every month + "count": 1, + "unit": "MONTH" + }, + // for 12 times + "cycleCount": 12 + }, + "prices": [{ + "duration": { + "cycleFrom": 1, + "numberOfCycles": 12 + }, + "price": { + "subtotal": "25", + "discount": "0", + "total": "25", + "currency": "USD" + } + }] + }, + ... + "currentCycle": { + "index": 3, + "startedDate": "2022-03-01T13:45:53.129Z", + "endedDate": "2022-04-01T13:45:53.129Z" + }, +``` ++ **A Single Payment for Duration plan:** A plan paid for with a single payment. The plan does not renew after the duration. + +*Example:* A plan with a single payment of $35 for 3 months. + +The `duration` `cycleFrom` and `numberOfCycles` will both be `1`, as the single price applies to the entirety of the subscription. + +`index` of `currentCycle` will remain `1` throughout the duration. +```javascript + "pricing": { + "singlePaymentForDuration": { + // Plan duration is 3 months + "count": 3, + "unit": "MONTH" + }, + "prices": [{ + "duration": { + "cycleFrom": 1, + "numberOfCycles": 1 + }, + "price": { + "subtotal": "35", + "discount": "0", + "total": "35", + "currency": "USD" + } + }] + }, + ... + "currentCycle": { + "index": 1, + "startedDate": "2022-01-01T13:45:53.129Z", + "endedDate": "2022-04-01T13:45:53.129Z" + }, +``` ++ **A Single Payment Unlimited plan:** A plan paid for with a single payment. The plan does not expire and remains valid until canceled. + +*Example:* An unlimited plan that is paid for in advance with one payment of $200. + +`singlePaymentUnlimited` is `true`. + +The `duration` `cycleFrom` and `numberOfCycles` will remain `1` throughout the duration of the plan. + +`index` of `currentCycle` will remain `1` throughout the duration. `singlePaymentUnlimitedPlans` don't return an `endedDate` in `currentCycle`. +```javascript + "pricing": { + "singlePaymentUnlimited": true, + "prices": [{ + "duration": { + "cycleFrom": 1, + "numberOfCycles": 1 + }, + "price": { + "subtotal": "200", + "discount": "0", + "total": "200", + "currency": "USD" + } + }] + }, + ... + "currentCycle": { + "index": 1, + "startedDate": "2021-06-015T13:45:53.129Z" + }, +``` + +### Free plans and free trial periods +A free plan that is valid until canceled is a `singlePaymentUnlimited` pricing model. A free plan with a limited duration is treated as a `singlePaymentForDuration` pricing model. + +A site owner can also add a free trial period, in days, to a `subscription` pricing model. When the free trial is over, the first payment cycle begins and the buyer is billed. During the free trial period, the `index` of `currentCycle` is `0`. A buyer only receives the free trial period for the first time they purchase a plan. For example, a buyer purchases a monthly plan for 3 months that includes a 7-day free trial period. The buyer may purchase the same plan again, for another 3 months, but will not receive the 7-day free trial period. + +When a buyer cancels their order during the free trial period, their subscription will expire at the end of the free trial period and they will not be billed. A site owner can [cancel an ordered plan](wix-pricing-plans-v2/orders/cancelorder) during the free trial period and choose to apply the cancellation `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. + +Canceling `IMMEDIATELY` ends the subscription for the buyer immediately, even during the free trial period, and the buyer won't be billed. Canceling at the `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period. Then, the subscription ends and the buyer is not billed. + +### Pricing plan types and visibility + ++ **Public pricing plans** are visible plans that site members and visitors can see on the site and purchase. By default, pricing plans are public when created. + ++ **Hidden pricing plans** are plans whose `public` property has been set to `false`. These plans cannot be seen on the site by the site member or visitor. For example, consider hiding a plan if it has reached its maximum capacity and temporarily is not available for purchase. + + Changing a plan’s visibility with the `public` property does not impact existing purchases. All purchases for hidden plans are still active and keep their terms and payment options. + ++ **Active pricing plans** include all non-archived plans, such as public plans and hidden plans. + ++ **Archived pricing plans** are plans that are no longer needed on the site. For example, discontinued plans. When a plan is archived, it is no longer visible as a public plan that can be chosen by site visitors. + +The `public` property is automatically set to `false` when a plan is archived. Archived plans cannot be purchased. + +Site owners can see archived plans in the Dashboard under **Pricing Plans -> Archived Plans**. + +Archiving cannot be reversed. Once archived, a plan cannot be set as active again for purchase. Archiving does not impact existing purchases made for the plan. All purchases are still active and keep their pricing and terms. \ No newline at end of file diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md b/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md index 576a939632..261aacbef4 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md @@ -33,6 +33,10 @@ Make sure to set up your site to: When setting up your site to accept pricing plans, define the plans you want to offer [using the Dashboard](https://support.wix.com/en/article/creating-a-plan-in-pricing-plans) or [using the Pricing Plans' Plans APIs](wix-pricing-plans-v2/plans). +### Creating plans +In order to build user presence and generate revenue on your site, Wix provides you with the ability to offer a robust selection of different pricing plans. You can customize your plans by price, expiration, terms, included services, and more in accordance with each plan's unique [pricing models](../Plans/guides/pricing-models.md). + +The [Plans API](https://www.wix.com/velo/reference/wix-pricing-plans-v2/plans) exposes the ability to create, edit, and manage your plans, in code, allowing you to customize and enhance your site for user and administrative experience. ### Managing orders @@ -43,145 +47,9 @@ Members can order pricing plans in 2 ways: > **Note:** > Updating the properties of a pricing plan does not affect any current orders of the plan by members. The existing orders retain their existing terms and pricing. - ### Pricing models -Pricing models contain the [pricing and duration options](https://support.wix.com/en/article/pricing-plans-creating-a-plan#step-3-setting-the-price-and-duration-of-your-plan) for a plan. - -Plans are based on a pricing model, which is defined with the plan's `pricing` property. A pricing model can be one of the following: -+ **A subscription:** A plan with recurring payment cycles. - -*Example:* A 1-year subscription with monthly, recurring payments. Each payment is $25, so the total price for the plan is $300. In this example, the subscription is in its third month. - -`cycleDuration` is the length of one payment cycle. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, `cycleDuration` only supports a value of `1`. - -`index` of `currentCycle` is the current payment cycle for the subscription. `index` is `0` when the order is in a free trial period. In all other cases, the `index` starts with `1` for the first payment cycle in the subscription. For orders with a single payment, the `index` will remain `1` throughout the duration. -```javascript - "pricing": { - "subscription": { - "cycleDuration": { - // Payment recurs every month - "count": 1, - "unit": "MONTH" - }, - // for 12 times - "cycleCount": 12 - }, - "prices": [{ - "duration": { - "cycleFrom": 1, - "numberOfCycles": 12 - }, - "price": { - "subtotal": "25", - "discount": "0", - "total": "25", - "currency": "USD" - } - }] - }, - ... - "currentCycle": { - "index": 3, - "startedDate": "2022-03-01T13:45:53.129Z", - "endedDate": "2022-04-01T13:45:53.129Z" - }, -``` -+ **A Single Payment for Duration plan:** A plan paid for with a single payment. The plan does not renew after the duration. - -*Example:* A plan with a single payment of $35 for 3 months. - -The `duration` `cycleFrom` and `numberOfCycles` will both be `1`, as the single price applies to the entirety of the subscription. - -`index` of `currentCycle` will remain `1` throughout the duration. -```javascript - "pricing": { - "singlePaymentForDuration": { - // Plan duration is 3 months - "count": 3, - "unit": "MONTH" - }, - "prices": [{ - "duration": { - "cycleFrom": 1, - "numberOfCycles": 1 - }, - "price": { - "subtotal": "35", - "discount": "0", - "total": "35", - "currency": "USD" - } - }] - }, - ... - "currentCycle": { - "index": 1, - "startedDate": "2022-01-01T13:45:53.129Z", - "endedDate": "2022-04-01T13:45:53.129Z" - }, -``` -+ **A Single Payment Unlimited plan:** A plan paid for with a single payment. The plan does not expire and remains valid until canceled. - -*Example:* An unlimited plan that is paid for in advance with one payment of $200. - -`singlePaymentUnlimited` is `true`. - -The `duration` `cycleFrom` and `numberOfCycles` will remain `1` throughout the duration of the plan. - -`index` of `currentCycle` will remain `1` throughout the duration. `singlePaymentUnlimitedPlans` don't return an `endedDate` in `currentCycle`. -```javascript - "pricing": { - "singlePaymentUnlimited": true, - "prices": [{ - "duration": { - "cycleFrom": 1, - "numberOfCycles": 1 - }, - "price": { - "subtotal": "200", - "discount": "0", - "total": "200", - "currency": "USD" - } - }] - }, - ... - "currentCycle": { - "index": 1, - "startedDate": "2021-06-015T13:45:53.129Z" - }, -``` - -### Free plans and free trial periods -A free plan that is valid until canceled is a `singlePaymentUnlimited` pricing model. A free plan with a limited duration is treated as a `singlePaymentForDuration` pricing model. - -A site owner can also add a free trial period, in days, to a `subscription` pricing model. When the free trial is over, the first payment cycle begins and the buyer is billed. During the free trial period, the `index` of `currentCycle` is `0`. A buyer only receives the free trial period for the first time they purchase a plan. For example, a buyer purchases a monthly plan for 3 months that includes a 7-day free trial period. The buyer may purchase the same plan again, for another 3 months, but will not receive the 7-day free trial period. - -When a buyer cancels their order during the free trial period, their subscription will expire at the end of the free trial period and they will not be billed. A site owner can [cancel an ordered plan](wix-pricing-plans-v2/orders/cancelorder) during the free trial period and choose to apply the cancellation `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`. - -Canceling `IMMEDIATELY` ends the subscription for the buyer immediately, even during the free trial period, and the buyer won't be billed. Canceling at the `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period. Then, the subscription ends and the buyer is not billed. - -### Pricing plan types and visibility - -+ **Public pricing plans** are visible plans that site members and visitors can see on the site and purchase. By default, pricing plans are public when created. - -+ **Hidden pricing plans** are plans whose `public` property has been set to `false`. These plans cannot be seen on the site by the site member or visitor. For example, consider hiding a plan if it has reached its maximum capacity and temporarily is not available for purchase. - - Changing a plan’s visibility with the `public` property does not impact existing purchases. All purchases for hidden plans are still active and keep their terms and payment options. - -+ **Active pricing plans** include all non-archived plans, such as public plans and hidden plans. - -+ **Archived pricing plans** are plans that are no longer needed on the site. For example, discontinued plans. When a plan is archived, it is no longer visible as a public plan that can be chosen by site visitors. - -The `public` property is automatically set to `false` when a plan is archived. Archived plans cannot be purchased. - -Site owners can see archived plans in the Dashboard under **Pricing Plans -> Archived Plans**. - -Archiving cannot be reversed. Once archived, a plan cannot be set as active again for purchase. Archiving does not impact existing purchases made for the plan. All purchases are still active and keep their pricing and terms. - - ### Orders and subscriptions -Actions related to basic pricing plan management are available from the [Pricing Plans](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmembership%3FreferralInfo%3Dvelo-docs) page in the Dashboard. These actions correspond to the functions available in the [Plans APIs](wix-pricing-plans-v2/plans/introduction). +Actions related to basic pricing plan management are available from the [Pricing Plans](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fmembership%3FreferralInfo%3Dvelo-docs) page in the Dashboard. These actions correspond to the functions available in the [Plans API](wix-pricing-plans-v2/plans/introduction). Every pricing plan order corresponds to a Wix subscription, including orders for single payment plans. You can see all orders from your site's [Subscriptions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fsubscriptions%3FreferralInfo%3Dvelo-docs) page in the Dashboard. Actions available on this page correspond to the functions available in the [Orders APIs](wix-pricing-plans-v2/orders/introduction). @@ -189,7 +57,7 @@ Every pricing plan order corresponds to a Wix subscription, including orders for > **Notes**: > -> + Wix pricing plans are 1 of several Wix subscriptions available from the Subscriptions page. For example, the Subscriptions page also includes Wix Stores subscriptions and Wix invoice subscriptions. +> + Wix pricing plans are 1 of several Wix subscriptions available from the [Subscriptions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fsubscriptions%3FreferralInfo%3Dvelo-docs) page. For example, the Subscriptions page also includes Wix Stores subscriptions and Wix invoice subscriptions. > > + Pricing plans can be 1 of 3 different pricing models: `singlePaymentForDuration`, `singlePaymentUnlimited`, or `subscription`. Orders for all pricing plan models are displayed on the Subscriptions page, not just `subscription` type models. See [Pricing Models](wix-pricing-plans-v2/introduction#pricing-models) to learn more. From cfc336654e8650d328df4191e4c219d24e83a624 Mon Sep 17 00:00:00 2001 From: ryangec Date: Sun, 3 Mar 2024 11:16:56 +0200 Subject: [PATCH 21/28] updated relative link to pricing-models article on intro --- .../wix-pricing-plans-v2/guides/pricing-plans-intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md b/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md index 261aacbef4..30f476ecc0 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/guides/pricing-plans-intro.md @@ -34,7 +34,7 @@ Make sure to set up your site to: When setting up your site to accept pricing plans, define the plans you want to offer [using the Dashboard](https://support.wix.com/en/article/creating-a-plan-in-pricing-plans) or [using the Pricing Plans' Plans APIs](wix-pricing-plans-v2/plans). ### Creating plans -In order to build user presence and generate revenue on your site, Wix provides you with the ability to offer a robust selection of different pricing plans. You can customize your plans by price, expiration, terms, included services, and more in accordance with each plan's unique [pricing models](../Plans/guides/pricing-models.md). +In order to build user presence and generate revenue on your site, Wix provides you with the ability to offer a robust selection of different pricing plans. You can customize your plans by price, expiration, terms, included services, and more in accordance with each plan's unique [pricing model](/Plans/guides/pricing-models). The [Plans API](https://www.wix.com/velo/reference/wix-pricing-plans-v2/plans) exposes the ability to create, edit, and manage your plans, in code, allowing you to customize and enhance your site for user and administrative experience. From 734c167741f78ec661a18d9fdf7bf4eaeff38700 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Sun, 3 Mar 2024 11:11:16 +0000 Subject: [PATCH 22/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index bf61869eb9..11e02e5bce 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -20,7 +20,7 @@ "displayName": "OrderAutoRenewCanceledEvent" } ], - "doc": "", + "doc": "Information about the order whose auto-renewal is canceled and metadata for the event.\n", "required": false } ], @@ -34,9 +34,9 @@ "doc": null }, "docs": { - "summary": "Triggered when an order is canceled and `effectiveAt` is set to `NEXT_PAYMENT_DATE`.", + "summary": "The `onOrderAutoRenewCanceled()` is triggered when an order is canceled and `effectiveAt` is set to `NEXT_PAYMENT_DATE`.", "description": [ - "This webhook is *not* triggered in the following scenarios:\n+ When an order is canceled and `effectiveAt` is set to `IMMEDIATELY`. Instead, at the time of cancellation, [Order Canceled](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-canceled-webhook) is triggered.\n+ When an order expires at the end of the current payment cycle because it was canceled and `effectiveAt` was set to `NEXT_PAYMENT_DATE`. Instead, at the time of expiration, [Order Canceled](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-canceled-webhook) and [Order Ended](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-ended-webhook) are triggered." + "The `onOrderAutoRenewCanceled()` event is *not* triggered in the following scenarios:\n+ When an order is canceled and `effectiveAt` is set to `IMMEDIATELY`. At the time of cancellation, [`onOrderCanceled`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordercanceled) is triggered instead.\n+ When an order expires at the end of the current payment cycle because it was canceled and `effectiveAt` was set to `NEXT_PAYMENT_DATE`. At the time of expiration, [`onOrderCanceled`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordercanceled) and [`onOrderEnded`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderended) are triggered instead." ], "examples": [ { @@ -176,7 +176,7 @@ "displayName": "OrderCanceledEvent" } ], - "doc": "", + "doc": "Information about the canceled order and metadata for the event.\n", "required": false } ], @@ -329,7 +329,7 @@ "displayName": "OrderCreated" } ], - "doc": "", + "doc": "Information about the created order and metadata for the event.\n", "required": false } ], @@ -450,7 +450,7 @@ "displayName": "OrderCycleStartedEvent" } ], - "doc": "", + "doc": "Information about the order whose payment cycle started and metadata for the event.\n", "required": false } ], @@ -585,7 +585,7 @@ "displayName": "OrderEndDatePostponedEvent" } ], - "doc": "", + "doc": "Information about the order that is postponed and metadata for the event.\n", "required": false } ], @@ -738,7 +738,7 @@ "displayName": "OrderEndedEvent" } ], - "doc": "", + "doc": "Information about the order that ended and metadata for the event.\n", "required": false } ], @@ -886,7 +886,7 @@ "displayName": "OrderMarkedAsPaidEvent" } ], - "doc": "", + "doc": "Information about the offline order that was paid and metadata for the event.\n", "required": false } ], @@ -1031,7 +1031,7 @@ "displayName": "OrderPausedEvent" } ], - "doc": "", + "doc": "Information about the order that is paused and metadata for the event.\n", "required": false } ], @@ -1184,7 +1184,7 @@ "displayName": "OrderPurchasedEvent" } ], - "doc": "", + "doc": "Information about the order that was purchased and metadata for the event.\n", "required": false } ], @@ -1319,7 +1319,7 @@ "displayName": "OrderResumedEvent" } ], - "doc": "", + "doc": "Information about the order that was resumed and metadata for the event\n", "required": false } ], @@ -1471,7 +1471,7 @@ "displayName": "OrderStartDateChangedEvent" } ], - "doc": "", + "doc": "Information about the order whose start date changed and metadata for the event.\n", "required": false } ], @@ -1607,7 +1607,7 @@ "displayName": "OrderStartedEvent" } ], - "doc": "", + "doc": "Information about the order that started and metadata for the event.\n", "required": false } ], @@ -1739,7 +1739,7 @@ "displayName": "OrderUpdated" } ], - "doc": "", + "doc": "Information about the order that was updated and metadata for the event.\n", "required": false } ], @@ -1755,7 +1755,7 @@ "docs": { "summary": "Triggered when an order is updated.", "description": [ - "Order Updated Webhook is triggered when any of the following happens:\n+ Order is paid for. [Order Purchased Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-purchased-webhook) is also triggered.\n+ Order reaches its start date or end date. [Order Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-started-webhook) and [Order Ended Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-ended-webhook), respectively, are also triggered.\n+ New payment cycle of an order starts. [Order Cycle Started Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-cycle-started-webhook) is also triggered.\n+ Offline order is marked as paid. [Order Marked As Paid Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-marked-as-paid-webhook) is also triggered.\n+ End date of the order is postponed. [Order End Date Postponed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-end-date-postponed-webhook) is also triggered\n+ Order is paused, or a paused order is resumed. [Order Paused Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-paused-webhook)\nand [Order Resumed Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-resumed-webhook), respectively, are also triggered.\n+ Order is canceled, either immediately or at the end of the payment cycle. [Order Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-canceled-webhook)\nand [Order Auto Renew Canceled Webhook](https://dev.wix.com/api/rest/wix-pricing-plans/pricing-plans/orders/order-auto-renew-canceled-webhook) are also triggered." + "This is a general webhook that is triggered when any update is made to an order. More specific webhooks are also triggered for the same originating events.\n\n| Order event | Also triggered |\n| ----------------------------------- | ------------------------------------------|\n| Order is paid for. | [`onOrderPurchased()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderpurchased) |\n| Free or offline order is created. | [`onOrderCreated()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordercreated) |\n| Order reaches its `startDate`. | [`onOrderStarted()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderstarted) |\n| Order reaches its `endDate`. | [`onOrderEnded()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderended) |\n| New payment cycle of an order starts. | [`onOrderCycleStarted()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordercyclestarted) |\n| Offline order is marked as paid. | [`onOrderMarkedAsPaid()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordermarkedaspaid) |\n| `endDate` of the order is postponed. | [`onOrderEndDatePostponed()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderenddatepostponed) |\n| Order is paused. | [`onOrderPaused()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderpaused) |\n| Paused order is resumed. | [`onOrderResumed()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderresumed) |\n| Order is canceled. | [`onOrderCanceled()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onordercanceled) |\n| Order is canceled and `effectiveAt` is set to `NEXT_PAYMENT_DATE`. | [`onOrderAutoRenewCanceled()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/events/onorderautorenewcanceled) |" ], "examples": [ { @@ -4883,7 +4883,7 @@ "displayName": "OrderAutoRenewCanceled" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -4934,7 +4934,7 @@ "displayName": "OrderCanceled" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -4964,7 +4964,7 @@ "displayName": "Order" } ], - "doc": "Created order." + "doc": "Order information." }, { "name": "metadata", @@ -5065,7 +5065,7 @@ "displayName": "OrderCycleStarted" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5116,7 +5116,7 @@ "displayName": "OrderEndDatePostponed" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5167,7 +5167,7 @@ "displayName": "OrderEnded" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5218,7 +5218,7 @@ "displayName": "OrderMarkedAsPaid" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5269,7 +5269,7 @@ "displayName": "OrderPaused" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5320,7 +5320,7 @@ "displayName": "OrderPurchased" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5371,7 +5371,7 @@ "displayName": "OrderResumed" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5422,7 +5422,7 @@ "displayName": "OrderStartDateChanged" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5473,7 +5473,7 @@ "displayName": "OrderStarted" } ], - "doc": "Event data." + "doc": "Data about the order." }, { "name": "metadata", @@ -5503,7 +5503,7 @@ "displayName": "Order" } ], - "doc": "Updated order." + "doc": "Order information." }, { "name": "metadata", From 769225b9966421a5df44331b3a8d944f00b84423 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Tue, 5 Mar 2024 15:32:16 +0000 Subject: [PATCH 23/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 6 +++--- .../wix-pricing-plans-v2/Plans.service.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index a00a2cb82f..9324f8c0b3 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -55,7 +55,7 @@ "docs": { "summary": "Cancels an existing order.", "description": [ - "The `cancelOrder()` function returns a Promise that resolves when the order is successfully canceled.\n\nFor orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.\nFor orders with one-time payments, a cancellation occurs `IMMEDIATELY`.\n\nCanceling an order changes the order status to `CANCELED`.\n\n#### Canceling during the free trial period.\n\nWhen 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.\n\nWhen a site owner cancels an ordered plan during the free trial period, they choose to apply the cancellation `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.\n\nCanceling `IMMEDIATELY` will end the subscription for the buyer\nimmediately, even during the free trial period and the buyer won't be billed.\nCanceling at the `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period. Then, the subscription ends and the buyer is not billed." + "The `cancelOrder()` function returns a Promise that resolves when the order is successfully canceled.\n\nFor orders with recurring payments, a cancellation can be set to occur either `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.\nFor orders with one-time payments, a cancellation occurs `IMMEDIATELY`.\n\nCanceling an order changes the order status to `CANCELED`.\n\n#### Canceling during the free trial period.\n\nWhen a site owner cancels an ordered plan during the free trial period, they choose to apply the cancellation `IMMEDIATELY` or at the `NEXT_PAYMENT_DATE`.\n\nCanceling `IMMEDIATELY` will end the subscription for the buyer\nimmediately, even during the free trial period and the buyer won't be billed.\n\nCanceling at the `NEXT_PAYMENT_DATE` allows the buyer to continue using the benefits of the subscription until the end of the free trial period. Then, the subscription ends and the buyer is not billed." ], "examples": [ { @@ -3854,7 +3854,7 @@ "docs": { "summary": "Starts the process of canceling an order.", "description": [ - "The `requestCancellation()` function returns a Promise that resolves when the order cancellation is successfully requested.\n\nFor orders with recurring payments, a cancellation can be set to occur either immediately or at the next payment date. For orders with one-time payments, a cancellation occurs immediately after the request is processed.\n\nRequesting an order cancellation starts the cancellation process. There may be some operations that continue to be processed before the status of the order is changed to `\"CANCELED\"`. For example, payments might need to be refunded before the order is fully canceled.\n" + "The `requestCancellation()` function returns a Promise that resolves when the order cancellation is successfully requested.\n\nFor orders with recurring payments, a cancellation can be set to occur either immediately or at the next payment date. For orders with one-time payments, a cancellation occurs immediately after the request is processed.\n\nRequesting an order cancellation starts the cancellation process. There may be some operations that continue to be processed before the status of the order is changed to `\"CANCELED\"`. For example, payments might need to be refunded before the order is fully canceled.\n\n#### Canceling during the free trial period.\n\nWhen 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.\n" ], "examples": [ { @@ -7129,7 +7129,7 @@ "referenceType": "wix-pricing-plans-v2.Orders.Cancellation" } ], - "doc": "Details about the cancellation of an order.\n\nOnly present if the status is `CANCELED`." + "doc": "Details about the cancellation of an order." }, { "name": "currentCycle", diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index b9ddbb4c1e..f415ede019 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -447,7 +447,7 @@ "docs": { "summary": "Creates a pricing plan.", "description": [ - "The `createPlan()` function returns a Promise that resolves to a newly-created pricing plan after is has successfully been created.\n\nThe passed `plan` object must contain a [pricing model](#introduction). A pricing model can be one of the following:\n- **A subscription**: A subscription with recurring payment and how often the plan occurs. Subscriptions can have free trial days.\n- **A plan that does not renew**: A single payment for a specific duration that doesn't renew.\n- **An unlimited plan**: A single payment for an unlimited amount of time (until canceled).\n\nPricing plans created by this function are available to the site owner in the Pricing Plans section in the Dashboard." + "The `createPlan()` function returns a Promise that resolves to a newly-created pricing plan after is has successfully been created.\n\nThe passed `plan` object must contain a [pricing model](https://www.wix.com/velo/reference/wix-pricing-plans-v2/plans/pricing-models). A pricing model can be one of the following:\n- **A subscription**: A subscription with recurring payment and how often the plan occurs. Subscriptions can have free trial days.\n- **A plan that does not renew**: A single payment for a specific duration that doesn't renew.\n- **An unlimited plan**: A single payment for an unlimited amount of time (until canceled).\n\nPricing plans created by this function are available to the site owner in the Pricing Plans section in the Dashboard." ], "examples": [ { @@ -4920,7 +4920,7 @@ "nativeType": "boolean" } ], - "doc": "Whether the buyer is allowed to cancel their plan. If `false`, calling the `cancelOrder()` function returns an error.\n\nDefault: `false`.\n\n" + "doc": "Whether the buyer is allowed to cancel their plan. If `false`, calling the [`requestCancellation()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/orders/requestcancellation) function returns an error.\n\nDefault: `true`.\n\n" }, { "name": "description", @@ -5628,7 +5628,7 @@ "nativeType": "boolean" } ], - "doc": "Whether the buyer is allowed to cancel their plan. If `false`, calling the `cancelOrder()` function returns an error.\n\nDefault: `false`.\n\n" + "doc": "Whether the buyer is allowed to cancel their plan. If `false`, calling the [`requestCancellation()`](https://www.wix.com/velo/reference/wix-pricing-plans-v2/orders/requestcancellation) function returns an error.\n\nDefault: `true`.\n\n" }, { "name": "description", From f3049feb4d50fdc517efcfe88a59bc3e9491cceb Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Sun, 10 Mar 2024 12:48:37 +0000 Subject: [PATCH 24/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Plans.service.json | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index f415ede019..e1b35463c8 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -1180,6 +1180,136 @@ "The `listPlans()` function returns a Promise that resolves to a list of up to 100 pricing plans. This includes public, hidden, and archived plans." ], "examples": [ + { + "title": "List all plans (dashboard page code) ", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPlans = elevate(plans.listPlans);", + "", + "export async function myListPlansFunction() {", + " try {", + " const plansList = await elevatedListPlans();", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to:", + " * [", + " * {", + " * \"_createdDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"_id\": \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", + " * \"_updatedDate\": \"2024-01-08T14:33:12.209Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"The value plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Silver Membership - Monthly\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Full site access\",", + " * \"Full video access\",", + " * \"Consultation booking\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"cycleCount\": 0,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * },", + " * \"freeTrialDays\": 14,", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"100\"", + " * },", + " * \"subscription\": {", + " * \"cycleCount\": 0,", + " * \"cycleDuration\": {", + " * \"count\": 1,", + " * \"unit\": \"MONTH\"", + " * }", + " * }", + " * },", + " * \"primary\": false,", + " * \"public\": true,", + " * \"slug\": \"silver-membership-monthly\",", + " * \"termsAndConditions\": \"\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", + " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"_updatedDate\": \"2024-01-09T09:08:05.665Z\",", + " * \"allowFutureStartDate\": false,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Full feature enablement - lifetime plan\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 0,", + " * \"name\": \"Premium Plan - Lifetime Membership\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Cloud drive and file upload services\",", + " * \"Unlimited video content access\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"EUR\",", + " * \"value\": \"1000\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"primary\": false,", + " * \"public\": true,", + " * \"slug\": \"premium-plan-lifetime-membership\",", + " * \"termsAndConditions\": \"This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.\"", + " * },", + " * {", + " * \"_createdDate\": \"2024-01-04T12:51:42.249Z\",", + " * \"_id\": \"025a0d1f-7076-4e27-9696-4a67075dc2aa\",", + " * \"_updatedDate\": \"2024-01-07T12:53:53.562Z\",", + " * \"allowFutureStartDate\": true,", + " * \"archived\": false,", + " * \"buyerCanCancel\": true,", + " * \"description\": \"Bronze membership to the MyGame World of Online Gaming\",", + " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", + " * \"hasOrders\": false,", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Bronze Plan\",", + " * \"perks\": {", + " * \"values\": [", + " * \"Multiplayer\",", + " * \"Multiple devices\",", + " * \"No ads\",", + " * \"Unlimited access\"", + " * ]", + " * },", + " * \"pricing\": {", + " * \"price\": {", + " * \"currency\": \"USD\",", + " * \"value\": \"10.00\"", + " * },", + " * \"singlePaymentUnlimited\": true", + " * },", + " * \"primary\": false,", + " * \"public\": false,", + " * \"slug\": \"bronze-plan-1\",", + " * \"termsAndConditions\": \"No sharing access with others!\"", + " * }", + " * ]", + " */" + ] + }, { "title": "List plans ", "body": [ @@ -1582,6 +1712,11 @@ ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "listPlans", "isAdminMethod": true }, From e8e8cdf095dbb76dc4fc6b9171990dee38332726 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Tue, 30 Apr 2024 15:19:43 +0000 Subject: [PATCH 25/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Orders.service.json | 174 ++++++++++++++++++ .../wix-pricing-plans-v2/Plans.service.json | 174 ++++++++++++++++++ 2 files changed, 348 insertions(+) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json index 9324f8c0b3..3e6eb5acce 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Orders.service.json @@ -6293,6 +6293,130 @@ ] } }, + { + "name": "IdentificationData", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "identityType", + "readOnly": true, + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Supported values:\n- `'ANONYMOUS_VISITOR'`\n- `'APP'`\n- `'MEMBER'`\n- `'UNKNOWN'`\n- `'WIX_USER'`" + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfIdentificationDataIdOneOf", + "members": [ + "anonymousVisitorId", + "appId", + "memberId", + "wixUserId" + ] + } + ] + }, + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "IdentificationDataIdOneOf", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "ItemMetadata", "members": [ @@ -7032,6 +7156,56 @@ ] } }, + { + "name": "MessageEnvelope", + "members": [ + { + "name": "data", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Stringify payload." + }, + { + "name": "eventType", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Event type." + }, + { + "name": "identity", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Orders.IdentificationData" + } + ], + "doc": "The identification type and identity data." + }, + { + "name": "instanceId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "App instance ID." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "OnBehalf", "members": [ diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index e1b35463c8..841448c12c 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -4479,6 +4479,130 @@ ] } }, + { + "name": "IdentificationData", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "identityType", + "readOnly": true, + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Supported values:\n- `'ANONYMOUS_VISITOR'`\n- `'APP'`\n- `'MEMBER'`\n- `'UNKNOWN'`\n- `'WIX_USER'`" + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfIdentificationDataIdOneOf", + "members": [ + "anonymousVisitorId", + "appId", + "memberId", + "wixUserId" + ] + } + ] + }, + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "IdentificationDataIdOneOf", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "ItemMetadata", "members": [ @@ -4870,6 +4994,56 @@ ] } }, + { + "name": "MessageEnvelope", + "members": [ + { + "name": "data", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Stringify payload." + }, + { + "name": "eventType", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Event type." + }, + { + "name": "identity", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.IdentificationData" + } + ], + "doc": "The identification type and identity data." + }, + { + "name": "instanceId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "App instance ID." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "Money", "members": [ From a693127a930792b6a4aa6896fb12df6e11726669 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Wed, 1 May 2024 09:42:00 +0000 Subject: [PATCH 26/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index 11e02e5bce..33aeb56f1e 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -7496,6 +7496,130 @@ ] } }, + { + "name": "pricingPlansV2PlanIdentificationData", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "identityType", + "readOnly": true, + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Supported values:\n- `'ANONYMOUS_VISITOR'`\n- `'APP'`\n- `'MEMBER'`\n- `'UNKNOWN'`\n- `'WIX_USER'`" + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfIdentificationDataIdOneOf", + "members": [ + "anonymousVisitorId", + "appId", + "memberId", + "wixUserId" + ] + } + ] + }, + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanIdentificationDataIdOneOf", + "members": [ + { + "name": "anonymousVisitorId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has not logged in to the site." + }, + { + "name": "appId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of an app." + }, + { + "name": "memberId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a site visitor that has logged in to the site." + }, + { + "name": "wixUserId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "ID of a Wix user (site owner, contributor, etc.)." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanItemMetadata", "members": [ @@ -7779,6 +7903,57 @@ ] } }, + { + "name": "pricingPlansV2PlanMessageEnvelope", + "members": [ + { + "name": "data", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Stringify payload." + }, + { + "name": "eventType", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Event type." + }, + { + "name": "identity", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanIdentificationData", + "displayName": "IdentificationData" + } + ], + "doc": "The identification type and identity data." + }, + { + "name": "instanceId", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "App instance ID." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanMoney", "members": [ From 6587e696c3fc8bb7e4de01f69234b6058a00b7a8 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Mon, 27 May 2024 15:09:02 +0000 Subject: [PATCH 27/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Plans.service.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 841448c12c..7330871c80 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json @@ -4282,7 +4282,7 @@ "nativeType": "string" } ], - "doc": "Unit of time for the cycle duration.\n\nSupported values: `\"DAY\"`, `\"WEEK\"`, `\"MONTH\"`, `\"YEAR\"`.\n\n" + "doc": "Unit of time for the cycle duration." } ], "docs": { @@ -4664,7 +4664,7 @@ "nativeType": "string" } ], - "doc": "Archived filter.\n\nSupported values: `\"ACTIVE\"`, `\"ARCHIVED\"`, `\"ARCHIVED_AND_ACTIVE\"`.\n\nDefault: `\"ACTIVE\"` (not archived).\n" + "doc": "Archived filter.\n\nDefault: `ACTIVE` (not archived).\n" }, { "name": "limit", @@ -4711,7 +4711,7 @@ "nativeType": "string" } ], - "doc": "Visibility filter.\n\nSupported values: `\"PUBLIC_AND_HIDDEN\"`, `\"PUBLIC\"`, `\"HIDDEN\"`.\n\nDefault: `\"PUBLIC_AND_HIDDEN\"` (meaning, both public and hidden plans are listed).\n\n" + "doc": "Visibility filter.\n\nDefault: `PUBLIC_AND_HIDDEN` (meaning, both public and hidden plans are listed).\n\n" } ], "docs": { @@ -4731,7 +4731,7 @@ "nativeType": "string" } ], - "doc": "Archived filter.\n\nSupported values: `\"ACTIVE\"`, `\"ARCHIVED\"`, `\"ARCHIVED_AND_ACTIVE\"`.\n\nDefault: `\"ACTIVE\"` (not archived).\n" + "doc": "Archived filter.\n\nDefault: `ACTIVE` (not archived).\n" }, { "name": "limit", @@ -4778,7 +4778,7 @@ "nativeType": "string" } ], - "doc": "Visibility filter.\n\nSupported values: `\"PUBLIC_AND_HIDDEN\"`, `\"PUBLIC\"`, `\"HIDDEN\"`.\n\nDefault: `\"PUBLIC_AND_HIDDEN\"` (meaning, both public and hidden plans are listed).\n\n" + "doc": "Visibility filter.\n\nDefault: `PUBLIC_AND_HIDDEN` (meaning, both public and hidden plans are listed).\n\n" } ], "docs": { From 8316deb08ef6b07c01a2a1752f4d60acf343a921 Mon Sep 17 00:00:00 2001 From: Wix Docs Feds Date: Tue, 28 May 2024 08:17:30 +0000 Subject: [PATCH 28/28] Auto commit to autodocs-wix-pricing-plans-v2 from WixDocs Server --- .../wix-pricing-plans-v2/Events.service.json | 183 +++--------------- 1 file changed, 23 insertions(+), 160 deletions(-) diff --git a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json index 33aeb56f1e..68c3ce65a0 100644 --- a/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json +++ b/wix-pricing-plans-v2/wix-pricing-plans-v2/Events.service.json @@ -1887,7 +1887,7 @@ "displayName": "PlanArchivedEvent" } ], - "doc": "Information about the pricing plan that was archived and metadata for the event.\n", + "doc": "", "required": false } ], @@ -1902,66 +1902,18 @@ }, "docs": { "summary": "An event that is triggered when a pricing plan is archived.", - "description": [ - "The `onPlanArchived()` event handler runs when a pricing plan is archived. The received `PlanArchivedEvent` object contains information about the pricing plan that was archived.\n\n>**Note:** Backend events don't work when previewing your site." - ], + "description": [], "examples": [ { "title": "onPlanArchived example", "body": [ - "// Place this code in the events.js file", - "// of your site's Backend section.", - "// Add the file if it doesn't exist.", "", - "export function wixPricingPlans_onPlanArchived(event) {", - " const planId = event.data._id;", - " const planName = event.data.name;", - " const eventTime = event.metadata.eventTime;", - "", - " console.log(`The plan, ${planName} with ID ${planId} was archived at ${eventTime}. Full event object:`, event);", - "}", + " export function wixPricingPlansV2_onPlanArchived(event) {", + " const eventId = event.metadata.id", + " const entityId = event.data.plan._id;", + " }", "", - "/* Full event object:", - " * {", - " * \"data\": {", - " * \"_createdDate\": \"2024-01-07T07:13:04.076Z\",", - " * \"_id\": \"0b9a1993-c1ff-4952-9575-915b48d1a5e0\",", - " * \"_updatedDate\": \"2024-01-09T12:32:26.807Z\",", - " * \"allowFutureStartDate\": false,", - " * \"archived\": true,", - " * \"buyerCanCancel\": true,", - " * \"description\": \"For new users just getting the feel of the product\",", - " * \"hasOrders\": false,", - " * \"maxPurchasesPerBuyer\": 0,", - " * \"name\": \"Simple Plan\",", - " * \"perks\": [", - " * \"Login member access\",", - " * \"Access to real-time articles\",", - " * \"Included in mailing list\"", - " * ],", - " * \"pricing\": {", - " * \"price\": {", - " * \"currency\": \"USD\",", - " * \"value\": \"3\"", - " * },", - " * \"singlePaymentForDuration\": {", - " * \"count\": 12,", - " * \"unit\": \"MONTH\"", - " * }", - " * },", - " * \"primary\": false,", - " * \"public\": false,", - " * \"slug\": \"simple-plan\",", - " * \"termsAndConditions\": \"I agree to refrain from sharing any of the exclusive content with non-members\"", - " * },", - " * \"metadata\": {", - " * \"entityId\": \"0b9a1993-c1ff-4952-9575-915b48d1a5e0\",", - " * \"eventTime\": \"2024-01-09T12:32:26.926390623Z\",", - " * \"id\": \"056d1192-470a-4605-9821-c4b7c906c0d1\",", - " * \"triggeredByAnonymizeRequest\": false", - " * }", - " * }", - " */" + " " ] } ] @@ -1972,7 +1924,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanArchived" + "syntaxName": "wixPricingPlansV2_onPlanArchived" }, { "name": "onPlanBuyerCanCancelUpdated", @@ -2034,7 +1986,7 @@ "displayName": "PlanCreated" } ], - "doc": "Information about the pricing plan that was created and metadata for the event.\n", + "doc": "", "required": false } ], @@ -2049,62 +2001,18 @@ }, "docs": { "summary": "An event that is triggered when a pricing plan is created.", - "description": [ - "The `onPlanCreated()` handler runs when a pricing plan is created. The received `PlanCreatedEvent` object contains information about the pricing plan that is created.\n\n>**Note:** Backend events don't work when previewing your site." - ], + "description": [], "examples": [ { "title": "onPlanCreated example", "body": [ - "// Place this code in the events.js file", - "// of your site's Backend section.", - "// Add the file if it doesn't exist.", - "", - "export function wixPricingPlans_onPlanCreated(event) {", - " const planId = event.data._id;", - " const planName = event.data.name;", - " const eventTime = event.metadata.eventTime;", "", - " console.log(`The plan, ${planName} with ID ${planId} was created at ${eventTime}. Full event object:`, event);", - "}", + " export function wixPricingPlansV2_onPlanCreated(event) {", + " const eventId = event.metadata.id", + " const entityId = event.entity._id;", + " }", "", - "/* Full event object: ", - " * {", - " * \"entity\": {", - " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", - " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", - " * \"_updatedDate\": \"2024-01-07T07:33:59.973Z\",", - " * \"allowFutureStartDate\": false,", - " * \"archived\": false,", - " * \"buyerCanCancel\": true,", - " * \"description\": \"Full feature enablement - lifetime plan\",", - " * \"hasOrders\": false,", - " * \"maxPurchasesPerBuyer\": 0,", - " * \"name\": \"Premium Plan - Lifetime Membership\",", - " * \"perks\": [", - " * \"Cloud drive and file upload services\",", - " * \"Unlimited video content access\"", - " * ],", - " * \"pricing\": {", - " * \"price\": {", - " * \"currency\": \"EUR\",", - " * \"value\": \"1000\"", - " * },", - " * \"singlePaymentUnlimited\": true", - " * },", - " * \"primary\": false,", - " * \"public\": true,", - " * \"slug\": \"premium-plan-lifetime-membership\",", - " * \"termsAndConditions\": \"This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.\",", - " * },", - " * \"metadata\": {", - " * \"entityId\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", - " * \"eventTime\": \"2024-01-07T07:34:00.110589Z\",", - " * \"id\": \"53be874c-0d44-4f53-9fce-d0cc565d447d\",", - " * \"triggeredByAnonymizeRequest\": false", - " * }", - " * }", - " */" + " " ] } ] @@ -2115,7 +2023,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanCreated" + "syntaxName": "wixPricingPlansV2_onPlanCreated" }, { "name": "onPlanUpdated", @@ -2146,60 +2054,15 @@ "description": [], "examples": [ { - "title": " ", + "title": "onPlanUpdated example", "body": [ - "export function wixPricingPlans_onPlanUpdated(event) {", - " const planId = event.data._id;", - " const planName = event.data.name;", - " const eventTime = event.metadata.eventTime;", "", - " console.log(`The plan, ${planName} with ID ${planId} was updated at ${eventTime}. Full event object:`, event);", - "}", + " export function wixPricingPlansV2_onPlanUpdated(event) {", + " const eventId = event.metadata.id", + " const entityId = event.entity._id;", + " }", "", - "/* Full event object:", - " * {", - " * \"entity\": {", - " * \"_createdDate\": \"2024-01-07T07:28:42.863Z\",", - " * \"_id\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", - " * \"_updatedDate\": \"2024-01-07T08:36:07.520Z\",", - " * \"allowFutureStartDate\": false,", - " * \"archived\": false,", - " * \"buyerCanCancel\": true,", - " * \"description\": \"Complete with all features. One month free trial.\",", - " * \"hasOrders\": false,", - " * \"maxPurchasesPerBuyer\": 0,", - " * \"name\": \"Premium Plan - annual - 30 day trial\",", - " * \"perks\": [", - " * \"Unlimited video library streaming access\",", - " * \"File sharing enabled for all channels\"", - " * ],", - " * \"pricing\": {", - " * \"freeTrialDays\": 30,", - " * \"price\": {", - " * \"value\": \"500\",", - " * \"currency\": \"EUR\"", - " * },", - " * \"subscription\": {", - " * \"cycleDuration\": {", - " * \"count\": 1,", - " * \"unit\": \"YEAR\"", - " * },", - " * \"cycleCount\": 2", - " * }", - " * },", - " * \"primary\": false,", - " * \"public\": true,", - " * \"slug\": \"premium-plan-annual-30-day-trial-1\",", - " * \"termsAndConditions\": \"Unlimited usage of services, subject to Fair Usage and Code of Conduct policies.\"", - " * },", - " * \"metadata\": {", - " * \"entityId\": \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", - " * \"eventTime\": \"2024-01-07T08:36:07.557665422Z\",", - " * \"id\": \"287b52a3-d937-4911-ab09-d782e44b415b\",", - " * \"triggeredByAnonymizeRequest\": false", - " * }", - " * }", - " */" + " " ] } ] @@ -2210,7 +2073,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanUpdated" + "syntaxName": "wixPricingPlansV2_onPlanUpdated" } ], "messages": [