- extend setup:dev script

- Stripe taxes refactoring
- billing subscription fixes
This commit is contained in:
Peter Papp
2021-03-24 08:19:52 +01:00
parent 09d2032a70
commit 0e3c6e286e
9 changed files with 106 additions and 48 deletions
@@ -824,6 +824,38 @@ class SetupDevEnvironment extends Command
[
'name' => 'purchase_code',
'value' => '26b889eb-3602-4bf2-beb3-3sc378fcf484',
],
[
'name' => 'billing_address',
'value' => 'Palo Alto 20',
],
[
'name' => 'billing_city',
'value' => 'Palo Alto',
],
[
'name' => 'billing_country',
'value' => 'US',
],
[
'name' => 'billing_name',
'value' => 'VueFileManager Inc.',
],
[
'name' => 'billing_phone_number',
'value' => '312343141243214',
],
[
'name' => 'billing_postal_code',
'value' => '43213',
],
[
'name' => 'billing_state',
'value' => 'California',
],
[
'name' => 'billing_vat_number',
'value' => '41241241234',
]
])->each(function ($col) {
Setting::forceCreate([
@@ -9,34 +9,33 @@ use App\Services\DemoService;
use App\Models\User;
use App\Services\StripeService;
use Auth;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Stripe\SetupIntent;
class SubscriptionController extends Controller
{
private $stripe;
private $demo;
/**
* SubscriptionController constructor.
* @param $payment
*/
public function __construct(StripeService $stripe)
public function __construct()
{
$this->stripe = $stripe;
$this->stripe = resolve(StripeService::class);
$this->demo = DemoService::class;
}
/**
* Generate setup intent
*
* @return \Stripe\SetupIntent
* @return Application|ResponseFactory|Response|SetupIntent
*/
public function setup_intent()
{
return $this->stripe
->getSetupIntent(
Auth::user()
);
return response(
$this->stripe->getSetupIntent(Auth::user()), 201
);
}
/**
@@ -69,7 +68,7 @@ class SubscriptionController extends Controller
* Upgrade account to subscription
*
* @param StoreUpgradeAccountRequest $request
* @return ResponseFactory|\Illuminate\Http\Response
* @return ResponseFactory|Response
*/
public function upgrade(StoreUpgradeAccountRequest $request)
{
@@ -107,7 +106,7 @@ class SubscriptionController extends Controller
/**
* Cancel Subscription
*
* @return ResponseFactory|\Illuminate\Http\Response
* @return ResponseFactory|Response
*/
public function cancel()
{
@@ -130,7 +129,7 @@ class SubscriptionController extends Controller
/**
* Resume Subscription
*
* @return ResponseFactory|\Illuminate\Http\Response
* @return ResponseFactory|Response
*/
public function resume()
{
+1 -1
View File
@@ -67,7 +67,7 @@ class User extends Authenticatable
// Find tax rate
$user_tax_rate = $rates->first(function ($item) {
return $item['jurisdiction'] === $this->settings->billing_country && $item['active'];
return $item['country'] === $this->settings->country && $item['active'];
});
return $user_tax_rate ? [$user_tax_rate['id']] : [];
+2 -2
View File
@@ -70,7 +70,7 @@ class StripeService
array_push($rates_public, [
'id' => $rate['id'],
'active' => $rate['active'],
'jurisdiction' => $rate['jurisdiction'],
'country' => $rate['country'],
'percentage' => $rate['percentage'],
'plan_price_formatted' => Cashier::formatAmount(round($amount + $tax)),
]);
@@ -283,7 +283,7 @@ class StripeService
$product = $this->stripe->products()->find($plan['product']);
return [
'plan' => $plan,
'plan' => $plan,
'product' => $product,
];
});