Skip to content

Commit fc6b100

Browse files
committed
Added card type and card mask fields to parsed status response
1 parent 6e3f04c commit fc6b100

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ This library provide ability to make requests to Transact Pro Gateway API v3.
1212
<dependency>
1313
<groupId>com.github.transactpro</groupId>
1414
<artifactId>gateway</artifactId>
15-
<version>1.3.5</version>
15+
<version>1.3.6</version>
1616
</dependency>
1717
```
1818

1919
#### Gradle
2020

2121
```groovy
22-
implementation 'com.github.transactpro:gateway:1.3.5'
22+
implementation 'com.github.transactpro:gateway:1.3.6'
2323
```
2424

2525
## Documentation
@@ -261,6 +261,13 @@ for (CSVRecord record : parsedCsv) {
261261
}
262262
```
263263

264+
### Useful enumerators
265+
266+
`com.github.transactpro.gateway.model.response.constants.ErrorCode` - error codes
267+
`com.github.transactpro.gateway.model.response.constants.Status` - transaction statuses
268+
`com.github.transactpro.gateway.model.response.constants.Enrollment` - card 3-D Secure enrollment statuses
269+
`com.github.transactpro.gateway.model.response.constants.CardFamily` - card families
270+
264271
### Customization
265272

266273
If you need to load an HTML form from Gateway instead of cardholder browser redirect, a special operation type may be used:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.transactpro</groupId>
88
<artifactId>gateway</artifactId>
9-
<version>1.3.5</version>
9+
<version>1.3.6</version>
1010

1111
<name>Transact Pro Gateway v3 Java client library</name>
1212
<description>A library that provide ability to make requests to Transact Pro Gateway API v3.</description>

src/main/java/com/github/transactpro/gateway/model/response/StatusResponse.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.transactpro.gateway.model.response;
22

3+
import com.github.transactpro.gateway.model.response.constants.CardFamily;
34
import com.github.transactpro.gateway.model.response.constants.Status;
45
import com.google.gson.annotations.SerializedName;
56
import lombok.Getter;
@@ -19,6 +20,10 @@ public static class TransactionStatus {
1920
private String statusText;
2021
@SerializedName("status-text-general")
2122
private String statusTextGeneral;
23+
@SerializedName("card-mask")
24+
private String cardMask;
25+
@SerializedName("card-family")
26+
private CardFamily cardFamily;
2227
}
2328

2429
@Getter
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.github.transactpro.gateway.model.response.constants;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Getter;
5+
6+
public enum CardFamily {
7+
@SerializedName("VISA")
8+
VISA(1),
9+
@SerializedName("MC")
10+
MASTER_CARD(2),
11+
@SerializedName("MA")
12+
MAESTRO(3),
13+
@SerializedName("AMEX")
14+
AMERICAN_EXPRESS(4);
15+
16+
@Getter
17+
private final int value;
18+
19+
CardFamily(int value) {
20+
this.value = value;
21+
}
22+
}

src/test/java/com/github/transactpro/gateway/operation/info/StatusTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.github.transactpro.gateway.model.Request;
44
import com.github.transactpro.gateway.model.Response;
55
import com.github.transactpro.gateway.model.response.StatusResponse;
6+
import com.github.transactpro.gateway.model.response.constants.CardFamily;
67
import org.junit.jupiter.api.AfterEach;
78
import org.junit.jupiter.api.BeforeEach;
89
import org.junit.jupiter.api.Test;
@@ -59,9 +60,10 @@ void validOperation() {
5960
@Test
6061
void parseStatusResponse() {
6162
String body = "{\"transactions\":[{\"gateway-transaction-id\":\"cd7b8bdf-3c78-4540-95d0-68018d2aba97\",\"status\":" +
62-
"[{\"gateway-transaction-id\":\"cd7b8bdf-3c78-4540-95d0-68018d2aba97\",\"status-code\":7,\"status-code-general\":8," +
63-
"\"status-text\":\"SUCCESS\",\"status-text-general\":\"EXPIRED\"}]},{\"gateway-transaction-id\":\"37908991-789b-4d79-8c6a-f90ba0ce12b6\"," +
64-
"\"status\":[{\"gateway-transaction-id\":\"37908991-789b-4d79-8c6a-f90ba0ce12b6\",\"status-code\":8,\"status-code-general\":7," +
63+
"[{\"card-mask\":\"534219*5267\",\"card-family\":\"MC\",\"gateway-transaction-id\":\"cd7b8bdf-3c78-4540-95d0-68018d2aba97\"," +
64+
"\"status-code\":7,\"status-code-general\":8,\"status-text\":\"SUCCESS\",\"status-text-general\":\"EXPIRED\"}]}," +
65+
"{\"gateway-transaction-id\":\"37908991-789b-4d79-8c6a-f90ba0ce12b6\",\"status\":[" +
66+
"{\"gateway-transaction-id\":\"37908991-789b-4d79-8c6a-f90ba0ce12b6\",\"status-code\":8,\"status-code-general\":7," +
6567
"\"status-text\":\"EXPIRED\",\"status-text-general\":\"SUCCESS\"}]}," +
6668
"{\"error\":{\"code\":400,\"message\":\"Failed to fetch data for transaction with gateway id: 99900000-789b-4d79-8c6a-f90ba0ce12b0\"}," +
6769
"\"gateway-transaction-id\":\"99900000-789b-4d79-8c6a-f90ba0ce12b0\"}]}";
@@ -77,6 +79,8 @@ void parseStatusResponse() {
7779
assertEquals(com.github.transactpro.gateway.model.response.constants.Status.EXPIRED, tr1.getStatus().get(0).getStatusCodeGeneral());
7880
assertEquals("SUCCESS", tr1.getStatus().get(0).getStatusText());
7981
assertEquals("EXPIRED", tr1.getStatus().get(0).getStatusTextGeneral());
82+
assertEquals(CardFamily.MASTER_CARD, tr1.getStatus().get(0).getCardFamily());
83+
assertEquals("534219*5267", tr1.getStatus().get(0).getCardMask());
8084

8185
StatusResponse.Element tr2 = parsedResponse.getTransactions().get(1);
8286
assertEquals("37908991-789b-4d79-8c6a-f90ba0ce12b6", tr2.getGatewayTransactionId());

0 commit comments

Comments
 (0)