Use query to insert payment and handle conflicts

This commit is contained in:
Jose Eduardo 2025-08-17 04:30:39 -04:00
parent b7ebc29af4
commit 95af8deae8

View File

@ -26,12 +26,14 @@ export class PaymentDefaultProcessor {
); );
if (!responseExists) return false; if (!responseExists) return false;
await this.repository.query(
await this.repository.save({ `
...payment, INSERT INTO payments (correlation_id, amount, payment_processor)
paymentProcessor: ProcessorTypeEnum.DEFAULT, VALUES ($1, $2, $3)
}); ON CONFLICT (correlation_id) DO NOTHING
`,
[payment.correlationId, payment.amount, ProcessorTypeEnum.DEFAULT],
);
return true; return true;
} }
} }