@henrylabs-interview/payment-processor 0.2.14 → 0.2.16

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.
@@ -387,19 +387,19 @@ export class Checkout {
387
387
  immediateWeight -= sameRecords * 10;
388
388
  deferredWeight += sameRecords * 5;
389
389
  retryWeight += sameRecords * 5;
390
- fraudWeight += sameRecords * 5;
390
+ fraudWeight += sameRecords * 15;
391
391
  // --- Adjust based on amount ---
392
392
  if (amount > 1000) {
393
- deferredWeight += sameRecords * 5;
394
- retryWeight += sameRecords * 5;
393
+ deferredWeight += sameRecords * 5 + 10;
394
+ retryWeight += sameRecords * 5 + 10;
395
395
  }
396
396
  if (amount > 5000) {
397
- immediateWeight -= sameRecords * 5;
398
- retryWeight += sameRecords * 5;
399
- fraudWeight += sameRecords * 5;
397
+ immediateWeight -= sameRecords * 5 + 15;
398
+ retryWeight += sameRecords * 5 + 30;
399
+ fraudWeight += sameRecords * 10;
400
400
  }
401
401
  if (amount > 10000) {
402
- fraudWeight += sameRecords * 5;
402
+ fraudWeight += sameRecords * 30;
403
403
  }
404
404
  // Ensure no negative weights
405
405
  immediateWeight = Math.max(0, immediateWeight);
@@ -29,27 +29,12 @@ export async function readHistory() {
29
29
  export async function writeHistory(params) {
30
30
  const history = await readHistory();
31
31
  const now = Date.now();
32
- const existingIndex = history.findIndex((v) => v.id === params.id);
33
- let record;
34
- if (existingIndex !== -1) {
35
- // Replace existing record
36
- record = {
37
- ...history[existingIndex],
38
- ...params,
39
- createdAt: history[existingIndex]?.createdAt ?? now,
40
- updatedAt: now,
41
- };
42
- history[existingIndex] = record;
43
- }
44
- else {
45
- // Add new record
46
- record = {
47
- ...params,
48
- createdAt: now,
49
- updatedAt: now,
50
- };
51
- history.push(record);
52
- }
32
+ const record = {
33
+ ...params,
34
+ createdAt: now,
35
+ updatedAt: now,
36
+ };
37
+ history.push(record);
53
38
  await Bun.write(path, JSON.stringify(history, null, 2));
54
39
  return record;
55
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henrylabs-interview/payment-processor",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",