| @@ -377,8 +377,9 @@ | ||
| 377 | 377 | 'SOS' => 'Sh', |
| 378 | 378 | 'SRD' => '$', |
| 379 | 379 | 'SSP' => '£', |
| 380 | 380 | 'STD' => 'Db', |
| 381 | + 'SVC' => '₡', | |
| 381 | 382 | 'SYP' => 'ل.س', |
| 382 | 383 | 'SZL' => 'L', |
| 383 | 384 | 'THB' => '฿', |
| 384 | 385 | 'TJS' => 'ЅМ', |
| @@ -427,8 +428,16 @@ | ||
| 427 | 428 | 'XAF' => esc_html__('Central African Cfa Franc', 'fluent-booking'), |
| 428 | 429 | 'XOF' => esc_html__('West African Cfa Franc', 'fluent-booking'), |
| 429 | 430 | 'XPF' => esc_html__('Cfp Franc', 'fluent-booking'), |
| 430 | 431 | )); |
| 432 | + } | |
| 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); | |
| 431 | 440 | } |
| 432 | 441 | |
| 433 | 442 | public static function isZeroDecimal($currencyCode) |
| 434 | 443 | { |