@ns8/ns8-shopify-switches
Advanced tools
Comparing version 1.0.156 to 1.0.157
@@ -166,20 +166,22 @@ "use strict"; | ||
exports.getClientDetails = getClientDetails; | ||
const shouldOrderBeProcessed = (transaction) => { | ||
const { kind, payment_details, status, source_name, } = transaction; | ||
let shouldProcessOrder = false; | ||
if (!payment_details && kind !== 'void' && kind !== 'refund' && (status === 'pending' || status === 'success')) { | ||
shouldProcessOrder = true; | ||
} | ||
if (payment_details && status === 'success' && (kind === 'sale' || kind === 'authorization')) { | ||
shouldProcessOrder = true; | ||
} | ||
if (source_name === 'pos') { | ||
shouldProcessOrder = false; | ||
} | ||
return shouldProcessOrder; | ||
}; | ||
exports.shouldOrderBeProcessed = shouldOrderBeProcessed; | ||
class ShopifyCreateOrderActionSwitch { | ||
async create(switchContext) { | ||
const { order_id, kind, payment_details, status, source_name, } = switchContext.data; | ||
const { order_id } = switchContext.data; | ||
console.log(switchContext.merchant.domain, order_id); | ||
let shouldProcessOrder = false; | ||
if (!payment_details && (status === 'pending' || status === 'success')) { | ||
shouldProcessOrder = true; | ||
} | ||
if (payment_details && status === 'success' && kind === 'authorization') { | ||
shouldProcessOrder = true; | ||
} | ||
if (payment_details && status === 'success' && kind === 'sale') { | ||
shouldProcessOrder = true; | ||
} | ||
if (source_name === 'pos') { | ||
shouldProcessOrder = false; | ||
} | ||
if (shouldProcessOrder) { | ||
if (shouldOrderBeProcessed(switchContext.data)) { | ||
const client = getShopifyClient_1.default(switchContext); | ||
@@ -186,0 +188,0 @@ const shopifyOrder = await client.order.get(order_id); |
{ | ||
"name": "@ns8/ns8-shopify-switches", | ||
"version": "1.0.156", | ||
"version": "1.0.157", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76830
911