fix(payment): properly delete refund (#12193)

**What**
- properly delete the refund record if refunding with the provider fails

---

CLOSES SUP-1398
This commit is contained in:
Frane Polić
2025-04-16 09:57:39 +02:00
committed by GitHub
parent 01542f6973
commit 9851598dae

View File

@@ -504,11 +504,14 @@ export default class PaymentModuleService
status !== PaymentSessionStatus.AUTHORIZED &&
status !== PaymentSessionStatus.CAPTURED
) {
await this.paymentSessionService_.update({
id: session.id,
status,
data,
}, sharedContext);
await this.paymentSessionService_.update(
{
id: session.id,
status,
data,
},
sharedContext
)
throw new MedusaError(
MedusaError.Types.NOT_ALLOWED,
`Session: ${session.id} was not authorized with the provider.`
@@ -770,7 +773,7 @@ export default class PaymentModuleService
try {
await this.refundPaymentFromProvider_(payment, refund, sharedContext)
} catch (error) {
await super.deleteRefunds(data.payment_id, sharedContext)
await super.deleteRefunds({ id: refund.id }, sharedContext)
throw error
}