-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EWT-85] fixes existing items returned by the `merchant-accounts/{id}…
…/transactions` endpoint and add support for refunds (#180)
- Loading branch information
Showing
20 changed files
with
703 additions
and
43 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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/truelayer/java/merchantaccounts/entities/transactions/Refund.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,42 @@ | ||
package com.truelayer.java.merchantaccounts.entities.transactions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonGetter; | ||
import com.truelayer.java.entities.CurrencyCode; | ||
import java.time.ZonedDateTime; | ||
import java.util.Optional; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Value; | ||
|
||
@Value | ||
@EqualsAndHashCode(callSuper = false) | ||
public class Refund extends Transaction { | ||
Type type = Type.REFUND; | ||
|
||
String id; | ||
|
||
CurrencyCode currency; | ||
|
||
int amountInMinor; | ||
|
||
/** | ||
* Represents the refund status, either <code>pending</code> or <code>executed</code>. | ||
*/ | ||
Transaction.Status status; | ||
|
||
ZonedDateTime createdAt; | ||
|
||
ZonedDateTime executedAt; | ||
|
||
com.truelayer.java.merchantaccounts.entities.transactions.beneficiary.PaymentSource beneficiary; | ||
|
||
Payout.ContextCode contextCode; | ||
|
||
String refundId; | ||
|
||
String paymentId; | ||
|
||
@JsonGetter | ||
public Optional<ZonedDateTime> getExecutedAt() { | ||
return Optional.ofNullable(executedAt); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/truelayer/java/merchantaccounts/entities/transactions/Remitter.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 com.truelayer.java.merchantaccounts.entities.transactions; | ||
|
||
import com.truelayer.java.merchantaccounts.entities.transactions.accountidentifier.AccountIdentifier; | ||
import java.util.List; | ||
import lombok.Value; | ||
|
||
/** | ||
* A transaction item specific DTO for external payments | ||
* representing account identifiers of either IBAN or SCAN type. | ||
* This is deliberately different from the more generic | ||
* {@link com.truelayer.java.entities.Remitter} class. | ||
*/ | ||
@Value | ||
public class Remitter { | ||
private List<AccountIdentifier> accountIdentifiers; | ||
|
||
private String accountHolderName; | ||
|
||
private String reference; | ||
} |
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
72 changes: 72 additions & 0 deletions
72
...ayer/java/merchantaccounts/entities/transactions/accountidentifier/AccountIdentifier.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,72 @@ | ||
package com.truelayer.java.merchantaccounts.entities.transactions.accountidentifier; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.truelayer.java.TrueLayerException; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.ToString; | ||
|
||
/** | ||
* A transaction item specific DTO for external payments | ||
* representing account identifiers of either IBAN or SCAN type only. | ||
* This is deliberately different from the more generic {@link com.truelayer.java.entities.Remitter Remitter} class. | ||
*/ | ||
@JsonTypeInfo( | ||
include = JsonTypeInfo.As.EXISTING_PROPERTY, | ||
use = JsonTypeInfo.Id.NAME, | ||
property = "type", | ||
defaultImpl = SortCodeAccountNumberAccountIdentifier.class) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = SortCodeAccountNumberAccountIdentifier.class, name = "sort_code_account_number"), | ||
@JsonSubTypes.Type(value = IbanAccountIdentifier.class, name = "iban"), | ||
}) | ||
@ToString | ||
@EqualsAndHashCode | ||
@Getter | ||
public abstract class AccountIdentifier { | ||
public abstract Type getType(); | ||
|
||
@JsonIgnore | ||
public boolean isSortCodeAccountNumberIdentifier() { | ||
return this instanceof SortCodeAccountNumberAccountIdentifier; | ||
} | ||
|
||
@JsonIgnore | ||
public boolean isIbanIdentifier() { | ||
return this instanceof IbanAccountIdentifier; | ||
} | ||
|
||
@JsonIgnore | ||
public SortCodeAccountNumberAccountIdentifier asSortCodeAccountNumber() { | ||
if (!isSortCodeAccountNumberIdentifier()) { | ||
throw new TrueLayerException(buildErrorMessage()); | ||
} | ||
return (SortCodeAccountNumberAccountIdentifier) this; | ||
} | ||
|
||
@JsonIgnore | ||
public IbanAccountIdentifier asIban() { | ||
if (!isIbanIdentifier()) { | ||
throw new TrueLayerException(buildErrorMessage()); | ||
} | ||
return (IbanAccountIdentifier) this; | ||
} | ||
|
||
private String buildErrorMessage() { | ||
return String.format("Identifier is of type %s.", this.getClass().getSimpleName()); | ||
} | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum Type { | ||
SORT_CODE_ACCOUNT_NUMBER("sort_code_account_number"), | ||
IBAN("iban"); | ||
|
||
@JsonValue | ||
private final String type; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../java/merchantaccounts/entities/transactions/accountidentifier/IbanAccountIdentifier.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,12 @@ | ||
package com.truelayer.java.merchantaccounts.entities.transactions.accountidentifier; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
public class IbanAccountIdentifier extends AccountIdentifier { | ||
private final Type type = Type.IBAN; | ||
|
||
private String iban; | ||
} |
14 changes: 14 additions & 0 deletions
14
...ounts/entities/transactions/accountidentifier/SortCodeAccountNumberAccountIdentifier.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,14 @@ | ||
package com.truelayer.java.merchantaccounts.entities.transactions.accountidentifier; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
public class SortCodeAccountNumberAccountIdentifier extends AccountIdentifier { | ||
private final Type type = Type.SORT_CODE_ACCOUNT_NUMBER; | ||
|
||
private String sortCode; | ||
|
||
private String accountNumber; | ||
} |
Oops, something went wrong.