mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 11:00:39 +00:00
- refactored PricingResource
- get_tax_rates added into StripeService.php
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Cashier\Cashier;
|
||||
use Laravel\Cashier\Exceptions\IncompletePayment;
|
||||
use Laravel\Cashier\Exceptions\PaymentActionRequired;
|
||||
use Stripe;
|
||||
@@ -48,6 +49,36 @@ class StripeService
|
||||
->all()['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plan tax rates
|
||||
*
|
||||
* @param $amount
|
||||
* @return array
|
||||
*/
|
||||
public function get_tax_rates($amount): array
|
||||
{
|
||||
$rates_public = [];
|
||||
|
||||
foreach ($this->getTaxRates() as $rate) {
|
||||
|
||||
// Continue when is not active
|
||||
if (!$rate['active']) continue;
|
||||
|
||||
// Calculate tax
|
||||
$tax = $amount * ($rate['percentage'] / 100);
|
||||
|
||||
array_push($rates_public, [
|
||||
'id' => $rate['id'],
|
||||
'active' => $rate['active'],
|
||||
'jurisdiction' => $rate['jurisdiction'],
|
||||
'percentage' => $rate['percentage'],
|
||||
'plan_price_formatted' => Cashier::formatAmount(round($amount + $tax)),
|
||||
]);
|
||||
}
|
||||
|
||||
return $rates_public;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default payment option or set new default payment
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user