@@ -42,7 +42,9 @@ public function canUpgrade(): bool
4242 if (($ verificationResult = $ this ->cache ()->get ($ cacheKey )) && $ verificationResult instanceof LicenseVerificationResult) {
4343 $ data = $ verificationResult ->getData ();
4444
45- return ($ data ['custom_data ' ]['can_upgrade ' ] ?? false ) === true ;
45+ $ pvSlug = data_get ($ data , 'meta.product_variant_slug ' , '' );
46+
47+ return is_string ($ pvSlug ) && $ pvSlug == 'free ' ;
4648 }
4749
4850 } catch (\Throwable $ th ) {
@@ -72,7 +74,7 @@ public function verify()
7274 return $ offlineResult ;
7375 }
7476
75- $ failedMessage = null ;
77+ $ failedReason = null ;
7678
7779 try {
7880
@@ -82,6 +84,7 @@ public function verify()
8284 $ response = Http::timeout (self ::REQUEST_TIMEOUT )->post ($ this ->fetchActionPath ('validate ' ), $ payload );
8385
8486 if ($ response ->successful ()) {
87+
8588 $ data = $ response ->json ();
8689
8790 if ($ data ['valid ' ] === true ) {
@@ -100,7 +103,7 @@ public function verify()
100103
101104 return $ result ;
102105 } else {
103- $ failedMessage = $ data ['reason ' ] ?? null ;
106+ $ failedReason = $ data ['reason ' ] ?? null ;
104107 }
105108 }
106109
@@ -111,9 +114,8 @@ public function verify()
111114 }
112115
113116 return LicenseVerificationResult::failureOnline (
114- str ('License verification failed ' )->finish (
115- $ failedMessage ? ": {$ failedMessage }" : ''
116- )->toString (),
117+ message: 'License verification failed ' ,
118+ reason: $ failedReason ,
117119 );
118120 }
119121
@@ -140,7 +142,7 @@ public function getSupportEmail(): ?string
140142 protected function verifyOffline ()
141143 {
142144 if (! $ this ->usingLicenseKeyFile ()) {
143- return LicenseVerificationResult::failureOffline ('License file not found ' );
145+ return LicenseVerificationResult::failureOffline (message: 'License file not found ' );
144146 }
145147
146148 try {
@@ -153,7 +155,7 @@ protected function verifyOffline()
153155
154156 logger ()->warning ('Failed to read license file ' , ['exception ' => $ th ]);
155157
156- return LicenseVerificationResult::failureOffline ('Failed to read license file ' );
158+ return LicenseVerificationResult::failureOffline (message: 'Failed to read license file ' );
157159
158160 }
159161 }
@@ -162,22 +164,22 @@ protected function dataVerification($licenseData): ?LicenseVerificationResult
162164 {
163165 // Verify the license key is the same
164166 if ($ licenseData ['license_key ' ] !== $ this ->getLicenseKey ()) {
165- return LicenseVerificationResult::failureOffline ('The license key in the file does not match the configured license key ' );
167+ return LicenseVerificationResult::failureOffline (reason: 'The license key in the file does not match the configured license key ' );
166168 }
167169
168170 // Verify the data is for the current domain
169171 if ($ licenseData ['domain ' ] !== $ this ->getCurrentDomain ()) {
170- return LicenseVerificationResult::failureOffline (' License file does not match the current domain ' );
172+ return LicenseVerificationResult::failureOffline (reason: ' domain_mismatch ' );
171173 }
172174
173175 // Verify the license is not expired
174176 if (Carbon::parse ($ licenseData ['expiry_date ' ])->isPast (Carbon::now ('UTC ' ))) {
175- return LicenseVerificationResult::failureOffline (' License expired ' );
177+ return LicenseVerificationResult::failureOffline (reason: ' expired ' );
176178 }
177179
178180 // Verify the checksum
179181 if ($ licenseData ['checksum ' ] !== $ this ->calculateChecksum (Arr::except ($ licenseData , 'checksum ' ))) {
180- return LicenseVerificationResult::failureOffline (' License file verification failed due to checksum mismatch ' );
182+ return LicenseVerificationResult::failureOffline (reason: ' checksum mismatch ' );
181183 }
182184
183185 return null ;
0 commit comments