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:
committed by
GitHub
parent
ff37cd190f
commit
cff54d7325
6
.changeset/sour-feet-sniff.md
Normal file
6
.changeset/sour-feet-sniff.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"medusa-payment-stripe": patch
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa-payment-stripe): Catch on idempotency key retrieve if not found
|
||||
@@ -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