Development discussions around Shopify APIs
Hi all!
I'm using a Node.js server to make requests to Shopify. Specifically, I'm using the advertised third party library for node (https://github.com/MONEI/Shopify-api-node)
After running through the OAuth flow, I have an "initialize Shopify function". It appears as below:
const initializeShopifyIntegration = async (
database: Database,
shopName: string,
accessToken: string,
brandId: number,
): Promise<void> => {
const shopify = new ShopifyAPI(shopName, accessToken);
// init webhooks
await shopify.createWebhook(SHOPIFY_UNINSTALL_TOPIC, brandId);
await shopify.createWebhook(SHOPIFY_CREATE_ORDER_TOPIC, brandId);
await shopify.createWebhook(SHOPIFY_ORDER_CANCEL_TOPIC, brandId);
await shopify.createWebhook(SHOPIFY_ORDER_DELETE_TOPIC, brandId);
await shopify.createWebhook(SHOPIFY_REFUNDS_TOPIC, brandId);
await shopify.pullAndIngestOrders(database, brandId);
await shopify.addScriptSnippet();
// const couponCodeHandler = new CouponCodeHandler(database);
// await couponCodeHandler.setUpOrChangeCouponCodeForBrand(brandId, null);
// await couponCodeHandler.createCouponCodesForAllExistingAffiliates(brandId);
Logger.debug('successfully run init');
return;
};
async createPriceRule(amount: number): Promise<Shopify.IPriceRule> {
const currentDate = new Date();
return await this.shopifyWrapper.priceRule.create({
value: amount,
value_type: 'percentage',
usage_limit: null,
title: PRICE_RULE_NAME,
target_type: 'line_item',
target_selection: 'all',
starts_at: currentDate.toString(),
once_per_customer: false,
customer_selection: 'all',
allocation_method: 'across',
});
}
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By