| @@ -430,8 +430,16 @@ | ||
| 430 | 430 | 'XPF' => esc_html__('Cfp Franc', 'fluent-booking'), |
| 431 | 431 | )); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | + // Every money write goes through here so the ledger and the gateway cannot diverge. | |
| 435 | + // Rounds rather than truncates: 2.01 * 100 is 200.99999999999997 in IEEE-754, so | |
| 436 | + // intval() records 200 where the card is charged 201. Factor is 1 for zero-decimal. | |
| 437 | + public static function toCents($value, $conversionFactor = 100) | |
| 438 | + { | |
| 439 | + return (int) round((float) $value * $conversionFactor); | |
| 440 | + } | |
| 441 | + | |
| 434 | 442 | public static function isZeroDecimal($currencyCode) |
| 435 | 443 | { |
| 436 | 444 | $currencyCode = strtoupper($currencyCode); |
| 437 | 445 | $zeroDecimals = self::zeroDecimalCurrencies(); |