Skip to content

Commit

Permalink
OctopusDeploy release: 10.2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
securesubmit-buildmaster committed May 16, 2023
1 parent 8ae4e4e commit 10cb587
Show file tree
Hide file tree
Showing 40 changed files with 1,763 additions and 224 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## v10.2.15 (05/16/2023)

### Enhancements:

-NTS Phase1 Issue:
- Synchorny value S added in Authorizer code (Issue-10183)
- Primary and Secondary fallback scenario's((For host response code 40,80,90) changes (Issue-10185)
- Batch Summary Total credits and Total debits related changes (Issue-10188)
- Batch close Retransmits : Updating message code when response code is 01(out of balance) (Issue-10194,10120)
- Estimated Purchase amount changes for WEX (Issue-10197)

- GP-API: Manage fund transfers, splits and reverse splits in your partner network.
- https://developer.globalpay.com/api/transfers
- https://developer.globalpay.com/api/transactions#/Split%20a%20Transaction%20Amount/splitTransaction
- Exclude vulnerable dependency on "commons-logging" suggested by Macroscope

## v10.2.14 (05/08/2023)

### Enhancements:
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.heartlandpaymentsystems</groupId>
<artifactId>globalpayments-sdk</artifactId>
<version>10.2.14</version>
<version>10.2.15</version>
<packaging>jar</packaging>
<name>Heartland &amp; Global Payments SDK</name>
<description>API for processing payments through Global Payments</description>
Expand Down Expand Up @@ -132,6 +132,12 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>joda-time</groupId>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/global/api/ServicesContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ private void removeConfiguration(String configName) throws ConfigurationExceptio
}
}

public static void removeConfig(String config) throws ConfigurationException {
instance.removeConfiguration(config);
}

public static void removeConfig() throws ConfigurationException {
instance.removeConfiguration("default");
}

public void dispose() {
for(ConfiguredServices cs : configurations.values())
cs.dispose();
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/global/api/builders/ManagementBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public class ManagementBuilder extends TransactionBuilder<Transaction> {
@Getter
private ArrayList<Product> miscProductData;

@Getter @Setter private String reference;
@Getter @Setter private FundsData fundsData;

public ManagementBuilder withMiscProductData(ArrayList<Product> values) {
this.miscProductData = values;
return this;
Expand Down Expand Up @@ -236,6 +239,7 @@ public String getTransactionId() {
return ((TransactionReference)paymentMethod).getTransactionId();
return null;
}

public String getTransportData() {
return transportData;
}
Expand Down Expand Up @@ -659,6 +663,15 @@ public ManagementBuilder withAccountType(AccountType value) {
this.accountType = value;
return this;
}
public ManagementBuilder withReference(String value) {
reference = value;
return this;
}
public ManagementBuilder withFundsData(FundsData value) {
fundsData = value;
return this;
}

public ManagementBuilder(TransactionType type) {
super(type, null);
}
Expand Down Expand Up @@ -711,6 +724,12 @@ public void setupValidations() {
.check("payLinkData").propertyOf(Integer.class, "usageLimit").isNotNull()
.check("payLinkData").propertyOf(PayLinkType.class, "type").isNotNull();

this.validations.of(TransactionType.Reversal)
.check("paymentMethod").isNotNull();

this.validations.of(TransactionType.SplitFunds)
.check("fundsData").isNotNull()
.check("amount").isNotNull();
}

public ManagementBuilder withAllowDuplicates(boolean value) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/global/api/entities/BatchSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public BatchSummary resubmitTransactions(List<String> transactionTokens) throws
return resubmitTransactions(transactionTokens, "default");
}
public BatchSummary resubmitTransactions(List<String> transactionTokens, String configName) throws ApiException {
if(!this.responseCode.equals("580")) {
if(!this.responseCode.equals("580") && !this.responseCode.equals("01")) {
throw new BuilderException("Batch recovery has not been requested for this batch.");
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/global/api/entities/FundsData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.global.api.entities;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Accessors(chain = true)
@Getter
@Setter
public class FundsData {

private String merchantId;
private String recipientAccountId;

}
22 changes: 22 additions & 0 deletions src/main/java/com/global/api/entities/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.global.api.entities.enums.TransactionType;
import com.global.api.entities.enums.TransactionTypeIndicator;
import com.global.api.entities.exceptions.GatewayException;
import com.global.api.entities.gpApi.entities.TransferFundsAccountDetails;
import com.global.api.gateways.events.IGatewayEvent;
import com.global.api.network.entities.gnap.GnapResponse;
import com.global.api.network.entities.NtsData;
Expand All @@ -25,6 +26,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

public class Transaction {
private String additionalResponseCode;
Expand Down Expand Up @@ -70,6 +72,19 @@ public class Transaction {
private HashMap<CardIssuerEntryTag, String> issuerData;
private PriorMessageInformation messageInformation;
@Getter @Setter private PayLinkResponse payLinkResponse;
@Getter private List<TransferFundsAccountDetails> transferFundsAccountDetailsList;
public void setTransferFundsAccountDetailsList(List<TransferFundsAccountDetails> value){
if (transactionReference == null) {
transactionReference = new TransactionReference();
}

if(value.size() > 0) {
transactionReference.setTransferFundsAccountDetailsList(value);
}

transferFundsAccountDetailsList = value;
}

@Getter @Setter private CardIssuerResponse cardIssuerResponse;
private BigDecimal pointsBalanceAmount;
private Transaction preAuthCompletion;
Expand Down Expand Up @@ -666,6 +681,13 @@ public ManagementBuilder confirm(BigDecimal amount) {
.withAmount(amount);
}

// Transfer part of transaction amount by a merchant to the partner account
public ManagementBuilder split(BigDecimal amount) {
return new ManagementBuilder(TransactionType.SplitFunds)
.withPaymentMethod(transactionReference)
.withAmount(amount);
}

public ManagementBuilder increment() {
return increment(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public enum PaymentMethodType implements IFlag {
APM,
Ewic,
BankPayment,
BNPL;
BNPL,
AccountFunds;

public long getLongValue() {
return 1 << this.ordinal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum TransactionType implements IFlag {
Release,
VerifyEnrolled,
VerifySignature,
TransferFunds,
TokenUpdate,
TokenDelete,
Confirm,
Expand All @@ -41,6 +42,7 @@ public enum TransactionType implements IFlag {
Tokenize,
CashOut,
SendFile,
SplitFunds,
Payment,
CashAdvance,
DisputeAcceptance,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.global.api.entities.enums;

public enum UsableBalanceMode {
AVAILABLE_BALANCE,
AVAILABLE_AND_PENDING_BALANCE
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import com.global.api.entities.*;
import com.global.api.entities.enums.*;
import com.global.api.entities.exceptions.GatewayException;
import com.global.api.entities.exceptions.UnsupportedTransactionException;
import com.global.api.gateways.GpApiConnector;
import com.global.api.gateways.OpenBankingProvider;
import com.global.api.paymentMethods.*;
import com.global.api.utils.EmvUtils;
import com.global.api.utils.EnumUtils;
import com.global.api.utils.JsonDoc;
import com.global.api.utils.StringUtils;
import com.global.api.utils.*;
import lombok.var;

import java.math.BigDecimal;
Expand All @@ -22,10 +20,11 @@
import static com.global.api.gateways.GpApiConnector.getValueIfNotNull;
import static com.global.api.utils.EnumUtils.mapDigitalWalletType;
import static com.global.api.utils.StringUtils.isNullOrEmpty;
import static com.global.api.utils.StringUtils.toNumeric;

public class GpApiAuthorizationRequestBuilder {

public static GpApiRequest buildRequest(AuthorizationBuilder builder, GpApiConnector gateway) throws GatewayException {
public static GpApiRequest buildRequest(AuthorizationBuilder builder, GpApiConnector gateway) throws GatewayException, UnsupportedTransactionException {
String merchantUrl = gateway.getMerchantUrl();
JsonDoc paymentMethod =
new JsonDoc()
Expand Down Expand Up @@ -305,14 +304,14 @@ else if (builderPaymentMethod instanceof ITrackData) {
if (builderPaymentMethod instanceof eCheck) {
eCheck check = (eCheck) builderPaymentMethod;
paymentMethod.set("name", check.getCheckHolderName());
paymentMethod.set("narrative", check.getMerchantNotes());

JsonDoc bankTransfer =
new JsonDoc()
.set("account_number", check.getAccountNumber())
.set("account_type", (check.getAccountType() != null) ? EnumUtils.getMapping(Target.GP_API, check.getAccountType()) : null)
.set("check_reference", check.getCheckReference())
.set("sec_code", check.getSecCode())
.set("narrative", check.getMerchantNotes());
.set("sec_code", check.getSecCode());

JsonDoc bank =
new JsonDoc()
Expand Down Expand Up @@ -470,6 +469,37 @@ else if (!StringUtils.isNullOrEmpty(encryptionData.getKsn())) {

}

if (builder.getTransactionType() == TransactionType.TransferFunds) {
if (!(builder.getPaymentMethod() instanceof AccountFunds)) {
throw new UnsupportedTransactionException("Payment method doesn't support funds transfers");
}

var fundsData = (AccountFunds) builder.getPaymentMethod();

var payload =
new JsonDoc()
.set("account_id", fundsData.getAccountId())
.set("account_name", fundsData.getAccountName())
.set("recipient_account_id", fundsData.getRecipientAccountId())
.set("reference", builder.getClientTransactionId() != null ? builder.getClientTransactionId() : GenerationUtils.generateOrderId())
.set("amount", toNumeric(builder.getAmount()))
.set("description", builder.getDescription())
.set("usable_balance_mode", fundsData.getUsableBalanceMode() == null
? null
: fundsData.getUsableBalanceMode().toString());

String endpoint = merchantUrl;
if (!StringUtils.isNullOrEmpty(fundsData.getMerchantId())) {
endpoint = "/merchants/" + fundsData.getMerchantId();
}

return
new GpApiRequest()
.setVerb(GpApiRequest.HttpMethod.Post)
.setEndpoint(endpoint + "/transfers")
.setRequestBody(payload.toString());
}

JsonDoc data = new JsonDoc()
.set("account_name", gateway.getGpApiConfig().getAccessTokenInfo().getTransactionProcessingAccountName())
.set("account_id", gateway.getGpApiConfig().getAccessTokenInfo().getTransactionProcessingAccountID())
Expand Down Expand Up @@ -578,19 +608,9 @@ private static JsonDoc setPayerInformation(AuthorizationBuilder builder) {
payer.set("reference", builder.getCustomerId() != null ? builder.getCustomerId() : (builder.getCustomerData() != null ? builder.getCustomerData().getId() : null));

if(builder.getPaymentMethod() instanceof eCheck) {
JsonDoc billingAddress = new JsonDoc();

Address builderBillingAddress = builder.getBillingAddress();

if(builderBillingAddress != null) {
billingAddress
.set("line_1", builderBillingAddress.getStreetAddress1())
.set("line_2", builderBillingAddress.getStreetAddress2())
.set("city", builderBillingAddress.getCity())
.set("postal_code", builderBillingAddress.getPostalCode())
.set("state", builderBillingAddress.getProvince())
.set("country", builderBillingAddress.getCountryCode());
JsonDoc billingAddress = GetBasicAddressInformation(builder.getBillingAddress());

if(!billingAddress.getKeys().isEmpty()) {
payer.set("billing_address", billingAddress);
}

Expand Down Expand Up @@ -629,17 +649,7 @@ private static JsonDoc setPayerInformation(AuthorizationBuilder builder) {
.set("email", builder.getCustomerData().getEmail())
.set("date_of_birth", builder.getCustomerData().getDateOfBirth());

JsonDoc billing_address = new JsonDoc();

if (builder.getBillingAddress() != null) {
billing_address
.set("line_1", builder.getBillingAddress().getStreetAddress1())
.set("line_2", builder.getBillingAddress().getStreetAddress2())
.set("city", builder.getBillingAddress().getCity())
.set("postal_code", builder.getBillingAddress().getPostalCode())
.set("state", builder.getBillingAddress().getState())
.set("country", builder.getBillingAddress().getCountryCode());
}
JsonDoc billing_address = GetBasicAddressInformation(builder.getBillingAddress());

if (builder.getCustomerData() != null) {
billing_address
Expand Down Expand Up @@ -763,6 +773,23 @@ private static String getEntryMode(AuthorizationBuilder builder, String channel)
}
}

private static JsonDoc GetBasicAddressInformation(Address address) {

JsonDoc basicAddressInformation = new JsonDoc();

if (address != null) {
basicAddressInformation
.set("line_1", address.getStreetAddress1())
.set("line_2", address.getStreetAddress2())
.set("city", address.getCity())
.set("postal_code", address.getPostalCode())
.set("state", address.getState())
.set("country", address.getCountryCode());
}

return basicAddressInformation;
}

private static String getCaptureMode(AuthorizationBuilder builder) {
if (builder.isMultiCapture()) {
return "MULTIPLE";
Expand Down
Loading

0 comments on commit 10cb587

Please sign in to comment.