This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates an order for a buyer who purchased the plan with an offline transaction.
The createOfflineOrder()
function returns a Promise that resolves to an order
object when the order has been created.
Payment of an offline order is handled in 1 of 2 ways.
true
in the paid
request parameter.markAsPaid()
function.When creating a non-free offline order:
"PENDING"
if the start date is in the future. Otherwise, the status is set to "ACTIVE"
.
The order's last payment status is set to "UNPAID"
or "PAID"
.When creating a free offline order:
"PENDING"
if the start date is in the future. Otherwise, the status is set to "ACTIVE"
."NOT_APPLICABLE"
.This function requires elevated permissions and runs only on the backend and on dashboard pages.
function createOfflineOrder(
planId: string,
memberId: string,
options: CreateOfflineOrderOptions,
): Promise<CreateOfflineOrderResponse>;
ID of the plan being ordered. See Plans for more information about plan IDs
ID of the member ordering the plan.
Options for creating an offline order.
import { orders } from "wix-pricing-plans.v2";
/* 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"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.