fix(medusa-payment-stripe): Catch on idempotency key retrieve if not found (#4025)
**What** In case the idempotency key is not found, an error will be thrown. We actually want to catch this error and create the key if it does not exists
This commit is contained in:
1 parent
ff37cd190f
commit
cff54d7325
3 files changed
+14
-6
No files matched your search
@@ -35,8 +35,8 @@ container.register(
|
||||
withTransaction: function () {
|
||||
return this
|
||||
},
|
||||
retrieve: jest.fn().mockReturnValue(undefined),
|
||||
create: jest.fn().mockReturnValue({}),
|
||||
retrieve: jest.fn().mockImplementation(async () => undefined),
|
||||
create: jest.fn().mockImplementation(async () => ({})),
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -226,10 +226,12 @@ async function completeCartIfNecessary({
|
||||
|
||||
const idempotencyKeyServiceTx =
|
||||
idempotencyKeyService.withTransaction(transactionManager)
|
||||
let idempotencyKey = await idempotencyKeyServiceTx.retrieve({
|
||||
request_path: "/stripe/hooks",
|
||||
idempotency_key: eventId,
|
||||
})
|
||||
let idempotencyKey = await idempotencyKeyServiceTx
|
||||
.retrieve({
|
||||
request_path: "/stripe/hooks",
|
||||
idempotency_key: eventId,
|
||||
})
|
||||
.catch(() => undefined)
|
||||
|
||||
if (!idempotencyKey) {
|
||||
idempotencyKey = await idempotencyKeyService
|
||||
|
||||
Reference in new issue
Block a user