Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Replaced resolveBillable with getBillable
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed May 11, 2021
1 parent d680448 commit 002ea80
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/BillingPortal.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function setBillableOnRequest(Closure $callback)
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public static function resolveBillable(Request $request)
public static function getBillable(Request $request)
{
$closure = static::$billableOnRequest;

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Inertia/BillingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BillingController extends Controller
public function portal(Request $request)
{
return $this->getBillingPortalRedirect(
BillingPortal::resolveBillable($request)
BillingPortal::getBillable($request)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Inertia/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InvoiceController extends Controller
*/
public function index(Request $request)
{
$invoices = BillingPortal::resolveBillable($request)->invoices()->map(function ($invoice) {
$invoices = BillingPortal::getBillable($request)->invoices()->map(function ($invoice) {
return [
'description' => $invoice->lines->data[0]->description,
'created' => $invoice->created,
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Controllers/Inertia/PaymentMethodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PaymentMethodController extends Controller
public function __construct(Request $request)
{
$this->middleware(function (Request $request, Closure $next) {
BillingPortal::resolveBillable($request)->createOrGetStripeCustomer();
BillingPortal::getBillable($request)->createOrGetStripeCustomer();

return $next($request);
});
Expand All @@ -38,7 +38,7 @@ public function __construct(Request $request)
*/
public function index(Request $request)
{
$billable = BillingPortal::resolveBillable($request);
$billable = BillingPortal::getBillable($request);

$billable->updateDefaultPaymentMethodFromStripe();

Expand Down Expand Up @@ -71,7 +71,7 @@ public function index(Request $request)
public function create(Request $request)
{
return Inertia::render('BillingPortal/PaymentMethod/Create', [
'intent' => BillingPortal::resolveBillable($request)->createSetupIntent(),
'intent' => BillingPortal::getBillable($request)->createSetupIntent(),
'stripe_key' => config('cashier.key'),
]);
}
Expand All @@ -88,7 +88,7 @@ public function store(Request $request)
'token' => ['required', 'string'],
]);

$billable = BillingPortal::resolveBillable($request);
$billable = BillingPortal::getBillable($request);

$billable->addPaymentMethod($request->token);

Expand All @@ -110,7 +110,7 @@ public function store(Request $request)
public function destroy(Request $request, string $paymentMethod)
{
try {
$paymentMethod = BillingPortal::resolveBillable($request)->findPaymentMethod($paymentMethod);
$paymentMethod = BillingPortal::getBillable($request)->findPaymentMethod($paymentMethod);
} catch (Exception $e) {
return Redirect::route('billing-portal.payment-method.index')
->banner('The payment method got removed!');
Expand All @@ -134,7 +134,7 @@ public function destroy(Request $request, string $paymentMethod)
public function setDefault(Request $request, string $paymentMethod)
{
try {
BillingPortal::resolveBillable($request)->updateDefaultPaymentMethod($paymentMethod);
BillingPortal::getBillable($request)->updateDefaultPaymentMethod($paymentMethod);
} catch (Exception $e) {
return Redirect::route('billing-portal.payment-method.index')
->banner('The default payment method got updated!');
Expand Down
10 changes: 5 additions & 5 deletions src/Http/Controllers/Inertia/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(Request $request)
*/
public function index(Request $request)
{
$user = BillingPortal::resolveBillable($request);
$user = BillingPortal::getBillable($request);

$subscription = $this->getCurrentSubscription($user, $request->subscription);

Expand All @@ -61,7 +61,7 @@ public function index(Request $request)
*/
public function subscribeToPlan(Request $request, string $planId)
{
$user = BillingPortal::resolveBillable($request);
$user = BillingPortal::getBillable($request);

$plan = Saas::getPlan($planId);

Expand Down Expand Up @@ -92,7 +92,7 @@ public function swapPlan(Request $request, string $newPlanId)
{
$plan = Saas::getPlan($newPlanId);

$billable = BillingPortal::resolveBillable($request);
$billable = BillingPortal::getBillable($request);

$subscription = $this->getCurrentSubscription($billable, $request->subscription);

Expand Down Expand Up @@ -122,7 +122,7 @@ public function swapPlan(Request $request, string $newPlanId)
*/
public function resumeSubscription(Request $request)
{
$billable = BillingPortal::resolveBillable($request);
$billable = BillingPortal::getBillable($request);

$subscription = $this->getCurrentSubscription($billable, $request->subscription);

Expand All @@ -148,7 +148,7 @@ public function resumeSubscription(Request $request)
*/
public function cancelSubscription(Request $request)
{
$billable = BillingPortal::resolveBillable($request);
$billable = BillingPortal::getBillable($request);

$subscription = $this->getCurrentSubscription($user, $request->subscription);

Expand Down

0 comments on commit 002ea80

Please sign in to comment.