Skip to content

Instantly share code, notes, and snippets.

@abishekrsrikaanth
Created July 29, 2021 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abishekrsrikaanth/6c54fd29391521b193930b1db8a7cb84 to your computer and use it in GitHub Desktop.
Save abishekrsrikaanth/6c54fd29391521b193930b1db8a7cb84 to your computer and use it in GitHub Desktop.
<?php
namespace App\Observers;
use App\Models\StripePlan;
use App\Shared\Services\Stripe\API as StripeAPI;
class StripePlanObserver
{
public function created(StripePlan $stripePlan): void
{
Nova::whenServing(function (NovaRequest $request) use ($stripePlan) {
$api = new StripeAPI();
$plan = $api->createPlan($stripePlan->name, $stripePlan->amount);
$stripePlan->setStripePlanInfo($plan->id, $plan->product);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment