mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 08:48:11 +00:00
fix: ( payment ) pass major amount to the payment provider
This commit is contained in:
@@ -137,7 +137,9 @@ export class PaymentsService {
|
||||
referenceType: PaymentReferenceType.BOOKING,
|
||||
referenceId: booking.id,
|
||||
orderRef: booking.bookingRef,
|
||||
amountMinor: booking.totalMinor,
|
||||
// Send the REAL (major) price, not minor units. The payment API no longer divides by 100
|
||||
// (freight already passes the real price), so the providers charge this value as-is.
|
||||
amountMinor: booking.totalMinor / 100,
|
||||
currency: booking.currency,
|
||||
provider: method as unknown as ProviderMethod,
|
||||
platform: dto.platform,
|
||||
@@ -634,11 +636,15 @@ export class PaymentsService {
|
||||
return { processed: false, reason: "booking-not-found" };
|
||||
}
|
||||
|
||||
if (booking.totalMinor !== event.amountMinor) {
|
||||
// The event carries the REAL (major) price the provider charged (passenger now sends
|
||||
// booking.totalMinor/100 on initiate), so convert it back to minor units before comparing
|
||||
// with booking.totalMinor (which is in minor units).
|
||||
const eventAmountMinor = Math.round(event.amountMinor * 100);
|
||||
if (booking.totalMinor !== eventAmountMinor) {
|
||||
// Refuse to confirm: a 4xx makes the relay retry and eventually flag the row FAILED,
|
||||
// which is the alertable signal for an asserted-vs-paid amount divergence.
|
||||
this.logger.error(
|
||||
`mark-paid: amount mismatch for booking ${booking.id}: booking=${booking.totalMinor} event=${event.amountMinor}`,
|
||||
`mark-paid: amount mismatch for booking ${booking.id}: booking=${booking.totalMinor} event=${event.amountMinor} (=${eventAmountMinor} minor)`,
|
||||
);
|
||||
throw new BadRequestException(
|
||||
"Event amount does not match booking total",
|
||||
|
||||
Reference in New Issue
Block a user