Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11, 17, 21 ]
java: [ 11, 17, 21, 25 ]

steps:
- uses: actions/checkout@v2
Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ This library provide ability to make requests to Transact Pro Gateway API v3.
<dependency>
<groupId>com.github.transactpro</groupId>
<artifactId>gateway</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</dependency>
```

#### Gradle

```groovy
implementation 'com.github.transactpro:gateway:2.0.1'
implementation 'com.github.transactpro:gateway:2.0.2'
```

## Documentation
Expand Down Expand Up @@ -214,6 +214,37 @@ Command command = new Command()
sms.setCommand(command);
```

### Using alternative payment methods

To use an alternative payment method (like Google Pay), send a received token AS-IS or data from a decrypted token.

```java
// set a corresponding flag that indicates a token provider
Command command = new Command().setPaymentMethodType(PaymentMethodType.PAYMENT_METHOD_TYPE_GOOGLE_PAY);
operation.setCommand(command);

// option 1: send received token AS-IS
PaymentMethod paymentMethod = new PaymentMethod().setToken('<token>');
operation.setPayment(paymentMethod);

// option 2: send data from decrypted token
ExternalTokenData externalTokenData = new ExternalTokenData()
.setCryptogram("<cryptogram from token>") // if available
.setEci("<ECI from token>") // if available
.setTransStatus("<transStatus from token>") // available for Click to Pay
.setDsTransId("<dsTransId from token>") // available for Click to Pay
.setAcsTransId("<acsTransId from token>") // available for Click to Pay
.setCardHolderAuthenticated(decryptedToken.paymentMethodDetails.assuranceDetails.cardHolderAuthenticated); // for Google Pay

PaymentMethod paymentMethod = new PaymentMethod()
.setPan("<card number>")
.setExpMmYy("<card expiry>")
.setCardHolderName("<cardholder name>") // if available
.setExternalTokenData(externalTokenData);

operation.setPayment(paymentMethod);
```

### Callback validation

```java
Expand Down
24 changes: 17 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.transactpro</groupId>
<artifactId>gateway</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>

<name>Transact Pro Gateway v3 Java client library</name>
<description>A library that provide ability to make requests to Transact Pro Gateway API v3.</description>
Expand Down Expand Up @@ -36,6 +36,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.release>11</maven.release>
<lombok.version>1.18.42</lombok.version>
</properties>

<distributionManagement>
Expand All @@ -53,10 +55,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>${maven.release}</release>
<annotationsProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationsProcessorPaths>
<compilerArgs>
<arg>-proc:full</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -94,7 +104,7 @@
<goal>jar</goal>
</goals>
<configuration>
<source>1.8</source>
<source>11</source>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -147,7 +157,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.7.0</version>
<version>5.20.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -179,7 +189,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/transactpro/gateway/Gateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Gateway {
private String url;
@Getter
private final Authorization authorization;
@Setter
private CloseableHttpClient httpClient;
private Validator validator;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.transactpro.gateway.adapters;

import com.github.transactpro.gateway.model.request.data.command.PaymentMethodType;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.lang.reflect.Type;

public class PaymentMethodTypeSerializer implements JsonSerializer<PaymentMethodType> {
@Override
public JsonElement serialize(PaymentMethodType paymentMethodType, Type type, JsonSerializationContext jsonSerializationContext) {
return jsonSerializationContext.serialize(paymentMethodType.getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.github.transactpro.gateway.model.request.data.command.CardVerificationMode;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodDataSource;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodType;
import com.github.transactpro.gateway.validation.base.CommandTransactionIdGroup;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
Expand All @@ -23,4 +24,5 @@ public class Command {
private CardVerificationMode cardVerification;
private PaymentMethodDataSource paymentMethodDataSource;
private String paymentMethodDataToken;
private PaymentMethodType paymentMethodType;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.transactpro.gateway.model.request.data;

import com.github.transactpro.gateway.model.request.data.payment.ExternalMPIData;
import com.github.transactpro.gateway.validation.base.PaymentMethodPanExpGroup;
import com.github.transactpro.gateway.model.request.data.payment.ExternalTokenData;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
Expand All @@ -15,13 +14,15 @@
public class PaymentMethod {

@CreditCardNumber(ignoreNonDigitCharacters = true)
@NotNull(groups = PaymentMethodPanExpGroup.class)
private String pan;
@NotNull(groups = PaymentMethodPanExpGroup.class)
private String expMmYy;
private String cvv;
private String cardholderName;
private String token;

@Valid
private ExternalMPIData externalMpiData;

@Valid
private ExternalTokenData externalTokenData;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.github.transactpro.gateway.model.request.data.command;

import lombok.Getter;

@Getter
public enum PaymentMethodType {
PAYMENT_METHOD_TYPE_CARD("cc"),
PAYMENT_METHOD_TYPE_GOOGLE_PAY("google_pay"),
PAYMENT_METHOD_TYPE_APPLE_PAY("apple_pay"),
PAYMENT_METHOD_TYPE_CLICK2PAY("click2pay");

private final String value;

PaymentMethodType(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.transactpro.gateway.model.request.data.payment;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors(chain = true)
public class ExternalTokenData {
private String cryptogram;
private String eci;
@SerializedName("transStatus")
private String transStatus;
@SerializedName("dsTransID")
private String dsTransID;
@SerializedName("acsTransID")
private String acsTransID;
@SerializedName("cardHolderAuthenticated")
private Boolean cardHolderAuthenticated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.github.transactpro.gateway.adapters.CardVerificationModeSerializer;
import com.github.transactpro.gateway.adapters.PaymentMethodDataSourceSerializer;
import com.github.transactpro.gateway.adapters.PaymentMethodTypeSerializer;
import com.github.transactpro.gateway.model.Request;
import com.github.transactpro.gateway.model.Response;
import com.github.transactpro.gateway.model.request.data.command.CardVerificationMode;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodDataSource;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodType;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand All @@ -21,6 +23,7 @@ public abstract class Operation<ResponseT> implements Operable {
@Getter
protected String requestUri;

@Getter
protected Request request;
protected Class<ResponseT> responseType;
@Getter
Expand All @@ -41,15 +44,12 @@ protected Request buildRequest() {
return new Request();
}

public Request getRequest() {
return request;
}

protected Gson buildJsonParser() {
return new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
.registerTypeAdapter(CardVerificationMode.class, new CardVerificationModeSerializer())
.registerTypeAdapter(PaymentMethodDataSource.class, new PaymentMethodDataSourceSerializer())
.registerTypeAdapter(PaymentMethodType.class, new PaymentMethodTypeSerializer())
.create();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import com.github.transactpro.gateway.model.request.data.System;
import com.github.transactpro.gateway.model.request.data.command.CardVerificationMode;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodDataSource;
import com.github.transactpro.gateway.model.request.data.command.PaymentMethodType;
import com.github.transactpro.gateway.model.request.data.general.Customer;
import com.github.transactpro.gateway.model.request.data.general.Order;
import com.github.transactpro.gateway.model.request.data.general.customer.Address;
import com.github.transactpro.gateway.model.request.data.payment.ExternalMPIData;
import com.github.transactpro.gateway.model.request.data.payment.ExternalTokenData;
import com.github.transactpro.gateway.model.response.PaymentResponse;
import com.github.transactpro.gateway.model.response.constants.ErrorCode;
import com.github.transactpro.gateway.model.response.constants.Status;
Expand Down Expand Up @@ -75,7 +77,8 @@ void validOperationAllFields() {
Command command = new Command()
.setCardVerification(CardVerificationMode.VERIFY)
.setPaymentMethodDataSource(PaymentMethodDataSource.DATA_SOURCE_USE_MERCHANT_SAVED_CARDHOLDER_INITIATED)
.setPaymentMethodDataToken("some-test-id");
.setPaymentMethodDataToken("some-test-id")
.setPaymentMethodType(PaymentMethodType.PAYMENT_METHOD_TYPE_GOOGLE_PAY);

Address address = new Address()
.setCity("Chalon-sur-Saône")
Expand Down Expand Up @@ -136,12 +139,21 @@ void validOperationAllFields() {
.setCavv("kBMI/uGZvlKCygBkcQIlLJeBTPLG")
.setTransStatus("Y");

ExternalTokenData externalTokenData = new ExternalTokenData()
.setCryptogram("AAMI/uGZvlKCygBkcQIlLJeBTPLG")
.setEci("05")
.setTransStatus("Y")
.setDsTransID("ad7d1791-11d4-45da-aa16-077cd8f6935c")
.setAcsTransID("be65a56e-66dc-448e-8f38-d78ee70cc6c9")
.setCardHolderAuthenticated(true);

PaymentMethod paymentMethod = new PaymentMethod()
.setCardholderName("John Smith")
.setCvv("000")
.setExpMmYy("12/18")
.setPan("0000000000000000")
.setExternalMpiData(externalMpiData);
.setExternalMpiData(externalMpiData)
.setExternalTokenData(externalTokenData);

operation.setCommand(command)
.setCustomer(customer)
Expand Down