@cloudcommerce/app-loyalty-points 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/functions-lib/cron-add-points.js.map +1 -1
- package/lib/functions-lib/get-program-id.js.map +1 -1
- package/lib/functions-lib/handle-loyalty-points-event.js.map +1 -1
- package/lib/loyalty-create-transaction.js.map +1 -1
- package/lib/loyalty-list-payments.js.map +1 -1
- package/lib/loyalty-points-events.js.map +1 -1
- package/package.json +11 -5
- package/.turbo/turbo-build.log +0 -5
- package/.turbo/turbo-test.log +0 -6
- package/CHANGELOG.md +0 -1
- package/src/functions-lib/cron-add-points.ts +0 -104
- package/src/functions-lib/get-program-id.ts +0 -23
- package/src/functions-lib/handle-loyalty-points-event.ts +0 -249
- package/src/index.ts +0 -1
- package/src/loyalty-create-transaction.ts +0 -249
- package/src/loyalty-list-payments.ts +0 -62
- package/src/loyalty-points-events.ts +0 -52
- package/src/loyalty-points.ts +0 -12
- package/tests/1-list-payments.test.mjs +0 -37
- package/tests/2-create-transaction.test.mjs +0 -41
- package/tsconfig.json +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron-add-points.js","sourceRoot":"","sources":["../../src/functions-lib/cron-add-points.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAGrC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,2CAA2C;IAC3C,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,aAA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;oCACtB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM;oCAC5B,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM;oCAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;iCAC/B,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC;6BAAM,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;4BACxC,MAAM,CAAC,IAAI,CAAC,2BAA2B,OAAO,EAAE,EAAE;gCAChD,UAAU;gCACV,cAAc;gCACd,WAAW;gCACX,MAAM;gCACN,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;6BAC5B,CAAC,CAAC;wBACL,CAAC;6BAAM,CAAC;4BACN,MAAM,GAAG,CAAC;wBACZ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,4CAA4C;QAC5C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-program-id.js","sourceRoot":"","sources":["../../src/functions-lib/get-program-id.ts"],"names":[],"mappings":"AAAA,eAAe,CACb,WAAkD,EAClD,KAAa,EACb,EAAE;IACF,IAAI,SAAS,GAAG,QAAQ,KAAK,EAAE,CAAC;IAChC,IAAI,WAAW,CAAC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"get-program-id.js","sourceRoot":"","sources":["../../src/functions-lib/get-program-id.ts"],"names":[],"mappings":"AAAA,eAAe,CACb,WAAkD,EAClD,KAAa,EACb,EAAE;IACF,IAAI,SAAS,GAAG,QAAQ,KAAK,EAAE,CAAC;IAChC,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;QAC3B,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC;IACrC,CAAC;SAAM,IAAI,WAAW,CAAC,IAAI,IAAI,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpE,SAAS,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;aACjD,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;aACrB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;aACrB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;aAC1B,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-loyalty-points-event.js","sourceRoot":"","sources":["../../src/functions-lib/handle-loyalty-points-event.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,SAAS,GAAG,MAAM,CAAC;AAKzB,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC1C,MAAM,CAAC,GAAG,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,UAA+C,EAAE,OAAmB,EAAE,EAAE;IAChG,IAAI,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"handle-loyalty-points-event.js","sourceRoot":"","sources":["../../src/functions-lib/handle-loyalty-points-event.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,SAAS,GAAG,MAAM,CAAC;AAKzB,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC1C,MAAM,CAAC,GAAG,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,UAA+C,EAAE,OAAmB,EAAE,EAAE;IAChG,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBAC/B,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YACR,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,UAA+C,EAAE,UAA6B,EAAE,EAAE;IACxG,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAA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@
|
|
|
1
|
-
{"version":3,"file":"loyalty-list-payments.js","sourceRoot":"","sources":["../src/loyalty-list-payments.ts"],"names":[],"mappings":"AAKA,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAE1D,eAAe,CAAC,IAAmB,EAAE,EAAE;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAA4B,CAAC;IAEjD,MAAM,OAAO,GAAG;QACd,GAAG,WAAW,CAAC,IAAI;QACnB,GAAG,WAAW,CAAC,WAAW;KAC3B,CAAC;IAEF,0BAA0B;IAC1B,uCAAuC;IACvC,MAAM,QAAQ,GAAyB;QACrC,gBAAgB,EAAE,EAAE;KACrB,CAAC;IAEF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;QACnD,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,gBAAgB,CAAC;IAErB,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC7B,IAAI,EAAE,SAAS;QACf,cAAc,EAAE;YACd,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,KAAK;SACZ;QACD,KAAK;KACN,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"loyalty-list-payments.js","sourceRoot":"","sources":["../src/loyalty-list-payments.ts"],"names":[],"mappings":"AAKA,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAE1D,eAAe,CAAC,IAAmB,EAAE,EAAE;IACrC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAA4B,CAAC;IAEjD,MAAM,OAAO,GAAG;QACd,GAAG,WAAW,CAAC,IAAI;QACnB,GAAG,WAAW,CAAC,WAAW;KAC3B,CAAC;IAEF,0BAA0B;IAC1B,uCAAuC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I,CAAC,YAAY,CAAC,MAAM,CAAC,EACzD,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,kBAAkB,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,aAAa,UAAU,KAAK,MAAM,GAAG,CAAC,CAAC;IAEnD,OAAO,wBAAwB,CAAC,MAAgB,EAAE,YAAY,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,uBAAuB,CACnC,eAAe,EACf,cAAc,CACf;IAED,aAAa,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM;SAC3C,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,YAAY,CAAC;SACtE,KAAK,CAAC,GAAG,EAAE;QACV,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC,CAAC;CACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-loyalty-points",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.0",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce app to handle simple loyalty points programs",
|
|
6
6
|
"main": "lib/loyalty-points.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"/lib",
|
|
9
|
+
"/lib-mjs",
|
|
10
|
+
"/types",
|
|
11
|
+
"/*.{js,mjs,ts}"
|
|
12
|
+
],
|
|
7
13
|
"exports": {
|
|
8
14
|
".": "./lib/loyalty-points.js",
|
|
9
15
|
"./events": "./lib/loyalty-points-events.js"
|
|
@@ -21,12 +27,12 @@
|
|
|
21
27
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/apps/loyalty-points#readme",
|
|
22
28
|
"dependencies": {
|
|
23
29
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
24
|
-
"@cloudcommerce/api": "2.
|
|
25
|
-
"@cloudcommerce/firebase": "2.
|
|
30
|
+
"@cloudcommerce/api": "2.10.0",
|
|
31
|
+
"@cloudcommerce/firebase": "2.10.0"
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
28
|
-
"@cloudcommerce/test-base": "2.
|
|
29
|
-
"@cloudcommerce/types": "2.
|
|
34
|
+
"@cloudcommerce/test-base": "2.10.0",
|
|
35
|
+
"@cloudcommerce/types": "2.10.0"
|
|
30
36
|
},
|
|
31
37
|
"scripts": {
|
|
32
38
|
"build": "bash ../../../scripts/build-lib.sh",
|
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Please refer to GitHub [repository releases](https://github.com/ecomplus/cloud-commerce/releases) or monorepo unified [CHANGELOG.md](https://github.com/ecomplus/cloud-commerce/blob/main/CHANGELOG.md).
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { CustomerSet, Orders } from '@cloudcommerce/types';
|
|
2
|
-
import logger from 'firebase-functions/logger';
|
|
3
|
-
import { getFirestore } from 'firebase-admin/firestore';
|
|
4
|
-
import api from '@cloudcommerce/api';
|
|
5
|
-
import { Endpoint } from '@cloudcommerce/api/types';
|
|
6
|
-
|
|
7
|
-
const addPoints = async () => {
|
|
8
|
-
const d = new Date();
|
|
9
|
-
// double checking paid orders after 5 days
|
|
10
|
-
d.setDate(d.getDate() - 5);
|
|
11
|
-
const db = getFirestore();
|
|
12
|
-
const snapshot = await db.collection('pointsToAdd')
|
|
13
|
-
.where('queuedAt', '<=', d)
|
|
14
|
-
.orderBy('queuedAt')
|
|
15
|
-
.get();
|
|
16
|
-
const { docs } = snapshot;
|
|
17
|
-
logger.info(`${docs.length} points to add`);
|
|
18
|
-
|
|
19
|
-
for (let i = 0; i < docs.length; i++) {
|
|
20
|
-
const { customerId, pointEntries } = docs[i].data();
|
|
21
|
-
const orderId = docs[i].ref.id as string & { length: 24 };
|
|
22
|
-
let order: Orders | undefined;
|
|
23
|
-
try {
|
|
24
|
-
// eslint-disable-next-line no-await-in-loop
|
|
25
|
-
order = (await api.get(`orders/${orderId}`)).data;
|
|
26
|
-
} catch (error: any) {
|
|
27
|
-
const status = error.response?.status;
|
|
28
|
-
if (status > 400 && status < 500) {
|
|
29
|
-
logger.warn(`failed reading order ${orderId}`, {
|
|
30
|
-
status,
|
|
31
|
-
response: error.response?.data,
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (order && Array.isArray(pointEntries) && pointEntries.length) {
|
|
39
|
-
const currentStatus = order.financial_status && order.financial_status.current;
|
|
40
|
-
if (currentStatus === 'paid') {
|
|
41
|
-
const tryAddPoints = (data: CustomerSet) => {
|
|
42
|
-
logger.info(`POST ${JSON.stringify(data)} ${customerId}`);
|
|
43
|
-
return api.post(`customers/${customerId}/loyalty_points_entries`, data);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const pointsEndpoint = `/customers/${customerId}/loyalty_points_entries`;
|
|
47
|
-
|
|
48
|
-
for (let ii = 0; ii < pointEntries.length; ii++) {
|
|
49
|
-
const pointsEntry = pointEntries[ii];
|
|
50
|
-
try {
|
|
51
|
-
// eslint-disable-next-line no-await-in-loop
|
|
52
|
-
await tryAddPoints(pointsEntry);
|
|
53
|
-
} catch (err: any) {
|
|
54
|
-
const status = err.response?.status;
|
|
55
|
-
if (status === 403) {
|
|
56
|
-
// delete older points entry and retry
|
|
57
|
-
|
|
58
|
-
const findUrl = `${pointsEndpoint}`
|
|
59
|
-
+ `?valid_thru<=${(new Date().toISOString())}&sort=active_points&limit=1`;
|
|
60
|
-
try {
|
|
61
|
-
// eslint-disable-next-line no-await-in-loop
|
|
62
|
-
await api.get(findUrl as Endpoint)
|
|
63
|
-
.then(({ data }) => {
|
|
64
|
-
const pointsList = data.result;
|
|
65
|
-
if (pointsList.length) {
|
|
66
|
-
const endpoint = `${pointsEndpoint}/${pointsList[0]._id}`;
|
|
67
|
-
return api.delete(endpoint as Endpoint)
|
|
68
|
-
.then(() => {
|
|
69
|
-
return tryAddPoints(pointsEntry);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
});
|
|
74
|
-
} catch (error: any) {
|
|
75
|
-
logger.warn(`failed cleaning/adding points retry to ${orderId}`, {
|
|
76
|
-
customerId,
|
|
77
|
-
pointsEntry,
|
|
78
|
-
url: error.config?.url,
|
|
79
|
-
method: error.config?.method,
|
|
80
|
-
status: error.response?.status,
|
|
81
|
-
response: error.response?.data,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
} else if (status > 400 && status < 500) {
|
|
85
|
-
logger.warn(`failed adding points to ${orderId}`, {
|
|
86
|
-
customerId,
|
|
87
|
-
pointsEndpoint,
|
|
88
|
-
pointsEntry,
|
|
89
|
-
status,
|
|
90
|
-
response: err.response.data,
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// eslint-disable-next-line no-await-in-loop
|
|
100
|
-
await docs[i].ref.delete();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default addPoints;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default (
|
|
2
|
-
programRule: { program_id: string; name: string; },
|
|
3
|
-
index: number,
|
|
4
|
-
) => {
|
|
5
|
-
let programId = `lpt__${index}`;
|
|
6
|
-
if (programRule.program_id) {
|
|
7
|
-
programId = programRule.program_id;
|
|
8
|
-
} else if (programRule.name && typeof programRule.name === 'string') {
|
|
9
|
-
programId = (`p0_${programRule.name.toLowerCase()}`)
|
|
10
|
-
.replace(/\n\s/g, '_')
|
|
11
|
-
.replace(/__/g, '_')
|
|
12
|
-
.replace(/áàãâ/g, 'a')
|
|
13
|
-
.replace(/éê/g, 'e')
|
|
14
|
-
.replace(/óõô/g, 'o')
|
|
15
|
-
.replace(/í/g, 'e')
|
|
16
|
-
.replace(/ú/g, 'u')
|
|
17
|
-
.replace(/ç/g, 'c')
|
|
18
|
-
.replace(/[^a-z0-9_]/g, '')
|
|
19
|
-
.substring(0, 30);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return programId;
|
|
23
|
-
};
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import type { Orders, Customers, ResourceId } from '@cloudcommerce/types';
|
|
2
|
-
import api from '@cloudcommerce/api';
|
|
3
|
-
import { getFirestore, Timestamp } from 'firebase-admin/firestore';
|
|
4
|
-
import logger from 'firebase-functions/logger';
|
|
5
|
-
import ecomUtils from '@ecomplus/utils';
|
|
6
|
-
import getProgramId from './get-program-id';
|
|
7
|
-
|
|
8
|
-
const ECHO_SUCCESS = 'SUCCESS';
|
|
9
|
-
const ECHO_SKIP = 'SKIP';
|
|
10
|
-
|
|
11
|
-
type UsedPointsEntries = Exclude<Customers['loyalty_points_entries'], undefined>[number]
|
|
12
|
-
& { original_active_points: number }
|
|
13
|
-
|
|
14
|
-
const responsePubSub = (response: string) => {
|
|
15
|
-
logger.log('(App: Loyalty Points): ', response);
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const haveEarnedPoints = (pointsList: Customers['loyalty_points_entries'], orderId: ResourceId) => {
|
|
20
|
-
if (pointsList) {
|
|
21
|
-
let hasEarned = false;
|
|
22
|
-
for (let i = 0; i < pointsList.length; i++) {
|
|
23
|
-
const point = pointsList[i];
|
|
24
|
-
if (point.order_id === orderId) {
|
|
25
|
-
hasEarned = true;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return hasEarned;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const findPointIndex = (pointsList: Customers['loyalty_points_entries'], pointEntry: UsedPointsEntries) => {
|
|
35
|
-
if (pointsList) {
|
|
36
|
-
for (let i = 0; i < pointsList.length; i++) {
|
|
37
|
-
const point = pointsList[i];
|
|
38
|
-
if (point.name === pointEntry.name) {
|
|
39
|
-
return i;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const handleLoyaltyPointsEvent = async (
|
|
47
|
-
order: Orders,
|
|
48
|
-
programRules: any[],
|
|
49
|
-
) => {
|
|
50
|
-
const orderId = order._id;
|
|
51
|
-
const currentStatus = order.financial_status && order.financial_status.current;
|
|
52
|
-
let isPaid: boolean = false;
|
|
53
|
-
let isCancelled: boolean = false;
|
|
54
|
-
|
|
55
|
-
switch (currentStatus) {
|
|
56
|
-
case 'paid':
|
|
57
|
-
isPaid = true;
|
|
58
|
-
break;
|
|
59
|
-
case 'unauthorized':
|
|
60
|
-
case 'partially_refunded':
|
|
61
|
-
case 'refunded':
|
|
62
|
-
case 'voided':
|
|
63
|
-
isCancelled = true;
|
|
64
|
-
break;
|
|
65
|
-
case 'partially_paid':
|
|
66
|
-
if (order.transactions) {
|
|
67
|
-
order.transactions.forEach((transaction) => {
|
|
68
|
-
if (transaction.payment_method.code !== 'loyalty_points' && transaction.status) {
|
|
69
|
-
switch (transaction.status.current) {
|
|
70
|
-
case 'unauthorized':
|
|
71
|
-
case 'refunded':
|
|
72
|
-
case 'voided':
|
|
73
|
-
isCancelled = true;
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
if (isPaid || isCancelled) {
|
|
88
|
-
// get app configured options
|
|
89
|
-
const { amount, buyers } = order;
|
|
90
|
-
const customerId = buyers && buyers[0] && buyers[0]._id;
|
|
91
|
-
if (customerId) {
|
|
92
|
-
const pointsList: Customers['loyalty_points_entries'] = (await api.get(
|
|
93
|
-
`customers/${customerId}/loyalty_points_entries`,
|
|
94
|
-
)
|
|
95
|
-
).data;
|
|
96
|
-
|
|
97
|
-
if (pointsList) {
|
|
98
|
-
const hasEarnedPoints = haveEarnedPoints(pointsList, orderId);
|
|
99
|
-
|
|
100
|
-
if (isPaid && !hasEarnedPoints) {
|
|
101
|
-
const docRef = getFirestore().doc(`pointsToAdd/${orderId}`);
|
|
102
|
-
const docSnapshot = await docRef.get();
|
|
103
|
-
if (!docSnapshot.exists) {
|
|
104
|
-
const pointEntries: any[] = [];
|
|
105
|
-
|
|
106
|
-
for (let i = 0; i < programRules.length; i++) {
|
|
107
|
-
const rule = programRules[i];
|
|
108
|
-
if (rule.earn_percentage === 0) {
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (
|
|
112
|
-
!rule.min_subtotal_to_earn
|
|
113
|
-
|| (amount?.subtotal && rule.min_subtotal_to_earn <= amount.subtotal)
|
|
114
|
-
) {
|
|
115
|
-
let subtotal = amount.subtotal as number;
|
|
116
|
-
|
|
117
|
-
if (Array.isArray(rule.category_ids) && rule.category_ids.length) {
|
|
118
|
-
if (!order.items || !order.items.length) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// eslint-disable-next-line no-await-in-loop
|
|
123
|
-
const { data: { result } } = await api.get('search/v1', {
|
|
124
|
-
limit: order.items.length,
|
|
125
|
-
params: {
|
|
126
|
-
_id: order.items.map((item) => item.product_id),
|
|
127
|
-
'categories._id': rule.category_ids,
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line no-await-in-loop
|
|
132
|
-
order.items.forEach((item) => {
|
|
133
|
-
if (!result.find(({ _id }) => _id === item.product_id)) {
|
|
134
|
-
subtotal -= (ecomUtils.price(item) * item.quantity);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const pointsValue = ((rule.earn_percentage || 1) / 100)
|
|
140
|
-
* (subtotal - (amount.discount || 0));
|
|
141
|
-
|
|
142
|
-
if (pointsValue > 0) {
|
|
143
|
-
let validThru: string | undefined;
|
|
144
|
-
if (rule.expiration_days > 0) {
|
|
145
|
-
const d = new Date();
|
|
146
|
-
d.setDate(d.getDate() + 2 + rule.expiration_days);
|
|
147
|
-
validThru = d.toISOString();
|
|
148
|
-
}
|
|
149
|
-
const data = {
|
|
150
|
-
name: rule.name,
|
|
151
|
-
program_id: getProgramId(rule, i),
|
|
152
|
-
earned_points: pointsValue,
|
|
153
|
-
active_points: pointsValue,
|
|
154
|
-
ratio: rule.ratio || 1,
|
|
155
|
-
order_id: orderId,
|
|
156
|
-
};
|
|
157
|
-
if (validThru) {
|
|
158
|
-
Object.assign(data, { valid_thru: validThru });
|
|
159
|
-
}
|
|
160
|
-
pointEntries.push(data);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
await docRef.set({
|
|
166
|
-
customerId,
|
|
167
|
-
pointEntries,
|
|
168
|
-
queuedAt: Timestamp.now(),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return responsePubSub(ECHO_SUCCESS);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (isCancelled && hasEarnedPoints) {
|
|
176
|
-
for (let i = 0; i < pointsList.length; i++) {
|
|
177
|
-
if (pointsList[i].order_id === orderId) {
|
|
178
|
-
// eslint-disable-next-line no-await-in-loop
|
|
179
|
-
await api.delete(`customers/${customerId}/loyalty_points_entries/${i}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return responsePubSub(ECHO_SUCCESS);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (isCancelled) {
|
|
188
|
-
const documentRef = getFirestore().doc(`billedPoints/${orderId}`);
|
|
189
|
-
const documentSnapshot = await documentRef.get();
|
|
190
|
-
|
|
191
|
-
if (documentSnapshot.exists) {
|
|
192
|
-
const usedPointsEntries = documentSnapshot.get('usedPointsEntries') as UsedPointsEntries[];
|
|
193
|
-
documentRef.delete();
|
|
194
|
-
|
|
195
|
-
if (Array.isArray(usedPointsEntries)) {
|
|
196
|
-
for (let i = 0; i < usedPointsEntries.length; i++) {
|
|
197
|
-
const pointsEntry = usedPointsEntries[i];
|
|
198
|
-
const pointsToRefund = pointsEntry.original_active_points
|
|
199
|
-
- pointsEntry.active_points;
|
|
200
|
-
if (pointsToRefund > 0) {
|
|
201
|
-
const pointIndex = findPointIndex(pointsList, pointsEntry);
|
|
202
|
-
|
|
203
|
-
if (pointIndex && pointsList) {
|
|
204
|
-
const activePoints = pointsList[pointIndex].active_points;
|
|
205
|
-
const body = {
|
|
206
|
-
active_points: activePoints + pointsToRefund,
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// eslint-disable-next-line no-await-in-loop
|
|
210
|
-
await api.patch(
|
|
211
|
-
`customers/${customerId}/loyalty_points_entries/${pointIndex}`,
|
|
212
|
-
body,
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
return responsePubSub(ECHO_SUCCESS);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const transaction = order.transactions
|
|
221
|
-
&& order.transactions.find((transactionFound) => {
|
|
222
|
-
return transactionFound.payment_method.code === 'loyalty_points';
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
if (transaction) {
|
|
226
|
-
const bodyPaymentHistory = {
|
|
227
|
-
transaction_id: transaction._id,
|
|
228
|
-
date_time: new Date().toISOString(),
|
|
229
|
-
status: currentStatus?.startsWith('partially') ? 'refunded' : currentStatus,
|
|
230
|
-
customer_notified: true,
|
|
231
|
-
} as any; // TODO: incompatible type=> amount and status
|
|
232
|
-
|
|
233
|
-
await api.post(`orders/${orderId}/payments_history`, bodyPaymentHistory);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return responsePubSub('');
|
|
240
|
-
}
|
|
241
|
-
// not paid nor cancelled
|
|
242
|
-
return responsePubSub(ECHO_SKIP);
|
|
243
|
-
} catch (err) {
|
|
244
|
-
logger.error('(App Loyalty Points) Error =>', err);
|
|
245
|
-
throw err;
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export default handleLoyaltyPointsEvent;
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './loyalty-points';
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AppModuleBody,
|
|
3
|
-
CreateTransactionParams,
|
|
4
|
-
CreateTransactionResponse,
|
|
5
|
-
Customers,
|
|
6
|
-
ResourceId,
|
|
7
|
-
} from '@cloudcommerce/types';
|
|
8
|
-
import api from '@cloudcommerce/api';
|
|
9
|
-
import { getFirestore } from 'firebase-admin/firestore';
|
|
10
|
-
import logger from 'firebase-functions/logger';
|
|
11
|
-
import getProgramId from './functions-lib/get-program-id';
|
|
12
|
-
|
|
13
|
-
type UsedPointsEntries = Exclude<Customers['loyalty_points_entries'], undefined>[number]
|
|
14
|
-
& { original_active_points: number }
|
|
15
|
-
|
|
16
|
-
const collectionRef = getFirestore().collection('billedPoints');
|
|
17
|
-
|
|
18
|
-
const updateTransactionStatus = (orderId: ResourceId) => {
|
|
19
|
-
setTimeout(async () => {
|
|
20
|
-
const order = (await api.get(`orders/${orderId}`)).data;
|
|
21
|
-
|
|
22
|
-
// appSdk.apiRequest(storeId, `/orders/${orderId}.json`).then(({ response }) => {
|
|
23
|
-
const { transactions } = order;
|
|
24
|
-
if (transactions) {
|
|
25
|
-
const transaction = transactions.find((transactionFound) => {
|
|
26
|
-
return transactionFound.payment_method.code === 'loyalty_points';
|
|
27
|
-
});
|
|
28
|
-
if (transaction) {
|
|
29
|
-
const bodyPaymentHistory = {
|
|
30
|
-
transaction_id: transaction._id,
|
|
31
|
-
date_time: new Date().toISOString(),
|
|
32
|
-
status: 'paid',
|
|
33
|
-
customer_notified: true,
|
|
34
|
-
} as any; // TODO: incompatible type=> amount and status;
|
|
35
|
-
await api.post(`orders/${orderId}/payments_history`, bodyPaymentHistory);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}, 500);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleUpdatedPoints = (
|
|
42
|
-
endpoint: any, // TODO: endpoint type not string compatible
|
|
43
|
-
body: { [x: string]: any },
|
|
44
|
-
orderId: ResourceId,
|
|
45
|
-
usedPointsEntries?: UsedPointsEntries[],
|
|
46
|
-
timeout = 400,
|
|
47
|
-
isLastRequest = false,
|
|
48
|
-
) => {
|
|
49
|
-
setTimeout(async () => {
|
|
50
|
-
await api.patch(endpoint, body);
|
|
51
|
-
// appSdk.apiRequest(storeId, endpoint, 'PATCH', data).then(() => {
|
|
52
|
-
logger.log(`#(App Loyalty Points): ${orderId} ${endpoint} => ${JSON.stringify(body)}`);
|
|
53
|
-
if (isLastRequest) {
|
|
54
|
-
updateTransactionStatus(orderId);
|
|
55
|
-
collectionRef.doc(orderId).set({ usedPointsEntries });
|
|
56
|
-
}
|
|
57
|
-
// });
|
|
58
|
-
}, timeout);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default async (appData: AppModuleBody) => {
|
|
62
|
-
const { application, storeId } = appData;
|
|
63
|
-
const params = appData.params as CreateTransactionParams;
|
|
64
|
-
// app configured options
|
|
65
|
-
const appConfig = { ...application.data, ...application.hidden_data };
|
|
66
|
-
const { lang, amount } = params;
|
|
67
|
-
|
|
68
|
-
// setup required `transaction` response object
|
|
69
|
-
const transaction: CreateTransactionResponse['transaction'] = {
|
|
70
|
-
amount: amount.total,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (params.payment_method.code === 'loyalty_points') {
|
|
74
|
-
const pointsApplied = params.loyalty_points_applied;
|
|
75
|
-
const programsRules = appConfig.programs_rules;
|
|
76
|
-
if (pointsApplied && Array.isArray(programsRules) && programsRules.length) {
|
|
77
|
-
// for (const programId in pointsApplied) {
|
|
78
|
-
Object.keys(pointsApplied).forEach((programId) => {
|
|
79
|
-
let pointsValue = pointsApplied[programId];
|
|
80
|
-
if (pointsValue > 0) {
|
|
81
|
-
const programRule = programsRules.find((programRuleFound, index) => {
|
|
82
|
-
if (programRuleFound) {
|
|
83
|
-
programRuleFound.program_id = getProgramId(programRuleFound, index);
|
|
84
|
-
return programId === programRuleFound.program_id;
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
if (programRule) {
|
|
90
|
-
let maxPoints = programRule.max_points;
|
|
91
|
-
const ratio = programRule.ratio || 1;
|
|
92
|
-
if (!maxPoints && programRule.max_amount_percentage && params.amount) {
|
|
93
|
-
maxPoints = Math.round(
|
|
94
|
-
((programRule.max_amount_percentage * params.amount.total) / 100) / ratio,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
if (maxPoints < pointsValue) {
|
|
98
|
-
pointsValue = maxPoints;
|
|
99
|
-
}
|
|
100
|
-
transaction.loyalty_points = {
|
|
101
|
-
name: programRule.name,
|
|
102
|
-
program_id: programRule.program_id,
|
|
103
|
-
ratio,
|
|
104
|
-
points_value: pointsValue,
|
|
105
|
-
};
|
|
106
|
-
transaction.amount = pointsValue * ratio;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (transaction.amount) {
|
|
114
|
-
const loyaltyPoints = transaction.loyalty_points;
|
|
115
|
-
const customerId = params.buyer.customer_id as ResourceId;
|
|
116
|
-
const orderId = params.order_id as ResourceId;
|
|
117
|
-
const usedPointsEntries: UsedPointsEntries[] = [];
|
|
118
|
-
try {
|
|
119
|
-
const customer = (await api.get(`customers/${customerId}`)).data;
|
|
120
|
-
// return appSdk.apiRequest(storeId, `/customers/${customerId}.json`)
|
|
121
|
-
// .then(({ response }) => {
|
|
122
|
-
const pointsEntries = customer.loyalty_points_entries;
|
|
123
|
-
let pointsToConsume = loyaltyPoints?.points_value;
|
|
124
|
-
|
|
125
|
-
if (pointsEntries && pointsToConsume) {
|
|
126
|
-
pointsEntries.sort((a, b) => {
|
|
127
|
-
let value = 0;
|
|
128
|
-
if (a.valid_thru && b.valid_thru) {
|
|
129
|
-
if (a.valid_thru < b.valid_thru) {
|
|
130
|
-
value = -1;
|
|
131
|
-
} else if (a.valid_thru > b.valid_thru) {
|
|
132
|
-
value = 1;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return value;
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
for (let i = 0; i < pointsEntries.length; i++) {
|
|
139
|
-
if (pointsToConsume <= 0) {
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
const pointsEntry = pointsEntries[i];
|
|
143
|
-
if (pointsEntry.program_id === loyaltyPoints?.program_id) {
|
|
144
|
-
const validThru = pointsEntry.valid_thru;
|
|
145
|
-
const activePoints = pointsEntry.active_points;
|
|
146
|
-
if (activePoints > 0 && (!validThru || new Date(validThru).getTime() >= Date.now())) {
|
|
147
|
-
const pointsDiff = activePoints - pointsToConsume;
|
|
148
|
-
if (pointsDiff > 0 && pointsDiff < 0.01) {
|
|
149
|
-
pointsToConsume = activePoints;
|
|
150
|
-
}
|
|
151
|
-
if (pointsToConsume >= activePoints) {
|
|
152
|
-
pointsToConsume -= activePoints;
|
|
153
|
-
pointsEntry.active_points = 0;
|
|
154
|
-
if (pointsToConsume < 0.02) {
|
|
155
|
-
pointsToConsume = 0;
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
pointsEntry.active_points -= pointsToConsume;
|
|
159
|
-
pointsToConsume = 0;
|
|
160
|
-
}
|
|
161
|
-
usedPointsEntries.push({
|
|
162
|
-
...pointsEntry,
|
|
163
|
-
original_active_points: activePoints,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (pointsToConsume <= 0) {
|
|
170
|
-
if (usedPointsEntries.length <= 3) {
|
|
171
|
-
usedPointsEntries.forEach((pointsEntry, i) => {
|
|
172
|
-
/* Obs:
|
|
173
|
-
Store api v2 => loyalty_points_entries do not have id,
|
|
174
|
-
but change can be done by index
|
|
175
|
-
*/
|
|
176
|
-
const endpoint = `customers/${customerId}/loyalty_points_entries/${i}`;
|
|
177
|
-
const body = {
|
|
178
|
-
active_points: pointsEntry.active_points,
|
|
179
|
-
};
|
|
180
|
-
handleUpdatedPoints(
|
|
181
|
-
endpoint,
|
|
182
|
-
body,
|
|
183
|
-
orderId,
|
|
184
|
-
usedPointsEntries,
|
|
185
|
-
(i + 1) * 400,
|
|
186
|
-
i + 1 === usedPointsEntries.length,
|
|
187
|
-
);
|
|
188
|
-
});
|
|
189
|
-
} else {
|
|
190
|
-
const endpoint = `customers/${customerId}`;
|
|
191
|
-
const body = {
|
|
192
|
-
loyalty_points_entries: pointsEntries,
|
|
193
|
-
};
|
|
194
|
-
handleUpdatedPoints(endpoint, body, orderId, usedPointsEntries, 400, true);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
transaction.status = {
|
|
200
|
-
current: pointsToConsume && pointsToConsume <= 0 ? 'authorized' : 'unauthorized',
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
status: 200,
|
|
205
|
-
redirect_to_payment: false,
|
|
206
|
-
transaction,
|
|
207
|
-
};
|
|
208
|
-
} catch (error: any) {
|
|
209
|
-
// try to debug request error
|
|
210
|
-
const errCode = 'POINTS_TRANSACTION_ERR';
|
|
211
|
-
let { message } = error;
|
|
212
|
-
const err = {
|
|
213
|
-
message: `CREATE_TRANSACTION_ERR #${storeId} - ${orderId} => ${message}`,
|
|
214
|
-
payment: '',
|
|
215
|
-
status: 0,
|
|
216
|
-
response: '',
|
|
217
|
-
usedPointsEntries,
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
if (error.response) {
|
|
221
|
-
const { status, data } = error.response;
|
|
222
|
-
err.status = status;
|
|
223
|
-
if (status !== 401 && status !== 403) {
|
|
224
|
-
if (typeof data === 'object' && data) {
|
|
225
|
-
err.response = JSON.stringify(data);
|
|
226
|
-
} else {
|
|
227
|
-
err.response = data;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (data && data.user_message) {
|
|
231
|
-
message = lang ? data.user_message[lang] : data.user_message.en_us;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
logger.error(err);
|
|
236
|
-
|
|
237
|
-
return {
|
|
238
|
-
error: errCode,
|
|
239
|
-
message,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return {
|
|
245
|
-
status: 200,
|
|
246
|
-
redirect_to_payment: false,
|
|
247
|
-
transaction,
|
|
248
|
-
};
|
|
249
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AppModuleBody,
|
|
3
|
-
ListPaymentsResponse,
|
|
4
|
-
ListPaymentsParams,
|
|
5
|
-
} from '@cloudcommerce/types';
|
|
6
|
-
import getProgramId from './functions-lib/get-program-id';
|
|
7
|
-
|
|
8
|
-
export default (data: AppModuleBody) => {
|
|
9
|
-
const { application } = data;
|
|
10
|
-
const params = data.params as ListPaymentsParams;
|
|
11
|
-
|
|
12
|
-
const appData = {
|
|
13
|
-
...application.data,
|
|
14
|
-
...application.hidden_data,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// const { storeId } = req
|
|
18
|
-
// setup basic required response object
|
|
19
|
-
const response: ListPaymentsResponse = {
|
|
20
|
-
payment_gateways: [],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const label = params.lang === 'pt_br' || !params.lang
|
|
24
|
-
? 'Pontos de fidelidade'
|
|
25
|
-
: 'Loyalty points';
|
|
26
|
-
|
|
27
|
-
response.payment_gateways.push({
|
|
28
|
-
type: 'payment',
|
|
29
|
-
payment_method: {
|
|
30
|
-
code: 'loyalty_points',
|
|
31
|
-
name: label,
|
|
32
|
-
},
|
|
33
|
-
label,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (Array.isArray(appData.programs_rules)) {
|
|
37
|
-
const pointsPrograms = {};
|
|
38
|
-
appData.programs_rules.forEach((programRule, index) => {
|
|
39
|
-
let maxPoints = programRule.max_points;
|
|
40
|
-
const ratio = programRule.ratio || 1;
|
|
41
|
-
if (!maxPoints && programRule.max_amount_percentage && params.amount) {
|
|
42
|
-
maxPoints = Math.round(
|
|
43
|
-
((programRule.max_amount_percentage * params.amount.total) / 100) / ratio,
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
const programId = getProgramId(programRule, index);
|
|
47
|
-
pointsPrograms[programId] = {
|
|
48
|
-
name: programRule.name,
|
|
49
|
-
ratio,
|
|
50
|
-
max_points: maxPoints,
|
|
51
|
-
min_subtotal_to_earn: programRule.min_subtotal_to_earn,
|
|
52
|
-
earn_percentage: programRule.earn_percentage,
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (Object.keys(pointsPrograms).length) {
|
|
57
|
-
response.loyalty_points_programs = pointsPrograms;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return response;
|
|
62
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
import '@cloudcommerce/firebase/lib/init';
|
|
3
|
-
import type { Orders } from '@cloudcommerce/types';
|
|
4
|
-
import {
|
|
5
|
-
createAppEventsFunction,
|
|
6
|
-
ApiEventHandler,
|
|
7
|
-
} from '@cloudcommerce/firebase/lib/helpers/pubsub';
|
|
8
|
-
import logger from 'firebase-functions/logger';
|
|
9
|
-
import config from '@cloudcommerce/firebase/lib/config';
|
|
10
|
-
import functions from 'firebase-functions/v1';
|
|
11
|
-
import handleLoyaltyPointsEvent from './functions-lib/handle-loyalty-points-event';
|
|
12
|
-
import addPoints from './functions-lib/cron-add-points';
|
|
13
|
-
|
|
14
|
-
const { httpsFunctionOptions: { region } } = config.get();
|
|
15
|
-
|
|
16
|
-
const handleApiEvent: ApiEventHandler = async ({
|
|
17
|
-
evName,
|
|
18
|
-
apiEvent,
|
|
19
|
-
apiDoc,
|
|
20
|
-
app,
|
|
21
|
-
}) => {
|
|
22
|
-
const resourceId = apiEvent.resource_id;
|
|
23
|
-
logger.info('>> ', resourceId, ' - Action: ', apiEvent.action);
|
|
24
|
-
const key = `${evName}_${resourceId}`;
|
|
25
|
-
const appData = { ...app.data, ...app.hidden_data };
|
|
26
|
-
const programRules = appData.programs_rules;
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
(Array.isArray(appData.ignore_events)
|
|
30
|
-
&& appData.ignore_events.includes(evName))
|
|
31
|
-
|| (!Array.isArray(programRules) || !programRules.length)
|
|
32
|
-
) {
|
|
33
|
-
logger.info('>> ', key, ' - Ignored event');
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
logger.info(`> Webhook ${resourceId} [${evName}]`);
|
|
37
|
-
|
|
38
|
-
return handleLoyaltyPointsEvent(apiDoc as Orders, programRules);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const loyaltypoints = {
|
|
42
|
-
onStoreEvent: createAppEventsFunction(
|
|
43
|
-
'loyaltyPoints',
|
|
44
|
-
handleApiEvent,
|
|
45
|
-
),
|
|
46
|
-
|
|
47
|
-
cronAddPoints: functions.region(region).pubsub
|
|
48
|
-
.schedule(process.env.CRONTAB_LOYALTYPOINTS_ADD_POINTS || '28 * * * *')
|
|
49
|
-
.onRun(() => {
|
|
50
|
-
return addPoints();
|
|
51
|
-
}),
|
|
52
|
-
};
|
package/src/loyalty-points.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '@cloudcommerce/firebase/lib/init';
|
|
2
|
-
import type { AppModuleBody } from '@cloudcommerce/types';
|
|
3
|
-
import handleListPayments from './loyalty-list-payments';
|
|
4
|
-
import handleCreateTransaction from './loyalty-create-transaction';
|
|
5
|
-
|
|
6
|
-
export const listPayments = async (modBody: AppModuleBody) => {
|
|
7
|
-
return handleListPayments(modBody);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const createTransaction = async (modBody: AppModuleBody) => {
|
|
11
|
-
return handleCreateTransaction(modBody);
|
|
12
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import test, { before, describe } from 'node:test';
|
|
4
|
-
import {
|
|
5
|
-
modulesUrl,
|
|
6
|
-
bodyListPayments,
|
|
7
|
-
} from '@cloudcommerce/test-base';
|
|
8
|
-
|
|
9
|
-
describe('Test payment list of Loyalty Points App', async () => {
|
|
10
|
-
let req;
|
|
11
|
-
let data;
|
|
12
|
-
const appId = 124890;
|
|
13
|
-
|
|
14
|
-
before(async () => {
|
|
15
|
-
req = await fetch(`${modulesUrl}/list_payments?app_id=${appId}`, {
|
|
16
|
-
method: 'POST',
|
|
17
|
-
body: JSON.stringify(bodyListPayments),
|
|
18
|
-
headers: {
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
data = (await req.json()).result;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('Check Status 200', async () => {
|
|
27
|
-
assert.strictEqual(req?.status, 200);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('Check validated is true', async () => {
|
|
31
|
-
assert.equal(data[0].validated, true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('Have payment gateways', async () => {
|
|
35
|
-
assert.notEqual(data[0].response.payment_gateways.length, 0);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import test, { before, describe } from 'node:test';
|
|
4
|
-
import {
|
|
5
|
-
modulesUrl,
|
|
6
|
-
bodyCreateTransaction,
|
|
7
|
-
} from '@cloudcommerce/test-base';
|
|
8
|
-
|
|
9
|
-
describe('Test to create a transaction in the loyalty points app', async () => {
|
|
10
|
-
let req;
|
|
11
|
-
let data;
|
|
12
|
-
const appId = 124890;
|
|
13
|
-
before(async () => {
|
|
14
|
-
const paymentMethod = {
|
|
15
|
-
code: 'loyalty_points',
|
|
16
|
-
};
|
|
17
|
-
bodyCreateTransaction.payment_method = paymentMethod;
|
|
18
|
-
|
|
19
|
-
req = await fetch(`${modulesUrl}/create_transaction?app_id=${appId}`, {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
body: JSON.stringify(bodyCreateTransaction),
|
|
22
|
-
headers: {
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
data = (await req.json()).result;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('Check Status 200', async () => {
|
|
31
|
-
assert.strictEqual(req?.status, 200);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('Check validated is true', async () => {
|
|
35
|
-
assert.equal(data[0].validated, true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('Have transaction', async () => {
|
|
39
|
-
assert.notEqual(data[0].response.transaction, undefined);
|
|
40
|
-
});
|
|
41
|
-
});
|