markAsPaid( )
Marks an offline pricing plan order as paid.
Description
The markAsPaid()
function returns a Promise that resolves when the offline order is successfully marked as paid.
The entire order is marked as paid, even if the order's payments are recurring.
Note: Marking separate payment cycles as paid is not yet supported. 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'sstartDate
.
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
markAsPaid()
function is supported for offline orders only.
The onOrderMarkedAsPaid()
and onOrderUpdated()
event handlers run when an offline order is marked as paid.
Note: Only site visitors with the Manage Pricing Plans and Manage Subscriptions permissions can mark offline orders as paid. You can override the permissions by setting the function's
suppressAuth
option totrue
.
Syntax
function markAsPaid(orderId: string, [options: Options]): Promise<void>
markAsPaid Parameters
NAME
TYPE
DESCRIPTION
ID of the order being marked as paid.
Options to use when marking an order as paid.
Returns
Fulfilled - When the order is marked as paid.
Return Type:
Related Content:
Was this helpful?
1import { orders } from 'wix-pricing-plans-backend';23// Sample orderId value: '19b28b41-1ef2-42dc-afaa-9dc1854d0191'45export async function myMarkAsPaidFunction(orderId) {6 try {7 const order = await orders.markAsPaid(orderId);89 return order;10 } catch (error) {11 console.error(error);12 }13}1415// Returns a promise that resolves to void
1import { orders } from 'wix-pricing-plans-backend';23/* Sample orderId value: '895fd8d9-f732-444f-a82b-19f7e55e9617'4 *5 * Sample options object:6 * {7 * suppressAuth : true8 * }9 */1011export async function myMarkAsPaidWithOptionsFunction(orderId, options) {12 try {13 const order = await orders.markAsPaid(orderId, options);1415 return order;16 } catch (error) {17 console.error(error);18 }19}2021// Returns a promise that resolves to void