diff --git a/app/Http/Resources/PricingResource.php b/app/Http/Resources/PricingResource.php index 35a7b296..f28d0f7a 100644 --- a/app/Http/Resources/PricingResource.php +++ b/app/Http/Resources/PricingResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use App\Services\StripeService; use Illuminate\Http\Resources\Json\JsonResource; use Laravel\Cashier\Cashier; @@ -26,43 +27,9 @@ class PricingResource extends JsonResource 'capacity_formatted' => format_gigabytes($this['product']['metadata']['capacity']), 'capacity' => (int)$this['product']['metadata']['capacity'], 'currency' => config('cashier.currency'), - 'tax_rates' => $this->get_tax_rates(), + 'tax_rates' => resolve(StripeService::class)->get_tax_rates($this['plan']['amount']) ] ] ]; } - - /** - * Get plan tax rates - * - * @return array - */ - private function get_tax_rates(): array - { - $stripe = resolve('App\Services\StripeService'); - - $rates_public = []; - - // Get tax rates - $rates = $stripe->getTaxRates(); - - foreach ($rates as $rate) { - - // Continue when is not active - if (!$rate['active']) continue; - - // Calculate tax - $tax = $this['plan']['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($this['plan']['amount'] + $tax)), - ]); - } - - return $rates_public; - } -} +} \ No newline at end of file diff --git a/app/Services/StripeService.php b/app/Services/StripeService.php index 89161c54..73c1b005 100644 --- a/app/Services/StripeService.php +++ b/app/Services/StripeService.php @@ -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 * diff --git a/resources/sass/vuefilemanager/_setup_wizard.scss b/resources/sass/vuefilemanager/_setup_wizard.scss index 397c4755..3790a54c 100644 --- a/resources/sass/vuefilemanager/_setup_wizard.scss +++ b/resources/sass/vuefilemanager/_setup_wizard.scss @@ -73,7 +73,7 @@ animation: spinner 5s linear infinite; circle, path { - stroke: $theme; + color: inherit; } }