mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Add PayPal decline code errors.
This commit is contained in:
committed by
Greyson Parrelli
parent
88da382a6f
commit
0303467c91
@@ -15,6 +15,27 @@ public final class ActiveSubscription {
|
||||
|
||||
public static final ActiveSubscription EMPTY = new ActiveSubscription(null, null);
|
||||
|
||||
public enum Processor {
|
||||
STRIPE("STRIPE"),
|
||||
BRAINTREE("BRAINTREE");
|
||||
|
||||
private final String code;
|
||||
|
||||
Processor(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
static Processor fromCode(String code) {
|
||||
for (Processor value : Processor.values()) {
|
||||
if (value.code.equals(code)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return STRIPE;
|
||||
}
|
||||
}
|
||||
|
||||
private enum Status {
|
||||
/**
|
||||
* The subscription is currently in a trial period and it's safe to provision your product for your customer.
|
||||
@@ -121,6 +142,7 @@ public final class ActiveSubscription {
|
||||
private final long billingCycleAnchor;
|
||||
private final boolean willCancelAtPeriodEnd;
|
||||
private final String status;
|
||||
private final Processor processor;
|
||||
|
||||
@JsonCreator
|
||||
public Subscription(@JsonProperty("level") int level,
|
||||
@@ -130,7 +152,8 @@ public final class ActiveSubscription {
|
||||
@JsonProperty("active") boolean isActive,
|
||||
@JsonProperty("billingCycleAnchor") long billingCycleAnchor,
|
||||
@JsonProperty("cancelAtPeriodEnd") boolean willCancelAtPeriodEnd,
|
||||
@JsonProperty("status") String status)
|
||||
@JsonProperty("status") String status,
|
||||
@JsonProperty("processor") String processor)
|
||||
{
|
||||
this.level = level;
|
||||
this.currency = currency;
|
||||
@@ -140,6 +163,7 @@ public final class ActiveSubscription {
|
||||
this.billingCycleAnchor = billingCycleAnchor;
|
||||
this.willCancelAtPeriodEnd = willCancelAtPeriodEnd;
|
||||
this.status = status;
|
||||
this.processor = Processor.fromCode(processor);
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
@@ -190,6 +214,10 @@ public final class ActiveSubscription {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Processor getProcessor() {
|
||||
return processor;
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
return !isActive() && !Status.isPaymentFailed(getStatus());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user