> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: onOrderPurchased(event: OrderPurchasedEvent) # Method package: wixPricingPlansBackend # Method menu location: wixPricingPlansBackend --> Events --> onOrderPurchased # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-purchased.md # Method Description: An event that triggers when an order is purchased. The `onOrderPurchased()` event handler runs when an order is purchased. The received `OrderPurchasedEvent` object contains information about the order that was purchased. An order is considered purchased if: + The order is paid for in full, or at least one of its billing cycle payments is paid. + An offline order is created, even if not yet marked as paid. + A free online order is created. > **Note:** Backend events don't work when previewing your site. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## An event triggered when an order is purchased ```javascript // 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 orderId = event.data.order._id; const eventId = event.metadata.id; const eventTime = event.metadata.eventTime; } /* Full event object: * { * "metadata": { * "id":"f2e01b16-48c3-4365-89c7-1e3710639f50", * "entityId":"938ca26d-41e0-4aae-81a2-286ae9afd6ef", * "eventTime":"2022-07-26T14:59:49.951623Z", * "triggeredByAnonymizeRequest":false * }, * "data": { * "order": { * "_id":"938ca26d-41e0-4aae-81a2-286ae9afd6ef", * "planId":"099e2c86-3b7e-4477-8c27-f77402b8cceb", * "subscriptionId":"1b879750-b4c3-4b17-9687-1f18f6b0ea19", * "wixPayOrderId":"3eb01dc8-45c7-426f-a910-13d8c6008532", * "buyer": { * "memberId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86", * "contactId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86" * }, * "priceDetails": { * "subtotal":"74.99", * "discount":"0", * "total":"74.99", * "planPrice":"74.99", * "currency":"EUR", * "subscription": { * "cycleDuration": { * "count":1, * "unit":"MONTH" * }, * "cycleCount":3 * }}, * "pricing": { * "subscription": { * "cycleDuration": { * "count":1, * "unit":"MONTH" * }, * "cycleCount":3 * }, * "prices": [{ * "duration": { * "cycleFrom":1, * "numberOfCycles":3 * }, * "price": { * "subtotal":"74.99", * "discount":"0", * "total":"74.99", * "currency":"EUR" * } * }]}, * "type":"OFFLINE", * "orderMethod":"UNKNOWN", * "status":"ACTIVE", * "autoRenewCanceled":false, * "lastPaymentStatus":"PAID", * "startDate":"2022-01-25T16:23:00.000Z", * "endDate":"2022-04-25T16:23:00.000Z", * "pausePeriods":[], * "earliestEndDate":"2022-04-25T16:23:00.000Z", * "currentCycle": { * "index":3, * "startedDate":"2022-03-25T16:23:00.000Z", * "endedDate":"2022-04-25T16:23:00.000Z" * }, * "planName":"Platinum Pro", * "planDescription":"", * "planPrice":"74.99", * "_createdDate":"2022-07-26T14:59:49.314Z", * "_updatedDate":"2022-07-26T14:59:49.314Z" * } * } * } */ ``` ---