Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Stripe API

Hi All,

I'm using Laravel obviously and Stripe API (not Cashier) and I want to get the amount to return into a properly formatted value.

Currently i get the customer charge object and the amount returns 2399 which I need to be displayed within the CMS as 23.99 so my question is how can I get this object then convert it to a proper format?

0 likes
7 replies
bashy's avatar

PHP's money_format() function?

{{ money_format('%n', $amount) }}
// I also make sure the locale is set somewhere
setlocale(LC_MONETARY, 'en_GB.UTF-8');
ritey's avatar
money_format('%.2n',23.99) 

should work

bashy's avatar

Depends how you stored it in the database. Decimal (10,2) should be good enough

psmail's avatar

@bashy I am pretty sure that storing currency as a decimal isn't best practice. Integer and divide by 100 is best practice as I understand it.

1 like

Please or to participate in this conversation.