我正在使用MONEI/Shopify-api-node在Shopify中创建应用程序。我已经完成了创建客户Shopify-api-node/test/customer.test.jsI的测试用例,只想要格式参数创建客户。当用户注册电子邮件和联系电话时,我希望客户在我的商店管理员处使用电子邮件和号码创建。我只想要格式化参数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('/');
}