diff --git a/src/main/java/com/adyen/model/TransactionItem.java b/src/main/java/com/adyen/model/TransactionItem.java index d0861e6..2ca76c6 100644 --- a/src/main/java/com/adyen/model/TransactionItem.java +++ b/src/main/java/com/adyen/model/TransactionItem.java @@ -6,7 +6,6 @@ public class TransactionItem { private String type; private String created; private String amount; - private String pspReference; public String getId() { return id; @@ -40,14 +39,6 @@ public void setAmount(String amount) { this.amount = amount; } - public String getPspReference() { - return pspReference; - } - - public void setPspReference(String pspReference) { - this.pspReference = pspReference; - } - public String getType() { return type; } @@ -76,11 +67,6 @@ public TransactionItem amount(String amount) { return this; } - public TransactionItem pspReference(String pspReference) { - this.pspReference = pspReference; - return this; - } - public TransactionItem type(String type) { this.type = type; return this; diff --git a/src/main/java/com/adyen/util/TransactionHandler.java b/src/main/java/com/adyen/util/TransactionHandler.java index ec51d01..aed6eaf 100644 --- a/src/main/java/com/adyen/util/TransactionHandler.java +++ b/src/main/java/com/adyen/util/TransactionHandler.java @@ -42,10 +42,9 @@ public TransactionItem getTransactionItem(Transaction transaction) { return new TransactionItem() .id(transaction.getId()) .status(transaction.getStatus().getValue()) - .type(transaction.getAmount().getValue() > 0 ? "Incoming" : "Outgoing") + .type(getType(transaction.getAmount())) .created(formatDate(transaction.getCreationDate())) - .amount(formatAmount(transaction.getAmount())) - .pspReference(transaction.getEventId()); + .amount(formatAmount(transaction.getAmount())); } private String formatAmount(Amount amount) { @@ -53,7 +52,8 @@ private String formatAmount(Amount amount) { if(amount != null) { NumberFormat numberFormat = NumberFormat.getNumberInstance(); - String formattedAmount = numberFormat.format(amount.getValue()); + // display absolute amount and format + String formattedAmount = numberFormat.format(Math.abs(amount.getValue())); ret = amount.getCurrency() + " " + formattedAmount; } return ret; @@ -63,4 +63,25 @@ private String formatDate(OffsetDateTime offsetDateTime) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); return offsetDateTime.format(formatter); } + + /** + * Determines type of the transaction + * Incoming: positive amount, funds added + * Outgoing: negative amount, funds deducted + * @param amount + * @return + */ + private String getType(Amount amount) { + String ret = ""; + + if(amount != null) { + if(amount.getValue() > 0) { + ret = "Incoming"; + } if(amount.getValue() < 0) { + ret = "Outgoing"; + } + } + + return ret; + } }