* @brief Validates the current license key and instance ID. */
| 263 | * @brief Validates the current license key and instance ID. |
| 264 | */ |
| 265 | void Licensing::LemonSqueezy::validate() |
| 266 | { |
| 267 | if (!canActivate()) |
| 268 | return; |
| 269 | |
| 270 | if (busy()) |
| 271 | return; |
| 272 | |
| 273 | m_busy = true; |
| 274 | Q_EMIT busyChanged(); |
| 275 | |
| 276 | QJsonObject payload; |
| 277 | payload.insert("license_key", license()); |
| 278 | payload.insert("instance_id", instanceId()); |
| 279 | |
| 280 | auto url = QUrl("https://api.lemonsqueezy.com/v1/licenses/validate"); |
| 281 | auto payloadData = QJsonDocument(payload).toJson(QJsonDocument::Compact); |
| 282 | |
| 283 | QNetworkRequest req(url); |
| 284 | req.setTransferTimeout(15 * 1000); |
| 285 | req.setHeader(QNetworkRequest::ContentTypeHeader, "application/vnd.api+json"); |
| 286 | req.setRawHeader("Accept", "application/vnd.api+json"); |
| 287 | |
| 288 | auto* reply = m_manager.post(req, payloadData); |
| 289 | connect(reply, &QNetworkReply::finished, this, [this, reply]() { |
| 290 | if (reply->error() != QNetworkReply::NoError) |
| 291 | qWarning() << "[LemonSqueezy] Validation network error:" << reply->errorString(); |
| 292 | |
| 293 | readValidationResponse( |
| 294 | reply->error() == QNetworkReply::NoError ? reply->readAll() : QByteArray(), false); |
| 295 | reply->deleteLater(); |
| 296 | |
| 297 | writeSettings(); |
| 298 | }); |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * @brief Deactivates the license on this machine; an offline certificate routes |
nothing calls this directly
no test coverage detected