@ns8/ns8-shopify-switches
Advanced tools
Comparing version 1.0.24 to 1.0.25
@@ -80,14 +80,14 @@ "use strict"; | ||
} | ||
const { account: { platform: { url: shopName, credentials, }, }, } = switchContext.authorization; | ||
const { value: accessToken } = credentials | ||
.find((item) => item.type === 'SHOPIFY_ACCESS_TOKEN'); | ||
const { name: shopName, id: shopId } = switchContext.merchant.shops[0]; | ||
const { token: accessToken } = switchContext.merchant.serviceIntegrations | ||
.find((item) => item.type === 'SHOPIFY'); | ||
const client = new Shopify({ shopName, accessToken }); | ||
const shopifyOrder = await client.order.get(order_id); | ||
const shopifyTransactionList = await client.transaction.list(order_id); | ||
const { app_id, id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], order_status_url, } = shopifyOrder; | ||
const { id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], } = shopifyOrder; | ||
return new ns8_protect_models_1.Order({ | ||
name, | ||
currency, | ||
shopId, | ||
platformOrderId: id.toString(), | ||
shopId: app_id.toString(), | ||
addresses: [ | ||
@@ -98,3 +98,2 @@ mapAddress(billing_address, 'BILLING'), | ||
customer: mapCustomer(customer), | ||
status: order_status_url, | ||
totalPrice: parseFloat(total_price), | ||
@@ -101,0 +100,0 @@ transactions: mapTransactions(shopifyTransactionList), |
@@ -7,3 +7,3 @@ "use strict"; | ||
this.onInstall = async (data) => { | ||
const { trackingScriptUrl: src, platformData: { shopName, accessToken, }, } = data; | ||
const { trackingScriptUrl: src, platformData: { shopName, accessToken, }, webhooks: { createOrder: createOrderEndpoint, updateShop: updateShopEndpoint = 'https://matt-local-api.ngrok.io/protect/executor?action=UPDATE_SHOP', }, } = data; | ||
const client = new Shopify({ shopName, accessToken }); | ||
@@ -29,7 +29,7 @@ const webhookList = await client.webhook.list(); | ||
topic: 'order_transactions/create', | ||
address: data.webhooks.createOrder, | ||
address: createOrderEndpoint, | ||
}); | ||
const shopUpdate = await client.webhook.create({ | ||
topic: 'shop/update', | ||
address: data.webhooks.updateShop, | ||
address: updateShopEndpoint, | ||
}); | ||
@@ -36,0 +36,0 @@ return { |
{ | ||
"name": "@ns8/ns8-shopify-switches", | ||
"version": "1.0.24", | ||
"version": "1.0.25", | ||
"description": "Custom switches for the shopify integration", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14582
183