%PDF- %PDF-
Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Helpers/ |
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Helpers/MoneyHelper.php |
<?php namespace App\Helpers; class MoneyHelper { const FEES = [ // Americas 'US' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'BR' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'CA' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'MX' => [ 'percent' => 2.9, 'fixed' => 0.20 ], // Asia-Pacific 'AU' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'CN' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'HK' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'IN' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'JP' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'my' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'NZ' => [ 'percent' => 2.9, 'fixed' => 0.20 ], 'SG' => [ 'percent' => 2.9, 'fixed' => 0.20 ], // Europeans 'GB' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'AT' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'BE' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'bg' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'cy' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'cz' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'DK' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'EE' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'FI' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'FR' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'DE' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'gr' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'hu' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'IE' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'IT' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'lv' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'lt' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'LU' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'mt' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'NL' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'NO' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'pl' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'PT' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'ro' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'RU' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'si' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'sk' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'ES' => [ 'percent' => 1.4, 'fixed' => 0.20 ], 'CH' => [ 'percent' => 1.4, 'fixed' => 0.20 ], ]; /** * Convert the value from a stripe value to a default value * * @return integer $amount */ public static function reverseStripeFormat($amount) { return $amount / 100; } /** * Convert the value into a value that can be used in Stripe * * @return integer $amount */ public static function stripeFormat($amount) { return $amount * 100; } /** * Calculate the stripe fees of an amount * * @return integer $amount * @param string $country */ public static function getStripeFees($amount, $country = 'GB') { $stripePercentage = \App\Helpers\MoneyHelper::FEES[$country]['percent']; $fixedFee = \App\Helpers\MoneyHelper::FEES[$country]['fixed']; $percentInDecimal = $stripePercentage / 100; return round(($percentInDecimal * $amount) + $fixedFee, 2); } }