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..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 @@ -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,21 +34,125 @@ "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": [ { "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", + " * }", + " * }", + " */", + "" ] } ] @@ -72,7 +176,7 @@ "displayName": "OrderCanceledEvent" } ], - "doc": "", + "doc": "Information about the canceled order and metadata for the event.\n", "required": false } ], @@ -94,13 +198,114 @@ { "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 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:", + " * {", + " * \"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", + " * }", + " * }", + " */", + "" ] } ] @@ -124,7 +329,7 @@ "displayName": "OrderCreated" } ], - "doc": "", + "doc": "Information about the created order and metadata for the event.\n", "required": false } ], @@ -144,13 +349,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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -174,7 +450,7 @@ "displayName": "OrderCycleStartedEvent" } ], - "doc": "", + "doc": "Information about the order whose payment cycle started and metadata for the event.\n", "required": false } ], @@ -196,13 +472,96 @@ { "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 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:", + " * {", + " * \"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", + " * }", + " * }", + " */ ", + " ", + "" ] } ] @@ -226,7 +585,7 @@ "displayName": "OrderEndDatePostponedEvent" } ], - "doc": "", + "doc": "Information about the order that is postponed and metadata for the event.\n", "required": false } ], @@ -246,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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -276,7 +738,7 @@ "displayName": "OrderEndedEvent" } ], - "doc": "", + "doc": "Information about the order that ended and metadata for the event.\n", "required": false } ], @@ -298,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", + " * }", + " * }", + " */", + "" ] } ] @@ -328,7 +886,7 @@ "displayName": "OrderMarkedAsPaidEvent" } ], - "doc": "", + "doc": "Information about the offline order that was paid and metadata for the event.\n", "required": false } ], @@ -348,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", + " * }", + " * }", + " */" ] } ] @@ -378,7 +1031,7 @@ "displayName": "OrderPausedEvent" } ], - "doc": "", + "doc": "Information about the order that is paused and metadata for the event.\n", "required": false } ], @@ -398,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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -428,7 +1184,7 @@ "displayName": "OrderPurchasedEvent" } ], - "doc": "", + "doc": "Information about the order that was purchased and metadata for the event.\n", "required": false } ], @@ -450,13 +1206,96 @@ { "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 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:", + " * {", + " * \"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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -480,7 +1319,7 @@ "displayName": "OrderResumedEvent" } ], - "doc": "", + "doc": "Information about the order that was resumed and metadata for the event\n", "required": false } ], @@ -500,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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -530,7 +1471,7 @@ "displayName": "OrderStartDateChangedEvent" } ], - "doc": "", + "doc": "Information about the order whose start date changed and metadata for the event.\n", "required": false } ], @@ -550,19 +1491,105 @@ { "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;", "", - " " - ] - } - ] - }, - "isVeloEvent": true, - "customLabels": [ + " 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", + " * }", + " * }", + " */ " + ] + } + ] + }, + "isVeloEvent": true, + "customLabels": [ { "id": "maturity-beta" } @@ -580,7 +1607,7 @@ "displayName": "OrderStartedEvent" } ], - "doc": "", + "doc": "Information about the order that started and metadata for the event.\n", "required": false } ], @@ -600,13 +1627,95 @@ { "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 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:", + " * {", + " * \"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", + " * }", + " * }", + " */ ", + "" ] } ] @@ -630,7 +1739,7 @@ "displayName": "OrderUpdated" } ], - "doc": "", + "doc": "Information about the order that was updated and metadata for the event.\n", "required": false } ], @@ -646,19 +1755,115 @@ "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) |" + "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": [ { "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) {", + " 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:", + " * {", + " * \"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", + " * }", + " * }", + " */", + "", + "" ] } ] @@ -682,7 +1887,7 @@ "displayName": "PlanArchivedEvent" } ], - "doc": "Information about the pricing plan that was archived and metadata for the event.\n", + "doc": "", "required": false } ], @@ -697,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", - " * }", - " * }", - " */" + " " ] } ] @@ -767,7 +1924,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanArchived" + "syntaxName": "wixPricingPlansV2_onPlanArchived" }, { "name": "onPlanBuyerCanCancelUpdated", @@ -811,7 +1968,12 @@ ] }, "isVeloEvent": true, - "syntaxName": "wixPricingPlans_onPlanArchived" + "customLabels": [ + { + "id": "maturity-beta" + } + ], + "syntaxName": "wixPricingPlans_onPlanBuyerCanCancelUpdated" }, { "name": "onPlanCreated", @@ -824,7 +1986,7 @@ "displayName": "PlanCreated" } ], - "doc": "Information about the pricing plan that was created and metadata for the event.\n", + "doc": "", "required": false } ], @@ -839,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", - " * }", - " * }", - " */" + " " ] } ] @@ -905,7 +2023,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanCreated" + "syntaxName": "wixPricingPlansV2_onPlanCreated" }, { "name": "onPlanUpdated", @@ -936,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", - " * }", - " * }", - " */" + " " ] } ] @@ -1000,7 +2073,7 @@ "id": "maturity-beta" } ], - "syntaxName": "wixPricingPlans_onPlanUpdated" + "syntaxName": "wixPricingPlansV2_onPlanUpdated" } ], "messages": [ @@ -1630,7 +2703,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": [ { @@ -1941,7 +3064,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", @@ -1951,7 +3074,7 @@ "nativeType": "number" } ], - "doc": "Number of items to load." + "doc": "Maximum number of items to return in the results." } ], "docs": { @@ -1971,7 +3094,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", @@ -1981,7 +3104,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": { @@ -2001,7 +3124,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 +3187,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 +3197,7 @@ "nativeType": "Date" } ], - "doc": "The time of the event. Useful if there was a delay in dispatching" + "doc": "Event timestamp." }, { "name": "originatedFrom", @@ -2104,7 +3227,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", @@ -2252,7 +3375,18 @@ }, { "name": "pricingPlansV2OrderEntityDeletedEvent", - "members": [], + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], "docs": { "description": [ "" @@ -3560,7 +4694,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", @@ -3612,7 +4746,7 @@ "displayName": "OrderAutoRenewCanceled" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3622,7 +4756,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3663,7 +4797,7 @@ "displayName": "OrderCanceled" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3673,7 +4807,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3693,7 +4827,7 @@ "displayName": "Order" } ], - "doc": "" + "doc": "Order information." }, { "name": "metadata", @@ -3703,7 +4837,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3794,7 +4928,7 @@ "displayName": "OrderCycleStarted" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3804,7 +4938,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3845,7 +4979,7 @@ "displayName": "OrderEndDatePostponed" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3855,7 +4989,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3896,7 +5030,7 @@ "displayName": "OrderEnded" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3906,7 +5040,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3947,7 +5081,7 @@ "displayName": "OrderMarkedAsPaid" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -3957,7 +5091,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -3998,7 +5132,7 @@ "displayName": "OrderPaused" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -4008,7 +5142,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4049,7 +5183,7 @@ "displayName": "OrderPurchased" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -4059,7 +5193,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4100,7 +5234,7 @@ "displayName": "OrderResumed" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -4110,7 +5244,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4151,7 +5285,7 @@ "displayName": "OrderStartDateChanged" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -4161,7 +5295,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4202,7 +5336,7 @@ "displayName": "OrderStarted" } ], - "doc": "" + "doc": "Data about the order." }, { "name": "metadata", @@ -4212,7 +5346,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -4232,7 +5366,7 @@ "displayName": "Order" } ], - "doc": "" + "doc": "Order information." }, { "name": "metadata", @@ -4242,7 +5376,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { @@ -5366,6 +6500,26 @@ ] } }, + { + "name": "pricingPlansV2PlanActionEvent", + "members": [ + { + "name": "bodyAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, { "name": "pricingPlansV2PlanApplicationError", "members": [ @@ -5675,74 +6829,355 @@ } }, { - "name": "pricingPlansV2PlanBuyerCanCancelUpdated", + "name": "pricingPlansV2PlanBuyerCanCancelUpdated", + "members": [ + { + "name": "plan", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", + "displayName": "Plan" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanClearPrimaryRequest", + "members": [], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanClearPrimaryResponse", + "members": [], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanCreatePlanRequest", + "members": [ + { + "name": "plan", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", + "displayName": "Plan" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanCreatePlanResponse", + "members": [ + { + "name": "plan", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", + "displayName": "Plan" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "pricingPlansV2PlanCursors", + "members": [ + { + "name": "next", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Cursor string pointing to the next page in the list of results." + }, + { + "name": "prev", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Cursor pointing to the previous page in the list of results." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "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": [ { - "name": "plan", + "name": "count", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", - "displayName": "Plan" + "nativeType": "number" } ], - "doc": "" - } - ], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "pricingPlansV2PlanClearPrimaryRequest", - "members": [], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "pricingPlansV2PlanClearPrimaryResponse", - "members": [], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "pricingPlansV2PlanCreatePlanRequest", - "members": [ + "doc": "The amount of a duration `unit` in a single payment cycle.\n\nCurrently limited to support only `1`.\n" + }, { - "name": "plan", + "name": "unit", + "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", - "displayName": "Plan" + "nativeType": "string" } ], - "doc": "" + "doc": "Unit of time for the cycle duration." } ], "docs": { "description": [ - "" + "A duration expressed in number of time units." ] } }, { - "name": "pricingPlansV2PlanCreatePlanResponse", + "name": "pricingPlansV2PlanEntityCreatedEvent", "members": [ { - "name": "plan", + "name": "entityAsJson", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanPlan", - "displayName": "Plan" + "nativeType": "string" } ], "doc": "" @@ -5755,27 +7190,17 @@ } }, { - "name": "pricingPlansV2PlanCursors", + "name": "pricingPlansV2PlanEntityDeletedEvent", "members": [ { - "name": "next", - "optional": true, - "type": [ - { - "nativeType": "string" - } - ], - "doc": "Cursor pointing to next page in the list of results." - }, - { - "name": "prev", + "name": "deletedEntityAsJson", "optional": true, "type": [ { "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Entity that was deleted" } ], "docs": { @@ -5785,32 +7210,22 @@ } }, { - "name": "pricingPlansV2PlanDuration", + "name": "pricingPlansV2PlanEntityUpdatedEvent", "members": [ { - "name": "count", - "optional": true, - "type": [ - { - "nativeType": "number" - } - ], - "doc": "The amount of a duration `unit` in a single payment cycle.\n\nCurrently limited to support only `1`.\n" - }, - { - "name": "unit", + "name": "currentEntityAsJson", "optional": true, "type": [ { "nativeType": "string" } ], - "doc": "Unit of time for the cycle duration." + "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": [ - "A duration expressed in number of time units." + "" ] } }, @@ -5944,6 +7359,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": [ @@ -6227,6 +7766,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": [ @@ -6588,7 +8178,37 @@ ] } }, + { + "name": "pricingPlansV2PlanPlanBuyerCanCancelUpdated", + "members": [ + { + "name": "data", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanBuyerCanCancelUpdated", + "displayName": "BuyerCanCancelUpdated" + } + ], + "doc": "Event data." + }, { + "name": "metadata", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Events.pricingPlansV2PlanBackendEventMetadata", + "displayName": "BackendEventMetadata" + } + ], + "doc": "Event metadata." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { "name": "pricingPlansV2PlanPlanCreated", "members": [ { @@ -6629,7 +8249,7 @@ "displayName": "Plan" } ], - "doc": "" + "doc": "Updated plan." }, { "name": "metadata", @@ -6639,7 +8259,7 @@ "displayName": "BackendEventMetadata" } ], - "doc": "" + "doc": "Event metadata." } ], "docs": { 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..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 @@ -55,30 +55,74 @@ "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": [ { - "title": "cancelOrder example", + "title": "Cancel an order immediately (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function cancelOrder(id, effectiveAt) {", - " try {", - " const result = await orders.cancelOrder(id, effectiveAt);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* 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';", + "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 */", + "" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "cancelOrder", "isAdminMethod": true }, @@ -95,6 +139,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 +161,7 @@ } ], "requiredFields": [ - "options.memberId", + "memberId", "planId" ], "ret": { @@ -132,26 +186,421 @@ ], "examples": [ { - "title": "createOfflineOrder example", + "title": "Create an offline order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function createOfflineOrder(planId, options) {", - " try {", - " const result = await orders.createOfflineOrder(planId, options);", - "", - " 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'", + " */", + "", + "export async function myCreateOfflineOrderFunction(planId, memberId) {", + " try {", + " const newOrder = await orders.createOfflineOrder(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 (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 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": [ + "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'", + " * ", + " * 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 const myCreateOfflineOrderFunctionWithOptions = webMethod(Permissions.Anyone, async (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 }, @@ -168,6 +617,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 +639,7 @@ } ], "requiredFields": [ - "options.memberId", + "memberId", "planId" ], "ret": { @@ -205,26 +664,495 @@ ], "examples": [ { - "title": "getOfflineOrderPreview example", + "title": "Create an offline order preview (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function getOfflineOrderPreview(planId, options) {", - " try {", - " const result = await orders.getOfflineOrderPreview(planId, options);", - "", - " 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'", + " */", + "", + "export async function myGetOfflineOrderPreviewFunction(planId, memberId) {", + " try {", + " const orderPreview = await orders.getOfflineOrderPreview(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 (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';", + "", + "/* 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 const myGetOfflineOrderPreviewFunction = webMethod(Permissions.Anyone, async (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 }, @@ -277,26 +1205,183 @@ ], "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);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "", + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", + "", + "export async function myGetPricePreviewFunction(planId) {", + " try {", + " const pricePreview = await orders.getPricePreview(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 (export from backend code)", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { orders } from 'wix-pricing-plans.v2';", + "", + "// Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' ", + "", + "", + "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId) => {", + " try {", + " const pricePreview = await orders.getPricePreview(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';", + "", + "/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'", + " *", + " * Sample options value:", + " * {", + " * couponCode: 'SUMMERSALE'", + " * }", + " */ ", + "", + "export const myGetPricePreviewFunction = webMethod(Permissions.Anyone, async (planId, options) => {", + " try {", + " const pricePreview = await orders.getPricePreview(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" }, { @@ -319,7 +1404,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 } ], @@ -348,26 +1433,354 @@ ], "examples": [ { - "title": "managementGetOrder example", + "title": "Get an order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function managementGetOrder(id, options) {", - " try {", - " const result = await orders.managementGetOrder(id, options);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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' ", + "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder);", + "", + "export const myManagementGetOrderFunction = webMethod(Permissions.Anyone, async (_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 { 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 options value: ", + " * {", + " * fieldSet: 'FULL'", + " * }", + " * ", + " */", + "", + "const elevatedManagementGetOrder = elevate(orders.managementGetOrder);", + "", + "export const myManagementGetOrderFunction = webMethod(Permissions.Anyone, async (_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 }, @@ -381,7 +1794,7 @@ "referenceType": "wix-pricing-plans-v2.Orders.ManagementListOrdersOptions" } ], - "doc": "Filtering, sorting, and pagination options.\n", + "doc": "Filtering, sorting, and pagination options.", "required": false } ], @@ -408,26 +1821,469 @@ ], "examples": [ { - "title": "managementListOrders example", + "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();", + "", + " 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 (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';", + "", + "/* 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 const myManagementListOrdersFunction = webMethod(Permissions.Anyone, async (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", + " * }", + " * }", + " */ ", " ", - " async function managementListOrders(options) {", - " try {", - " const result = await orders.managementListOrders(options);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "" ] + }, + { + "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." + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "managementListOrders", "isAdminMethod": true }, @@ -470,26 +2326,280 @@ ], "examples": [ { - "title": "markAsPaid example", + "title": "Mark an order as paid (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function markAsPaid(id) {", - " try {", - " const result = await orders.markAsPaid(id);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* 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 */", + "" + ] + }, + { + "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." + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "markAsPaid", "isAdminMethod": true }, @@ -542,21 +2652,291 @@ ], "examples": [ { - "title": "memberGetOrder example", + "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';", - " ", - " 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 const memberGetOrder = webMethod(Permissions.Anyone, async (_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';", + "", + "/* Sample _id: 'b14e3821-868f-4aa6-b874-e9240100985c' ", + " *", + " * Sample options value:", + " * {", + " * fieldSet: 'FULL'", + " * }", + " */", + "", + "export async function memberGetOrder(_id, options) {", + " try {", + " const order = await orders.memberGetOrder(_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\"", + " * }", + " */ ", + "", + "", + "", + "" + ] + }, + { + "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: 'b14e3821-868f-4aa6-b874-e9240100985c' ", + " *", + " * Sample options value:", + " * {", + " * fieldSet: 'FULL'", + " * }", + " */", + "", + "export const memberGetOrder = webMethod(Permissions.Anyone, async (_id, options) => {", + " try {", + " const order = await orders.memberGetOrder(_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\"", + " * }", + " */", + "" ] } ] @@ -601,26 +2981,517 @@ ], "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", + " * }", + " * }", + " * ]", + " * }", + " */ " ] + }, + { + "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", + " * }", + " * }", + " * ]", + " * }", + " */", + "" + ] + }, + { + "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. " + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "memberListOrders" }, { @@ -662,26 +3533,161 @@ ], "examples": [ { - "title": "pauseOrder example", + "title": "Pause a pricing plan order (dashboard page code)", "body": [ "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function pauseOrder(id) {", - " try {", - " const result = await orders.pauseOrder(id);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* 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 */", + "" + ] + }, + { + "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. " + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "pauseOrder", "isAdminMethod": true }, @@ -735,26 +3741,70 @@ ], "examples": [ { - "title": "postponeEndDate example", + "title": "Postpone an order's end date (dashboard page code)", "body": [ - "import { orders } from 'wix-pricing-plans.v2';", - " ", - " async function postponeEndDate(id, endDate) {", - " try {", - " const result = await orders.postponeEndDate(id, endDate);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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 elevatedPostponeEndDate(_id, endDate);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* 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 */", + "" ] } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "postponeEndDate", "isAdminMethod": true }, @@ -804,30 +3854,139 @@ "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": [ { - "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 */" ] + }, + { + "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. " + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "requestCancellation" }, { @@ -869,26 +4028,143 @@ ], "examples": [ { - "title": "resumeOrder example", + "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);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* 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';", - " ", - " async function resumeOrder(id) {", - " try {", - " const result = await orders.resumeOrder(id);", - "", - " return result;", - " } catch (error) {", - " console.error(error);", - " // Handle the error", - " }", - " }", - " " + "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 */", + "" ] + }, + { + "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. " + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "resumeOrder", "isAdminMethod": true } @@ -1506,6 +4782,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": [ @@ -1664,15 +5009,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, @@ -1978,7 +5314,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 +5324,7 @@ "nativeType": "number" } ], - "doc": "Number of items to load." + "doc": "Maximum number of items to return in the results." } ], "docs": { @@ -2008,7 +5344,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 +5354,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 +5374,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 +5434,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 +5444,7 @@ "nativeType": "Date" } ], - "doc": "The time of the event. Useful if there was a delay in dispatching" + "doc": "Event timestamp." }, { "name": "originatedFrom", @@ -2138,7 +5474,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 +5617,18 @@ }, { "name": "EntityDeletedEvent", - "members": [], + "members": [ + { + "name": "deletedEntityAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Entity that was deleted" + } + ], "docs": { "description": [ "" @@ -2568,15 +5915,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, @@ -2955,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": [ @@ -3695,17 +7157,47 @@ } }, { - "name": "MemberQueryOrdersOptions", + "name": "MessageEnvelope", "members": [ { - "name": "query", + "name": "data", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Orders.QueryV2" + "nativeType": "string" } ], - "doc": "" + "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": { @@ -3811,7 +7303,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/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.service.json b/wix-pricing-plans-v2/wix-pricing-plans-v2/Plans.service.json index 5aa0656e45..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 @@ -48,15 +48,68 @@ ], "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';", "", "/* Sample _id value: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */", "", "export async function myArchivePlanFunction(_id) {", " try {", + " const archivedPlan = await plans.archivePlan(_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.\"", + " * } ", + " */" + ] + }, + { + "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);", "", @@ -65,7 +118,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -98,8 +151,7 @@ " * \"slug\": \"basic\",", " * \"termsAndConditions\": \"After 90 day free trial ends, your plan will end and you will need to purchase a paid plan.\"", " * } ", - " */", - "" + " */" ] } ] @@ -154,10 +206,9 @@ ], "examples": [ { - "title": "Arrange plans ", + "title": "Arrange plans (dashboard page code)", "body": [ "import { plans } from 'wix-pricing-plans.v2';", - "import { elevate } from 'wix-auth';", "", "/* Sample ids value:", " * [", @@ -171,6 +222,37 @@ "", "export async function myArrangePlansFunction(ids) {", " try {", + " const arranged = await plans.arrangePlans(ids);", + "", + " return;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "/* Promise resolves to void */" + ] + }, + { + "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);", "", @@ -179,11 +261,71 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", - "/* Promise resolves to void */", - "" + "/* Promise resolves to void */" ] + }, + { + "title": "Sort plans alphabetically ", + "body": [ + "/*************************************", + " * 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 const sortPlansBySlug = webMethod(Permissions.Anyone, async (direction) => {", + " let publicPlansQuery = plans.queryPublicPlans();", + "", + " if (direction === 'ascending') {", + " publicPlansQuery = publicPlansQuery.ascending('slug');", + " } else {", + " publicPlansQuery = publicPlansQuery.descending('slug');", + " }", + "", + " 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.web';", + "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 descending order by plan slug. " + } } ] }, @@ -217,15 +359,13 @@ ], "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';", "", "export async function myClearPrimaryFunction() {", " try {", - " const elevatedClearPrimary = elevate(plans.clearPrimary);", - " const clearedPrimary = await elevatedClearPrimary();", + " const clearedPrimary = await plans.clearPrimary();", "", " return;", " } catch (error) {", @@ -236,6 +376,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 */", + "" + ] } ] }, @@ -284,28 +447,55 @@ "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": [ { - "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!'", " * }", " */", "", "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;", + " const perks = newPlan.perks;", "", " return newPlan;", " } catch (error) {", @@ -316,36 +506,49 @@ "", "/* 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';", "", @@ -383,7 +586,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);", @@ -397,7 +600,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -440,61 +643,273 @@ " */ ", "" ] - } - ] - }, - "isVeloEvent": false, - "syntaxName": "createPlan", - "isAdminMethod": true - }, - { - "name": "getPlan", - "params": [ - { - "name": "_id", - "type": [ - { - "nativeType": "string" - } - ], - "doc": "Plan ID.", - "required": true - } - ], - "requiredFields": [ - "_id" - ], - "ret": { - "type": [ + }, { - "complexType": { - "nativeType": "Promise", - "typeParams": [ - { - "referenceType": "wix-pricing-plans-v2.Plans.Plan" - } - ] - } - } - ], - "doc": "Fulfilled - The retrieved plan's information.\n" - }, - "docs": { - "summary": "Retrieves a pricing plan by the specified ID.", - "description": [ + "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.web.js *", + " *************************************/", + "", + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export const listPlans = webMethod(Permissions.Anyone, async () => {", + " try {", + " const response = await elevatedListPlans();", + " const allPlans = response.plans;", + "", + " return allPlans;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const getPlan = webMethod(Permissions.Anyone, async (planId) => {", + " try {", + " const selectedPlan = await elevatedGetPlan(planId);", + "", + " return selectedPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const createPlan = webMethod(Permissions.Anyone, async (plan) => {", + " try {", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions.web';", + "$w.onReady(async function () {", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", + " let selectedPlan;", + "", + " $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);", + " });", + "});", + "", + "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": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " + } + } + ] + }, + "isVeloEvent": false, + "syntaxName": "createPlan", + "isAdminMethod": true + }, + { + "name": "getPlan", + "params": [ + { + "name": "_id", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Plan ID.", + "required": true + } + ], + "requiredFields": [ + "_id" + ], + "ret": { + "type": [ + { + "complexType": { + "nativeType": "Promise", + "typeParams": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.Plan" + } + ] + } + } + ], + "doc": "Fulfilled - The retrieved plan's information.\n" + }, + "docs": { + "summary": "Retrieves a pricing plan by the specified ID.", + "description": [ "The `getPlan()` function returns a Promise that resolves to a plan whose ID matched the specified ID." ], "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';", "", "/* Sample _id value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */", "", "export async function myGetPlanFunction(_id) {", " try {", + " const myPlan = await plans.getPlan(_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": "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);", "", @@ -503,7 +918,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -545,6 +960,102 @@ " * } ", " */" ] + }, + { + "title": "Duplicate a plan ", + "body": [ + "/*************************************", + " * 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 elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export const listPlans = webMethod(Permissions.Anyone, async () => {", + " try {", + " const response = await elevatedListPlans();", + " const allPlans = response.plans;", + "", + " return allPlans;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const getPlan = webMethod(Permissions.Anyone, async (planId) => {", + " try {", + " const selectedPlan = await elevatedGetPlan(planId);", + "", + " return selectedPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const createPlan = webMethod(Permissions.Anyone, async (plan) => {", + " try {", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions.web';", + "$w.onReady(async function () {", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", + " let selectedPlan;", + "", + " $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);", + " });", + "});", + "", + "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": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " + } } ] }, @@ -578,15 +1089,13 @@ ], "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';", "", "export async function myGetPlanStatsFunction() {", " try {", - " const elevatedGetPlanStats = elevate(plans.getPlanStats);", - " const planStats = elevatedGetPlanStats();", + " const planStats = plans.getPlanStats();", "", " return planStats;", " } catch (error) {", @@ -601,27 +1110,54 @@ " * }", " */" ] - } - ] - }, - "isVeloEvent": false, - "syntaxName": "getPlanStats", - "isAdminMethod": true - }, - { - "name": "listPlans", - "params": [ - { - "name": "options", - "type": [ - { - "referenceType": "wix-pricing-plans-v2.Plans.ListPlansOptions" - } - ], - "doc": "Options for filtering and paging the list of plans.", - "required": false - } - ], + }, + { + "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 ", + " * }", + " */", + "" + ] + } + ] + }, + "isVeloEvent": false, + "syntaxName": "getPlanStats", + "isAdminMethod": true + }, + { + "name": "listPlans", + "params": [ + { + "name": "options", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.ListPlansOptions" + } + ], + "doc": "Options for filtering and paging the list of plans.", + "required": false + } + ], "requiredFields": [], "ret": { "type": [ @@ -645,14 +1181,15 @@ ], "examples": [ { - "title": "List plans ", + "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 elevatedListPlans = elevate(plans.listPlans);", " const plansList = await elevatedListPlans();", "", " return plansList;", @@ -663,6 +1200,136 @@ "}", "", "/* 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": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "export const myListPlansFunction = webMethod(Permissions.Anyone, async () => {", + " try {", + " const elevatedListPlans = elevate(plans.listPlans);", + " const plansList = await elevatedListPlans();", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", " * {", " * \"pagingMetadata\": {", " * \"count\": 4,", @@ -777,12 +1444,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';", "", @@ -793,7 +1462,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);", @@ -803,7 +1472,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -941,12 +1610,113 @@ " * }", " * ]", " * }", - " */" + " */", + "" ] + }, + { + "title": "Duplicate a plan ", + "body": [ + "/*************************************", + " * Backend code - plan-functions.jsw *", + " *************************************/", + "", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "const elevatedListPlans = elevate(plans.listPlans);", + "const elevatedGetPlan = elevate(plans.getPlan);", + "const elevatedCreatePlan = elevate(plans.createPlan);", + "", + "export async function listPlans() {", + " try {", + " const response = await elevatedListPlans();", + " const allPlans = response.plans;", + "", + " return allPlans;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function getPlan(planId) {", + " try {", + " const selectedPlan = await elevatedGetPlan(planId);", + "", + " return selectedPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "export async function createPlan(plan) {", + " try {", + " const newPlan = await elevatedCreatePlan(plan);", + "", + " return newPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "}", + "", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listPlans, getPlan, createPlan } from 'backend/plan-functions';", + "$w.onReady(async function () {", + " $w('#plansDropdown').disable();", + " $w('#clonePlanBtn').disable();", + " populatePlansDropdown();", + "", + " let selectedPlan;", + "", + " $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);", + " });", + "});", + "", + "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": "The `populatePlansDropdown` function retrieves all plans and then populates them into the `#plansDropdown`. The `#plansDropdown` and `#clonePlanBtn` are set to `disabled` by default. " + } } ] }, "isVeloEvent": false, + "customLabels": [ + { + "id": "maturity-beta" + } + ], "syntaxName": "listPlans", "isAdminMethod": true }, @@ -987,7 +1757,7 @@ ], "examples": [ { - "title": "List public plans ", + "title": "List public plans", "body": [ "import { plans } from 'wix-pricing-plans.v2';", "import { elevate } from 'wix-auth';", @@ -1191,70 +1961,277 @@ ] }, { - "title": "List public plans with options ", + "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';", "", - "/* Sample options value:", - " * {", - " * limit: 3,", - " * offset: 1,", - " * planIds: [", - " * \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", - " * \"b20feb39-a452-453e-96ee-01036adcd04e\",", - " * \"025a0d1f-7076-4e27-9696-4a67075dc2aa\",", - " * \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", - " * \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", - " * \"7a3375ce-18a9-42cb-8e39-47918ade45ec\"", - " * ]", - " * }", - " */", - "", - "export async function myListPublicPlansFunction(options) {", + "export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async () => {", " try {", " const elevatedListPublicPlans = elevate(plans.listPublicPlans);", - " const plansList = await elevatedListPublicPlans(options);", + " const plansList = await elevatedListPublicPlans();", "", " return plansList;", " } catch(error) {", " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", - " * {", + " * { ", " * \"pagingMetadata\": {", - " * \"count\": 3,", - " * \"hasNext\": true,", - " * \"offset\": 1,", + " * \"count\": 5,", + " * \"hasNext\": false,", + " * \"offset\": 0,", " * \"total\": 5", " * },", " * \"plans\": [", " * {", - " * \"_createdDate\": \"2024-01-07T07:33:59.973Z\",", - " * \"_id\": \"b20feb39-a452-453e-96ee-01036adcd04e\",", - " * \"_updatedDate\": \"2024-01-09T09:08:05.665Z\",", + " * \"_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\": \"Full feature enablement - lifetime plan\",", + " * \"description\": \"The value plan\",", " * \"formId\": \"ee62cefa-bdc2-4b5d-baab-6faeef83cecb\",", " * \"hasOrders\": false,", - " * \"maxPurchasesPerBuyer\": 0,", - " * \"name\": \"Premium Plan - Lifetime Membership\",", + " * \"maxPurchasesPerBuyer\": 1,", + " * \"name\": \"Silver Membership - Monthly\",", " * \"perks\": {", " * \"values\": [", - " * \"Cloud drive and file upload services\",", - " * \"Unlimited video content access\"", + " * \"Full site access\",", + " * \"Full video access\",", + " * \"Consultation booking\"", " * ]", " * },", " * \"primary\": false,", " * \"pricing\": {", + " * \"freeTrialDays\": 14,", " * \"price\": {", " * \"currency\": \"EUR\",", - " * \"value\": \"1000\"", + " * \"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 with options ", + "body": [ + "import { Permissions, webMethod } from 'wix-web-module';", + "import { plans } from 'wix-pricing-plans.v2';", + "import { elevate } from 'wix-auth';", + "", + "/* Sample options value:", + " * {", + " * limit: 3,", + " * offset: 1,", + " * planIds: [", + " * \"d2fa5805-0d1a-4cfb-9b43-e683cf5fa990\",", + " * \"b20feb39-a452-453e-96ee-01036adcd04e\",", + " * \"025a0d1f-7076-4e27-9696-4a67075dc2aa\",", + " * \"838f2c9d-c8d0-4799-a10a-e2f23849db10\",", + " * \"cb4a8c57-273a-4567-94e3-cc43d5d339f2\",", + " * \"7a3375ce-18a9-42cb-8e39-47918ade45ec\"", + " * ]", + " * }", + " */", + "", + "export const myListPublicPlansFunction = webMethod(Permissions.Anyone, async (options) => {", + " try {", + " const elevatedListPublicPlans = elevate(plans.listPublicPlans);", + " const plansList = await elevatedListPublicPlans(options);", + "", + " return plansList;", + " } catch(error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/* Promise resolves to:", + " * {", + " * \"pagingMetadata\": {", + " * \"count\": 3,", + " * \"hasNext\": true,", + " * \"offset\": 1,", + " * \"total\": 5", + " * },", + " * \"plans\": [", + " * {", + " * \"_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", " * },", @@ -1335,9 +2312,73 @@ " * }", " * ]", " * }", - " */ ", - "" + " */" ] + }, + { + "title": "Make a plan primary ", + "body": [ + "/*************************************", + " * 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 const listPublicPlans = webMethod(Permissions.Anyone, async () => {", + " try {", + " const response = await elevatedListPublicPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " const primaryPlan = await elevatedMakePlanPrimary(_id);", + "", + " return primaryPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';", + "", + "$w.onReady(function () {", + " populateDropdown();", + " $w('#plansList').onChange(async () => {", + " await makePlanPrimaryFunction(", + " $w('#plansList').value", + " )", + " });", + "});", + "", + "async function populateDropdown() {", + " const plans = await 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. " + } } ] }, @@ -1383,15 +2424,68 @@ ], "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';", "", "/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' */", "", "export async function myMakePlanPrimaryFunction(_id) {", " try {", + " const primaryPlan = await plans.makePlanPrimary(_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 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);", "", @@ -1400,7 +2494,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -1421,74 +2515,344 @@ " * \"Unlimited video content access\"", " * ]", " * },", - " * \"pricing\": {", - " * \"price\": {", + " * \"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.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 const listPublicPlans = webMethod(Permissions.Anyone, async () => {", + " try {", + " const response = await elevatedListPublicPlans();", + " const plansList = response.plans;", + "", + " return plansList;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {", + " try {", + " const primaryPlan = await elevatedMakePlanPrimary(_id);", + "", + " return primaryPlan;", + " } catch (error) {", + " console.error(error);", + " // Handle the error", + " }", + "});", + "", + "/*************", + " * Page code *", + " *************/", + "", + "import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';", + "", + "$w.onReady(function () {", + " populateDropdown();", + " $w('#plansList').onChange(async () => {", + " await makePlanPrimaryFunction(", + " $w('#plansList').value", + " )", + " });", + "});", + "", + "async function populateDropdown() {", + " const plans = await 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. " + } + } + ] + }, + "isVeloEvent": false, + "syntaxName": "makePlanPrimary", + "isAdminMethod": true + }, + { + "name": "queryPublicPlans", + "params": [], + "requiredFields": [], + "ret": { + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.PlansQueryBuilder" + } + ], + "doc": null + }, + "docs": { + "summary": "Creates a query to retrieve a list of public pricing plans. ", + "description": [ + "", + "", + "The `queryPublicPlans()` function builds a query to retrieve a list of up to 1,000 public plans and returns a [`PublicPlansQueryBuilder`](#plansquerybuilder) object. ", + "", + "The returned object contains the query definition which is typically used to run the query using the [`find()`](#plansquerybuilder/find) function. ", + "", + "You can refine the query by chaining `PublicPlansQueryBuilder` functions onto the query. `PublicPlansQueryBuilder` functions enable you to sort, filter, and control the results that `queryPublicPlans()` returns. ", + "", + "`queryPublicPlans()` runs with the following `PublicPlansQueryBuilder` defaults that you can override:", + "- [`skip`](#plansquerybuilder/skip): `0`", + "- [`limit`](#plansquerybuilder/limit): `50`", + "", + "The functions that are chained to `queryPublicPlans()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the `_id` property in ascending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by `_id` in ascending order, per created date value.", + "", + "The following `PublicPlansQueryBuilder` functions are supported for the `queryPublicPlans()` function. For a full description of the Plans object, see the object returned for the [`items`](#plansqueryresult/items) property in [`PublicPlansQueryResult`](#plansqueryresult).", + "", + "", + "|PROPERTY\t|SUPPORTED FILTERS & SORTING\t", + "|:---:|:---:|", + "|`_id`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`startsWith()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#startsWith),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", + "|`primary`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", + "|`_createdDate`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`lt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#lt),[`le()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#le),[`gt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#gt),[`ge()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ge),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", + "|`_updatedDate`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`lt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#lt),[`le()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#le),[`gt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#gt),[`ge()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ge),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", + "|`slug`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`startsWith()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#startsWith),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|" + ], + "examples": [ + { + "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\"", + " * \"value\": \"1000\",", + " * \"singlePaymentUnlimited\": true", " * },", - " * \"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.\"", " * },", - " * \"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.\"", - " * }", + " * {", + " * \"_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\": \"\"", + " * }", + " * ]", " */" ] - } - ] - }, - "isVeloEvent": false, - "syntaxName": "makePlanPrimary", - "isAdminMethod": true - }, - { - "name": "queryPublicPlans", - "params": [], - "requiredFields": [], - "ret": { - "type": [ - { - "referenceType": "wix-pricing-plans-v2.Plans.PlansQueryBuilder" - } - ], - "doc": null - }, - "docs": { - "summary": "Creates a query to retrieve a list of public pricing plans. ", - "description": [ - "", - "", - "The `queryPublicPlans()` function builds a query to retrieve a list of up to 1,000 public plans and returns a [`PublicPlansQueryBuilder`](#plansquerybuilder) object. ", - "", - "The returned object contains the query definition which is typically used to run the query using the [`find()`](#plansquerybuilder/find) function. ", - "", - "You can refine the query by chaining `PublicPlansQueryBuilder` functions onto the query. `PublicPlansQueryBuilder` functions enable you to sort, filter, and control the results that `queryPublicPlans()` returns. ", - "", - "`queryPublicPlans()` runs with the following `PublicPlansQueryBuilder` defaults that you can override:", - "- [`skip`](#plansquerybuilder/skip): `0`", - "- [`limit`](#plansquerybuilder/limit): `50`", - "", - "The functions that are chained to `queryPublicPlans()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the `_id` property in ascending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by `_id` in ascending order, per created date value.", - "", - "The following `PublicPlansQueryBuilder` functions are supported for the `queryPublicPlans()` function. For a full description of the Plans object, see the object returned for the [`items`](#plansqueryresult/items) property in [`PublicPlansQueryResult`](#plansqueryresult).", - "", - "", - "|PROPERTY\t|SUPPORTED FILTERS & SORTING\t", - "|:---:|:---:|", - "|`_id`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`startsWith()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#startsWith),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", - "|`primary`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", - "|`_createdDate`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`lt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#lt),[`le()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#le),[`gt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#gt),[`ge()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ge),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", - "|`_updatedDate`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`lt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#lt),[`le()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#le),[`gt()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#gt),[`ge()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ge),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|", - "|`slug`|[`eq()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#eq),[`ne()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ne),[`exists()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#exists),[`in()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#in),[`hasSome()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#hasSome),[`startsWith()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#startsWith),[`ascending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#ascending),[`descending()`](wix-pricing-plans-v2.Plans.PlansQueryBuilder#descending)|" - ], - "examples": [ + }, { - "title": "Build and execute a query to find all public plans ", + "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;", @@ -1501,7 +2865,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Returned items:", " * [", @@ -1683,15 +3047,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()", @@ -1704,7 +3070,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Returned item:", " * {", @@ -1739,15 +3105,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()", @@ -1760,10 +3128,72 @@ " 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.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 const sortPlansBySlug = webMethod(Permissions.Anyone, async (direction) => {", + " let publicPlansQuery = plans.queryPublicPlans();", + "", + " if (direction === 'ascending') {", + " publicPlansQuery = publicPlansQuery.ascending('slug');", + " } else {", + " publicPlansQuery = publicPlansQuery.descending('slug');", + " }", + "", + " 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.web';", + "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 descending order by plan slug. " + } } ] }, @@ -1820,8 +3250,75 @@ ], "examples": [ { - "title": "Hide a plan ", + "title": "Hide a plan (dashboard page code)", + "body": [ + "import { plans } from 'wix-pricing-plans.v2';", + "", + "/* Sample _id value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'", + " * ", + " * Sample visible value: false", + " */", + "", + "export async function mySetPlanVisibilityFunction(_id, visible) {", + " try {", + " const hiddenPlan = plans.setPlanVisibility(_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\": \"\"", + " * }", + " * }", + " */ " + ] + }, + { + "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';", "", @@ -1830,7 +3327,7 @@ " * Sample visible value: false", " */", "", - "export async function mySetPlanVisibilityFunction(_id, visible) {", + "export const mySetPlanVisibilityFunction = webMethod(Permissions.Anyone, async (_id, visible) => {", " try {", " const elevatedSetPlanVisibility = elevate(plans.setPlanVisibility);", " const hiddenPlan = elevatedSetPlanVisibility(_id,visible);", @@ -1840,7 +3337,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", " ", "/* Promise resolves to:", " * {", @@ -1884,7 +3381,8 @@ " * \"termsAndConditions\": \"\"", " * }", " * }", - " */ " + " */ ", + "" ] } ] @@ -1943,10 +3441,9 @@ ], "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';", "", "/* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' ", " * ", @@ -1959,8 +3456,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) {", @@ -2004,9 +3500,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';", "", @@ -2044,7 +3605,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);", @@ -2054,7 +3615,7 @@ " console.error(error);", " // Handle the error", " }", - "}", + "});", "", "/* Promise resolves to:", " * {", @@ -2092,51 +3653,239 @@ " * \"termsAndConditions\": \"I agree to refrain from sharing any of the exclusive content with non-members\"", " * }", " */", - "", - "", "" ] } ] - }, - "isVeloEvent": false, - "syntaxName": "updatePlan", - "isAdminMethod": true - } - ], - "messages": [ + }, + "isVeloEvent": false, + "syntaxName": "updatePlan", + "isAdminMethod": true + } + ], + "messages": [ + { + "name": "ActionEvent", + "members": [ + { + "name": "bodyAsJson", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "ApplicationError", + "members": [ + { + "name": "code", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Error code." + }, + { + "name": "data", + "optional": true, + "type": [ + { + "nativeType": "Object" + } + ], + "doc": "Data related to the error." + }, + { + "name": "description", + "optional": true, + "type": [ + { + "nativeType": "string" + } + ], + "doc": "Description of the error." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "ArchivePlanRequest", + "members": [ + { + "name": "_id", + "type": [ + { + "nativeType": "string" + } + ], + "doc": "" + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "ArchivePlanResponse", + "members": [ + { + "name": "plan", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.Plan" + } + ], + "doc": "Archived plan info." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "ArrangePlansRequest", + "members": [ + { + "name": "ids", + "type": [ + { + "complexType": { + "nativeType": "Array", + "typeParams": [ + { + "nativeType": "string" + } + ] + } + } + ], + "doc": "IDs of all non-archived plans in the order you want them arranged." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "ArrangePlansResponse", + "members": [], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "BulkActionMetadata", + "members": [ + { + "name": "totalFailures", + "optional": true, + "type": [ + { + "nativeType": "number" + } + ], + "doc": "Number of items that couldn't be processed." + }, + { + "name": "totalSuccesses", + "optional": true, + "type": [ + { + "nativeType": "number" + } + ], + "doc": "Number of items that were successfully processed." + }, + { + "name": "undetailedFailures", + "optional": true, + "type": [ + { + "nativeType": "number" + } + ], + "doc": "Number of failures without details because detailed failure threshold was exceeded." + } + ], + "docs": { + "description": [ + "" + ] + } + }, { - "name": "ApplicationError", + "name": "BulkArchivePlanOptions", "members": [ { - "name": "code", + "name": "returnFullEntity", "optional": true, "type": [ { - "nativeType": "string" + "nativeType": "boolean" } ], - "doc": "Error code." - }, + "doc": "Set to true to return Plan entity in response." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "BulkArchivePlanRequest", + "members": [ { - "name": "data", - "optional": true, + "name": "ids", "type": [ { - "nativeType": "Object" + "complexType": { + "nativeType": "Array", + "typeParams": [ + { + "nativeType": "string" + } + ] + } } ], - "doc": "Data related to the error." + "doc": "List of Plan IDs." }, { - "name": "description", + "name": "returnFullEntity", "optional": true, "type": [ { - "nativeType": "string" + "nativeType": "boolean" } ], - "doc": "Description of the error." + "doc": "Set to true to return Plan entity in response." } ], "docs": { @@ -2146,13 +3895,31 @@ } }, { - "name": "ArchivePlanRequest", + "name": "BulkArchivePlanResponse", "members": [ { - "name": "_id", + "name": "bulkActionMetadata", + "optional": true, "type": [ { - "nativeType": "string" + "referenceType": "wix-pricing-plans-v2.Plans.BulkActionMetadata" + } + ], + "doc": "" + }, + { + "name": "results", + "optional": true, + "type": [ + { + "complexType": { + "nativeType": "Array", + "typeParams": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.BulkPlanResult" + } + ] + } } ], "doc": "" @@ -2165,8 +3932,18 @@ } }, { - "name": "ArchivePlanResponse", + "name": "BulkPlanResult", "members": [ + { + "name": "itemMetadata", + "optional": true, + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.ItemMetadata" + } + ], + "doc": "" + }, { "name": "plan", "optional": true, @@ -2175,7 +3952,7 @@ "referenceType": "wix-pricing-plans-v2.Plans.Plan" } ], - "doc": "Archived plan info." + "doc": "" } ], "docs": { @@ -2185,23 +3962,17 @@ } }, { - "name": "ArrangePlansRequest", + "name": "BuyerCanCancelUpdated", "members": [ { - "name": "ids", + "name": "plan", + "optional": true, "type": [ { - "complexType": { - "nativeType": "Array", - "typeParams": [ - { - "nativeType": "string" - } - ] - } + "referenceType": "wix-pricing-plans-v2.Plans.Plan" } ], - "doc": "IDs of all non-archived plans in the order you want them arranged." + "doc": "" } ], "docs": { @@ -2211,7 +3982,7 @@ } }, { - "name": "ArrangePlansResponse", + "name": "ClearPrimaryRequest", "members": [], "docs": { "description": [ @@ -2220,37 +3991,75 @@ } }, { - "name": "BulkActionMetadata", + "name": "ClearPrimaryResponse", + "members": [], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "CreatePlanRequest", "members": [ { - "name": "totalFailures", + "name": "plan", + "type": [ + { + "referenceType": "wix-pricing-plans-v2.Plans.Plan" + } + ], + "doc": "Information for the plan being created." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "CreatePlanResponse", + "members": [ + { + "name": "plan", "optional": true, "type": [ { - "nativeType": "number" + "referenceType": "wix-pricing-plans-v2.Plans.Plan" } ], - "doc": "Number of items that couldn't be processed." - }, + "doc": "Plan info." + } + ], + "docs": { + "description": [ + "" + ] + } + }, + { + "name": "Cursors", + "members": [ { - "name": "totalSuccesses", + "name": "next", "optional": true, "type": [ { - "nativeType": "number" + "nativeType": "string" } ], - "doc": "Number of items that were successfully processed." + "doc": "Cursor string pointing to the next page in the list of results." }, { - "name": "undetailedFailures", + "name": "prev", "optional": true, "type": [ { - "nativeType": "number" + "nativeType": "string" } ], - "doc": "Number of failures without details because detailed failure threshold was exceeded." + "doc": "Cursor pointing to the previous page in the list of results." } ], "docs": { @@ -2260,19 +4069,142 @@ } }, { - "name": "BulkArchivePlanOptions", + "name": "DomainEvent", "members": [ { - "name": "returnFullEntity", + "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": [ { - "nativeType": "boolean" + "referenceType": "wix-pricing-plans-v2.Plans.EntityUpdatedEvent" } ], - "doc": "Set to true to return Plan entity in response." + "doc": "" } ], + "extra": { + "oneOfGroups": [ + { + "name": "oneOfDomainEventBodyOneOf", + "members": [ + "actionEvent", + "createdEvent", + "deletedEvent", + "updatedEvent" + ] + } + ] + }, "docs": { "description": [ "" @@ -2280,67 +4212,44 @@ } }, { - "name": "BulkArchivePlanRequest", + "name": "DomainEventBodyOneOf", "members": [ { - "name": "ids", + "name": "actionEvent", + "optional": true, "type": [ { - "complexType": { - "nativeType": "Array", - "typeParams": [ - { - "nativeType": "string" - } - ] - } + "referenceType": "wix-pricing-plans-v2.Plans.ActionEvent" } ], - "doc": "List of Plan IDs." + "doc": "" }, { - "name": "returnFullEntity", + "name": "createdEvent", "optional": true, "type": [ { - "nativeType": "boolean" + "referenceType": "wix-pricing-plans-v2.Plans.EntityCreatedEvent" } ], - "doc": "Set to true to return Plan entity in response." - } - ], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "BulkArchivePlanResponse", - "members": [ + "doc": "" + }, { - "name": "bulkActionMetadata", + "name": "deletedEvent", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.BulkActionMetadata" + "referenceType": "wix-pricing-plans-v2.Plans.EntityDeletedEvent" } ], "doc": "" }, { - "name": "results", + "name": "updatedEvent", "optional": true, "type": [ { - "complexType": { - "nativeType": "Array", - "typeParams": [ - { - "referenceType": "wix-pricing-plans-v2.Plans.BulkPlanResult" - } - ] - } + "referenceType": "wix-pricing-plans-v2.Plans.EntityUpdatedEvent" } ], "doc": "" @@ -2353,44 +4262,44 @@ } }, { - "name": "BulkPlanResult", + "name": "Duration", "members": [ { - "name": "itemMetadata", + "name": "count", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.ItemMetadata" + "nativeType": "number" } ], - "doc": "" + "doc": "Number of days days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`." }, { - "name": "plan", + "name": "unit", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.Plan" + "nativeType": "string" } ], - "doc": "" + "doc": "Unit of time for the cycle duration." } ], "docs": { "description": [ - "" + "A duration expressed in number of time units." ] } }, { - "name": "BuyerCanCancelUpdated", + "name": "EntityCreatedEvent", "members": [ { - "name": "plan", + "name": "entityAsJson", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.Plan" + "nativeType": "string" } ], "doc": "" @@ -2403,34 +4312,17 @@ } }, { - "name": "ClearPrimaryRequest", - "members": [], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "ClearPrimaryResponse", - "members": [], - "docs": { - "description": [ - "" - ] - } - }, - { - "name": "CreatePlanRequest", + "name": "EntityDeletedEvent", "members": [ { - "name": "plan", + "name": "deletedEntityAsJson", + "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.Plan" + "nativeType": "string" } ], - "doc": "Information for the plan being created." + "doc": "Entity that was deleted" } ], "docs": { @@ -2440,17 +4332,17 @@ } }, { - "name": "CreatePlanResponse", + "name": "EntityUpdatedEvent", "members": [ { - "name": "plan", + "name": "currentEntityAsJson", "optional": true, "type": [ { - "referenceType": "wix-pricing-plans-v2.Plans.Plan" + "nativeType": "string" } ], - "doc": "Plan info." + "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": { @@ -2460,27 +4352,27 @@ } }, { - "name": "Cursors", + "name": "Fee", "members": [ { - "name": "next", + "name": "amount", "optional": true, "type": [ { "nativeType": "string" } ], - "doc": "Cursor pointing to next page in the list of results." + "doc": "Amount of fee to be charged" }, { - "name": "prev", + "name": "name", "optional": true, "type": [ { "nativeType": "string" } ], - "doc": "Cursor pointing to previous page in the list of results." + "doc": "Fee name" } ], "docs": { @@ -2490,36 +4382,36 @@ } }, { - "name": "Duration", + "name": "FeeConfig", "members": [ { - "name": "count", + "name": "appliedAt", "optional": true, "type": [ { - "nativeType": "number" + "nativeType": "string" } ], - "doc": "Number of days days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`." + "doc": "The time this fee will be charged" }, { - "name": "unit", + "name": "fee", "optional": true, "type": [ { - "nativeType": "string" + "referenceType": "wix-pricing-plans-v2.Plans.Fee" } ], - "doc": "Unit of time for the cycle duration.\n\nSupported values: `\"DAY\"`, `\"WEEK\"`, `\"MONTH\"`, `\"YEAR\"`.\n\n" + "doc": "" } ], "docs": { "description": [ - "A duration expressed in number of time units." + "" ] } }, - { + { "name": "GetPlanRequest", "members": [ { @@ -2587,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": [ @@ -2648,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", @@ -2695,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": { @@ -2715,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", @@ -2762,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": { @@ -2978,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": [ @@ -3163,7 +5229,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", @@ -3871,7 +5937,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", 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" } 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..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 @@ -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 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. ### 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.