Developer Tools
Money
PayMongo amounts are integer centavos: 10000 is ₱100.00. The Money value object keeps them integers while you add, subtract, compare, and format, so a float never reaches a request.
- Send amounts as integers in centavos. A float such as 1449.5 is never correct for PayMongo.
- Money is immutable: add() and subtract() return a new amount, and no step does float math.
- toDecimal() gives an exact decimal string and format() a display string; both come from the integer.
- Money serializes to JSON as its centavos, so it can go straight into a request body.
- The only currency the package supports is PHP.
Formatting and arithmetic
PHP
use Luigel\Paymongo\Support\Money;
public function arithmetic(): array
{
$price = Money::ofCentavos(129900);
$shipping = Money::ofCentavos(15050);
$total = $price->add($shipping);
$refunded = $total->subtract(Money::ofCentavos(50000));
return [
'centavos' => $total->centavos(),
'decimal' => $total->toDecimal(),
'formatted' => $total->format(),
'after_refund' => $refunded->format(),
'json' => (string) json_encode(['amount' => $total]),
];
}