Fix crash when outcomeReason is null.
This commit is contained in:
parent
43f4bc5abe
commit
f9c0156757
3 changed files with 19 additions and 2 deletions
|
@ -301,6 +301,8 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
|||
SignalStore.donationsValues().setUnexpectedSubscriptionCancelationTimestamp(timestamp);
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue();
|
||||
} else if (chargeFailure != null) {
|
||||
Log.d(TAG, "Charge failure detected: " + chargeFailure, true);
|
||||
|
||||
StripeDeclineCode declineCode = StripeDeclineCode.Companion.getFromCode(chargeFailure.getOutcomeNetworkReason());
|
||||
DonationError.PaymentSetupError paymentSetupError;
|
||||
|
||||
|
|
|
@ -53,7 +53,11 @@ sealed class StripeDeclineCode {
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun getFromCode(code: String): StripeDeclineCode {
|
||||
fun getFromCode(code: String?): StripeDeclineCode {
|
||||
if (code == null) {
|
||||
return Unknown("null")
|
||||
}
|
||||
|
||||
val typedCode: Code? = Code.values().firstOrNull { it.code == code }
|
||||
return typedCode?.let { Known(typedCode) } ?: Unknown(code)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.HashSet;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ActiveSubscription {
|
||||
|
||||
public static final ActiveSubscription EMPTY = new ActiveSubscription(null, null);
|
||||
|
@ -270,7 +272,7 @@ public final class ActiveSubscription {
|
|||
* <p>
|
||||
* See: <a href="https://stripe.com/docs/api/charges/object#charge_object-outcome-reason">https://stripe.com/docs/api/charges/object#charge_object-outcome-reason</a>
|
||||
*/
|
||||
public String getOutcomeNetworkReason() {
|
||||
public @Nullable String getOutcomeNetworkReason() {
|
||||
return outcomeNetworkReason;
|
||||
}
|
||||
|
||||
|
@ -282,5 +284,14 @@ public final class ActiveSubscription {
|
|||
public String getOutcomeType() {
|
||||
return outcomeType;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "ChargeFailure{" +
|
||||
"code='" + code + '\'' +
|
||||
", outcomeNetworkStatus='" + outcomeNetworkStatus + '\'' +
|
||||
", outcomeNetworkReason='" + outcomeNetworkReason + '\'' +
|
||||
", outcomeType='" + outcomeType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue