Skip to content

Commit 303c6a6

Browse files
author
Piotr Chowaniec
committed
Adds fee total amount to TransactionSummary
1 parent aad93a2 commit 303c6a6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/main/java/com/global/api/entities/TransactionSummary.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ public class TransactionSummary {
152152
private String safReferenceNumber;
153153
private String cardAcquisition;
154154
private String transactionTime;
155+
156+
private BigDecimal feeTotalAmount; //The value contain precision lower than the lowest denomination of the currency. For example 1298.67 USD means $12.98 and 0.67 of a penny.
155157
}

src/main/java/com/global/api/mapping/GpApiMapping.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.global.api.utils.EnumUtils;
1818
import com.global.api.utils.JsonDoc;
1919
import com.global.api.utils.StringUtils;
20-
import com.google.gson.JsonElement;
2120
import lombok.var;
2221
import org.joda.time.DateTime;
2322

@@ -505,6 +504,11 @@ public static TransactionSummary mapTransactionSummary(JsonDoc doc) throws Gatew
505504
}
506505
}
507506

507+
if(doc.has("fees")) {
508+
JsonDoc fees = doc.get("fees");
509+
summary.setFeeTotalAmount(fees.getDecimal("total_amount_decimal"));
510+
}
511+
508512
summary.setFraudManagementResponse(doc.has("risk_assessment") ? mapFraudManagementReport(doc.get("risk_assessment")) : null);
509513

510514
return summary;

src/test/java/com/global/api/tests/gpapi/GpApiMappingTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.joda.time.DateTime;
2020
import org.junit.Test;
2121

22+
import java.math.BigDecimal;
23+
2224
import static com.global.api.gateways.GpApiConnector.parseGpApiDate;
2325
import static com.global.api.gateways.GpApiConnector.parseGpApiDateTime;
2426
import static org.junit.Assert.assertEquals;
@@ -35,7 +37,7 @@ public GpApiMappingTest() throws ApiException {
3537
@Test
3638
public void MapTransactionSummaryTest() throws GatewayException {
3739
// Arrange
38-
String rawJson = "{\"id\":\"TRN_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"time_created\":\"2020-06-05T03:08:20.896Z\",\"time_last_updated\":\"\",\"status\":\"PREAUTHORIZED\",\"type\":\"SALE\",\"merchant_id\":\"MER_c4c0df11039c48a9b63701adeaa296c3\",\"merchant_name\":\"Sandbox_merchant_2\",\"account_id\":\"TRA_6716058969854a48b33347043ff8225f\",\"account_name\":\"Transaction_Processing\",\"channel\":\"CNP\",\"amount\":\"10000\",\"currency\":\"CAD\",\"reference\":\"My-TRANS-184398775\",\"description\":\"41e7877b-da90-4c5f-befe-7f024b96311e\",\"order_reference\":\"\",\"time_created_reference\":\"\",\"batch_id\":\"\",\"initiator\":\"\",\"country\":\"\",\"language\":\"\",\"ip_address\":\"97.107.232.5\",\"site_reference\":\"\",\"payment_method\":{\"result\":\"00\",\"message\":\"SUCCESS\",\"entry_mode\":\"ECOM\",\"name\":\"NAME NOT PROVIDED\",\"card\":{\"funding\":\"CREDIT\",\"brand\":\"VISA\",\"authcode\":\"12345\",\"brand_reference\":\"TQ76bJf7qzkC30U0\",\"masked_number_first6last4\":\"411111XXXXXX1111\",\"cvv_indicator\":\"PRESENT\",\"cvv_result\":\"MATCHED\",\"avs_address_result\":\"MATCHED\",\"avs_postal_code_result\":\"MATCHED\"}},\"action_create_id\":\"ACT_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"parent_resource_id\":\"TRN_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"action\":{\"id\":\"ACT_kLkU0qND7wyuW0Br76ZNyAnlPTjHsb\",\"type\":\"TRANSACTION_SINGLE\",\"time_created\":\"2020-11-24T15:43:43.990Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"JF2GQpeCrOivkBGsTRiqkpkdKp67Gxi0\",\"app_name\":\"test_app\"}}";
40+
String rawJson = "{\"id\":\"TRN_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"time_created\":\"2020-06-05T03:08:20.896Z\",\"time_last_updated\":\"\",\"status\":\"PREAUTHORIZED\",\"type\":\"SALE\",\"merchant_id\":\"MER_c4c0df11039c48a9b63701adeaa296c3\",\"merchant_name\":\"Sandbox_merchant_2\",\"account_id\":\"TRA_6716058969854a48b33347043ff8225f\",\"account_name\":\"Transaction_Processing\",\"channel\":\"CNP\",\"amount\":\"10000\",\"currency\":\"CAD\",\"reference\":\"My-TRANS-184398775\",\"description\":\"41e7877b-da90-4c5f-befe-7f024b96311e\",\"order_reference\":\"\",\"time_created_reference\":\"\",\"batch_id\":\"\",\"initiator\":\"\",\"country\":\"\",\"language\":\"\",\"ip_address\":\"97.107.232.5\",\"site_reference\":\"\",\"payment_method\":{\"result\":\"00\",\"message\":\"SUCCESS\",\"entry_mode\":\"ECOM\",\"name\":\"NAME NOT PROVIDED\",\"card\":{\"funding\":\"CREDIT\",\"brand\":\"VISA\",\"authcode\":\"12345\",\"brand_reference\":\"TQ76bJf7qzkC30U0\",\"masked_number_first6last4\":\"411111XXXXXX1111\",\"cvv_indicator\":\"PRESENT\",\"cvv_result\":\"MATCHED\",\"avs_address_result\":\"MATCHED\",\"avs_postal_code_result\":\"MATCHED\"}},\"action_create_id\":\"ACT_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"parent_resource_id\":\"TRN_TvY1QFXxQKtaFSjNaLnDVdo3PZ7ivz\",\"fees\":{\"total_amount_decimal\":\"123.12\"},\"action\":{\"id\":\"ACT_kLkU0qND7wyuW0Br76ZNyAnlPTjHsb\",\"type\":\"TRANSACTION_SINGLE\",\"time_created\":\"2020-11-24T15:43:43.990Z\",\"result_code\":\"SUCCESS\",\"app_id\":\"JF2GQpeCrOivkBGsTRiqkpkdKp67Gxi0\",\"app_name\":\"test_app\"}}";
3941

4042
JsonDoc doc = JsonDoc.parse(rawJson);
4143

@@ -71,6 +73,10 @@ public void MapTransactionSummaryTest() throws GatewayException {
7173
assertEquals(card.getString("masked_number_first6last4"), transaction.getMaskedCardNumber());
7274
}
7375
}
76+
if (doc.has("fees")) {
77+
assertEquals(doc.get("fees").getDecimal("total_amount_decimal"), transaction.getFeeTotalAmount());
78+
assertEquals(new BigDecimal("123.12"), transaction.getFeeTotalAmount());
79+
}
7480
}
7581

7682
@Test

0 commit comments

Comments
 (0)