Fix license change AppSumo
This commit is contained in:
parent
5fb634471e
commit
796b69f60f
|
@ -47,8 +47,10 @@ class AppSumoController extends Controller
|
||||||
|
|
||||||
private function handleChangeEvent($request)
|
private function handleChangeEvent($request)
|
||||||
{
|
{
|
||||||
$this->deactivateLicense($request->prev_license_key);
|
$license = $this->deactivateLicense($request->prev_license_key);
|
||||||
$this->createLicense($request->json()->all());
|
$this->createLicense(array_merge($request->json()->all(), [
|
||||||
|
'user_id' => $license->user_id,
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handleDeactivateEvent($request)
|
private function handleDeactivateEvent($request)
|
||||||
|
@ -56,7 +58,7 @@ class AppSumoController extends Controller
|
||||||
$this->deactivateLicense($request->license_key);
|
$this->deactivateLicense($request->license_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createLicense(array $licenseData)
|
private function createLicense(array $licenseData): License
|
||||||
{
|
{
|
||||||
$license = License::firstOrNew([
|
$license = License::firstOrNew([
|
||||||
'license_key' => $licenseData['license_key'],
|
'license_key' => $licenseData['license_key'],
|
||||||
|
@ -71,21 +73,25 @@ class AppSumoController extends Controller
|
||||||
'license_key' => $license->license_key,
|
'license_key' => $license->license_key,
|
||||||
'license_id' => $license->id,
|
'license_id' => $license->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $license;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deactivateLicense(string $licenseKey)
|
private function deactivateLicense(string $licenseKey): License
|
||||||
{
|
{
|
||||||
$oldLicense = License::where([
|
$license = License::where([
|
||||||
'license_key' => $licenseKey,
|
'license_key' => $licenseKey,
|
||||||
'license_provider' => 'appsumo',
|
'license_provider' => 'appsumo',
|
||||||
])->firstOrFail();
|
])->firstOrFail();
|
||||||
$oldLicense->update([
|
$license->update([
|
||||||
'status' => License::STATUS_INACTIVE,
|
'status' => License::STATUS_INACTIVE,
|
||||||
]);
|
]);
|
||||||
Log::info('[APPSUMO] De-activating license', [
|
Log::info('[APPSUMO] De-activating license', [
|
||||||
'license_key' => $licenseKey,
|
'license_key' => $licenseKey,
|
||||||
'license_id' => $oldLicense->id,
|
'license_id' => $license->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $license;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateSignature(Request $request)
|
private function validateSignature(Request $request)
|
||||||
|
|
Loading…
Reference in New Issue