mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
frontend & backend update
This commit is contained in:
@@ -6,12 +6,12 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Subscription\StoreUpgradeAccountRequest;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
use App\Invoice;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\StripeService;
|
||||
use Auth;
|
||||
use Cartalyst\Stripe\Exception\CardErrorException;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Cashier\Exceptions\IncompletePayment;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
@@ -35,21 +35,29 @@ class SubscriptionController extends Controller
|
||||
*/
|
||||
public function stripe_setup_intent()
|
||||
{
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Create stripe customer if not exist
|
||||
$user->createOrGetStripeCustomer();
|
||||
|
||||
// Return setup intent
|
||||
return $user->createSetupIntent();
|
||||
return $this->stripe->getSetupIntent($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user subscription detail
|
||||
*
|
||||
* @return UserSubscription
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return new UserSubscription(
|
||||
Auth::user()
|
||||
);
|
||||
$slug_user_subscription = 'subscription-user-' . Auth::id();
|
||||
|
||||
if (Cache::has($slug_user_subscription)) {
|
||||
return Cache::get($slug_user_subscription);
|
||||
}
|
||||
|
||||
return Cache::rememberForever($slug_user_subscription, function () {
|
||||
return new UserSubscription(
|
||||
Auth::user()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +77,9 @@ class SubscriptionController extends Controller
|
||||
// Set user billing
|
||||
$user->setBilling($request->input('billing'));
|
||||
|
||||
// Update stripe customer billing info
|
||||
$this->stripe->updateCustomerDetails($user);
|
||||
|
||||
// Make subscription
|
||||
$this->stripe->createOrReplaceSubscription($request, $user);
|
||||
|
||||
@@ -77,9 +88,6 @@ class SubscriptionController extends Controller
|
||||
'storage_capacity' => $plan['product']['metadata']['capacity']
|
||||
]);
|
||||
|
||||
// Store invoice
|
||||
Invoice::create(get_invoice_data($user, $plan, 'stripe'));
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user