I want to create a custom automation that converts the buyer of one special product into a member of my website.
Up to now I have created a custom automation flow triggered by "order submitted" then checks the SKU of the order and in case this SKU matches the SKU of the special product I want the contact (given by the payload) into a member. But I can't get the createMember function working - Any ideas/help appreciated Error message: Contact must have a name, phone number or email address. details:
import { members } from "wix-members.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
const elevatedCreateMember = elevate(members.createMember);
console.log("Create Member started");
export const invoke =
async({payload})=> {
const smember = {
loginEmail: payload.contact.email
}
console.log(smember.loginEmail);
try {
const newMember = await elevatedCreateMember(payload.contact);
console.log("Created new member:", newMember);
return {};
} catch (error) {
console.error(error);
console.log("contact: ",payload.contact);
// Handle the error
}
}