There’s an error in the Velo API that needs to be fixed…no idea where else to post this but the reason I found it just now was that others on this forum have found it before. Wix should have a place to submit documentation errors more easily.
PLEASE CAN SOMEONE CORRECT THE API…IT’S COST ME HOURS OF TIME TODAY TRYING TO FIGURE OUT AND I AM CLEARLY NOT THE FIRST PERSON TO DO SO.
The API calls out wixPricingPlans_onPlanPurchased(event) as the event that can be run in events.js after a plan is purchased. The correct event name is actually wixPaidPlans_onPlanPurchased, though…which is not detailed anywhere in the documentation but the event variable structure is EXACTLY the same as below.
Here’s the sample code from the API:
import wixData from "wix-data";
export function wixPricingPlans_onPlanPurchased(event) {
// Insert a title reflecting the type of transaction, and
// the event's order object (json) into
// the collection's data field.
if (event.order.price.amount === 0) {
let orderData = {
title: "Free plan purchased",
data: event.order,
};
wixData.insert("planEvents", orderData);
} else {
let orderData = {
title: "Regular plan purchased",
data: event.order,
};
wixData.insert("planEvents", orderData);
}
}
/* Event object for a free, one-month purchase, ordered using Thailand baht currency:
*
* When the purchase is free, the `wixPayOrderId` is blank,
* the `price.amount` is 0, and the paymentStatus is marked `PAID`.
*
* {
* "order":{
* "paymentStatus":"PAID",
* "validUntil":"2019-09-12T05:43:53.246Z",
* "price":{
* "currency":"THB",
* "amount":0
* },
* "validFrom":"2019-08-12T05:43:53.246Z",
* "planName":"valid 1 week",
* "wixPayOrderId":"",
* "recurring":false,
* "id":"b8401bab-8e5d-4bf6-944b-b2d56698d4c9",
* "dateCreated":"2019-08-12T05:43:53.246Z",
* "status":"ACTIVE",
* "roleId":"",
* "planDescription":"Platinum Plan",
* "memberId":"42d90dcb-b9ad-47be-9a36-488be3dec679",
* "orderType":"ONLINE",
* "planId":"a52f41cc-8129-4812-9e1c-fafa2807a25d",
* "validFor":{
* "forever":false,
* "period":{
* "amount":1,
* "unit":"MONTH"
* }
* }
* }
* }
*
*
* Event object for a purchase that is valid until the user cancels:
*
* When the purchase is valid until the user cancels, `validFor.forever` is true, and
* `validFor.forever.period.amount` is 0.
*
* {
* "order":{
* "paymentStatus":"PAID",
* "validUntil":"2019-09-12T05:43:53.246Z",
* "price":{
* "currency":"USD",
* "amount":0
* },
* "cancellationReason":"CANCELLATION_REASON_UNDEFINED",
* "validFrom":"2019-08-12T05:43:53.246Z",
* "planName":"valid 1 week",
* "wixPayOrderId":"a52f41cc-8129-4812-9e1c-fafa2807a25d",
* "recurring":false,
* "id":"b8401bab-8e5d-4bf6-944b-b2d56698d4c9",
* "dateCreated":"2019-08-12T05:43:53.246Z",
* "status":"ACTIVE",
* "roleId":"",
* "planDescription":"Gold Plan",
* "memberId":"42d90dcb-b9ad-47be-9a36-488be3dec679",
* "orderType":"ONLINE",
* "planId":"a52f41cc-8129-4812-9e1c-fafa2807a25d",
* "validFor":{
* "forever":true,
* "period":{
* "amount":0,
* "unit":"MONTH"
* }
* }
* }
* }
*
*/