mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-14 08:16:03 +02:00
Merge pull request #12758 from zfox23/commerce_fixCertificateInfoError
Commerce: Fix Certificate Info error
This commit is contained in:
commit
0c9d65bc15
2 changed files with 34 additions and 8 deletions
|
@ -51,7 +51,24 @@ Rectangle {
|
|||
|
||||
onCertificateInfoResult: {
|
||||
if (result.status !== 'success') {
|
||||
console.log("Failed to get certificate info", result.message);
|
||||
console.log("Failed to get certificate info", result.data.message);
|
||||
// We should still tell the user that static cert verification failed
|
||||
if (root.certificateStatus !== 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Certificate Unavailable";
|
||||
popText.text = "";
|
||||
showInMarketplaceButton.visible = false;
|
||||
root.certInfoReplaceMode = 0;
|
||||
root.itemName = "";
|
||||
root.itemEdition = "";
|
||||
root.itemOwner = "";
|
||||
root.dateOfPurchase = "";
|
||||
root.itemCost = "";
|
||||
errorText.text = "Information about this certificate is currently unavailable. Please try again later.";
|
||||
}
|
||||
} else {
|
||||
root.marketplaceUrl = result.data.marketplace_item_url;
|
||||
root.isMyCert = result.isMyCert ? result.isMyCert : false;
|
||||
|
|
|
@ -35,12 +35,19 @@ QJsonObject Ledger::apiResponse(const QString& label, QNetworkReply& reply) {
|
|||
QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) {
|
||||
QString response = reply.readAll();
|
||||
qWarning(commerce) << "FAILED" << label << response;
|
||||
QJsonObject result
|
||||
{
|
||||
{ "status", "fail" },
|
||||
{ "message", response }
|
||||
};
|
||||
return result;
|
||||
|
||||
// tempResult will be NULL if the response isn't valid JSON.
|
||||
QJsonDocument tempResult = QJsonDocument::fromJson(response.toLocal8Bit());
|
||||
if (tempResult.isNull()) {
|
||||
QJsonObject result
|
||||
{
|
||||
{ "status", "fail" },
|
||||
{ "message", response }
|
||||
};
|
||||
return result;
|
||||
} else {
|
||||
return tempResult.object();
|
||||
}
|
||||
}
|
||||
#define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); }
|
||||
#define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); }
|
||||
|
@ -337,7 +344,9 @@ void Ledger::certificateInfoSuccess(QNetworkReply& reply) {
|
|||
qInfo(commerce) << "certificateInfo" << "response" << QJsonDocument(replyObject).toJson(QJsonDocument::Compact);
|
||||
emit certificateInfoResult(replyObject);
|
||||
}
|
||||
void Ledger::certificateInfoFailure(QNetworkReply& reply) { failResponse("certificateInfo", reply); }
|
||||
void Ledger::certificateInfoFailure(QNetworkReply& reply) {
|
||||
emit certificateInfoResult(failResponse("certificateInfo", reply));
|
||||
}
|
||||
void Ledger::certificateInfo(const QString& certificateId) {
|
||||
QString endpoint = "proof_of_purchase_status/transfer";
|
||||
QJsonObject request;
|
||||
|
|
Loading…
Reference in a new issue