Skip to content

Commit 30535e1

Browse files
author
Gerald Baulig
committedFeb 28, 2025·
fix(submit): surpress fulfillment double response
1 parent b3c64b0 commit 30535e1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed
 

‎cfg/config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,15 @@
392392
},
393393
"errors": {
394394
"INVALID_CREDENTIALS": {
395-
"code": "401",
395+
"code": 401,
396396
"message": "Invalid credentials"
397397
},
398398
"USER_NOT_LOGGED_IN": {
399-
"code": "401",
399+
"code": 401,
400400
"message": "Invalid authentication context, please log in first"
401401
},
402402
"ACTION_NOT_ALLOWED": {
403-
"code": "403",
403+
"code": 403,
404404
"message": "Action not allowed on this resource"
405405
}
406406
},

‎src/service.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,6 @@ export class OrderingService
15121512
try {
15131513
if (this.fulfillment_service) {
15141514
this.logger?.debug('Evaluate fulfillment on submit...');
1515-
response.fulfillments = [];
15161515
const fulfillment_map: Record<string, FulfillmentResponse> = {};
15171516
await this._evaluateFulfillment(
15181517
{
@@ -1534,13 +1533,12 @@ export class OrderingService
15341533
r => {
15351534
r.items?.forEach(
15361535
fulfillment => {
1537-
const id = fulfillment.payload?.references?.[0]?.instance_id
1538-
?? fulfillment.status?.id;
1536+
const id = fulfillment.payload?.references?.[0]?.instance_id;
15391537
const order = response_map[id];
15401538
if (order && fulfillment.status?.code !== 200) {
15411539
order.status = fulfillment.status;
15421540
}
1543-
fulfillment_map[id] =fulfillment;
1541+
fulfillment_map[id] = fulfillment;
15441542
}
15451543
);
15461544

@@ -1559,7 +1557,7 @@ export class OrderingService
15591557
throw error;
15601558
}
15611559
).finally(
1562-
() => response.fulfillments.push(...Object.values(fulfillment_map))
1560+
() => response.fulfillments = Object.values(fulfillment_map)
15631561
);
15641562

15651563
this.logger?.debug('Create fulfillment on submit...');
@@ -1583,7 +1581,7 @@ export class OrderingService
15831581
r => {
15841582
r.items?.forEach(
15851583
fulfillment => {
1586-
const id = fulfillment.payload?.references?.[0]?.instance_id ?? fulfillment.status?.id;
1584+
const id = fulfillment.payload?.references?.[0]?.instance_id;
15871585
const order = response_map[id];
15881586
if (order && fulfillment.status?.code !== 200) {
15891587
order.status = fulfillment.status;
@@ -1608,7 +1606,7 @@ export class OrderingService
16081606
throw error;
16091607
}
16101608
).finally(
1611-
() => response.fulfillments.push(...Object.values(fulfillment_map))
1609+
() => response.fulfillments = Object.values(fulfillment_map)
16121610
);
16131611
}
16141612

0 commit comments

Comments
 (0)
Please sign in to comment.