-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-13334 API returns exemption object
API should return exemption object in payment responses when appropriate.
- Loading branch information
1 parent
3424a0d
commit f4ae724
Showing
21 changed files
with
502 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package uk.gov.pay.api.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@Schema(name = "Exemption", description = "A structure representing that 3DS exemption was requested and the outcome of the exemption, if applicable.") | ||
public class Exemption { | ||
@JsonProperty("requested") | ||
private boolean requested; | ||
@JsonProperty("type") | ||
private String type; | ||
@JsonProperty("outcome") | ||
private ExemptionOutcome outcome; | ||
|
||
public Exemption() { | ||
} | ||
|
||
public Exemption(Boolean requested, String type, ExemptionOutcome outcome) { | ||
this.requested = requested; | ||
this.type = type; | ||
this.outcome = outcome; | ||
} | ||
|
||
@Schema(description = "Indicates whether an exemption was requested for the given payment.", example = "true", accessMode = READ_ONLY) | ||
public boolean getRequested() { | ||
return requested; | ||
} | ||
|
||
@Schema(description = "Indicates the type of exemption. Only present for corporate exemption", example = "corporate", accessMode = READ_ONLY) | ||
public String getType() { | ||
return type; | ||
} | ||
|
||
@Schema(description = "The outcome of the requested exemption", accessMode = READ_ONLY) | ||
public ExemptionOutcome getOutcome() { | ||
return outcome; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package uk.gov.pay.api.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@Schema(name = "Outcome", description = "A structure representing the outcome of a 3DS exemption, if known.") | ||
public class ExemptionOutcome { | ||
@JsonProperty("result") | ||
private String result; | ||
|
||
public ExemptionOutcome() { | ||
|
||
} | ||
public ExemptionOutcome(String result) { | ||
this.result = result; | ||
} | ||
|
||
@Schema(description = "The outcome of the requested exemption", example = "honoured", accessMode = READ_ONLY) | ||
public String getResult() { | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/uk/gov/pay/api/utils/ExemptionEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package uk.gov.pay.api.utils; | ||
|
||
import uk.gov.pay.api.model.Exemption; | ||
|
||
import java.util.Optional; | ||
|
||
public class ExemptionEvaluator { | ||
public static Exemption evaluateExemption(Exemption maybeExemption) { | ||
return Optional.ofNullable(maybeExemption) | ||
.map(exemption -> { | ||
if (exemption.getType() != null | ||
&& exemption.getType().equals("corporate") | ||
&& exemption.getOutcome() != null) { | ||
return exemption; | ||
} | ||
return null; | ||
}) | ||
.orElse(null); | ||
} | ||
} |
Oops, something went wrong.