- Pay and subscribe from generated Subscription Request

This commit is contained in:
Peter Papp
2021-03-22 15:41:47 +01:00
parent 0db55b51d2
commit 778a94e5ba
6 changed files with 158 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Laravel\Cashier\Exceptions\IncompletePayment;
use Laravel\Cashier\Exceptions\PaymentActionRequired;
@@ -13,6 +14,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class StripeService
{
/**
* Stripe Service constructor.
*/
@@ -241,10 +243,20 @@ class StripeService
*/
public function getPlan($id)
{
$plan = $this->stripe->plans()->find($id);
$product = $this->stripe->products()->find($plan['product']);
if (Cache::has("plan-$id")) {
return Cache::get("plan-$id");
}
return compact('plan', 'product');
return Cache::rememberForever("plan-$id", function () use ($id) {
$plan = $this->stripe->plans()->find($id);
$product = $this->stripe->products()->find($plan['product']);
return [
'plan' => $plan,
'product' => $product,
];
});
}
/**