com.global.api.services.CheckService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of globalpayments-sdk Show documentation
Show all versions of globalpayments-sdk Show documentation
API for processing payments through Global Payments
package com.global.api.services;
import com.global.api.ServicesContainer;
import com.global.api.builders.AuthorizationBuilder;
import com.global.api.builders.ManagementBuilder;
import com.global.api.entities.enums.PaymentMethodType;
import com.global.api.entities.enums.TransactionType;
import com.global.api.entities.exceptions.ApiException;
import com.global.api.paymentMethods.TransactionReference;
import com.global.api.serviceConfigs.GatewayConfig;
import java.math.BigDecimal;
public class CheckService {
public CheckService(GatewayConfig config) throws ApiException {
ServicesContainer.configureService(config);
}
// Recurring
// Charge
public AuthorizationBuilder charge() {
return charge(null);
}
public AuthorizationBuilder charge(BigDecimal amount) {
return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
}
// Void
public ManagementBuilder voidTransaction(String transactionId) {
return voidTransaction(transactionId,false);
}
// Void using client transaction ID
public ManagementBuilder voidTransaction(String transactionId, boolean isClientTxnId) {
if (isClientTxnId) {
TransactionReference reference = new TransactionReference();
reference.setPaymentMethodType(PaymentMethodType.ACH);
reference.setClientTransactionId(transactionId);
return new ManagementBuilder(TransactionType.Void).withPaymentMethod(reference);
} else {
TransactionReference reference = new TransactionReference();
reference.setPaymentMethodType(PaymentMethodType.ACH);
reference.setTransactionId(transactionId);
return new ManagementBuilder(TransactionType.Void).withPaymentMethod(reference);
}
}
}