mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Implement pending one-time donation error handling.
This commit is contained in:
@@ -113,6 +113,7 @@ import org.whispersystems.signalservice.internal.contacts.entities.KeyBackupResp
|
||||
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
|
||||
import org.whispersystems.signalservice.internal.crypto.AttachmentDigest;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.DonationProcessorError;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.DonationReceiptCredentialError;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.ForbiddenException;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupExistsException;
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.GroupMismatchedDevicesException;
|
||||
@@ -1174,6 +1175,16 @@ public class PushServiceSocket {
|
||||
NO_HEADERS,
|
||||
(code, body) -> {
|
||||
if (code == 204) throw new NonSuccessfulResponseCodeException(204);
|
||||
if (code == 402) {
|
||||
DonationReceiptCredentialError donationReceiptCredentialError;
|
||||
try {
|
||||
donationReceiptCredentialError = JsonUtil.fromJson(body.string(), DonationReceiptCredentialError.class);
|
||||
} catch (IOException e) {
|
||||
throw new NonSuccessfulResponseCodeException(402);
|
||||
}
|
||||
|
||||
throw donationReceiptCredentialError;
|
||||
}
|
||||
});
|
||||
|
||||
ReceiptCredentialResponseJson responseJson = JsonUtil.fromJson(response, ReceiptCredentialResponseJson.class);
|
||||
@@ -2668,11 +2679,14 @@ public class PushServiceSocket {
|
||||
}
|
||||
|
||||
if (responseCode == 440) {
|
||||
DonationProcessorError exception;
|
||||
try {
|
||||
throw JsonUtil.fromJson(body.string(), DonationProcessorError.class);
|
||||
exception = JsonUtil.fromJson(body.string(), DonationProcessorError.class);
|
||||
} catch (IOException e) {
|
||||
throw new NonSuccessfulResponseCodeException(440);
|
||||
}
|
||||
|
||||
throw exception;
|
||||
} else {
|
||||
throw new NonSuccessfulResponseCodeException(responseCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2023 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.signalservice.internal.push.exceptions
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription.ChargeFailure
|
||||
|
||||
/**
|
||||
* HTTP 402 Exception when trying to submit credentials for a donation with
|
||||
* a failed payment.
|
||||
*/
|
||||
class DonationReceiptCredentialError @JsonCreator constructor(
|
||||
val chargeFailure: ChargeFailure
|
||||
) : NonSuccessfulResponseCodeException(402) {
|
||||
override fun toString(): String {
|
||||
return """
|
||||
DonationReceiptCredentialError (402)
|
||||
Charge Failure: $chargeFailure
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user