All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.global.api.services.CheckService Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
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);
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy