Use query to insert payment and handle conflicts
This commit is contained in:
parent
b7ebc29af4
commit
95af8deae8
@ -26,12 +26,14 @@ export class PaymentDefaultProcessor {
|
||||
);
|
||||
|
||||
if (!responseExists) return false;
|
||||
|
||||
await this.repository.save({
|
||||
...payment,
|
||||
paymentProcessor: ProcessorTypeEnum.DEFAULT,
|
||||
});
|
||||
|
||||
await this.repository.query(
|
||||
`
|
||||
INSERT INTO payments (correlation_id, amount, payment_processor)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (correlation_id) DO NOTHING
|
||||
`,
|
||||
[payment.correlationId, payment.amount, ProcessorTypeEnum.DEFAULT],
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user