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;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user