1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/PaymentDrivers/Stripe/Utilities.php

38 lines
851 B
PHP
Raw Normal View History

2020-06-01 14:17:29 +02:00
<?php
2020-06-10 17:38:10 +02:00
/**
* Invoice Ninja (https://invoiceninja.com).
2020-06-10 17:38:10 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2020-06-10 17:38:10 +02:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2020-06-10 17:38:10 +02:00
*/
2020-06-01 14:17:29 +02:00
namespace App\PaymentDrivers\Stripe;
trait Utilities
{
/*Helpers for currency conversions, NOTE* for some currencies we need to change behaviour */
public function convertFromStripeAmount($amount, $precision, $currency)
2020-06-01 14:17:29 +02:00
{
if($currency->code == "JPY")
return $amount;
2020-06-01 14:17:29 +02:00
return $amount / pow(10, $precision);
2020-06-01 14:17:29 +02:00
}
public function convertToStripeAmount($amount, $precision, $currency)
2020-06-01 14:17:29 +02:00
{
if($currency->code == "JPY")
return $amount;
return round(($amount * pow(10, $precision)),0);
2020-06-01 14:17:29 +02:00
}
}