我正在使用MONEI/Shopify-api-node在Shopify中创建应用。我已经完成了创建客户Shopify-api-node/test/customer.test.js的测试用例,我只想使用格式参数来创建客户。当用户使用电子邮件和联系方式进行注册时,我希望在我的商店管理员中使用电子邮件和联系方式来创建客户。只想要Format of params for webhook.create
这样的格式参数如果有人曾经创建过客户,请在此处放置所需的参数。 另外,请检查我的代码是否是创建客户的正确方法。
const createCustomer = function(shopDomain, accessToken, customer) {
const shopName=shopDomain.replace('.myshopify.com','');
const shopify = new ShopifyAPIClient({ shopName: shopName, accessToken: accessToken });
shopify.customer.create(customer).then(
response => console.log(`customer ${customer.url} created`),
err => console.log(`Error creating customer ${customer.url} ${JSON.stringify(err.response.body)}`)
);
}
函数调用
afterAuth(request, response) {
const { session: { accessToken, shop } } = request;
createCustomer(shop,accessToken,{
topic: 'admin/customers',
address: `${SHOPIFY_APP_HOST}/admin/customers`,
});
return response.redirect('/');
}