Skip to content

Commit

Permalink
create discount code webhook + yarn server
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ban committed Sep 8, 2022
1 parent 3b0f99c commit b7b7783
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"main": "index.js",
"license": "MIT",
"type": "module",
"scripts": {
"server": "node server"
},
"dependencies": {
"dotenv": "^16.0.2",
"node-fetch": "^3.2.10"
Expand Down
3 changes: 1 addition & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ http.createServer(async (req, res) => {
res.end('OK');
if (body != undefined && body.length > 0) {
const discount = JSON.parse(body);
const prefix = config.PREFIX;
createDiscountCode(prefix, name, cartDiscountId);
createDiscountCode("SHEERID-", discount.name, cartDiscountId);
}
});
} else if (req.url === '/webhook' && req.method === 'POST') {
Expand Down
2 changes: 1 addition & 1 deletion src/discount.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ const createDiscountCode = (prefix, name, cartDiscountId) => {
})
}

export { getCartDiscount, getCartDiscounts, createCartDiscount };
export { getCartDiscount, getCartDiscounts, createCartDiscount, createDiscountCode };

0 comments on commit b7b7783

Please sign in to comment.