2022-08-11 09:46:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if(!function_exists('randomString')){
|
|
|
|
function randomString($length = 12)
|
|
|
|
{
|
|
|
|
$characters = '23456789ABCDEFGHJKLMNOPQRSTUVWXYZ';
|
|
|
|
$charactersLength = strlen($characters);
|
|
|
|
$randomString = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
|
|
}
|
|
|
|
return $randomString;
|
|
|
|
}
|
|
|
|
}
|
2023-06-08 10:24:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
if(!function_exists('stripeFormatCurrency')){
|
|
|
|
function stripeFormatCurrency($amount, $currency = "USD"){
|
|
|
|
// https://stripe.com/docs/currencies#zero-decimal
|
|
|
|
if(in_array($currency,['BIF','CLP','DJF','GNF','JPY','KMF','KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'])) {
|
|
|
|
return number_format(ceil($amount) , 0, '', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(in_array($currency,['BHD','JOD','KWD','OMR','TND'])) {
|
|
|
|
$number = $amount*1000;
|
|
|
|
$remainder = $number % 10;
|
|
|
|
if ($remainder != 0) {
|
|
|
|
$number += 10 - $remainder;
|
|
|
|
}
|
|
|
|
return number_format($number , 0, '', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
return number_format(($amount*100) , 0, '', '');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|