【发布时间】:2018-09-19 06:09:48
【问题描述】:
我正在使用 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('/');
}
【问题讨论】:
标签: node.js api shopify shopify-app