mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
fix: ( payment ) pass major amount to the payment provider
This commit is contained in:
@@ -35,12 +35,14 @@ export class SmsClientService implements OnApplicationBootstrap {
|
||||
this.logger.warn(`RABBITMQ disabled — skipped SMS to ${dto.to}`);
|
||||
return {};
|
||||
}
|
||||
// The external send-sms consumer reads the content from `sms`, not `message`.
|
||||
this.smsClient.emit("send-sms", {
|
||||
...dto,
|
||||
to: dto.to,
|
||||
sms: dto.message,
|
||||
appKey: "IFHCRS-LICENSE-MANAGEMENT",
|
||||
});
|
||||
this.logger.log(
|
||||
`SMS emitted to RabbitMQ [${process.env.SMS_QUEUE ?? "sms_queue"}] pattern='send-sms' to=${dto.to} message="${dto.message}"`,
|
||||
`SMS emitted to RabbitMQ [${process.env.SMS_QUEUE ?? "sms_queue"}] pattern='send-sms' to=${dto.to} sms="${dto.message}"`,
|
||||
);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -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