> 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 # MarkAsPaid # Package: pricingPlans # Namespace: OrderManagementService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/orders/mark-as-paid.md ## Permission Scopes: Manage Orders: SCOPE.DC-PAIDPLANS.MANAGE-ORDERS ## Introduction Marks an offline order as paid. > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments. Marking an offline order as paid causes the following changes: - The order's `lastPaymentStatus` changes to `"PAID"`. - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`. An error occurs if you attempt to: - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice. - Mark an online order as paid. The Mark as Paid method is supported for offline orders only. --- ## REST API ### Schema ``` Method: markAsPaid Description: Marks an offline order as paid. > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments. Marking an offline order as paid causes the following changes: - The order's `lastPaymentStatus` changes to `"PAID"`. - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`. An error occurs if you attempt to: - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice. - Mark an online order as paid. The Mark as Paid method is supported for offline orders only. URL: https://www.wixapis.com/pricing-plans/v2/orders/{id}/mark-as-paid Method: POST Return type: MarkAsPaidResponse EMPTY-OBJECT {} ``` ### Examples ### MarkAsPaid ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/pricing-plans/v2/orders/d5ce1234-c0a9-476c-abd3-c78aa8589a78/mark-as-paid' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.pricingPlans.OrderManagementService.markAsPaid(_id) Description: Marks an offline order as paid. > __Note__: Marking separate payment cycles as paid is not yet supported. The entire order will be marked as paid. Subsequent offline payments do trigger events and emails, but are not registered as additional offline payments. Marking an offline order as paid causes the following changes: - The order's `lastPaymentStatus` changes to `"PAID"`. - The order's status changes to either `"PENDING"` or `"ACTIVE"`, depending on the order's `startDate`. An error occurs if you attempt to: - Mark an already-paid, offline order as paid. You cannot mark an offline order as paid twice. - Mark an online order as paid. The Mark as Paid method is supported for offline orders only. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: _id Method parameters: param name: _id | type: string | description: Order GUID. | required: true Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Create an offline order for an existing member (with $w) This example provides a dropdown list of site members and public plans to complete a manual offline transaction. ```javascript /********************************** * Backend code - utils.web.js/ts * *********************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { orders, plans } from '@wix/pricing-plans'; import { auth } from '@wix/essentials'; const elevatedListPublicPlans = auth.elevate(plans.listPublicPlans); const elevatedCreateOfflineOrder = auth.elevate(orders.createOfflineOrder); const elevatedMarkAsPaid = auth.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'; $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.order._id; markAsPaid(orderId); }); }); async function populatePlansDropdown() { const plans = await listPublicPlans(); $w('#plansListDropdown').options = plans.map((item) => { return { label: item.name, value: item._id } }); } ``` ### Manager cancellation or updated payment status of multiple orders (with $w) 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. ```javascript /********************************** * Backend code - utils.web.js/ts * *********************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { orders } from '@wix/pricing-plans'; import { auth } from '@wix/essentials'; const elevatedManagementListOrders = auth.elevate(orders.managementListOrders); const elevatedCancelOrder = auth.elevate(orders.cancelOrder); const elevatedMarkAsPaid = auth.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(); } ``` ### Mark an order as paid (with elevated permissions) ```javascript import { orders } from '@wix/pricing-plans'; import { auth } from '@wix/essentials'; /* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5' */ const elevatedMarkAsPaid = auth.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 */ ``` ### Mark an order as paid ```javascript import { orders } from '@wix/pricing-plans'; /* Sample _id value: '82d99338-5653-459a-a751-b57483f7cfb5' */ export async function myMarkAsPaidFunction(_id) { try { await orders.markAsPaid(_id); return; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### markAsPaid (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { orders } from '@wix/pricing-plans'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { orders }, // Include the auth strategy and host as relevant }); async function markAsPaid(_id) { const response = await myWixClient.orders.markAsPaid(_id); }; ``` ---