Add outcome network status and outcome reason to subscription info
This commit is contained in:
		
							parent
							
								
									12f76c24b1
								
							
						
					
					
						commit
						c2bb46f41d
					
				| 
						 | 
					@ -13,6 +13,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 | 
				
			||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
 | 
					import com.fasterxml.jackson.annotation.JsonInclude.Include;
 | 
				
			||||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
					import com.fasterxml.jackson.annotation.JsonProperty;
 | 
				
			||||||
import com.google.common.base.Strings;
 | 
					import com.google.common.base.Strings;
 | 
				
			||||||
 | 
					import com.stripe.model.Charge;
 | 
				
			||||||
 | 
					import com.stripe.model.Charge.Outcome;
 | 
				
			||||||
import com.stripe.model.Invoice;
 | 
					import com.stripe.model.Invoice;
 | 
				
			||||||
import com.stripe.model.InvoiceLineItem;
 | 
					import com.stripe.model.InvoiceLineItem;
 | 
				
			||||||
import com.stripe.model.Subscription;
 | 
					import com.stripe.model.Subscription;
 | 
				
			||||||
| 
						 | 
					@ -673,13 +675,19 @@ public class SubscriptionController {
 | 
				
			||||||
    public static class ChargeFailure {
 | 
					    public static class ChargeFailure {
 | 
				
			||||||
      private final String code;
 | 
					      private final String code;
 | 
				
			||||||
      private final String message;
 | 
					      private final String message;
 | 
				
			||||||
 | 
					      private final String outcomeNetworkStatus;
 | 
				
			||||||
 | 
					      private final String outcomeReason;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      @JsonCreator
 | 
					      @JsonCreator
 | 
				
			||||||
      public ChargeFailure(
 | 
					      public ChargeFailure(
 | 
				
			||||||
          @JsonProperty("code") String code,
 | 
					          @JsonProperty("code") String code,
 | 
				
			||||||
          @JsonProperty("message") String message) {
 | 
					          @JsonProperty("message") String message,
 | 
				
			||||||
 | 
					          @JsonProperty("outcomeNetworkStatus") String outcomeNetworkStatus,
 | 
				
			||||||
 | 
					          @JsonProperty("outcomeReason") String outcomeReason) {
 | 
				
			||||||
        this.code = code;
 | 
					        this.code = code;
 | 
				
			||||||
        this.message = message;
 | 
					        this.message = message;
 | 
				
			||||||
 | 
					        this.outcomeNetworkStatus = outcomeNetworkStatus;
 | 
				
			||||||
 | 
					        this.outcomeReason = outcomeReason;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      public String getCode() {
 | 
					      public String getCode() {
 | 
				
			||||||
| 
						 | 
					@ -689,6 +697,14 @@ public class SubscriptionController {
 | 
				
			||||||
      public String getMessage() {
 | 
					      public String getMessage() {
 | 
				
			||||||
        return message;
 | 
					        return message;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      public String getOutcomeNetworkStatus() {
 | 
				
			||||||
 | 
					        return outcomeNetworkStatus;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      public String getOutcomeReason() {
 | 
				
			||||||
 | 
					        return outcomeReason;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final Subscription subscription;
 | 
					    private final Subscription subscription;
 | 
				
			||||||
| 
						 | 
					@ -732,9 +748,13 @@ public class SubscriptionController {
 | 
				
			||||||
                    GetSubscriptionInformationResponse.ChargeFailure chargeFailure = null;
 | 
					                    GetSubscriptionInformationResponse.ChargeFailure chargeFailure = null;
 | 
				
			||||||
                    if (subscription.getLatestInvoiceObject() != null && subscription.getLatestInvoiceObject().getChargeObject() != null &&
 | 
					                    if (subscription.getLatestInvoiceObject() != null && subscription.getLatestInvoiceObject().getChargeObject() != null &&
 | 
				
			||||||
                        (subscription.getLatestInvoiceObject().getChargeObject().getFailureCode() != null || subscription.getLatestInvoiceObject().getChargeObject().getFailureMessage() != null)) {
 | 
					                        (subscription.getLatestInvoiceObject().getChargeObject().getFailureCode() != null || subscription.getLatestInvoiceObject().getChargeObject().getFailureMessage() != null)) {
 | 
				
			||||||
 | 
					                      Charge charge = subscription.getLatestInvoiceObject().getChargeObject();
 | 
				
			||||||
 | 
					                      Outcome outcome = charge.getOutcome();
 | 
				
			||||||
                      chargeFailure = new GetSubscriptionInformationResponse.ChargeFailure(
 | 
					                      chargeFailure = new GetSubscriptionInformationResponse.ChargeFailure(
 | 
				
			||||||
                          subscription.getLatestInvoiceObject().getChargeObject().getFailureCode(),
 | 
					                          charge.getFailureCode(),
 | 
				
			||||||
                          subscription.getLatestInvoiceObject().getChargeObject().getFailureMessage());
 | 
					                          charge.getFailureMessage(),
 | 
				
			||||||
 | 
					                          outcome != null ? outcome.getNetworkStatus() : null,
 | 
				
			||||||
 | 
					                          outcome != null ? outcome.getReason() : null);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return Response.ok(
 | 
					                    return Response.ok(
 | 
				
			||||||
                        new GetSubscriptionInformationResponse(
 | 
					                        new GetSubscriptionInformationResponse(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue